From 161b2202a61225d2bc649a2fe43c03a6551dcb65 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Fri, 19 Feb 2021 18:45:11 +0200 Subject: [PATCH] Custom color is always black --- src/utils/confighandler.cpp | 18 +----------------- src/utils/confighandler.h | 3 +-- src/widgets/capture/capturewidget.cpp | 5 +++-- src/widgets/capture/colorpicker.cpp | 8 +------- src/widgets/capture/colorpicker.h | 2 -- 5 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 279824a2..4102eb96 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -117,22 +117,6 @@ QVector ConfigHandler::getUserColors() return colors; } -void ConfigHandler::setUserColors(const QVector& l) -{ - QStringList hexColors; - - for (const QColor& color : l) { - if (color.isValid()) { - hexColors.append(color.name()); - } else { - hexColors.append(QStringLiteral("picker")); - } - } - - m_settings.setValue(QStringLiteral("userColors"), - QVariant::fromValue(hexColors)); -} - QString ConfigHandler::savePath() { return m_settings.value(QStringLiteral("savePath")).toString(); @@ -301,7 +285,7 @@ int ConfigHandler::drawThicknessValue() return res; } -void ConfigHandler::setdrawThickness(const int thickness) +void ConfigHandler::setDrawThickness(const int thickness) { m_settings.setValue(QStringLiteral("drawThickness"), thickness); } diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 4448b28a..9fa5abd8 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -32,7 +32,6 @@ public: void setButtons(const QVector&); QVector getUserColors(); - void setUserColors(const QVector&); QString savePath(); void setSavePath(const QString&); @@ -65,7 +64,7 @@ public: void setDisabledTrayIcon(const bool); int drawThicknessValue(); - void setdrawThickness(const int); + void setDrawThickness(const int); bool keepOpenAppLauncherValue(); void setKeepOpenAppLauncher(const bool); diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index f08d37c1..eb5bf31d 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -200,7 +200,7 @@ CaptureWidget::~CaptureWidget() } else { emit captureFailed(m_id); } - m_config.setdrawThickness(m_context.thickness); + m_config.setDrawThickness(m_context.thickness); } // redefineButtons retrieves the buttons configured to be shown with the @@ -548,6 +548,7 @@ void CaptureWidget::mouseReleaseEvent(QMouseEvent* e) m_colorPicker->hide(); m_rightClick = false; if (!m_context.color.isValid()) { + m_context.color = ConfigHandler().drawColorValue(); m_panel->show(); } // when we end the drawing we have to register the last point and @@ -1003,7 +1004,7 @@ void CaptureWidget::decrementCircleCount() void CaptureWidget::setDrawThickness(const int& t) { m_context.thickness = qBound(0, t, 100); - ConfigHandler().setdrawThickness(m_context.thickness); + ConfigHandler().setDrawThickness(m_context.thickness); emit thicknessChanged(m_context.thickness); } diff --git a/src/widgets/capture/colorpicker.cpp b/src/widgets/capture/colorpicker.cpp index a4bba16e..b53375c8 100644 --- a/src/widgets/capture/colorpicker.cpp +++ b/src/widgets/capture/colorpicker.cpp @@ -53,11 +53,6 @@ ColorPicker::ColorPicker(QWidget* parent) } } -QColor ColorPicker::drawColor() -{ - return m_drawColor; -} - void ColorPicker::show() { grabMouse(); @@ -131,8 +126,7 @@ void ColorPicker::mouseMoveEvent(QMouseEvent* e) { for (int i = 0; i < m_colorList.size(); ++i) { if (m_colorAreaList.at(i).contains(e->pos())) { - m_drawColor = m_colorList.at(i); - emit colorSelected(m_drawColor); + emit colorSelected(m_colorList.at(i)); update(); break; } diff --git a/src/widgets/capture/colorpicker.h b/src/widgets/capture/colorpicker.h index ae16987c..88eda7dd 100644 --- a/src/widgets/capture/colorpicker.h +++ b/src/widgets/capture/colorpicker.h @@ -25,8 +25,6 @@ class ColorPicker : public QWidget public: explicit ColorPicker(QWidget* parent = nullptr); - QColor drawColor(); - void show(); void hide();