Implementation of the widget managing background data. More...
#include <QtxBackgroundTool.h>
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 | |
QComboBox * | myModeCombo |
QStackedWidget * | myCContainer |
QWidget * | myTContainer |
QCheckBox * | myTextureCheck |
QLineEdit * | myFileName |
QPushButton * | myBrowseBtn |
QComboBox * | myTextureMode |
QtxColorButton * | myFirstColor |
QtxColorButton * | mySecondColor |
QStringList | myGradients |
QIntList | myGradientsIds |
bool | myTextureAllowed |
QMap< int, bool > | myTypesAllowed |
QMap< int, bool > | myTextureTypesAllowed |
QString | myImageFormats |
int | myLastGradient |
The background data can be specified as:
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:
QtxBackgroundTool::QtxBackgroundTool | ( | QWidget * | parent = 0 | ) |
Creates a background data widget with horizontal orientation.
parent | parent widget |
References Horizontal, and init().
QtxBackgroundTool::QtxBackgroundTool | ( | Qt::Orientation | o, |
QWidget * | parent = 0 |
||
) |
Creates a background data widget with specified orientation.
o | widget orientation |
parent | parent widget |
References init().
|
virtual |
|
privateslot |
References myFileName, and myImageFormats.
Qtx::BackgroundData QtxBackgroundTool::data | ( | ) | const |
References QtxColorButton::color(), Qtx::ColorBackground, Qtx::CustomGradientBackground, isModeAllowed(), isTextureAllowed(), myFileName, myFirstColor, myLastGradient, myModeCombo, mySecondColor, myTextureCheck, myTextureMode, Qtx::BackgroundData::setColor(), Qtx::BackgroundData::setGradient(), Qtx::BackgroundData::setMode(), Qtx::BackgroundData::setTexture(), Qtx::BackgroundData::setTextureShown(), Qtx::SimpleGradientBackground, and TypeRole.
void QtxBackgroundTool::gradients | ( | QStringList & | gradList, |
QIntList & | idList | ||
) | const |
gradients | gradients names are returned via this parameter |
ids | gradients identifiers are returned via this parameter (empty list can be returned) |
References myGradients, and myGradientsIds.
QString QtxBackgroundTool::imageFormats | ( | ) | const |
|
private |
References browse(), Qtx::CenterTexture, Qtx::ColorBackground, Qtx::CustomGradientBackground, myBrowseBtn, myCContainer, myFileName, myFirstColor, myModeCombo, mySecondColor, myTContainer, myTextureCheck, myTextureMode, setImageFormats(), setModeAllowed(), setOrientation(), setTextureAllowed(), setTextureModeAllowed(), Qtx::SimpleGradientBackground, Qtx::StretchTexture, Qtx::TileTexture, and updateState().
|
private |
bool QtxBackgroundTool::isModeAllowed | ( | Qtx::BackgroundMode | mode | ) | const |
mode | background mode |
true
if specified background mode is enabled or false
otherwise References myTypesAllowed.
bool QtxBackgroundTool::isTextureAllowed | ( | ) | const |
true
if texture controls are enabled or false
otherwise References myTextureAllowed.
bool QtxBackgroundTool::isTextureModeAllowed | ( | Qtx::TextureMode | mode | ) | const |
mode | texture mode |
true
if specified texture mode is enabled or false
otherwise References myTextureTypesAllowed.
Qt::Orientation QtxBackgroundTool::orientation | ( | ) | const |
void QtxBackgroundTool::setData | ( | const Qtx::BackgroundData & | bgData | ) |
bgData | background data being set to the widget |
References Qtx::BackgroundData::gradient(), IdRole, Qtx::BackgroundData::isTextureShown(), Qtx::BackgroundData::mode(), myFileName, myFirstColor, myModeCombo, mySecondColor, myTextureCheck, myTextureMode, QtxColorButton::setColor(), Qtx::SimpleGradientBackground, Qtx::BackgroundData::texture(), and TypeRole.
void QtxBackgroundTool::setGradients | ( | const QStringList & | gradList, |
const QIntList & | idList = QIntList() |
||
) |
gradients | gradients names |
ids | optional 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 | ) |
void QtxBackgroundTool::setModeAllowed | ( | Qtx::BackgroundMode | mode, |
bool | on = true |
||
) |
mode | background mode |
on | enable / disable flag (true by default) |
References Qtx::CustomGradientBackground, data(), internalUpdate(), isModeAllowed(), myTypesAllowed, and setData().
void QtxBackgroundTool::setOrientation | ( | Qt::Orientation | orientation | ) |
orientation | new widget orientation |
References Horizontal, isTextureAllowed(), myCContainer, myModeCombo, and myTContainer.
void QtxBackgroundTool::setTextureAllowed | ( | bool | on = true | ) |
on | enable / disable flag (true by default) |
References myTextureAllowed, orientation(), and setOrientation().
void QtxBackgroundTool::setTextureModeAllowed | ( | Qtx::TextureMode | mode, |
bool | on = true |
||
) |
mode | texture mode |
on | enable / disable flag (true by default) |
References data(), internalUpdate(), isTextureModeAllowed(), myTextureTypesAllowed, and setData().
|
privateslot |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |