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>
This commit is contained in:
yavuzmert
2020-11-04 23:01:04 +03:00
committed by GitHub
parent ee6675aee0
commit 47e2905edf
17 changed files with 54 additions and 23 deletions

View File

@@ -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()) {