diff --git a/data/data.qrc b/data/data.qrc index 3b2ca3e0..e1ba7a53 100644 --- a/data/data.qrc +++ b/data/data.qrc @@ -19,6 +19,7 @@ style/smartplaylistsearchterm.css html/oauthsuccess.html pictures/strawberry.png + pictures/strawberry-grey.png pictures/strawberry-faded.png pictures/strawbs.png pictures/nomusic.png diff --git a/data/icons.qrc b/data/icons.qrc index 21307b33..0b7b484a 100644 --- a/data/icons.qrc +++ b/data/icons.qrc @@ -72,6 +72,7 @@ icons/128x128/star-grey.png icons/128x128/star.png icons/128x128/strawberry.png + icons/128x128/strawberry-grey.png icons/128x128/tools-wizard.png icons/128x128/view-choose.png icons/128x128/view-fullscreen.png @@ -164,6 +165,7 @@ icons/64x64/star-grey.png icons/64x64/star.png icons/64x64/strawberry.png + icons/64x64/strawberry-grey.png icons/64x64/tools-wizard.png icons/64x64/view-choose.png icons/64x64/view-fullscreen.png @@ -260,6 +262,7 @@ icons/48x48/star-grey.png icons/48x48/star.png icons/48x48/strawberry.png + icons/48x48/strawberry-grey.png icons/48x48/tools-wizard.png icons/48x48/view-choose.png icons/48x48/view-fullscreen.png @@ -356,6 +359,7 @@ icons/32x32/star-grey.png icons/32x32/star.png icons/32x32/strawberry.png + icons/32x32/strawberry-grey.png icons/32x32/tools-wizard.png icons/32x32/view-choose.png icons/32x32/view-fullscreen.png @@ -452,6 +456,7 @@ icons/22x22/star-grey.png icons/22x22/star.png icons/22x22/strawberry.png + icons/22x22/strawberry-grey.png icons/22x22/tools-wizard.png icons/22x22/view-choose.png icons/22x22/view-fullscreen.png diff --git a/data/icons/128x128/strawberry-grey.png b/data/icons/128x128/strawberry-grey.png new file mode 100644 index 00000000..ae2f3b94 Binary files /dev/null and b/data/icons/128x128/strawberry-grey.png differ diff --git a/data/icons/22x22/strawberry-grey.png b/data/icons/22x22/strawberry-grey.png new file mode 100644 index 00000000..017efef1 Binary files /dev/null and b/data/icons/22x22/strawberry-grey.png differ diff --git a/data/icons/32x32/strawberry-grey.png b/data/icons/32x32/strawberry-grey.png new file mode 100644 index 00000000..1ba1e82d Binary files /dev/null and b/data/icons/32x32/strawberry-grey.png differ diff --git a/data/icons/48x48/strawberry-grey.png b/data/icons/48x48/strawberry-grey.png new file mode 100644 index 00000000..4f6c944c Binary files /dev/null and b/data/icons/48x48/strawberry-grey.png differ diff --git a/data/icons/64x64/strawberry-grey.png b/data/icons/64x64/strawberry-grey.png new file mode 100644 index 00000000..0b5ee597 Binary files /dev/null and b/data/icons/64x64/strawberry-grey.png differ diff --git a/data/icons/full/strawberry-grey.png b/data/icons/full/strawberry-grey.png new file mode 100644 index 00000000..cd7872d0 Binary files /dev/null and b/data/icons/full/strawberry-grey.png differ diff --git a/data/pictures/strawberry-grey.png b/data/pictures/strawberry-grey.png new file mode 100644 index 00000000..d8902ffe Binary files /dev/null and b/data/pictures/strawberry-grey.png differ diff --git a/src/core/macsystemtrayicon.h b/src/core/macsystemtrayicon.h index 1e66278d..316375b7 100644 --- a/src/core/macsystemtrayicon.h +++ b/src/core/macsystemtrayicon.h @@ -58,6 +58,7 @@ protected: private: QPixmap normal_icon_; + QPixmap grey_icon_; std::unique_ptr p_; Q_DISABLE_COPY(MacSystemTrayIcon); }; diff --git a/src/core/macsystemtrayicon.mm b/src/core/macsystemtrayicon.mm index 62c3098c..bb531fae 100644 --- a/src/core/macsystemtrayicon.mm +++ b/src/core/macsystemtrayicon.mm @@ -165,7 +165,8 @@ class MacSystemTrayIconPrivate { MacSystemTrayIcon::MacSystemTrayIcon(QObject* parent) : SystemTrayIcon(parent), - normal_icon_(QPixmap(":/pictures/strawberry.png").scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation)) { + normal_icon_(QPixmap(":/pictures/strawberry.png").scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation)), + grey_icon_(QPixmap(":/pictures/strawberry-grey.png").scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation)) { QApplication::setWindowIcon(normal_icon_); } diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 680b774e..73ce3726 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -1023,6 +1023,7 @@ void MainWindow::ReloadSettings() { s.beginGroup(BehaviourSettingsPage::kSettingsGroup); keep_running_ = s.value("keeprunning", false).toBool(); playing_widget_ = s.value("playing_widget", true).toBool(); + bool trayicon_progress = s.value("trayicon_progress", false).toBool(); if (playing_widget_ != ui_->widget_playing->IsEnabled()) TabSwitched(); doubleclick_addmode_ = BehaviourSettingsPage::AddBehaviour(s.value("doubleclick_addmode", BehaviourSettingsPage::AddBehaviour_Append).toInt()); doubleclick_playmode_ = BehaviourSettingsPage::PlayBehaviour(s.value("doubleclick_playmode", BehaviourSettingsPage::PlayBehaviour_Never).toInt()); @@ -1034,6 +1035,8 @@ void MainWindow::ReloadSettings() { int iconsize = s.value(AppearanceSettingsPage::kIconSizePlayControlButtons, 32).toInt(); s.endGroup(); + if (tray_icon_) tray_icon_->SetTrayiconProgress(trayicon_progress); + ui_->back_button->setIconSize(QSize(iconsize, iconsize)); ui_->pause_play_button->setIconSize(QSize(iconsize, iconsize)); ui_->stop_button->setIconSize(QSize(iconsize, iconsize)); @@ -2960,7 +2963,7 @@ void MainWindow::SetToggleScrobblingIcon(const bool value) { if (value) { if (app_->playlist_manager()->active() && app_->playlist_manager()->active()->scrobbled()) ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", 22)); - else + else ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", 22)); // TODO: Create a faint version of the icon } else { diff --git a/src/core/qtsystemtrayicon.cpp b/src/core/qtsystemtrayicon.cpp index efff2c1e..fa958159 100644 --- a/src/core/qtsystemtrayicon.cpp +++ b/src/core/qtsystemtrayicon.cpp @@ -54,7 +54,10 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject *parent) action_mute_(nullptr) { app_name_[0] = app_name_[0].toUpper(); - + QIcon theme_icon_grey = IconLoader::Load("strawberry-grey"); + if (! theme_icon_grey.isNull()) { + grey_icon_ = theme_icon_grey.pixmap(48, QIcon::Disabled); + } tray_->setIcon(normal_icon_); tray_->installEventFilter(this); ClearNowPlaying(); diff --git a/src/core/systemtrayicon.cpp b/src/core/systemtrayicon.cpp index 57e31673..bb06fbdb 100644 --- a/src/core/systemtrayicon.cpp +++ b/src/core/systemtrayicon.cpp @@ -47,31 +47,31 @@ SystemTrayIcon::SystemTrayIcon(QObject *parent) QPixmap SystemTrayIcon::CreateIcon(const QPixmap &icon, const QPixmap &grey_icon) { - Q_UNUSED(grey_icon); - QRect rect(icon.rect()); - // The angle of the line that's used to cover the icon. - // Centered on rect.topRight() - double angle = double(100 - song_progress()) / 100.0 * M_PI_2 + M_PI; - double length = sqrt(pow(rect.width(), 2.0) + pow(rect.height(), 2.0)); - - QPolygon mask; - mask << rect.topRight(); - mask << rect.topRight() + QPoint(length * sin(angle), -length * cos(angle)); - - if (song_progress() > 50) mask << rect.bottomLeft(); - - mask << rect.topLeft(); - mask << rect.topRight(); - QPixmap ret(icon); QPainter p(&ret); - // Draw the grey bit - //p.setClipRegion(mask); - //p.drawPixmap(0, 0, grey_icon); - //p.setClipping(false); + if (trayicon_progress_) { + // The angle of the line that's used to cover the icon. + // Centered on rect.topLeft() + double angle = double(100 - song_progress()) / 100.0 * M_PI_2; + double length = sqrt(pow(rect.width(), 2.0) + pow(rect.height(), 2.0)); + + QPolygon mask; + mask << rect.topLeft(); + mask << rect.topLeft() + QPoint(length * sin(angle), length * cos(angle)); + + if (song_progress() > 50) mask << rect.bottomRight(); + + mask << rect.topRight(); + mask << rect.topLeft(); + + // Draw the grey bit + p.setClipRegion(mask); + p.drawPixmap(0, 0, grey_icon); + p.setClipping(false); + } // Draw the playing or paused icon in the top-right if (!current_state_icon().isNull()) { diff --git a/src/core/systemtrayicon.h b/src/core/systemtrayicon.h index 2976d57b..8e5b4eab 100644 --- a/src/core/systemtrayicon.h +++ b/src/core/systemtrayicon.h @@ -57,6 +57,7 @@ class SystemTrayIcon : public QObject { public slots: void SetProgress(int percentage); + void SetTrayiconProgress(bool enabled) { trayicon_progress_ = enabled; } virtual void SetPaused(); virtual void SetPlaying(bool enable_play_pause = false); virtual void SetStopped(); @@ -85,6 +86,7 @@ class SystemTrayIcon : public QObject { QPixmap playing_icon_; QPixmap paused_icon_; QPixmap current_state_icon_; + bool trayicon_progress_; }; #endif // SYSTEMTRAYICON_H diff --git a/src/settings/behavioursettingspage.cpp b/src/settings/behavioursettingspage.cpp index 869a8356..31761677 100644 --- a/src/settings/behavioursettingspage.cpp +++ b/src/settings/behavioursettingspage.cpp @@ -68,6 +68,7 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog) : SettingsP #ifdef Q_OS_MACOS ui_->checkbox_showtrayicon->hide(); ui_->checkbox_keeprunning->hide(); + ui_->checkbox_trayicon_progress->hide(); ui_->checkbox_scrolltrayicon->hide(); ui_->groupbox_startup->hide(); #endif @@ -155,19 +156,23 @@ void BehaviourSettingsPage::Load() { if (QSystemTrayIcon::isSystemTrayAvailable()) { ui_->checkbox_showtrayicon->setEnabled(true); ui_->checkbox_keeprunning->setEnabled(true); + ui_->checkbox_trayicon_progress->setEnabled(true); ui_->checkbox_scrolltrayicon->setEnabled(true); ui_->radiobutton_hide->setEnabled(true); ui_->checkbox_showtrayicon->setChecked(s.value("showtrayicon", true).toBool()); ui_->checkbox_keeprunning->setChecked(s.value("keeprunning", false).toBool()); + ui_->checkbox_trayicon_progress->setChecked(s.value("trayicon_progress", false).toBool()); ui_->checkbox_scrolltrayicon->setChecked(s.value("scrolltrayicon", ui_->checkbox_showtrayicon->isChecked()).toBool()); } else { ui_->checkbox_showtrayicon->setEnabled(false); ui_->checkbox_keeprunning->setEnabled(false); + ui_->checkbox_trayicon_progress->setEnabled(false); ui_->checkbox_scrolltrayicon->setEnabled(false); ui_->radiobutton_hide->setEnabled(false); ui_->checkbox_showtrayicon->setChecked(false); ui_->checkbox_keeprunning->setChecked(false); + ui_->checkbox_trayicon_progress->setChecked(false); ui_->checkbox_scrolltrayicon->setChecked(false); ui_->radiobutton_hide->setChecked(false); } @@ -235,6 +240,7 @@ void BehaviourSettingsPage::Save() { s.setValue("showtrayicon", ui_->checkbox_showtrayicon->isChecked()); s.setValue("keeprunning", ui_->checkbox_keeprunning->isChecked()); + s.setValue("trayicon_progress", ui_->checkbox_trayicon_progress->isChecked()); s.setValue("resumeplayback", ui_->checkbox_resumeplayback->isChecked()); s.setValue("playing_widget", ui_->checkbox_playingwidget->isChecked()); s.setValue("scrolltrayicon", ui_->checkbox_scrolltrayicon->isChecked()); @@ -275,6 +281,7 @@ void BehaviourSettingsPage::ShowTrayIconToggled(bool on) { ui_->radiobutton_hide->setEnabled(on); if (!on && ui_->radiobutton_hide->isChecked()) ui_->radiobutton_remember->setChecked(true); ui_->checkbox_keeprunning->setEnabled(on); + ui_->checkbox_trayicon_progress->setEnabled(on); ui_->checkbox_scrolltrayicon->setEnabled(on); } diff --git a/src/settings/behavioursettingspage.ui b/src/settings/behavioursettingspage.ui index 2dd515a8..661b5529 100644 --- a/src/settings/behavioursettingspage.ui +++ b/src/settings/behavioursettingspage.ui @@ -34,6 +34,13 @@ + + + + Show song progress on system tray icon + + + @@ -340,6 +347,7 @@ checkbox_showtrayicon checkbox_keeprunning + checkbox_trayicon_progress checkbox_resumeplayback checkbox_playingwidget checkbox_scrolltrayicon