From 09fbdb1bc2a251743a41d1e1b65774f6bf3d4708 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 12 Jan 2018 21:58:53 +1000 Subject: [PATCH] Drop color button/dialog live update option from API and UI This options is broken in QGIS 3.0, but in any case has been mostly made redundant by the live styling dock, and the other non blocking color pickers which are implemented in most areas of qgis now. --- doc/api_break.dox | 2 + python/gui/qgscolorbutton.sip | 19 --------- python/gui/qgscolordialog.sip | 19 --------- src/app/qgsoptions.cpp | 2 - src/gui/qgscolorbutton.cpp | 32 ++++++--------- src/gui/qgscolorbutton.h | 17 -------- src/gui/qgscolordialog.cpp | 45 ---------------------- src/gui/qgscolordialog.h | 16 -------- src/gui/symbology/qgssymbolslistwidget.cpp | 2 - src/ui/qgsoptionsbase.ui | 10 +---- 10 files changed, 14 insertions(+), 150 deletions(-) diff --git a/doc/api_break.dox b/doc/api_break.dox index 90aff1efafe..fcb6f4ba554 100644 --- a/doc/api_break.dox +++ b/doc/api_break.dox @@ -627,12 +627,14 @@ QgsColorButton {#qgis_api_break_3_0_QgsColorButton} - Behaviour enum and its corresponding setter/getter have been renamed to Behavior - setAllowAlpha() and allowAlpha() were removed. Use setAllowOpacity() and allowOpacity() instead. +- acceptLiveUpdates() and setAcceptLiveUpdates() were removed. This functionality is no longer supported. QgsColorDialog {#qgis_api_break_3_0_QgsColorDialog} -------------- - setAllowAlpha() was removed. Use setAllowOpacity() instead. +- getLiveColor() was removed. This functionality is no longer supported. QgsColorEffect {#qgis_api_break_3_0_QgsColorEffect} diff --git a/python/gui/qgscolorbutton.sip b/python/gui/qgscolorbutton.sip index faae83283cf..0d74ea3d4b7 100644 --- a/python/gui/qgscolorbutton.sip +++ b/python/gui/qgscolorbutton.sip @@ -98,25 +98,6 @@ Returns the title for the color chooser dialog window. :return: title for the color chooser dialog .. seealso:: :py:func:`setColorDialogTitle` -%End - - bool acceptLiveUpdates() const; -%Docstring -Returns whether the button accepts live updates from QColorDialog. - -:return: true if the button will be accepted immediately when the dialog's color changes - -.. seealso:: :py:func:`setAcceptLiveUpdates` -%End - - void setAcceptLiveUpdates( const bool accept ); -%Docstring -Sets whether the button accepts live updates from QColorDialog. Live updates may cause changes -that are not undoable on QColorDialog cancel. - -:param accept: set to true to enable live updates - -.. seealso:: :py:func:`acceptLiveUpdates` %End void setShowMenu( const bool showMenu ); diff --git a/python/gui/qgscolordialog.sip b/python/gui/qgscolordialog.sip index 87b2b65de08..534773525e3 100644 --- a/python/gui/qgscolordialog.sip +++ b/python/gui/qgscolordialog.sip @@ -56,25 +56,6 @@ for the color dialog. Defaults to true. :param allowOpacity: set to false to disable opacity modification .. versionadded:: 3.0 -%End - - static QColor getLiveColor( const QColor &initialColor, QObject *updateObject, const char *updateSlot, - QWidget *parent = 0, - const QString &title = QString(), - const bool allowOpacity = true ); -%Docstring -Return a color selection from a color dialog, with live updating of interim selections. - -:param initialColor: the initial color of the selection dialog. -:param updateObject: the receiver object of the live updating. -:param updateSlot: the receiver object's slot for live updating (e.g. SLOT( setValidColor( const QColor& ) ) ). -:param parent: parent widget -:param title: the title of the dialog. -:param allowOpacity: set to true to allow modification of color opacity value (transparency) - -:return: Selected color on accepted() or initialColor on rejected(). - -.. seealso:: :py:func:`getColor` %End static QColor getColor( const QColor &initialColor, QWidget *parent, const QString &title = QString(), diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index 5bbdaa9d5cd..b3620cf740e 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -563,7 +563,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetCurrentIndex( cmbUITheme->findText( theme, Qt::MatchFixedString ) ); mNativeColorDialogsChkBx->setChecked( mSettings->value( QStringLiteral( "/qgis/native_color_dialogs" ), false ).toBool() ); - mLiveColorDialogsChkBx->setChecked( mSettings->value( QStringLiteral( "/qgis/live_color_dialogs" ), false ).toBool() ); //set the state of the checkboxes //Changed to default to true as of QGIS 1.7 @@ -1301,7 +1300,6 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/qgis/messageTimeout" ), mMessageTimeoutSpnBx->value() ); mSettings->setValue( QStringLiteral( "/qgis/native_color_dialogs" ), mNativeColorDialogsChkBx->isChecked() ); - mSettings->setValue( QStringLiteral( "/qgis/live_color_dialogs" ), mLiveColorDialogsChkBx->isChecked() ); // rasters settings mSettings->setValue( QStringLiteral( "/Raster/defaultRedBand" ), spnRed->value() ); diff --git a/src/gui/qgscolorbutton.cpp b/src/gui/qgscolorbutton.cpp index f76b710feac..87da501fe4a 100644 --- a/src/gui/qgscolorbutton.cpp +++ b/src/gui/qgscolorbutton.cpp @@ -110,32 +110,22 @@ void QgsColorButton::showColorDialog() QColor newColor; QgsSettings settings; - if ( mAcceptLiveUpdates && settings.value( QStringLiteral( "qgis/live_color_dialogs" ), false ).toBool() ) + // first check if we need to use the limited native dialogs + bool useNative = settings.value( QStringLiteral( "qgis/native_color_dialogs" ), false ).toBool(); + if ( useNative ) { - // live updating dialog - QgsColorDialog will automatically use native dialog if option is set - newColor = QgsColorDialog::getLiveColor( - color(), this, SLOT( setValidColor( const QColor & ) ), - this, mColorDialogTitle, mAllowOpacity ); + // why would anyone want this? who knows.... maybe the limited nature of native dialogs helps ease the transition for MapInfo users? + newColor = QColorDialog::getColor( color(), this, mColorDialogTitle, mAllowOpacity ? QColorDialog::ShowAlphaChannel : ( QColorDialog::ColorDialogOption )0 ); } else { - // not using live updating dialog - first check if we need to use the limited native dialogs - bool useNative = settings.value( QStringLiteral( "qgis/native_color_dialogs" ), false ).toBool(); - if ( useNative ) - { - // why would anyone want this? who knows.... maybe the limited nature of native dialogs helps ease the transition for MapInfo users? - newColor = QColorDialog::getColor( color(), this, mColorDialogTitle, mAllowOpacity ? QColorDialog::ShowAlphaChannel : ( QColorDialog::ColorDialogOption )0 ); - } - else - { - QgsColorDialog dialog( this, nullptr, color() ); - dialog.setTitle( mColorDialogTitle ); - dialog.setAllowOpacity( mAllowOpacity ); + QgsColorDialog dialog( this, nullptr, color() ); + dialog.setTitle( mColorDialogTitle ); + dialog.setAllowOpacity( mAllowOpacity ); - if ( dialog.exec() ) - { - newColor = dialog.color(); - } + if ( dialog.exec() ) + { + newColor = dialog.color(); } } diff --git a/src/gui/qgscolorbutton.h b/src/gui/qgscolorbutton.h index b9dc417d39e..6a4536c2a39 100644 --- a/src/gui/qgscolorbutton.h +++ b/src/gui/qgscolorbutton.h @@ -48,7 +48,6 @@ class GUI_EXPORT QgsColorButton : public QToolButton Q_OBJECT Q_PROPERTY( QString colorDialogTitle READ colorDialogTitle WRITE setColorDialogTitle ) - Q_PROPERTY( bool acceptLiveUpdates READ acceptLiveUpdates WRITE setAcceptLiveUpdates ) Q_PROPERTY( QColor color READ color WRITE setColor ) Q_PROPERTY( bool allowOpacity READ allowOpacity WRITE setAllowOpacity ) Q_PROPERTY( bool showMenu READ showMenu WRITE setShowMenu ) @@ -121,21 +120,6 @@ class GUI_EXPORT QgsColorButton : public QToolButton */ QString colorDialogTitle() const; - /** - * Returns whether the button accepts live updates from QColorDialog. - * \returns true if the button will be accepted immediately when the dialog's color changes - * \see setAcceptLiveUpdates - */ - bool acceptLiveUpdates() const { return mAcceptLiveUpdates; } - - /** - * Sets whether the button accepts live updates from QColorDialog. Live updates may cause changes - * that are not undoable on QColorDialog cancel. - * \param accept set to true to enable live updates - * \see acceptLiveUpdates - */ - void setAcceptLiveUpdates( const bool accept ) { mAcceptLiveUpdates = accept; } - /** * Sets whether the drop-down menu should be shown for the button. The default behavior is to * show the menu. @@ -426,7 +410,6 @@ class GUI_EXPORT QgsColorButton : public QToolButton QColor mDefaultColor; QString mContext; bool mAllowOpacity = false; - bool mAcceptLiveUpdates = true; bool mColorSet = false; bool mShowNoColorOption = false; diff --git a/src/gui/qgscolordialog.cpp b/src/gui/qgscolordialog.cpp index cc2c24e7f76..367f3024d6f 100644 --- a/src/gui/qgscolordialog.cpp +++ b/src/gui/qgscolordialog.cpp @@ -77,51 +77,6 @@ void QgsColorDialog::setAllowOpacity( const bool allowOpacity ) mColorWidget->setAllowOpacity( allowOpacity ); } -QColor QgsColorDialog::getLiveColor( const QColor &initialColor, QObject *updateObject, const char *updateSlot, QWidget *parent, const QString &title, const bool allowOpacity ) -{ - QColor returnColor( initialColor ); - - QgsSettings settings; - - //using native color dialogs? - bool useNative = settings.value( QStringLiteral( "qgis/native_color_dialogs" ), false ).toBool(); - if ( useNative ) - { - QColorDialog *liveDialog = new QColorDialog( initialColor, parent ); - liveDialog->setWindowTitle( title.isEmpty() ? tr( "Select Color" ) : title ); - liveDialog->setOptions( allowOpacity ? QColorDialog::ShowAlphaChannel : ( QColorDialog::ColorDialogOption )0 ); - - connect( liveDialog, SIGNAL( currentColorChanged( const QColor & ) ), - updateObject, updateSlot ); - - if ( liveDialog->exec() ) - { - returnColor = liveDialog->currentColor(); - } - delete liveDialog; - } - else - { - QgsColorDialog *liveDialog = new QgsColorDialog( parent, nullptr, initialColor ); - liveDialog->setWindowTitle( title.isEmpty() ? tr( "Select Color" ) : title ); - if ( !allowOpacity ) - { - liveDialog->setAllowOpacity( false ); - } - - connect( liveDialog, SIGNAL( currentColorChanged( const QColor & ) ), - updateObject, updateSlot ); - - if ( liveDialog->exec() ) - { - returnColor = liveDialog->color(); - } - delete liveDialog; - } - - return returnColor; -} - QColor QgsColorDialog::getColor( const QColor &initialColor, QWidget *parent, const QString &title, const bool allowOpacity ) { QString dialogTitle = title.isEmpty() ? tr( "Select Color" ) : title; diff --git a/src/gui/qgscolordialog.h b/src/gui/qgscolordialog.h index 21dff312e50..1a54411e479 100644 --- a/src/gui/qgscolordialog.h +++ b/src/gui/qgscolordialog.h @@ -69,22 +69,6 @@ class GUI_EXPORT QgsColorDialog : public QDialog, private Ui::QgsColorDialogBase */ void setAllowOpacity( const bool allowOpacity ); - /** - * Return a color selection from a color dialog, with live updating of interim selections. - * \param initialColor the initial color of the selection dialog. - * \param updateObject the receiver object of the live updating. - * \param updateSlot the receiver object's slot for live updating (e.g. SLOT( setValidColor( const QColor& ) ) ). - * \param parent parent widget - * \param title the title of the dialog. - * \param allowOpacity set to true to allow modification of color opacity value (transparency) - * \returns Selected color on accepted() or initialColor on rejected(). - * \see getColor - */ - static QColor getLiveColor( const QColor &initialColor, QObject *updateObject, const char *updateSlot, - QWidget *parent = nullptr, - const QString &title = QString(), - const bool allowOpacity = true ); - /** * Return a color selection from a color dialog. * \param initialColor the initial color of the selection dialog. diff --git a/src/gui/symbology/qgssymbolslistwidget.cpp b/src/gui/symbology/qgssymbolslistwidget.cpp index 2171e3c8736..053cf759684 100644 --- a/src/gui/symbology/qgssymbolslistwidget.cpp +++ b/src/gui/symbology/qgssymbolslistwidget.cpp @@ -108,8 +108,6 @@ QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbol *symbol, QgsStyle *style, connect( this, &QgsSymbolsListWidget::changed, this, &QgsSymbolsListWidget::updateAssistantSymbol ); updateAssistantSymbol(); - // Live color updates are not undoable to child symbol layers - btnColor->setAcceptLiveUpdates( false ); btnColor->setAllowOpacity( true ); btnColor->setColorDialogTitle( tr( "Select Color" ) ); btnColor->setContext( QStringLiteral( "symbology" ) ); diff --git a/src/ui/qgsoptionsbase.ui b/src/ui/qgsoptionsbase.ui index 2a7b96d5dd5..43cbe53e709 100644 --- a/src/ui/qgsoptionsbase.ui +++ b/src/ui/qgsoptionsbase.ui @@ -320,7 +320,7 @@ - 9 + 0 @@ -693,13 +693,6 @@ - - - - Use live-updating color chooser dialogs - - - @@ -5354,7 +5347,6 @@ The bigger the number, the faster zooming with the mouse wheel will be. mDataSourceManagerNonModal mCustomGroupBoxChkBx mNativeColorDialogsChkBx - mLiveColorDialogsChkBx mProjectOnLaunchCmbBx mProjectOnLaunchLineEdit mProjectOnLaunchPushBtn