Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QtxBackgroundTool Class Reference

Implementation of the widget managing background data. More...

#include <QtxBackgroundTool.h>

Inheritance diagram for QtxBackgroundTool:
Inheritance graph

Public Member Functions

 QtxBackgroundTool (QWidget *=0)
 Constructor. More...
 
 QtxBackgroundTool (Qt::Orientation, QWidget *=0)
 Constructor. More...
 
virtual ~QtxBackgroundTool ()
 Destructor. More...
 
Qtx::BackgroundData data () const
 Get background data from the widget. More...
 
void setData (const Qtx::BackgroundData &)
 Set background data from the widget. More...
 
void gradients (QStringList &, QIntList &) const
 Get allowed two-color gradients to the widget. More...
 
void setGradients (const QStringList &, const QIntList &=QIntList())
 Set allowed two-color gradients to the widget. More...
 
bool isModeAllowed (Qtx::BackgroundMode) const
 Check if specific background mode is allowed. More...
 
void setModeAllowed (Qtx::BackgroundMode, bool=true)
 Enable / disable specific background mode. More...
 
bool isTextureModeAllowed (Qtx::TextureMode) const
 Check if specific texture mode is allowed. More...
 
void setTextureModeAllowed (Qtx::TextureMode, bool=true)
 Enable / disable specific texture mode. More...
 
bool isTextureAllowed () const
 Check if texture controls are allowed (shown) More...
 
void setTextureAllowed (bool=true)
 Enable / disable texture controls. More...
 
QString imageFormats () const
 Get allowed image formats. More...
 
void setImageFormats (const QString &)
 Set allowed image formats. More...
 
Qt::Orientation orientation () const
 Get widget editor orientation. More...
 
void setOrientation (Qt::Orientation)
 Change widget orientation. More...
 

Private Types

enum  { Color, Gradient }
 
enum  { TypeRole = Qt::UserRole, IdRole }
 

Private Slots

void updateState ()
 Update widget state. More...
 
void browse ()
 Called when "Browse..." button is pressed. More...
 

Private Member Functions

void init (Qt::Orientation)
 Perform internal initialization. More...
 
void internalUpdate ()
 Initialization: fill in the widget with items according to the available modes. More...
 

Private Attributes

QComboBoxmyModeCombo
 
QStackedWidget * myCContainer
 
QWidgetmyTContainer
 
QCheckBox * myTextureCheck
 
QLineEditmyFileName
 
QPushButton * myBrowseBtn
 
QComboBoxmyTextureMode
 
QtxColorButtonmyFirstColor
 
QtxColorButtonmySecondColor
 
QStringList myGradients
 
QIntList myGradientsIds
 
bool myTextureAllowed
 
QMap< int, bool > myTypesAllowed
 
QMap< int, bool > myTextureTypesAllowed
 
QString myImageFormats
 
int myLastGradient
 

Detailed Description

The background data can be specified as:

  • image (by assigning the file name to be used as background texture)
  • single color (by assigning any color)
  • simple two-color gradient (with the gradient type id and two colors)
  • complex gradient (by assigning arbitrary gradient data) (NOT IMPLEMENTED YET)

To enable / disable any background type, setModeAllowed() function can be used. Widget's orientation can be specified via the constructor parameter of changed with setOrientation() function.

To specify two-color gradient modes, use setGradient() function. By default, no gradient modes are provided by the widget.

Arbitrary gradient mode is not implemented yet, it is remaining for future improvement.

Typical usage can be as follows:

// create tool widget
// assign gradients types
QStringList sl;
sl << "Horizontal" << "Vertical" << "First diagonal" << "Second diagonal";
tool->setGradients(sl);
// disable image texture and custom gradient modes
tool->setModeAllowed(Qtx::ImageBackground, false);
// initialize widget with the some background data
tool->setData( bgData );
Todo:
Complete support of custom gradient (QLinearGradient, QRadialGradient, QConicalGradient).
See Also
Qtx::BackgroundData, QtxBackgroundDialog, Qtx::stringToBackground(), Qtx::backgroundToString()

Member Enumeration Documentation

anonymous enum
private
Enumerator
Color 
Gradient 
anonymous enum
private
Enumerator
TypeRole 
IdRole 

Constructor & Destructor Documentation

QtxBackgroundTool::QtxBackgroundTool ( QWidget parent = 0)

Creates a background data widget with horizontal orientation.

Parameters
parentparent widget

References Horizontal, and init().

QtxBackgroundTool::QtxBackgroundTool ( Qt::Orientation  o,
QWidget parent = 0 
)

Creates a background data widget with specified orientation.

Parameters
owidget orientation
parentparent widget

References init().

QtxBackgroundTool::~QtxBackgroundTool ( )
virtual

Member Function Documentation

void QtxBackgroundTool::browse ( )
privateslot

References myFileName, and myImageFormats.

void QtxBackgroundTool::gradients ( QStringList &  gradList,
QIntList idList 
) const
Parameters
gradientsgradients names are returned via this parameter
idsgradients identifiers are returned via this parameter (empty list can be returned)

References myGradients, and myGradientsIds.

QString QtxBackgroundTool::imageFormats ( ) const
Returns
image formats
See Also
setImageFormats()

References myImageFormats.

bool QtxBackgroundTool::isModeAllowed ( Qtx::BackgroundMode  mode) const
Parameters
modebackground mode
Returns
true if specified background mode is enabled or false otherwise
See Also
setModeAllowed()

References myTypesAllowed.

bool QtxBackgroundTool::isTextureAllowed ( ) const
Returns
true if texture controls are enabled or false otherwise
See Also
setTextureAllowed(), setTextureModeAllowed()

References myTextureAllowed.

bool QtxBackgroundTool::isTextureModeAllowed ( Qtx::TextureMode  mode) const
Parameters
modetexture mode
Returns
true if specified texture mode is enabled or false otherwise
See Also
setTextureModeAllowed(), setTextureAllowed()

References myTextureTypesAllowed.

Qt::Orientation QtxBackgroundTool::orientation ( ) const
Returns
orientation
See Also
setOrientation()

References Horizontal, and Vertical.

void QtxBackgroundTool::setGradients ( const QStringList &  gradList,
const QIntList idList = QIntList() 
)
Parameters
gradientsgradients names
idsoptional gradients identifiers; if not specified, gradients are automatically numbered starting from 0

References data(), internalUpdate(), myGradients, myGradientsIds, myLastGradient, and setData().

void QtxBackgroundTool::setImageFormats ( const QString &  formats)
Parameters
formatsimage formats
See Also
imageFormats()

References myImageFormats.

void QtxBackgroundTool::setModeAllowed ( Qtx::BackgroundMode  mode,
bool  on = true 
)
Parameters
modebackground mode
onenable / disable flag (true by default)
See Also
isModeAllowed()

References Qtx::CustomGradientBackground, data(), internalUpdate(), isModeAllowed(), myTypesAllowed, and setData().

void QtxBackgroundTool::setOrientation ( Qt::Orientation  orientation)
Parameters
orientationnew widget orientation
See Also
orientation()

References Horizontal, isTextureAllowed(), myCContainer, myModeCombo, and myTContainer.

void QtxBackgroundTool::setTextureAllowed ( bool  on = true)
Parameters
onenable / disable flag (true by default)
See Also
isTextureAllowed(), setTextureModeAllowed()

References myTextureAllowed, orientation(), and setOrientation().

void QtxBackgroundTool::setTextureModeAllowed ( Qtx::TextureMode  mode,
bool  on = true 
)
Parameters
modetexture mode
onenable / disable flag (true by default)
See Also
isTextureModeAllowed(), setTextureAllowed()

References data(), internalUpdate(), isTextureModeAllowed(), myTextureTypesAllowed, and setData().

Member Data Documentation

QPushButton* QtxBackgroundTool::myBrowseBtn
private
QStackedWidget* QtxBackgroundTool::myCContainer
private
QLineEdit* QtxBackgroundTool::myFileName
private
QtxColorButton* QtxBackgroundTool::myFirstColor
private
QStringList QtxBackgroundTool::myGradients
private
QIntList QtxBackgroundTool::myGradientsIds
private
QString QtxBackgroundTool::myImageFormats
private
int QtxBackgroundTool::myLastGradient
private
QComboBox* QtxBackgroundTool::myModeCombo
private
QtxColorButton* QtxBackgroundTool::mySecondColor
private
QWidget* QtxBackgroundTool::myTContainer
private
bool QtxBackgroundTool::myTextureAllowed
private
QCheckBox* QtxBackgroundTool::myTextureCheck
private
QComboBox* QtxBackgroundTool::myTextureMode
private
QMap<int, bool> QtxBackgroundTool::myTextureTypesAllowed
private
QMap<int, bool> QtxBackgroundTool::myTypesAllowed
private

The documentation for this class was generated from the following files: