Determine whether to use bright custom colors automatically
This commit is contained in:
parent
97a8dc3f99
commit
2139b204e3
|
@ -521,9 +521,6 @@ achieve a dark theming:
|
|||
load the file as a base
|
||||
https://raw.githubusercontent.com/Martchus/syncthingtray/master/tray/resources/dark-palette.ini
|
||||
and tweak the colors to your liking.
|
||||
* To make the rest of the colors used by Syncthing Tray fit with the dark color
|
||||
palette, enable "Bright custom text colors" in Syncthing Tray's settings under
|
||||
"Tray/Appearance".
|
||||
* To make general icons fit with the dark color palette, configure an
|
||||
appropriate icon them, e.g. select "Breeze Dark" as icon theme in Syncthing
|
||||
Tray's settings under "Qt/Appearance".
|
||||
|
|
|
@ -8,7 +8,7 @@ endforeach ()
|
|||
set(TS_FILES ../translations/${META_PROJECT_NAME}_de_DE.ts ../translations/${META_PROJECT_NAME}_en_US.ts)
|
||||
|
||||
# find qtutilities
|
||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.2.0 REQUIRED)
|
||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.7.0 REQUIRED)
|
||||
use_qt_utilities()
|
||||
|
||||
# find qtforkawesomequickimageprovider
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="" native="true">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -29,20 +29,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="colorsLabel">
|
||||
<property name="text">
|
||||
<string>Colors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="brightTextColorsCheckBox">
|
||||
<property name="text">
|
||||
<string>Bright custom text colors (use for dark color scheme)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="sizeVerticalLayout">
|
||||
<property name="spacing">
|
||||
|
@ -128,7 +114,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="passiveLabel">
|
||||
<property name="text">
|
||||
<string>States to enable passive mode</string>
|
||||
|
@ -138,7 +124,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QListView" name="passiveListView">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
|
|
|
@ -91,7 +91,6 @@ bool AppearanceOptionPage::apply()
|
|||
{
|
||||
KConfigGroup config = m_applet->config();
|
||||
config.writeEntry<QSize>("size", QSize(ui()->widthSpinBox->value(), ui()->heightSpinBox->value()));
|
||||
config.writeEntry<bool>("brightColors", ui()->brightTextColorsCheckBox->isChecked());
|
||||
config.writeEntry("passiveStates", m_passiveStatusSelection.toVariantList());
|
||||
|
||||
return true;
|
||||
|
@ -103,7 +102,6 @@ void AppearanceOptionPage::reset()
|
|||
const auto size(config.readEntry<>("size", QSize(25, 25)));
|
||||
ui()->widthSpinBox->setValue(size.width());
|
||||
ui()->heightSpinBox->setValue(size.height());
|
||||
ui()->brightTextColorsCheckBox->setChecked(config.readEntry<>("brightColors", false));
|
||||
m_passiveStatusSelection.applyVariantList(config.readEntry("passiveStates", QVariantList()));
|
||||
}
|
||||
|
||||
|
|
|
@ -149,6 +149,7 @@ void SyncthingApplet::init()
|
|||
m_currentConnectionConfig = config().readEntry<int>("selectedConfig", 0);
|
||||
|
||||
// apply settings and connect according to settings
|
||||
setBrightColors(isPaletteDark(paletteFromTheme(m_theme)));
|
||||
handleSettingsChanged();
|
||||
|
||||
m_initialized = true;
|
||||
|
@ -445,11 +446,6 @@ void SyncthingApplet::handleSettingsChanged()
|
|||
|
||||
// apply appearance settings
|
||||
setSize(config.readEntry<QSize>("size", QSize(25, 25)));
|
||||
const bool brightColors = config.readEntry<bool>("brightColors", false);
|
||||
m_dirModel.setBrightColors(brightColors);
|
||||
m_devModel.setBrightColors(brightColors);
|
||||
m_downloadModel.setBrightColors(brightColors);
|
||||
m_recentChangesModel.setBrightColors(brightColors);
|
||||
IconManager::instance().applySettings(&settings.icons.status);
|
||||
|
||||
// restore selected states
|
||||
|
@ -560,7 +556,9 @@ void SyncthingApplet::handleThemeChanged()
|
|||
|
||||
// return to the event loop before setting the new theme color; otherwise Qt Quick does not update the images
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
IconManager::instance().setPalette(paletteFromTheme(m_theme));
|
||||
const auto palette = paletteFromTheme(m_theme);
|
||||
IconManager::instance().setPalette(palette);
|
||||
setBrightColors(isPaletteDark(palette));
|
||||
if (m_imageProvider) {
|
||||
m_imageProvider->setDefaultColor(m_theme.color(Plasma::Theme::TextColor, Plasma::Theme::NormalColorGroup));
|
||||
}
|
||||
|
@ -568,6 +566,14 @@ void SyncthingApplet::handleThemeChanged()
|
|||
});
|
||||
}
|
||||
|
||||
void SyncthingApplet::setBrightColors(bool brightColors)
|
||||
{
|
||||
m_dirModel.setBrightColors(brightColors);
|
||||
m_devModel.setBrightColors(brightColors);
|
||||
m_downloadModel.setBrightColors(brightColors);
|
||||
m_recentChangesModel.setBrightColors(brightColors);
|
||||
}
|
||||
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
void SyncthingApplet::handleSystemdStatusChanged()
|
||||
{
|
||||
|
|
|
@ -184,6 +184,7 @@ private Q_SLOTS:
|
|||
void handleImageProviderDestroyed();
|
||||
void handleThemeChanged();
|
||||
void setPassive(bool passive);
|
||||
void setBrightColors(bool brightColors);
|
||||
|
||||
private:
|
||||
Plasma::Theme m_theme;
|
||||
|
|
|
@ -97,7 +97,7 @@ find_package(${PACKAGE_NAMESPACE_PREFIX}c++utilities${CONFIGURATION_PACKAGE_SUFF
|
|||
use_cpp_utilities()
|
||||
|
||||
# find qtutilities
|
||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.4.0 REQUIRED)
|
||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.7.0 REQUIRED)
|
||||
use_qt_utilities()
|
||||
|
||||
# find backend libraries
|
||||
|
|
|
@ -108,6 +108,7 @@ TrayWidget::TrayWidget(TrayMenu *parent)
|
|||
m_ui->downloadsTreeView->setModel(&m_dlModel);
|
||||
m_ui->recentChangesTreeView->setModel(&m_recentChangesModel);
|
||||
m_ui->recentChangesTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
setBrightColorsOfModelsAccordingToPalette();
|
||||
|
||||
// setup sync-all button
|
||||
m_cornerFrame = new QFrame(this);
|
||||
|
@ -503,11 +504,6 @@ void TrayWidget::applySettings(const QString &connectionConfig)
|
|||
if (settings.appearance.tabPosition >= QTabWidget::North && settings.appearance.tabPosition <= QTabWidget::East) {
|
||||
m_ui->tabWidget->setTabPosition(static_cast<QTabWidget::TabPosition>(settings.appearance.tabPosition));
|
||||
}
|
||||
const auto brightColors = settings.appearance.brightTextColors;
|
||||
m_dirModel.setBrightColors(brightColors);
|
||||
m_devModel.setBrightColors(brightColors);
|
||||
m_dlModel.setBrightColors(brightColors);
|
||||
m_recentChangesModel.setBrightColors(brightColors);
|
||||
IconManager::instance().applySettings(&settings.icons.status, settings.icons.distinguishTrayIcons ? &settings.icons.tray : nullptr);
|
||||
|
||||
// update status icon and text of tray icon because reconnect interval might have changed
|
||||
|
@ -524,6 +520,17 @@ void TrayWidget::applySettings(const QString &connectionConfig)
|
|||
}
|
||||
}
|
||||
|
||||
bool TrayWidget::event(QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::PaletteChange:
|
||||
setBrightColorsOfModelsAccordingToPalette();
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void TrayWidget::applySettingsOnAllInstances()
|
||||
{
|
||||
for (TrayWidget *instance : s_instances) {
|
||||
|
@ -830,4 +837,13 @@ void TrayWidget::showDialog(QWidget *dlg, bool maximized)
|
|||
dlg->activateWindow();
|
||||
}
|
||||
|
||||
void TrayWidget::setBrightColorsOfModelsAccordingToPalette()
|
||||
{
|
||||
const auto brightColors = isPaletteDark(palette());
|
||||
m_dirModel.setBrightColors(brightColors);
|
||||
m_devModel.setBrightColors(brightColors);
|
||||
m_dlModel.setBrightColors(brightColors);
|
||||
m_recentChangesModel.setBrightColors(brightColors);
|
||||
}
|
||||
|
||||
} // namespace QtGui
|
||||
|
|
|
@ -74,6 +74,9 @@ public Q_SLOTS:
|
|||
void quitTray();
|
||||
void applySettings(const QString &connectionConfig = QString());
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleStatusChanged(Data::SyncthingStatus status);
|
||||
static void applySettingsOnAllInstances();
|
||||
|
@ -101,6 +104,7 @@ private Q_SLOTS:
|
|||
void handleNewNotification(CppUtilities::DateTime when, const QString &msg);
|
||||
void handleConnectionSelected(QAction *connectionAction);
|
||||
void showDialog(QWidget *dlg, bool maximized = false);
|
||||
void setBrightColorsOfModelsAccordingToPalette();
|
||||
|
||||
private:
|
||||
TrayMenu *m_menu;
|
||||
|
|
|
@ -78,7 +78,7 @@ find_package(${PACKAGE_NAMESPACE_PREFIX}c++utilities${CONFIGURATION_PACKAGE_SUFF
|
|||
use_cpp_utilities(VISIBILITY PUBLIC)
|
||||
|
||||
# find qtutilities
|
||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.5.0 REQUIRED)
|
||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.7.0 REQUIRED)
|
||||
use_qt_utilities()
|
||||
|
||||
# find backend libraries
|
||||
|
|
|
@ -125,132 +125,6 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="colorsLabel">
|
||||
<property name="text">
|
||||
<string>Colors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QCheckBox" name="brightTextColorsCheckBox">
|
||||
<property name="text">
|
||||
<string>Bright custom text colors (use for dark color scheme)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="guiElementsLabel">
|
||||
<property name="text">
|
||||
<string>Optional GUI elements</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="showTrafficCheckBox">
|
||||
<property name="text">
|
||||
<string>Traffic statistics</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="positioningLabel">
|
||||
<property name="text">
|
||||
<string>Positioning</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<layout class="QVBoxLayout" name="positioningVerticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useCursorPosCheckBox">
|
||||
<property name="text">
|
||||
<string>Use cursor position</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="assumeIconPosLabel">
|
||||
<property name="text">
|
||||
<string>Otherwise assume tray icon coordinates to be:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="positioningHorizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="xPosSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>x: </string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-10000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="yPosSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>y: </string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-10000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="positioningHorizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="sizeLabel">
|
||||
<property name="text">
|
||||
|
@ -338,6 +212,118 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="guiElementsLabel">
|
||||
<property name="text">
|
||||
<string>Optional GUI elements</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="showTrafficCheckBox">
|
||||
<property name="text">
|
||||
<string>Traffic statistics</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="positioningLabel">
|
||||
<property name="text">
|
||||
<string>Positioning</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<layout class="QVBoxLayout" name="positioningVerticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useCursorPosCheckBox">
|
||||
<property name="text">
|
||||
<string>Use cursor position</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="assumeIconPosLabel">
|
||||
<property name="text">
|
||||
<string>Otherwise assume tray icon coordinates to be:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="positioningHorizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="xPosSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>x: </string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-10000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="yPosSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>y: </string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-10000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="positioningHorizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -341,7 +341,6 @@ void restore()
|
|||
appearance.trayMenuSize = settings.value(QStringLiteral("trayMenuSize"), appearance.trayMenuSize).toSize();
|
||||
appearance.frameStyle = settings.value(QStringLiteral("frameStyle"), appearance.frameStyle).toInt();
|
||||
appearance.tabPosition = settings.value(QStringLiteral("tabPos"), appearance.tabPosition).toInt();
|
||||
appearance.brightTextColors = settings.value(QStringLiteral("brightTextColors"), appearance.brightTextColors).toBool();
|
||||
v.icons.status = StatusIconSettings(settings.value(QStringLiteral("statusIcons")).toString());
|
||||
v.icons.tray = StatusIconSettings(settings.value(QStringLiteral("trayIcons")).toString());
|
||||
v.icons.status.renderSize = settings.value(QStringLiteral("statusIconsRenderSize"), v.icons.status.renderSize).toSize();
|
||||
|
@ -452,7 +451,6 @@ void save()
|
|||
settings.setValue(QStringLiteral("trayMenuSize"), appearance.trayMenuSize);
|
||||
settings.setValue(QStringLiteral("frameStyle"), appearance.frameStyle);
|
||||
settings.setValue(QStringLiteral("tabPos"), appearance.tabPosition);
|
||||
settings.setValue(QStringLiteral("brightTextColors"), appearance.brightTextColors);
|
||||
settings.setValue(QStringLiteral("statusIcons"), v.icons.status.toString());
|
||||
settings.setValue(QStringLiteral("trayIcons"), v.icons.tray.toString());
|
||||
settings.setValue(QStringLiteral("statusIconsRenderSize"), v.icons.status.renderSize);
|
||||
|
|
|
@ -62,7 +62,6 @@ struct SYNCTHINGWIDGETS_EXPORT Appearance {
|
|||
QSize trayMenuSize = QSize(450, 400);
|
||||
int frameStyle = static_cast<int>(QFrame::NoFrame) | static_cast<int>(QFrame::Plain);
|
||||
int tabPosition = QTabWidget::South;
|
||||
bool brightTextColors = false;
|
||||
struct SYNCTHINGWIDGETS_EXPORT Positioning {
|
||||
QPoint assumedIconPosition;
|
||||
bool useCursorPosition = true;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "resources/../../tray/resources/config.h"
|
||||
|
||||
#include <qtutilities/misc/compat.h>
|
||||
#include <qtutilities/misc/desktoputils.h>
|
||||
#include <qtutilities/paletteeditor/colorbutton.h>
|
||||
#include <qtutilities/settingsdialog/optioncategory.h>
|
||||
#include <qtutilities/settingsdialog/optioncategorymodel.h>
|
||||
|
@ -488,8 +489,6 @@ bool AppearanceOptionPage::apply()
|
|||
settings.frameStyle = style;
|
||||
settings.tabPosition = ui()->tabPosComboBox->currentIndex();
|
||||
|
||||
settings.brightTextColors = ui()->brightTextColorsCheckBox->isChecked();
|
||||
|
||||
settings.positioning.useCursorPosition = ui()->useCursorPosCheckBox->isChecked();
|
||||
settings.positioning.assumedIconPosition = QPoint(ui()->xPosSpinBox->value(), ui()->yPosSpinBox->value());
|
||||
return true;
|
||||
|
@ -529,8 +528,6 @@ void AppearanceOptionPage::reset()
|
|||
ui()->frameShadowComboBox->setCurrentIndex(index);
|
||||
ui()->tabPosComboBox->setCurrentIndex(settings.tabPosition);
|
||||
|
||||
ui()->brightTextColorsCheckBox->setChecked(settings.brightTextColors);
|
||||
|
||||
ui()->useCursorPosCheckBox->setChecked(settings.positioning.useCursorPosition);
|
||||
ui()->xPosSpinBox->setValue(settings.positioning.assumedIconPosition.x());
|
||||
ui()->yPosSpinBox->setValue(settings.positioning.assumedIconPosition.y());
|
||||
|
@ -1239,6 +1236,9 @@ QWidget *SystemdOptionPage::setupWidget()
|
|||
= QObject::connect(m_service, &SyncthingService::stateChanged, bind(&SystemdOptionPage::handleStatusChanged, this, _1, _2, _3));
|
||||
m_enabledChangedConn
|
||||
= QObject::connect(m_service, &SyncthingService::unitFileStateChanged, bind(&SystemdOptionPage::handleEnabledChanged, this, _1));
|
||||
if (const auto *optionPageWidget = qobject_cast<OptionPageWidget *>(widget)) {
|
||||
QObject::connect(optionPageWidget, &OptionPageWidget::paletteChanged, std::bind(&SystemdOptionPage::updateColors, this));
|
||||
}
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
@ -1294,22 +1294,22 @@ void SystemdOptionPage::handleDescriptionChanged(const QString &description)
|
|||
: description);
|
||||
}
|
||||
|
||||
void setIndicatorColor(QWidget *indicator, const QColor &color)
|
||||
static void setIndicatorColor(QWidget *indicator, const QColor &color)
|
||||
{
|
||||
indicator->setStyleSheet(QStringLiteral("border-radius:8px;background-color:") + color.name());
|
||||
}
|
||||
|
||||
void SystemdOptionPage::handleStatusChanged(const QString &activeState, const QString &subState, DateTime activeSince)
|
||||
{
|
||||
QStringList status;
|
||||
m_status.clear();
|
||||
if (!activeState.isEmpty()) {
|
||||
status << activeState;
|
||||
m_status << activeState;
|
||||
}
|
||||
if (!subState.isEmpty()) {
|
||||
status << subState;
|
||||
m_status << subState;
|
||||
}
|
||||
|
||||
const bool isRunning = m_service && m_service->isRunning();
|
||||
const bool isRunning = updateRunningColor();
|
||||
QString timeStamp;
|
||||
if (isRunning && !activeSince.isNull()) {
|
||||
timeStamp = QLatin1Char('\n') % QCoreApplication::translate("QtGui::SystemdOptionPage", "since ")
|
||||
|
@ -1317,24 +1317,42 @@ void SystemdOptionPage::handleStatusChanged(const QString &activeState, const QS
|
|||
}
|
||||
|
||||
ui()->statusValueLabel->setText(
|
||||
status.isEmpty() ? QCoreApplication::translate("QtGui::SystemdOptionPage", "unknown") : status.join(QStringLiteral(" - ")) + timeStamp);
|
||||
setIndicatorColor(ui()->statusIndicator,
|
||||
status.isEmpty() ? Colors::gray(values().appearance.brightTextColors)
|
||||
: (isRunning ? Colors::green(values().appearance.brightTextColors) : Colors::red(values().appearance.brightTextColors)));
|
||||
m_status.isEmpty() ? QCoreApplication::translate("QtGui::SystemdOptionPage", "unknown") : m_status.join(QStringLiteral(" - ")) + timeStamp);
|
||||
ui()->startPushButton->setVisible(!isRunning);
|
||||
ui()->stopPushButton->setVisible(!status.isEmpty() && isRunning);
|
||||
ui()->stopPushButton->setVisible(!m_status.isEmpty() && isRunning);
|
||||
}
|
||||
|
||||
void SystemdOptionPage::handleEnabledChanged(const QString &unitFileState)
|
||||
{
|
||||
const bool isEnabled = m_service && m_service->isEnabled();
|
||||
const auto isEnabled = updateEnabledColor();
|
||||
ui()->unitFileStateValueLabel->setText(
|
||||
unitFileState.isEmpty() ? QCoreApplication::translate("QtGui::SystemdOptionPage", "unknown") : unitFileState);
|
||||
setIndicatorColor(
|
||||
ui()->enabledIndicator, isEnabled ? Colors::green(values().appearance.brightTextColors) : Colors::gray(values().appearance.brightTextColors));
|
||||
ui()->enablePushButton->setVisible(!isEnabled);
|
||||
ui()->disablePushButton->setVisible(!unitFileState.isEmpty() && isEnabled);
|
||||
}
|
||||
|
||||
bool SystemdOptionPage::updateRunningColor()
|
||||
{
|
||||
const bool isRunning = m_service && m_service->isRunning();
|
||||
const auto brightColors = isPaletteDark(widget()->palette());
|
||||
setIndicatorColor(ui()->statusIndicator,
|
||||
m_status.isEmpty() ? Colors::gray(brightColors) : (isRunning ? Colors::green(brightColors) : Colors::red(brightColors)));
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
bool SystemdOptionPage::updateEnabledColor()
|
||||
{
|
||||
const auto isEnabled = m_service && m_service->isEnabled();
|
||||
const auto brightColors = isPaletteDark(widget()->palette());
|
||||
setIndicatorColor(ui()->enabledIndicator, isEnabled ? Colors::green(brightColors) : Colors::gray(brightColors));
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
void SystemdOptionPage::updateColors()
|
||||
{
|
||||
updateRunningColor();
|
||||
updateEnabledColor();
|
||||
}
|
||||
#endif
|
||||
|
||||
// WebViewOptionPage
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <qtutilities/settingsdialog/settingsdialog.h>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
|
@ -147,7 +148,11 @@ void handleSystemUnitChanged();
|
|||
void handleDescriptionChanged(const QString &description);
|
||||
void handleStatusChanged(const QString &activeState, const QString &subState, CppUtilities::DateTime activeSince);
|
||||
void handleEnabledChanged(const QString &unitFileState);
|
||||
bool updateRunningColor();
|
||||
bool updateEnabledColor();
|
||||
void updateColors();
|
||||
Data::SyncthingService *const m_service;
|
||||
QStringList m_status;
|
||||
QMetaObject::Connection m_unitChangedConn;
|
||||
QMetaObject::Connection m_descChangedConn;
|
||||
QMetaObject::Connection m_statusChangedConn;
|
||||
|
|
Loading…
Reference in New Issue