diff --git a/app/SysTray-X/SysTray-X.qrc b/app/SysTray-X/SysTray-X.qrc index 00f0cd2..b704796 100644 --- a/app/SysTray-X/SysTray-X.qrc +++ b/app/SysTray-X/SysTray-X.qrc @@ -28,5 +28,6 @@ languages/SysTray-X.pt-BR.ts languages/SysTray-X.zh-CN.qm languages/SysTray-X.zh-TW.qm + files/icons/blank-icon-dark.png diff --git a/app/SysTray-X/files/icons/blank-icon-dark.png b/app/SysTray-X/files/icons/blank-icon-dark.png new file mode 100644 index 0000000..1ba18db Binary files /dev/null and b/app/SysTray-X/files/icons/blank-icon-dark.png differ diff --git a/app/SysTray-X/preferences.cpp b/app/SysTray-X/preferences.cpp index 47fd106..de4373c 100644 --- a/app/SysTray-X/preferences.cpp +++ b/app/SysTray-X/preferences.cpp @@ -65,6 +65,8 @@ Preferences::Preferences( QObject *parent ) : QObject( parent ) m_version_build = QLatin1String( APP_BUILD ); m_version_hash = QLatin1String( APP_GITHASH ); m_version_branch = QLatin1String( APP_GITBRANCH ); + + m_theme = PREF_THEME_LIGHT; } @@ -528,6 +530,32 @@ void Preferences::setCloseType( CloseType close_type ) } +/* + * Get the theme pref. + */ +Preferences::Theme Preferences::getTheme() const +{ + return m_theme; +} + + +/* + * Set the theme pref. + */ +void Preferences::setTheme( Theme theme ) +{ + if( m_theme != theme ) + { + m_theme = theme; + + /* + * Tell the world the new preference + */ + emit signalThemeChange(); + } +} + + /* * Get the debug state. */ diff --git a/app/SysTray-X/preferences.h b/app/SysTray-X/preferences.h index 60009f7..b2dbc72 100644 --- a/app/SysTray-X/preferences.h +++ b/app/SysTray-X/preferences.h @@ -63,6 +63,11 @@ class Preferences : public QObject PREF_COUNT_NEW }; + enum Theme { + PREF_THEME_LIGHT = 0, + PREF_THEME_DARK + }; + /* * Window states */ @@ -365,6 +370,20 @@ class Preferences : public QObject */ void setCloseType( CloseType close_type ); + /** + * @brief getTheme. Get the theme state. + * + * @return The state. + */ + Theme getTheme() const; + + /** + * @brief setTheme. Set the theme state. + * + * @param The state. + */ + void setTheme( Theme theme ); + /** * @brief getDebug. Get the debug windows state. * @@ -486,6 +505,11 @@ class Preferences : public QObject */ void signalDebugChange(); + /** + * @brief signalThemeChange. Signal a theme state change. + */ + void signalThemeChange(); + private: /** @@ -618,6 +642,10 @@ class Preferences : public QObject */ QString m_version_branch; + /** + * @brief m_theme. The theme. + */ + Theme m_theme; }; #endif // PREFERENCES_H diff --git a/app/SysTray-X/preferences.ui b/app/SysTray-X/preferences.ui index b1f1888..13ab07b 100644 --- a/app/SysTray-X/preferences.ui +++ b/app/SysTray-X/preferences.ui @@ -7,7 +7,7 @@ 0 0 541 - 664 + 648 @@ -19,15 +19,15 @@ - + - + Default icon - + Icon @@ -112,19 +112,6 @@ Mail notification icon - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -256,6 +243,45 @@ + + + + Theme + + + + + + + + Light + + + true + + + themeGroup + + + + + + + Dark + + + false + + + themeGroup + + + + + + + + @@ -264,7 +290,7 @@ 20 - 113 + 78 @@ -566,10 +592,11 @@ - - - + + + + diff --git a/app/SysTray-X/preferencesdialog.cpp b/app/SysTray-X/preferencesdialog.cpp index ac18b43..42849fa 100644 --- a/app/SysTray-X/preferencesdialog.cpp +++ b/app/SysTray-X/preferencesdialog.cpp @@ -118,6 +118,12 @@ PreferencesDialog::PreferencesDialog( SysTrayXLink *link, Preferences *pref, QWi * Set number size */ setNumberSize( m_pref->getNumberSize() ); + + /* + * Set theme button Ids + */ + m_ui->themeGroup->setId( m_ui->lightRadioButton, Preferences::PREF_THEME_LIGHT); + m_ui->themeGroup->setId( m_ui->darkRadioButton, Preferences::PREF_THEME_DARK ); } @@ -320,6 +326,15 @@ void PreferencesDialog::setCountType( Preferences::CountType count_type ) } +/* + * Set the theme + */ +void PreferencesDialog::setTheme( Preferences::Theme theme ) +{ + ( m_ui->themeGroup->button( theme ) )->setChecked( true ); +} + + /* * Handle the accept signal */ @@ -348,10 +363,26 @@ void PreferencesDialog::slotAccept() m_pref->setCloseType( static_cast< Preferences::CloseType >( m_ui->closeTypeGroup->checkedId() ) ); m_pref->setShowNumber( m_ui->showNumberCheckBox->isChecked() ); - m_pref->setNumberColor( m_number_color ); m_pref->setNumberSize( m_ui->numberSizeSpinBox->value() ); m_pref->setCountType( static_cast< Preferences::CountType >( m_ui->countTypeGroup->checkedId() ) ); + Preferences::Theme theme = static_cast< Preferences::Theme >( m_ui->themeGroup->checkedId() ); + m_pref->setTheme( theme ); + + /* + * Force different color? + */ + if( theme == Preferences::PREF_THEME_LIGHT && m_number_color == "#ffffff" ) + { + setNumberColor( "#000000" ); + } + else + if( theme == Preferences::PREF_THEME_DARK && m_number_color == "#000000" ) + { + setNumberColor( "#ffffff" ); + } + m_pref->setNumberColor( m_number_color ); + m_pref->setDebug( m_ui->debugWindowCheckBox->isChecked() ); /* @@ -398,6 +429,8 @@ void PreferencesDialog::slotReject() setNumberSize( m_pref->getNumberSize()); setCountType( m_pref->getCountType() ); + setTheme( m_pref->getTheme() ); + setDebug( m_pref->getDebug()); } @@ -601,3 +634,12 @@ void PreferencesDialog::slotCountTypeChange() { setCountType( m_pref->getCountType() ); } + + +/* + * Handle the theme change signal + */ +void PreferencesDialog::slotThemeChange() +{ + setTheme( m_pref->getTheme() ); +} diff --git a/app/SysTray-X/preferencesdialog.h b/app/SysTray-X/preferencesdialog.h index a556fb1..6277169 100644 --- a/app/SysTray-X/preferencesdialog.h +++ b/app/SysTray-X/preferencesdialog.h @@ -158,6 +158,13 @@ class PreferencesDialog : public QDialog */ void setCountType( Preferences::CountType count_type ); + /** + * @brief setTheme. Set the theme. + * + * @param theme The theme. + */ + void setTheme( Preferences::Theme theme ); + signals: /** @@ -244,6 +251,11 @@ class PreferencesDialog : public QDialog */ void slotCountTypeChange(); + /** + * @brief slotThemeChange. Slot for handling theme change. + */ + void slotThemeChange(); + private slots: /** diff --git a/app/SysTray-X/systrayx.cpp b/app/SysTray-X/systrayx.cpp index 060cbcc..4fff755 100644 --- a/app/SysTray-X/systrayx.cpp +++ b/app/SysTray-X/systrayx.cpp @@ -123,6 +123,7 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent ) connect( m_preferences, &Preferences::signalStartMinimizedChange, m_pref_dialog, &PreferencesDialog::slotStartMinimizedChange ); connect( m_preferences, &Preferences::signalRestoreWindowPositionsChange, m_pref_dialog, &PreferencesDialog::slotRestoreWindowPositionsChange ); connect( m_preferences, &Preferences::signalCloseTypeChange, m_pref_dialog, &PreferencesDialog::slotCloseTypeChange ); + connect( m_preferences, &Preferences::signalThemeChange, m_pref_dialog, &PreferencesDialog::slotThemeChange ); connect( m_preferences, &Preferences::signalDebugChange, m_pref_dialog, &PreferencesDialog::slotDebugChange ); connect( m_preferences, &Preferences::signalDefaultIconTypeChange, m_link, &SysTrayXLink::slotDefaultIconTypeChange ); @@ -138,6 +139,7 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent ) connect( m_preferences, &Preferences::signalStartMinimizedChange, m_link, &SysTrayXLink::slotStartMinimizedChange ); connect( m_preferences, &Preferences::signalRestoreWindowPositionsChange, m_link, &SysTrayXLink::slotRestoreWindowPositionsChange ); connect( m_preferences, &Preferences::signalCloseTypeChange, m_link, &SysTrayXLink::slotCloseTypeChange ); + connect( m_preferences, &Preferences::signalThemeChange, m_link, &SysTrayXLink::slotThemeChange ); connect( m_preferences, &Preferences::signalDebugChange, m_link, &SysTrayXLink::slotDebugChange ); connect( m_preferences, &Preferences::signalHideDefaultIconChange, this, &SysTrayX::slotSelectIconObjectPref ); @@ -288,6 +290,7 @@ void SysTrayX::showTrayIcon() connect( m_preferences, &Preferences::signalShowNumberChange, m_tray_icon, &SysTrayXIcon::slotShowNumberChange ); connect( m_preferences, &Preferences::signalNumberColorChange, m_tray_icon, &SysTrayXIcon::slotNumberColorChange ); connect( m_preferences, &Preferences::signalNumberSizeChange, m_tray_icon, &SysTrayXIcon::slotNumberSizeChange ); + connect( m_preferences, &Preferences::signalThemeChange, m_tray_icon, &SysTrayXIcon::slotThemeChange ); connect( m_link, &SysTrayXLink::signalUnreadMail, m_tray_icon, &SysTrayXIcon::slotSetUnreadMail ); @@ -322,6 +325,7 @@ void SysTrayX::hideTrayIcon() disconnect( m_preferences, &Preferences::signalShowNumberChange, m_tray_icon, &SysTrayXIcon::slotShowNumberChange ); disconnect( m_preferences, &Preferences::signalNumberColorChange, m_tray_icon, &SysTrayXIcon::slotNumberColorChange ); disconnect( m_preferences, &Preferences::signalNumberSizeChange, m_tray_icon, &SysTrayXIcon::slotNumberSizeChange ); + disconnect( m_preferences, &Preferences::signalThemeChange, m_tray_icon, &SysTrayXIcon::slotThemeChange ); disconnect( m_link, &SysTrayXLink::signalUnreadMail, m_tray_icon, &SysTrayXIcon::slotSetUnreadMail ); @@ -394,6 +398,7 @@ void SysTrayX::showKdeTrayIcon() connect( m_preferences, &Preferences::signalShowNumberChange, m_kde_tray_icon, &SysTrayXStatusNotifier::slotShowNumberChange ); connect( m_preferences, &Preferences::signalNumberColorChange, m_kde_tray_icon, &SysTrayXStatusNotifier::slotNumberColorChange ); connect( m_preferences, &Preferences::signalNumberSizeChange, m_kde_tray_icon, &SysTrayXStatusNotifier::slotNumberSizeChange ); + connect( m_preferences, &Preferences::signalThemeChange, m_kde_tray_icon, &SysTrayXStatusNotifier::slotThemeChange ); connect( m_link, &SysTrayXLink::signalUnreadMail, m_kde_tray_icon, &SysTrayXStatusNotifier::slotSetUnreadMail ); @@ -427,6 +432,7 @@ void SysTrayX::hideKdeTrayIcon() disconnect( m_preferences, &Preferences::signalShowNumberChange, m_kde_tray_icon, &SysTrayXStatusNotifier::slotShowNumberChange ); disconnect( m_preferences, &Preferences::signalNumberColorChange, m_kde_tray_icon, &SysTrayXStatusNotifier::slotNumberColorChange ); disconnect( m_preferences, &Preferences::signalNumberSizeChange, m_kde_tray_icon, &SysTrayXStatusNotifier::slotNumberSizeChange ); + disconnect( m_preferences, &Preferences::signalThemeChange, m_kde_tray_icon, &SysTrayXStatusNotifier::slotThemeChange ); disconnect( m_link, &SysTrayXLink::signalUnreadMail, m_kde_tray_icon, &SysTrayXStatusNotifier::slotSetUnreadMail ); diff --git a/app/SysTray-X/systrayxicon.cpp b/app/SysTray-X/systrayxicon.cpp index 7629088..6e71a0f 100644 --- a/app/SysTray-X/systrayxicon.cpp +++ b/app/SysTray-X/systrayxicon.cpp @@ -240,7 +240,17 @@ void SysTrayXIcon::renderIcon() { case Preferences::PREF_BLANK_ICON: { - pixmap = QPixmap( ":/files/icons/blank-icon.png" ); + Preferences::Theme theme = m_pref->getTheme(); + + if( theme == Preferences::PREF_THEME_LIGHT ) + { + pixmap = QPixmap( ":/files/icons/blank-icon.png" ); + } + else + { + pixmap = QPixmap( ":/files/icons/blank-icon-dark.png" ); + } + break; } @@ -395,6 +405,15 @@ void SysTrayXIcon::slotNumberSizeChange() } +/* + * Handle the theme change signal + */ +void SysTrayXIcon::slotThemeChange() +{ + renderIcon(); +} + + /* * Handle activation of the tray icon */ diff --git a/app/SysTray-X/systrayxicon.h b/app/SysTray-X/systrayxicon.h index 63ad480..cbb41b5 100644 --- a/app/SysTray-X/systrayxicon.h +++ b/app/SysTray-X/systrayxicon.h @@ -161,6 +161,11 @@ class SysTrayXIcon : public QSystemTrayIcon */ void slotNumberSizeChange(); + /** + * @brief slotThemeChange. Slot for handling theme change signals. + */ + void slotThemeChange(); + private slots: /** diff --git a/app/SysTray-X/systrayxlink.cpp b/app/SysTray-X/systrayxlink.cpp index 990b8f0..9213e5f 100644 --- a/app/SysTray-X/systrayxlink.cpp +++ b/app/SysTray-X/systrayxlink.cpp @@ -712,6 +712,16 @@ void SysTrayXLink::DecodePreferences( const QJsonObject& pref ) m_pref->setCloseType( close_type ); } + if( pref.contains( "theme" ) && pref[ "theme" ].isString() ) + { + Preferences::Theme theme = static_cast< Preferences::Theme >( pref[ "theme" ].toString().toInt() ); + + /* + * Store the new theme + */ + m_pref->setTheme( theme ); + } + if( pref.contains( "debug" ) && pref[ "debug" ].isString() ) { bool debug = pref[ "debug" ].toString() == "true"; @@ -749,6 +759,7 @@ void SysTrayXLink::EncodePreferences( const Preferences& pref ) prefObject.insert("numberColor", QJsonValue::fromVariant( QString( pref.getNumberColor() ) ) ); prefObject.insert("numberSize", QJsonValue::fromVariant( QString::number( pref.getNumberSize() ) ) ); prefObject.insert("countType", QJsonValue::fromVariant( QString::number( pref.getCountType() ) ) ); + prefObject.insert("theme", QJsonValue::fromVariant( QString::number( pref.getTheme() ) ) ); QJsonObject preferencesObject; preferencesObject.insert("preferences", prefObject ); @@ -949,7 +960,22 @@ void SysTrayXLink::slotCountTypeChange() } +/* + * Handle a positions change signal + */ void SysTrayXLink::slotPositions( QList< QPoint > positions ) { sendPositions( positions ); } + + +/* + * Handle a theme change signal + */ +void SysTrayXLink::slotThemeChange() +{ + if( m_pref->getAppPrefChanged() ) + { + sendPreferences(); + } +} diff --git a/app/SysTray-X/systrayxlink.h b/app/SysTray-X/systrayxlink.h index d8e3808..df2b5c2 100644 --- a/app/SysTray-X/systrayxlink.h +++ b/app/SysTray-X/systrayxlink.h @@ -309,6 +309,11 @@ class SysTrayXLink : public QObject */ void slotPositions( QList< QPoint > positions ); + /** + * @brief slotThemeChange. Slot for handling theme change signals. + */ + void slotThemeChange(); + private slots: /** diff --git a/app/SysTray-X/systrayxstatusnotifier.cpp b/app/SysTray-X/systrayxstatusnotifier.cpp index c24eb0a..8447ba1 100644 --- a/app/SysTray-X/systrayxstatusnotifier.cpp +++ b/app/SysTray-X/systrayxstatusnotifier.cpp @@ -275,7 +275,16 @@ void SysTrayXStatusNotifier::renderIcon() { case Preferences::PREF_BLANK_ICON: { - pixmap = QPixmap( ":/files/icons/blank-icon.png" ); + Preferences::Theme theme = m_pref->getTheme(); + + if( theme == Preferences::PREF_THEME_LIGHT ) + { + pixmap = QPixmap( ":/files/icons/blank-icon.png" ); + } + else + { + pixmap = QPixmap( ":/files/icons/blank-icon-dark.png" ); + } break; } @@ -460,6 +469,15 @@ void SysTrayXStatusNotifier::slotNumberSizeChange() } +/* + * Handle the theme change signal + */ +void SysTrayXStatusNotifier::slotThemeChange() +{ + renderIcon(); +} + + /* * Handle activate request of the notification icon */ diff --git a/app/SysTray-X/systrayxstatusnotifier.h b/app/SysTray-X/systrayxstatusnotifier.h index 4f1beb5..1804639 100644 --- a/app/SysTray-X/systrayxstatusnotifier.h +++ b/app/SysTray-X/systrayxstatusnotifier.h @@ -182,6 +182,11 @@ class SysTrayXStatusNotifier : public KStatusNotifierItem */ void slotNumberSizeChange(); + /** + * @brief slotThemeChange. Slot for handling theme change signals. + */ + void slotThemeChange(); + private slots: /** diff --git a/webext/_locales/de/messages.json b/webext/_locales/de/messages.json index bbef320..b355382 100644 --- a/webext/_locales/de/messages.json +++ b/webext/_locales/de/messages.json @@ -204,6 +204,21 @@ "description": "Count new mails" }, + "icons_theme": { + "message": "Thema", + "description": "The theme" + }, + + "icons_theme_light": { + "message": "Licht", + "description": "The light theme" + }, + + "icons_theme_dark": { + "message": "Dunkel", + "description": "The dark theme" + }, + "accounts": { "message": "Konten", "description": "Title for Accounts options" diff --git a/webext/_locales/el/messages.json b/webext/_locales/el/messages.json index ae76469..18221ec 100644 --- a/webext/_locales/el/messages.json +++ b/webext/_locales/el/messages.json @@ -204,6 +204,21 @@ "description": "Count new mails" }, + "icons_theme": { + "message": "θέμα", + "description": "The theme" + }, + + "icons_theme_light": { + "message": "φως", + "description": "The light theme" + }, + + "icons_theme_dark": { + "message": "σκοτάδι", + "description": "The dark theme" + }, + "accounts": { "message": "Λογαριασμοί", "description": "Title for Accounts options" diff --git a/webext/_locales/en-US/messages.json b/webext/_locales/en-US/messages.json index 1bf8803..81b6771 100644 --- a/webext/_locales/en-US/messages.json +++ b/webext/_locales/en-US/messages.json @@ -204,6 +204,21 @@ "description": "Count new mails" }, + "icons_theme": { + "message": "Theme", + "description": "The theme" + }, + + "icons_theme_light": { + "message": "Light", + "description": "The light theme" + }, + + "icons_theme_dark": { + "message": "Dark", + "description": "The dark theme" + }, + "accounts": { "message": "Accounts", "description": "Title for Accounts options" diff --git a/webext/_locales/it/messages.json b/webext/_locales/it/messages.json index 2924336..a9c5d3c 100644 --- a/webext/_locales/it/messages.json +++ b/webext/_locales/it/messages.json @@ -204,6 +204,21 @@ "description": "Count new mails" }, + "icons_theme": { + "message": "Tema", + "description": "The theme" + }, + + "icons_theme_light": { + "message": "Leggero", + "description": "The light theme" + }, + + "icons_theme_dark": { + "message": "Scuro", + "description": "The dark theme" + }, + "accounts": { "message": "Account", "description": "Title for Accounts options" diff --git a/webext/_locales/nl/messages.json b/webext/_locales/nl/messages.json index 5c02b33..5671f4a 100644 --- a/webext/_locales/nl/messages.json +++ b/webext/_locales/nl/messages.json @@ -203,6 +203,21 @@ "message": "Nieuw", "description": "Count new mails" }, + + "icons_theme": { + "message": "Thema", + "description": "The theme" + }, + + "icons_theme_light": { + "message": "Licht", + "description": "The light theme" + }, + + "icons_theme_dark": { + "message": "Donker", + "description": "The dark theme" + }, "accounts": { "message": "Accounts", diff --git a/webext/_locales/pt-BR/messages.json b/webext/_locales/pt-BR/messages.json index 9fcb25f..c7b3938 100644 --- a/webext/_locales/pt-BR/messages.json +++ b/webext/_locales/pt-BR/messages.json @@ -204,6 +204,21 @@ "description": "Count new mails" }, + "icons_theme": { + "message": "Tema", + "description": "The theme" + }, + + "icons_theme_light": { + "message": "Claro", + "description": "The light theme" + }, + + "icons_theme_dark": { + "message": "Escuro", + "description": "The dark theme" + }, + "accounts": { "message": "Contas", "description": "Title for Accounts options" diff --git a/webext/_locales/ru/messages.json b/webext/_locales/ru/messages.json index 6523aa9..8748e35 100644 --- a/webext/_locales/ru/messages.json +++ b/webext/_locales/ru/messages.json @@ -204,6 +204,21 @@ "description": "Count new mails" }, + "icons_theme": { + "message": "Tема", + "description": "The theme" + }, + + "icons_theme_light": { + "message": "светлая", + "description": "The light theme" + }, + + "icons_theme_dark": { + "message": "темная", + "description": "The dark theme" + }, + "accounts": { "message": "Аккаунты", "description": "Title for Accounts options" diff --git a/webext/background.js b/webext/background.js index b3b8588..859f0a7 100644 --- a/webext/background.js +++ b/webext/background.js @@ -303,6 +303,7 @@ SysTrayX.Messaging = { "numberColor", "numberSize", "countType", + "theme", ]); getter.then(this.sendPreferencesStorage, this.onSendPreferecesStorageError); }, @@ -320,9 +321,16 @@ SysTrayX.Messaging = { const iconMime = result.iconMime || "image/png"; const icon = result.icon || []; const showNumber = result.showNumber || "true"; - const numberColor = result.numberColor || "#000000"; + let numberColor = result.numberColor || "#000000"; const numberSize = result.numberSize || "10"; const countType = result.countType || "0"; + const theme = result.theme || "0"; + + if (theme == "0" && numberColor == "#ffffff") { + numberColor = "#000000"; + } else if (theme == "1" && numberColor == "#000000") { + numberColor = "#ffffff"; + } // Send it to the app SysTrayX.Link.postSysTrayXMessage({ @@ -342,6 +350,7 @@ SysTrayX.Messaging = { numberColor: numberColor, numberSize: numberSize, countType: countType, + theme: theme, }, }); @@ -512,6 +521,13 @@ SysTrayX.Link = { }); } + const theme = response["preferences"].theme; + if (theme) { + browser.storage.sync.set({ + theme: theme, + }); + } + const debug = response["preferences"].debug; if (debug) { browser.storage.sync.set({ diff --git a/webext/css/options.css b/webext/css/options.css index 207f524..f95409f 100644 --- a/webext/css/options.css +++ b/webext/css/options.css @@ -114,6 +114,14 @@ body { padding: 10px 10px 10px 10px; } +#themeselect { + width: 25em; + border-style: solid; + border-width: 1px; + margin: 10px 10px 10px 10px; + padding: 10px 10px 10px 10px; +} + ul, #accountsTree { list-style-type: none; diff --git a/webext/icons/blank-icon-dark.png b/webext/icons/blank-icon-dark.png new file mode 100644 index 0000000..1ba18db Binary files /dev/null and b/webext/icons/blank-icon-dark.png differ diff --git a/webext/options.html b/webext/options.html index b5a5665..decece3 100644 --- a/webext/options.html +++ b/webext/options.html @@ -344,6 +344,28 @@ + + + + + + + + + +
+ __MSG_icons_theme__ +
+ + +
+ + +