Skip to content

Commit

Permalink
Update ColorToolButton
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Sep 16, 2024
1 parent c7454d0 commit a10c879
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
21 changes: 8 additions & 13 deletions src/ui/widgets/colortoolbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ ColorToolButton::ColorToolButton(QWidget * const parent)
setAutoPopup(false); // TODO: add to settings (auto/click popup)
setPopupMode(ToolButtonPopupMode::InstantPopup);

mColorWidget = new ColorSettingsWidget(this);
mColorWidget->setColorModeVisible(false);
mColorWidget->setContentsMargins(10, 10, 10, 10);
mColorWidget->setMinimumWidth(250);

mColorAct = new QWidgetAction(this);
mColorAct->setDefaultWidget(mColorWidget);

mColorLabel = new ColorLabel(this, false);

const auto lay = new QVBoxLayout(this);
Expand Down Expand Up @@ -75,19 +82,7 @@ void ColorToolButton::setColorStrokeTarget(OutlineSettingsAnimator * const targe

void ColorToolButton::setColorTarget(ColorAnimator * const target)
{
if (mColorWidget) {
mColorAct->releaseWidget(mColorWidget);
delete mColorWidget;
mColorWidget = nullptr;
}

if (target) {
mColorWidget = eWidgets::sColorWidget(this, target, false);
mColorWidget->setContentsMargins(10, 10, 10, 10);
mColorWidget->setMinimumWidth(250);
mColorAct->setDefaultWidget(mColorWidget);
}

mColorWidget->setTarget(target);
mColorTarget.assign(target);
if (target) {
mColorTarget << connect(target->getVal1Animator(),
Expand Down
3 changes: 2 additions & 1 deletion src/ui/widgets/colortoolbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "widgets/colorlabel.h"
#include "widgets/toolbutton.h"
#include "conncontextptr.h"
#include "widgets/colorsettingswidget.h"

#include <QWidgetAction>

Expand All @@ -52,7 +53,7 @@ namespace Friction
private:
QColor mColor;
ColorLabel *mColorLabel;
QWidget *mColorWidget;
ColorSettingsWidget *mColorWidget;
QWidgetAction *mColorAct;
ConnContextQPtr<ColorAnimator> mColorTarget;
ConnContextQPtr<FillSettingsAnimator> mColorFillTarget;
Expand Down

0 comments on commit a10c879

Please sign in to comment.