24 #include <QPushButton> 26 #include <QToolButton> 27 #include <QFileDialog> 28 #include <QMessageBox> 29 #include <QDesktopWidget> 30 #include <QMouseEvent> 31 #include <QInputDialog> 46 QColor returnColor( initialColor );
51 connect( liveDialog, SIGNAL( currentColorChanged(
const QColor& ) ),
52 updateObject, updateSlot );
54 if ( liveDialog->
exec() )
71 , mPreviousColor( color )
82 mButtonBox->addButton( resetButton, QDialogButtonBox::ResetRole );
87 mColorWidget->setColor( color );
88 mColorWidget->setPreviousColor( color );
91 mColorWidget->setAllowAlpha(
true );
103 return mColorWidget->color();
113 mAllowAlpha = allowAlpha;
114 mColorWidget->setAllowAlpha( allowAlpha );
119 QColor returnColor( initialColor );
128 updateObject, updateSlot );
130 if ( liveDialog->
exec() )
132 returnColor = liveDialog->
color();
135 liveDialog =
nullptr;
146 bool useNative = settings.
value(
"/qgis/native_color_dialogs",
false ).
toBool();
149 return QColorDialog::getColor( initialColor, parent, dialogTitle, allowAlpha ? QColorDialog::ShowAlphaChannel : ( QColorDialog::ColorDialogOption )0 );
158 if ( dialog->
exec() )
160 result = dialog->
color();
171 void QgsColorDialogV2::on_mButtonBox_accepted()
177 void QgsColorDialogV2::on_mButtonBox_rejected()
183 void QgsColorDialogV2::on_mButtonBox_clicked(
QAbstractButton * button )
185 if ( mButtonBox->buttonRole( button ) == QDialogButtonBox::ResetRole && mPreviousColor.
isValid() )
191 void QgsColorDialogV2::saveSettings()
211 mColorWidget->setColor( fixedColor );
void setOptions(QFlags< QColorDialog::ColorDialogOption > options)
QByteArray toByteArray() const
virtual void closeEvent(QCloseEvent *e)
QgsColorDialogV2(QWidget *parent=nullptr, const Qt::WindowFlags &fl=QgisGui::ModalDialogFlags, const QColor &color=QColor())
Create a new color picker dialog.
QColor color() const
Returns the current color for the dialog.
A custom QGIS dialog for selecting a color.
void currentColorChanged(const QColor &color)
Emitted when the dialog's color changes.
QString tr(const char *sourceText, const char *disambiguation, int n)
void setValue(const QString &key, const QVariant &value)
void setAllowAlpha(const bool allowAlpha)
Sets whether alpha modification (transparency) is permitted for the color dialog. ...
typedef ColorDialogOptions
void setTitle(const QString &title)
Sets the title for the color dialog.
QColor getColor(const QColor &initial, QWidget *parent, const QString &title, QFlags< QColorDialog::ColorDialogOption > options)
void closeEvent(QCloseEvent *e) override
QVariant value(const QString &key, const QVariant &defaultValue) const
static QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), const bool allowAlpha=false)
Return a color selection from a color dialog.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setColor(const QColor &color)
Sets the current color for the dialog.
static QColor getLiveColor(const QColor &initialColor, QObject *updateObject, const char *updateSlot, QWidget *parent=nullptr, const QString &title="", const QColorDialog::ColorDialogOptions &options=nullptr)
Return a color selection from a QColorDialog, with live updating of interim selections.
static QColor getLiveColor(const QColor &initialColor, QObject *updateObject, const char *updateSlot, QWidget *parent=nullptr, const QString &title=QString(), const bool allowAlpha=true)
Return a color selection from a color dialog, with live updating of interim selections.