diff --git a/ChangeLog b/ChangeLog index 5acb9fc713..6fd99335cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Unreleased Version 2.2.2-pre * Fix: Don't mess up gridmap settings when opening brush settings dialog and initially changing a value in it. Thanks Blozzom for reporting. * Fix: Default "confirm action" to both the regular enter key as well as the one on the numpad. Thanks MachKerman for reporting. * Feature: Add settings button to color wheel, sliders and palette at the top-left of the dock. For the wheel, this allows changing the settings here now instead of having to go into the preferences. For the sliders, you can now toggle the color space here and decide whether to show all sliders and the hex input. For the palette, this just moves the menu button that used to be in the row below. Thanks MachKerman for suggesting. + * Feature: Align color wheel to the top of the dock instead of the center by default. Can be toggled in the dock's menu. Thanks MorrowShore for suggesting. 2024-08-09 Version 2.2.2-beta.3 * Fix: Use more accurate timers for performance profiles if the platform supports it. diff --git a/src/desktop/docks/colorspinner.cpp b/src/desktop/docks/colorspinner.cpp index 431ec19bed..91b0af866d 100644 --- a/src/desktop/docks/colorspinner.cpp +++ b/src/desktop/docks/colorspinner.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace docks { @@ -24,6 +25,8 @@ struct ColorSpinnerDock::Private { QAction *colorSpaceHclAction = nullptr; QAction *directionAscendingAction = nullptr; QAction *directionDescendingAction = nullptr; + QAction *alignTopAction = nullptr; + QAction *alignCenterAction = nullptr; color_widgets::Swatch *lastUsedSwatch = nullptr; color_widgets::ColorWheel *colorwheel = nullptr; bool updating = false; @@ -149,6 +152,28 @@ ColorSpinnerDock::ColorSpinnerDock(const QString &title, QWidget *parent) } }); + QMenu *alignMenu = menu->addMenu(tr("Alignment")); + QActionGroup *alignGroup = new QActionGroup(this); + + d->alignTopAction = alignMenu->addAction(tr("Top")); + d->alignTopAction->setCheckable(true); + alignGroup->addAction(d->alignTopAction); + connect(d->alignTopAction, &QAction::toggled, this, [this](bool toggled) { + if(toggled && !d->updating) { + dpApp().settings().setColorWheelAlign(int(Qt::AlignTop)); + } + }); + + d->alignCenterAction = alignMenu->addAction(tr("Center")); + d->alignCenterAction->setCheckable(true); + alignGroup->addAction(d->alignCenterAction); + connect( + d->alignCenterAction, &QAction::toggled, this, [this](bool toggled) { + if(toggled && !d->updating) { + dpApp().settings().setColorWheelAlign(int(Qt::AlignCenter)); + } + }); + d->menuButton = new widgets::GroupedToolButton(this); d->menuButton->setIcon(QIcon::fromTheme("application-menu")); d->menuButton->setPopupMode(QToolButton::InstantPopup); @@ -171,10 +196,18 @@ ColorSpinnerDock::ColorSpinnerDock(const QString &title, QWidget *parent) d->lastUsedSwatch, &color_widgets::Swatch::colorSelected, this, &ColorSpinnerDock::colorSelected); - // Create main widget - d->colorwheel = new color_widgets::ColorWheel(this); + QWidget *widget = new QWidget(this); + widget->setContentsMargins(0, 0, 0, 0); + + QVBoxLayout *layout = new QVBoxLayout(widget); + layout->setContentsMargins(4, 4, 4, 4); + layout->setSpacing(0); + + d->colorwheel = new color_widgets::ColorWheel; d->colorwheel->setMinimumSize(64, 64); - setWidget(d->colorwheel); + layout->addWidget(d->colorwheel); + + setWidget(widget); connect( d->colorwheel, &color_widgets::ColorWheel::colorSelected, this, @@ -185,6 +218,7 @@ ColorSpinnerDock::ColorSpinnerDock(const QString &title, QWidget *parent) settings.bindColorWheelAngle(this, &ColorSpinnerDock::setAngle); settings.bindColorWheelSpace(this, &ColorSpinnerDock::setColorSpace); settings.bindColorWheelMirror(this, &ColorSpinnerDock::setMirror); + settings.bindColorWheelAlign(this, &ColorSpinnerDock::setAlign); } ColorSpinnerDock::~ColorSpinnerDock() @@ -271,4 +305,16 @@ void ColorSpinnerDock::setMirror(bool mirror) } } +void ColorSpinnerDock::setAlign(int align) +{ + QScopedValueRollback guard(d->updating, true); + if(align & int(Qt::AlignTop)) { + d->alignTopAction->setChecked(true); + d->colorwheel->setAlignTop(true); + } else { + d->alignCenterAction->setChecked(true); + d->colorwheel->setAlignTop(false); + } +} + } diff --git a/src/desktop/docks/colorspinner.h b/src/desktop/docks/colorspinner.h index 60cf9157c6..64e26aa6ec 100644 --- a/src/desktop/docks/colorspinner.h +++ b/src/desktop/docks/colorspinner.h @@ -23,6 +23,7 @@ public slots: void setAngle(color_widgets::ColorWheel::AngleEnum angle); void setColorSpace(color_widgets::ColorWheel::ColorSpaceEnum colorSpace); void setMirror(bool mirror); + void setAlign(int align); signals: void colorSelected(const QColor &color); diff --git a/src/desktop/settings_table.h b/src/desktop/settings_table.h index ef3e2dbf20..7ab87406cc 100644 --- a/src/desktop/settings_table.h +++ b/src/desktop/settings_table.h @@ -74,6 +74,7 @@ SETTING(colorSlidersShowAll , ColorSlidersShowAll , "settings/colors SETTING(colorSlidersShowInput , ColorSlidersShowInput , "settings/colorsliders/showinput" , true) SETTING(colorSlidersMode , ColorSlidersMode , "settings/colorsliders/mode" , 0) SETTING(colorWheelAngle , ColorWheelAngle , "settings/colorwheel/rotate" , color_widgets::ColorWheel::AngleEnum::AngleRotating) +SETTING(colorWheelAlign , ColorWheelAlign , "settings/colorwheel/align" , int(Qt::AlignTop)) SETTING(colorWheelMirror , ColorWheelMirror , "settings/colorwheel/mirror" , true) SETTING(colorWheelShape , ColorWheelShape , "settings/colorwheel/shape" , color_widgets::ColorWheel::ShapeEnum::ShapeTriangle) SETTING(colorWheelSpace , ColorWheelSpace , "settings/colorwheel/space" , color_widgets::ColorWheel::ColorSpaceEnum::ColorHSV)