diff --git a/src/desktop/dialogs/colordialog.cpp b/src/desktop/dialogs/colordialog.cpp index 128c36c031..e96b7a0e7f 100644 --- a/src/desktop/dialogs/colordialog.cpp +++ b/src/desktop/dialogs/colordialog.cpp @@ -2,6 +2,7 @@ #include "desktop/main.h" #include +#include namespace dialogs { @@ -14,6 +15,18 @@ void applyColorDialogSettings(color_widgets::ColorDialog *dlg) settings.bindColorWheelMirror(dlg, &color_widgets::ColorDialog::setWheelMirrored); } +void setColorDialogResetColor(color_widgets::ColorDialog *dlg, const QColor &color) +{ + color_widgets::ColorPreview *preview = dlg->findChild( + QStringLiteral("preview"), Qt::FindDirectChildrenOnly); + if(preview) { + preview->setComparisonColor(color); + preview->setDisplayMode(color_widgets::ColorPreview::SplitColor); + } else { + qWarning("Preview not found in color dialog, reset color not set"); + } +} + color_widgets::ColorDialog *newColorDialog(QWidget *parent) { color_widgets::ColorDialog *dlg = new color_widgets::ColorDialog{parent}; diff --git a/src/desktop/dialogs/colordialog.h b/src/desktop/dialogs/colordialog.h index ab9f35118a..81ece41907 100644 --- a/src/desktop/dialogs/colordialog.h +++ b/src/desktop/dialogs/colordialog.h @@ -10,6 +10,11 @@ namespace dialogs { // Applies the user's color wheel settings to the given color dialog. void applyColorDialogSettings(color_widgets::ColorDialog *dlg); +// Sets the color that the Reset button inside the dialog will reset to. +// Also changes the preview to split mode, to make it clear what reset will do. +void setColorDialogResetColor( + color_widgets::ColorDialog *dlg, const QColor &color); + // Makes a color dialog with the user's color wheel settings applied. color_widgets::ColorDialog * newColorDialog(QWidget *parent); diff --git a/src/desktop/dialogs/settingsdialog/userinterface.cpp b/src/desktop/dialogs/settingsdialog/userinterface.cpp index 4b67dd3b32..712b2e346e 100644 --- a/src/desktop/dialogs/settingsdialog/userinterface.cpp +++ b/src/desktop/dialogs/settingsdialog/userinterface.cpp @@ -163,6 +163,7 @@ void UserInterface::pickCanvasBackgroundColor(desktop::settings::Settings &setti dlg.setColor(settings.canvasViewBackgroundColor()); dlg.setAlphaEnabled(false); dialogs::applyColorDialogSettings(&dlg); + dialogs::setColorDialogResetColor(&dlg, CANVAS_VIEW_BACKGROUND_COLOR_DEFAULT); if(dlg.exec() == QDialog::Accepted) { settings.setCanvasViewBackgroundColor(dlg.color()); } diff --git a/src/desktop/settings_table.h b/src/desktop/settings_table.h index c23568b1c6..a07109a6d2 100644 --- a/src/desktop/settings_table.h +++ b/src/desktop/settings_table.h @@ -1,5 +1,7 @@ #include "libclient/settings_table_macros.h" +#define CANVAS_VIEW_BACKGROUND_COLOR_DEFAULT QColor(100, 100, 100) + #ifndef KINETIC_SCROLL_GESTURE_DEFAULT # ifdef Q_OS_ANDROID # define KINETIC_SCROLL_GESTURE_DEFAULT KineticScrollGesture::LeftClick @@ -34,7 +36,7 @@ SETTING(brushCursor , BrushCursor , "settings/brushcursor" , widgets::CanvasView::BrushCursor::TriangleRight) SETTING(brushOutlineWidth , BrushOutlineWidth , "settings/brushoutlinewidth" , 1.0) -SETTING(canvasViewBackgroundColor , CanvasViewBackgroundColor , "settings/canvasviewbackgroundcolor" , QColor(100, 100, 100)) +SETTING(canvasViewBackgroundColor , CanvasViewBackgroundColor , "settings/canvasviewbackgroundcolor" , CANVAS_VIEW_BACKGROUND_COLOR_DEFAULT) SETTING(canvasScrollBars , CanvasScrollBars , "settings/canvasscrollbars" , true) SETTING(canvasShortcuts , CanvasShortcuts , "settings/canvasshortcuts2" , QVariantMap()) #ifdef Q_OS_ANDROID