Skip to content

Commit

Permalink
Bookmark color shortcut (B) #119
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Mar 1, 2024
1 parent a0c4c5e commit 269879a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/app/GUI/ColorWidgets/colorlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ void ColorLabel::setAlpha(const qreal alpha_t) {
update();
}

void ColorLabel::addBookmark()
{
const QColor col = QColor::fromHsvF(qreal(mHue),
qreal(mSaturation),
qreal(mValue),
mAlpha);
Document::sInstance->addBookmarkColor(col);
}

void ColorLabel::paintGL() {
qreal pixelRatio = devicePixelRatioF();
glClear(GL_COLOR_BUFFER_BIT);
Expand Down
2 changes: 2 additions & 0 deletions src/app/GUI/ColorWidgets/colorlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class ColorLabel : public ColorWidget {
void setLastColorHSV(GLfloat h, GLfloat s, GLfloat v);
void mousePressEvent(QMouseEvent *e);
void setAlpha(const qreal alpha_t);
void addBookmark();

private:
void paintGL();
qreal mAlpha = 1;
Expand Down
10 changes: 10 additions & 0 deletions src/app/GUI/ColorWidgets/colorsettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#include "GUI/global.h"
#include "GUI/actionbutton.h"
#include "GUI/ColorWidgets/savedcolorswidget.h"
#include "appsupport.h"

#include <QShortcut>

void ColorSettingsWidget::updateWidgetTargets()
{
Expand Down Expand Up @@ -275,6 +278,13 @@ ColorSettingsWidget::ColorSettingsWidget(QWidget *parent) : QWidget(parent) {
mColorLabel->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);

const auto book = new QShortcut(QKeySequence(AppSupport::getSettings("shortcuts",
"colorBookmark",
"B").toString()),
this);
connect(book, &QShortcut::activated,
mColorLabel, &ColorLabel::addBookmark);

// mWheelWidget->setLayout(mWheelLayout);
// mWheelLayout->setAlignment(Qt::AlignTop);
// wheel_triangle_widget = new H_Wheel_SV_Triangle(this);
Expand Down

0 comments on commit 269879a

Please sign in to comment.