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:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user