Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Use theme for Recorder thread indicator colors

Freya Lupen08aca5ef2d5c
diff --git a/plugins/dockers/recorder/CMakeLists.txt b/plugins/dockers/recorder/CMakeLists.txt
index 25643fb420..4adedd0099 100644
--- a/plugins/dockers/recorder/CMakeLists.txt
+++ b/plugins/dockers/recorder/CMakeLists.txt
@@ -39,5 +39,8 @@ install(FILES
kis_add_library(kritarecorderdocker MODULE ${KRITA_RECORDERDOCKER_SOURCES})
target_link_libraries(kritarecorderdocker kritaui Threads::Threads)
+if (QT_MAJOR_VERSION STREQUAL "6")
+target_link_libraries(kritarecorderdocker KF6::ColorScheme)
+endif()
install(TARGETS kritarecorderdocker DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
diff --git a/plugins/dockers/recorder/recorderdocker_dock.cpp b/plugins/dockers/recorder/recorderdocker_dock.cpp
index a23c74a0b2..e771841ad0 100644
--- a/plugins/dockers/recorder/recorderdocker_dock.cpp
+++ b/plugins/dockers/recorder/recorderdocker_dock.cpp
@@ -16,6 +16,9 @@
#include "recorder_export_config.h"
#include <klocalizedstring.h>
+#include <kactioncollection.h>
+#include "kcolorscheme.h"
+
#include <kis_action_registry.h>
#include <kis_canvas2.h>
#include <kis_icon_utils.h>
@@ -23,7 +26,6 @@
#include <KisDocument.h>
#include <KisViewManager.h>
#include <KoDocumentInfo.h>
-#include <kactioncollection.h>
#include <KisPart.h>
#include <KisKineticScroller.h>
#include "KisMainWindow.h"
@@ -46,18 +48,18 @@ namespace
const QString keyActionRecordToggle = "recorder_record_toggle";
const QString keyActionExport = "recorder_export";
-const QString activeColorGreen(" color='#5cab25'");
-const QString inactiveColorGreen(" color='#b4e196'");
-const QString activeColorOrange(" color='#ca8f14'");
-const QString inactiveColorOrange(" color='#ffe5af'");
-const QString activeColorRed(" color='#da4453'");
-const QString inactiveColorRed(" color='#f2c4c9'");
-const QString inactiveColorGray(" color='#3e3e3e'");
+QString activeColorPositive;
+QString activeColorNeutral;
+QString activeColorNegative;
+QString colorNormal;
+QString inactiveColorPositive;
+QString inactiveColorNeutral;
+QString inactiveColorNegative;
-const QColor textColorOrange(0xff, 0xe5, 0xaf);
-const QColor buttonColorOrange(0xca, 0x8f, 0x14);
-const QColor textColorRed(0xf2, 0xc4, 0xc9);
-const QColor buttonColorRed(0xda, 0x44, 0x53);
+QColor textColorNeutral;
+QColor buttonColorNeutral;
+QColor textColorNegative;
+QColor buttonColorNegative;
}
@@ -317,33 +319,27 @@ public:
void updateRecIndicator()
{
- auto threads = writer.recorderThreads.get();
- auto threadsInUse = writer.recorderThreads.getUsed();
+ uint threads = writer.recorderThreads.get();
+ uint threadsInUse = writer.recorderThreads.getUsed();
QString label("<font style='letter-spacing:-4px'>");
- QString activeColor;
- QString inactiveColor;
+ QString threadColor;
for (unsigned int threadNr = 1; threadNr <= ThreadSystemValue::MaxThreadCount ; threadNr++)
{
if (threadNr > threads) {
- activeColor = inactiveColorGray;
- inactiveColor = inactiveColorGray;
+ threadColor = colorNormal;
} else if (threadNr > ThreadSystemValue::MaxRecordThreadCount) {
- activeColor = activeColorRed;
- inactiveColor = inactiveColorRed;
+ threadColor = threadNr <= threadsInUse ? activeColorNegative : inactiveColorNegative;
} else if (threadNr > ThreadSystemValue::IdealRecordThreadCount) {
- activeColor = activeColorOrange;
- inactiveColor = inactiveColorOrange;
+ threadColor = threadNr <= threadsInUse ? activeColorNeutral : inactiveColorNeutral;
} else {
- activeColor = activeColorGreen;
- inactiveColor = inactiveColorGreen;
+ threadColor = threadNr <= threadsInUse ? activeColorPositive : inactiveColorPositive;
}
- label.append(QString("<font%1>▍</font>")
- .arg(threadNr <= threadsInUse ? activeColor : inactiveColor));
+ label.append(QString("<font color='%1'>▍</font>").arg(threadColor));
}
// don't remove empty <font></font> tag else label will jump a few pixels around
- label.append(QString("</font><font> %1 </font><font%2>●</font>")
+ label.append(QString("</font><font> %1 </font><font color='%2'>●</font>")
.arg(i18nc("Recording symbol", "REC"))
- .arg(paused ? "" : activeColorRed));
+ .arg(paused ? "" : activeColorNegative));
statusBarLabel->setText(label);
statusBarLabel->setToolTip(paused ? i18n("Recorder is paused") : QString(i18n("Active recording with %1 of %2 available threads")).arg(threadsInUse).arg(threads));
}
@@ -364,8 +360,8 @@ public:
// Number of threads exceeds ideal thread count
// -> switch color of threads slider and spin wheel to red
QPalette pal;
- pal.setColor(QPalette::Text, textColorRed);
- pal.setColor(QPalette::Button, buttonColorRed);
+ pal.setColor(QPalette::Text, textColorNegative);
+ pal.setColor(QPalette::Button, buttonColorNegative);
ui->spinThreads->setPalette(pal);
ui->sliderThreads->setPalette(pal);
toolTipText = QString(
@@ -375,8 +371,8 @@ public:
// Number of threads exceeds ideal recorder thread count
// -> switch color of threads slider and spin wheel to orange
QPalette pal;
- pal.setColor(QPalette::Text, textColorOrange);
- pal.setColor(QPalette::Button, buttonColorOrange);
+ pal.setColor(QPalette::Text, textColorNeutral);
+ pal.setColor(QPalette::Button, buttonColorNeutral);
ui->spinThreads->setPalette(pal);
ui->sliderThreads->setPalette(pal);
toolTipText = QString(
@@ -584,6 +580,31 @@ void RecorderDockerDock::onMainWindowIsBeingCreated(KisMainWindow *window)
KisKActionCollection *actionCollection = window->viewManager()->actionCollection();
actionCollection->addAction(keyActionRecordToggle, d->recordToggleAction);
actionCollection->addAction(keyActionExport, d->exportAction);
+
+ connect(window, SIGNAL(themeChanged()), this, SLOT(onThemeChanged()));
+ onThemeChanged();
+}
+
+void RecorderDockerDock::onThemeChanged()
+{
+ KColorScheme activeScheme(QPalette::Active, KColorScheme::Window);
+ activeColorPositive = activeScheme.foreground(KColorScheme::PositiveText).color().name();
+ activeColorNeutral = activeScheme.foreground(KColorScheme::NeutralText).color().name();
+ activeColorNegative = activeScheme.foreground(KColorScheme::NegativeText).color().name();
+
+ KColorScheme disabledScheme(QPalette::Disabled, KColorScheme::Window);
+ inactiveColorPositive = disabledScheme.foreground(KColorScheme::PositiveText).color().name();
+ inactiveColorNeutral = disabledScheme.foreground(KColorScheme::NeutralText).color().name();
+ inactiveColorNegative = disabledScheme.foreground(KColorScheme::NegativeText).color().name();
+ colorNormal = disabledScheme.foreground(KColorScheme::NormalText).color().name();
+
+ textColorNeutral = activeScheme.foreground(KColorScheme::NeutralText).color();
+ buttonColorNeutral = activeScheme.background(KColorScheme::NeutralBackground).color();
+ textColorNegative = activeScheme.foreground(KColorScheme::NegativeText).color();
+ buttonColorNegative = activeScheme.background(KColorScheme::NegativeBackground).color();
+
+ d->updateThreadUi();
+ d->updateRecIndicator();
}
bool RecorderDockerDock::onRecordButtonToggled(bool checked)
diff --git a/plugins/dockers/recorder/recorderdocker_dock.h b/plugins/dockers/recorder/recorderdocker_dock.h
index 9ad701aa87..fa5c763a4a 100644
--- a/plugins/dockers/recorder/recorderdocker_dock.h
+++ b/plugins/dockers/recorder/recorderdocker_dock.h
@@ -35,6 +35,7 @@ public:
private Q_SLOTS:
void onMainWindowIsBeingCreated(KisMainWindow *window);
+ void onThemeChanged();
void onRecordIsolateLayerModeToggled(bool checked);
void onAutoRecordToggled(bool checked);