From 51c1a37b50b5d06731e2b23b5d33507f4e6dc61d Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Fri, 19 May 2017 23:57:53 +0200 Subject: [PATCH] Add ui color modification logic --- capture/capturewidget.cpp | 2 ++ config/configwindow.cpp | 6 ++++++ config/uicoloreditor.cpp | 36 ++++++++++++++++++++++++++++++++++++ config/uicoloreditor.h | 13 ++++++++----- flameshot.pro | 6 ++++-- 5 files changed, 56 insertions(+), 7 deletions(-) diff --git a/capture/capturewidget.cpp b/capture/capturewidget.cpp index 5f81ad06..5ca0c3b4 100644 --- a/capture/capturewidget.cpp +++ b/capture/capturewidget.cpp @@ -97,11 +97,13 @@ CaptureWidget::~CaptureWidget() { // selection in the capture void CaptureWidget::redefineButtons() { QSettings settings; + QString buttonStyle = Button::getStyle(); auto buttonsInt = settings.value("buttons").value >(); QVector vectorButtons; for (auto i: buttonsInt) { auto t = static_cast(i); Button *b = new Button(t, this); + b->setStyleSheet(buttonStyle); if (t == Button::Type::selectionIndicator) { m_sizeIndButton = b; } diff --git a/config/configwindow.cpp b/config/configwindow.cpp index 33b14803..2c9ce491 100644 --- a/config/configwindow.cpp +++ b/config/configwindow.cpp @@ -18,6 +18,7 @@ #include "configwindow.h" #include "capture/button.h" #include "config/buttonlistview.h" +#include "config/uicoloreditor.h" #include #include #include @@ -32,6 +33,11 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QWidget(parent){ QVBoxLayout *baseLayout = new QVBoxLayout(this); + QLabel *colorSelectionLabel = new QLabel("Choose the UI color", this); + baseLayout->addWidget(colorSelectionLabel); + + baseLayout->addWidget(new UIcolorEditor(this)); + QLabel *buttonSelectLabel = new QLabel("Choose the buttons to enable", this); baseLayout->addWidget(buttonSelectLabel); diff --git a/config/uicoloreditor.cpp b/config/uicoloreditor.cpp index 76ffab0b..638a3b2d 100644 --- a/config/uicoloreditor.cpp +++ b/config/uicoloreditor.cpp @@ -1,5 +1,41 @@ #include "uicoloreditor.h" +#include "color_wheel.hpp" +#include "buttonlistview.h" +#include +#include +#include UIcolorEditor::UIcolorEditor(QWidget *parent) : QWidget(parent) { + setFixedSize(200,130); + QHBoxLayout *hLayout = new QHBoxLayout; + QVBoxLayout *vLayout = new QVBoxLayout; + setLayout(hLayout); + color_widgets::ColorWheel *colorWheel = new color_widgets::ColorWheel(this); + connect(colorWheel, &color_widgets::ColorWheel::mouseReleaseOnColor, this, + &UIcolorEditor::updateUIcolor); + connect(colorWheel, &color_widgets::ColorWheel::colorChanged, this, + &UIcolorEditor::updateLocalColor); + + QSettings settings; + m_uiColor = settings.value("uiColor").value(); + + colorWheel->setColor(m_uiColor); + colorWheel->setFixedSize(100,100); + hLayout->addWidget(colorWheel); + + hLayout->addLayout(vLayout); + + + + setLayout(hLayout); +} + +void UIcolorEditor::updateUIcolor() { + QSettings settings; + settings.setValue("uiColor", m_uiColor); +} + +void UIcolorEditor::updateLocalColor(QColor c) { + m_uiColor = c; } diff --git a/config/uicoloreditor.h b/config/uicoloreditor.h index 52a5062c..dff47375 100644 --- a/config/uicoloreditor.h +++ b/config/uicoloreditor.h @@ -1,5 +1,5 @@ -#ifndef UICOLOREDITOR_H -#define UICOLOREDITOR_H +#ifndef UICOLORPICKER_H +#define UICOLORPICKER_H #include @@ -8,9 +8,12 @@ class UIcolorEditor : public QWidget { public: explicit UIcolorEditor(QWidget *parent = 0); -signals: +private slots: + void updateUIcolor(); + void updateLocalColor(QColor); -public slots: +private: + QColor m_uiColor; }; -#endif // UICOLOREDITOR_H +#endif // UICOLORPICKER_H diff --git a/flameshot.pro b/flameshot.pro index 71f36322..b0c1f366 100644 --- a/flameshot.pro +++ b/flameshot.pro @@ -43,7 +43,8 @@ SOURCES += main.cpp\ capture/capturewidget.cpp \ capture/capturemodification.cpp \ capture/colorpicker.cpp \ - config/buttonlistview.cpp + config/buttonlistview.cpp \ + config/uicoloreditor.cpp HEADERS += \ nativeeventfilter.h \ @@ -56,7 +57,8 @@ HEADERS += \ capture/capturewidget.h \ capture/capturemodification.h \ capture/colorpicker.h \ - config/buttonlistview.h + config/buttonlistview.h \ + config/uicoloreditor.h RESOURCES += \ graphics.qrc