Re-enable progress on system tray icon (#578)
* Re-enable progress on system tray icon * fix copy-paste typo in mac sources * Make tray icon progress optional * Move tray icon progress setting control to MainWindow * Move trayicon settings to behavioursettings Co-authored-by: Yavuz Mert <yavuz.mert@darkbluesystems.net>
@ -19,6 +19,7 @@
|
|||||||
<file>style/smartplaylistsearchterm.css</file>
|
<file>style/smartplaylistsearchterm.css</file>
|
||||||
<file>html/oauthsuccess.html</file>
|
<file>html/oauthsuccess.html</file>
|
||||||
<file>pictures/strawberry.png</file>
|
<file>pictures/strawberry.png</file>
|
||||||
|
<file>pictures/strawberry-grey.png</file>
|
||||||
<file>pictures/strawberry-faded.png</file>
|
<file>pictures/strawberry-faded.png</file>
|
||||||
<file>pictures/strawbs.png</file>
|
<file>pictures/strawbs.png</file>
|
||||||
<file>pictures/nomusic.png</file>
|
<file>pictures/nomusic.png</file>
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
<file>icons/128x128/star-grey.png</file>
|
<file>icons/128x128/star-grey.png</file>
|
||||||
<file>icons/128x128/star.png</file>
|
<file>icons/128x128/star.png</file>
|
||||||
<file>icons/128x128/strawberry.png</file>
|
<file>icons/128x128/strawberry.png</file>
|
||||||
|
<file>icons/128x128/strawberry-grey.png</file>
|
||||||
<file>icons/128x128/tools-wizard.png</file>
|
<file>icons/128x128/tools-wizard.png</file>
|
||||||
<file>icons/128x128/view-choose.png</file>
|
<file>icons/128x128/view-choose.png</file>
|
||||||
<file>icons/128x128/view-fullscreen.png</file>
|
<file>icons/128x128/view-fullscreen.png</file>
|
||||||
@ -164,6 +165,7 @@
|
|||||||
<file>icons/64x64/star-grey.png</file>
|
<file>icons/64x64/star-grey.png</file>
|
||||||
<file>icons/64x64/star.png</file>
|
<file>icons/64x64/star.png</file>
|
||||||
<file>icons/64x64/strawberry.png</file>
|
<file>icons/64x64/strawberry.png</file>
|
||||||
|
<file>icons/64x64/strawberry-grey.png</file>
|
||||||
<file>icons/64x64/tools-wizard.png</file>
|
<file>icons/64x64/tools-wizard.png</file>
|
||||||
<file>icons/64x64/view-choose.png</file>
|
<file>icons/64x64/view-choose.png</file>
|
||||||
<file>icons/64x64/view-fullscreen.png</file>
|
<file>icons/64x64/view-fullscreen.png</file>
|
||||||
@ -260,6 +262,7 @@
|
|||||||
<file>icons/48x48/star-grey.png</file>
|
<file>icons/48x48/star-grey.png</file>
|
||||||
<file>icons/48x48/star.png</file>
|
<file>icons/48x48/star.png</file>
|
||||||
<file>icons/48x48/strawberry.png</file>
|
<file>icons/48x48/strawberry.png</file>
|
||||||
|
<file>icons/48x48/strawberry-grey.png</file>
|
||||||
<file>icons/48x48/tools-wizard.png</file>
|
<file>icons/48x48/tools-wizard.png</file>
|
||||||
<file>icons/48x48/view-choose.png</file>
|
<file>icons/48x48/view-choose.png</file>
|
||||||
<file>icons/48x48/view-fullscreen.png</file>
|
<file>icons/48x48/view-fullscreen.png</file>
|
||||||
@ -356,6 +359,7 @@
|
|||||||
<file>icons/32x32/star-grey.png</file>
|
<file>icons/32x32/star-grey.png</file>
|
||||||
<file>icons/32x32/star.png</file>
|
<file>icons/32x32/star.png</file>
|
||||||
<file>icons/32x32/strawberry.png</file>
|
<file>icons/32x32/strawberry.png</file>
|
||||||
|
<file>icons/32x32/strawberry-grey.png</file>
|
||||||
<file>icons/32x32/tools-wizard.png</file>
|
<file>icons/32x32/tools-wizard.png</file>
|
||||||
<file>icons/32x32/view-choose.png</file>
|
<file>icons/32x32/view-choose.png</file>
|
||||||
<file>icons/32x32/view-fullscreen.png</file>
|
<file>icons/32x32/view-fullscreen.png</file>
|
||||||
@ -452,6 +456,7 @@
|
|||||||
<file>icons/22x22/star-grey.png</file>
|
<file>icons/22x22/star-grey.png</file>
|
||||||
<file>icons/22x22/star.png</file>
|
<file>icons/22x22/star.png</file>
|
||||||
<file>icons/22x22/strawberry.png</file>
|
<file>icons/22x22/strawberry.png</file>
|
||||||
|
<file>icons/22x22/strawberry-grey.png</file>
|
||||||
<file>icons/22x22/tools-wizard.png</file>
|
<file>icons/22x22/tools-wizard.png</file>
|
||||||
<file>icons/22x22/view-choose.png</file>
|
<file>icons/22x22/view-choose.png</file>
|
||||||
<file>icons/22x22/view-fullscreen.png</file>
|
<file>icons/22x22/view-fullscreen.png</file>
|
||||||
|
BIN
data/icons/128x128/strawberry-grey.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
data/icons/22x22/strawberry-grey.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
data/icons/32x32/strawberry-grey.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
data/icons/48x48/strawberry-grey.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
data/icons/64x64/strawberry-grey.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
data/icons/full/strawberry-grey.png
Normal file
After Width: | Height: | Size: 352 KiB |
BIN
data/pictures/strawberry-grey.png
Normal file
After Width: | Height: | Size: 127 KiB |
@ -58,6 +58,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap normal_icon_;
|
QPixmap normal_icon_;
|
||||||
|
QPixmap grey_icon_;
|
||||||
std::unique_ptr<MacSystemTrayIconPrivate> p_;
|
std::unique_ptr<MacSystemTrayIconPrivate> p_;
|
||||||
Q_DISABLE_COPY(MacSystemTrayIcon);
|
Q_DISABLE_COPY(MacSystemTrayIcon);
|
||||||
};
|
};
|
||||||
|
@ -165,7 +165,8 @@ class MacSystemTrayIconPrivate {
|
|||||||
|
|
||||||
MacSystemTrayIcon::MacSystemTrayIcon(QObject* parent)
|
MacSystemTrayIcon::MacSystemTrayIcon(QObject* parent)
|
||||||
: SystemTrayIcon(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_);
|
QApplication::setWindowIcon(normal_icon_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,6 +1023,7 @@ void MainWindow::ReloadSettings() {
|
|||||||
s.beginGroup(BehaviourSettingsPage::kSettingsGroup);
|
s.beginGroup(BehaviourSettingsPage::kSettingsGroup);
|
||||||
keep_running_ = s.value("keeprunning", false).toBool();
|
keep_running_ = s.value("keeprunning", false).toBool();
|
||||||
playing_widget_ = s.value("playing_widget", true).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();
|
if (playing_widget_ != ui_->widget_playing->IsEnabled()) TabSwitched();
|
||||||
doubleclick_addmode_ = BehaviourSettingsPage::AddBehaviour(s.value("doubleclick_addmode", BehaviourSettingsPage::AddBehaviour_Append).toInt());
|
doubleclick_addmode_ = BehaviourSettingsPage::AddBehaviour(s.value("doubleclick_addmode", BehaviourSettingsPage::AddBehaviour_Append).toInt());
|
||||||
doubleclick_playmode_ = BehaviourSettingsPage::PlayBehaviour(s.value("doubleclick_playmode", BehaviourSettingsPage::PlayBehaviour_Never).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();
|
int iconsize = s.value(AppearanceSettingsPage::kIconSizePlayControlButtons, 32).toInt();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
|
if (tray_icon_) tray_icon_->SetTrayiconProgress(trayicon_progress);
|
||||||
|
|
||||||
ui_->back_button->setIconSize(QSize(iconsize, iconsize));
|
ui_->back_button->setIconSize(QSize(iconsize, iconsize));
|
||||||
ui_->pause_play_button->setIconSize(QSize(iconsize, iconsize));
|
ui_->pause_play_button->setIconSize(QSize(iconsize, iconsize));
|
||||||
ui_->stop_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 (value) {
|
||||||
if (app_->playlist_manager()->active() && app_->playlist_manager()->active()->scrobbled())
|
if (app_->playlist_manager()->active() && app_->playlist_manager()->active()->scrobbled())
|
||||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", 22));
|
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
|
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", 22)); // TODO: Create a faint version of the icon
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -54,7 +54,10 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject *parent)
|
|||||||
action_mute_(nullptr) {
|
action_mute_(nullptr) {
|
||||||
|
|
||||||
app_name_[0] = app_name_[0].toUpper();
|
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_->setIcon(normal_icon_);
|
||||||
tray_->installEventFilter(this);
|
tray_->installEventFilter(this);
|
||||||
ClearNowPlaying();
|
ClearNowPlaying();
|
||||||
|
@ -47,31 +47,31 @@ SystemTrayIcon::SystemTrayIcon(QObject *parent)
|
|||||||
|
|
||||||
QPixmap SystemTrayIcon::CreateIcon(const QPixmap &icon, const QPixmap &grey_icon) {
|
QPixmap SystemTrayIcon::CreateIcon(const QPixmap &icon, const QPixmap &grey_icon) {
|
||||||
|
|
||||||
Q_UNUSED(grey_icon);
|
|
||||||
|
|
||||||
QRect rect(icon.rect());
|
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);
|
QPixmap ret(icon);
|
||||||
QPainter p(&ret);
|
QPainter p(&ret);
|
||||||
|
|
||||||
// Draw the grey bit
|
if (trayicon_progress_) {
|
||||||
//p.setClipRegion(mask);
|
// The angle of the line that's used to cover the icon.
|
||||||
//p.drawPixmap(0, 0, grey_icon);
|
// Centered on rect.topLeft()
|
||||||
//p.setClipping(false);
|
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
|
// Draw the playing or paused icon in the top-right
|
||||||
if (!current_state_icon().isNull()) {
|
if (!current_state_icon().isNull()) {
|
||||||
|
@ -57,6 +57,7 @@ class SystemTrayIcon : public QObject {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void SetProgress(int percentage);
|
void SetProgress(int percentage);
|
||||||
|
void SetTrayiconProgress(bool enabled) { trayicon_progress_ = enabled; }
|
||||||
virtual void SetPaused();
|
virtual void SetPaused();
|
||||||
virtual void SetPlaying(bool enable_play_pause = false);
|
virtual void SetPlaying(bool enable_play_pause = false);
|
||||||
virtual void SetStopped();
|
virtual void SetStopped();
|
||||||
@ -85,6 +86,7 @@ class SystemTrayIcon : public QObject {
|
|||||||
QPixmap playing_icon_;
|
QPixmap playing_icon_;
|
||||||
QPixmap paused_icon_;
|
QPixmap paused_icon_;
|
||||||
QPixmap current_state_icon_;
|
QPixmap current_state_icon_;
|
||||||
|
bool trayicon_progress_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SYSTEMTRAYICON_H
|
#endif // SYSTEMTRAYICON_H
|
||||||
|
@ -68,6 +68,7 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog) : SettingsP
|
|||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
ui_->checkbox_showtrayicon->hide();
|
ui_->checkbox_showtrayicon->hide();
|
||||||
ui_->checkbox_keeprunning->hide();
|
ui_->checkbox_keeprunning->hide();
|
||||||
|
ui_->checkbox_trayicon_progress->hide();
|
||||||
ui_->checkbox_scrolltrayicon->hide();
|
ui_->checkbox_scrolltrayicon->hide();
|
||||||
ui_->groupbox_startup->hide();
|
ui_->groupbox_startup->hide();
|
||||||
#endif
|
#endif
|
||||||
@ -155,19 +156,23 @@ void BehaviourSettingsPage::Load() {
|
|||||||
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
ui_->checkbox_showtrayicon->setEnabled(true);
|
ui_->checkbox_showtrayicon->setEnabled(true);
|
||||||
ui_->checkbox_keeprunning->setEnabled(true);
|
ui_->checkbox_keeprunning->setEnabled(true);
|
||||||
|
ui_->checkbox_trayicon_progress->setEnabled(true);
|
||||||
ui_->checkbox_scrolltrayicon->setEnabled(true);
|
ui_->checkbox_scrolltrayicon->setEnabled(true);
|
||||||
ui_->radiobutton_hide->setEnabled(true);
|
ui_->radiobutton_hide->setEnabled(true);
|
||||||
ui_->checkbox_showtrayicon->setChecked(s.value("showtrayicon", true).toBool());
|
ui_->checkbox_showtrayicon->setChecked(s.value("showtrayicon", true).toBool());
|
||||||
ui_->checkbox_keeprunning->setChecked(s.value("keeprunning", false).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());
|
ui_->checkbox_scrolltrayicon->setChecked(s.value("scrolltrayicon", ui_->checkbox_showtrayicon->isChecked()).toBool());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui_->checkbox_showtrayicon->setEnabled(false);
|
ui_->checkbox_showtrayicon->setEnabled(false);
|
||||||
ui_->checkbox_keeprunning->setEnabled(false);
|
ui_->checkbox_keeprunning->setEnabled(false);
|
||||||
|
ui_->checkbox_trayicon_progress->setEnabled(false);
|
||||||
ui_->checkbox_scrolltrayicon->setEnabled(false);
|
ui_->checkbox_scrolltrayicon->setEnabled(false);
|
||||||
ui_->radiobutton_hide->setEnabled(false);
|
ui_->radiobutton_hide->setEnabled(false);
|
||||||
ui_->checkbox_showtrayicon->setChecked(false);
|
ui_->checkbox_showtrayicon->setChecked(false);
|
||||||
ui_->checkbox_keeprunning->setChecked(false);
|
ui_->checkbox_keeprunning->setChecked(false);
|
||||||
|
ui_->checkbox_trayicon_progress->setChecked(false);
|
||||||
ui_->checkbox_scrolltrayicon->setChecked(false);
|
ui_->checkbox_scrolltrayicon->setChecked(false);
|
||||||
ui_->radiobutton_hide->setChecked(false);
|
ui_->radiobutton_hide->setChecked(false);
|
||||||
}
|
}
|
||||||
@ -235,6 +240,7 @@ void BehaviourSettingsPage::Save() {
|
|||||||
|
|
||||||
s.setValue("showtrayicon", ui_->checkbox_showtrayicon->isChecked());
|
s.setValue("showtrayicon", ui_->checkbox_showtrayicon->isChecked());
|
||||||
s.setValue("keeprunning", ui_->checkbox_keeprunning->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("resumeplayback", ui_->checkbox_resumeplayback->isChecked());
|
||||||
s.setValue("playing_widget", ui_->checkbox_playingwidget->isChecked());
|
s.setValue("playing_widget", ui_->checkbox_playingwidget->isChecked());
|
||||||
s.setValue("scrolltrayicon", ui_->checkbox_scrolltrayicon->isChecked());
|
s.setValue("scrolltrayicon", ui_->checkbox_scrolltrayicon->isChecked());
|
||||||
@ -275,6 +281,7 @@ void BehaviourSettingsPage::ShowTrayIconToggled(bool on) {
|
|||||||
ui_->radiobutton_hide->setEnabled(on);
|
ui_->radiobutton_hide->setEnabled(on);
|
||||||
if (!on && ui_->radiobutton_hide->isChecked()) ui_->radiobutton_remember->setChecked(true);
|
if (!on && ui_->radiobutton_hide->isChecked()) ui_->radiobutton_remember->setChecked(true);
|
||||||
ui_->checkbox_keeprunning->setEnabled(on);
|
ui_->checkbox_keeprunning->setEnabled(on);
|
||||||
|
ui_->checkbox_trayicon_progress->setEnabled(on);
|
||||||
ui_->checkbox_scrolltrayicon->setEnabled(on);
|
ui_->checkbox_scrolltrayicon->setEnabled(on);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkbox_trayicon_progress">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show song progress on system tray icon</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkbox_resumeplayback">
|
<widget class="QCheckBox" name="checkbox_resumeplayback">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -340,6 +347,7 @@
|
|||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>checkbox_showtrayicon</tabstop>
|
<tabstop>checkbox_showtrayicon</tabstop>
|
||||||
<tabstop>checkbox_keeprunning</tabstop>
|
<tabstop>checkbox_keeprunning</tabstop>
|
||||||
|
<tabstop>checkbox_trayicon_progress</tabstop>
|
||||||
<tabstop>checkbox_resumeplayback</tabstop>
|
<tabstop>checkbox_resumeplayback</tabstop>
|
||||||
<tabstop>checkbox_playingwidget</tabstop>
|
<tabstop>checkbox_playingwidget</tabstop>
|
||||||
<tabstop>checkbox_scrolltrayicon</tabstop>
|
<tabstop>checkbox_scrolltrayicon</tabstop>
|
||||||
|