diff options
author | Ken Moore <ken@ixsystems.com> | 2017-05-03 10:27:31 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-05-03 10:27:31 -0400 |
commit | cebca8cef5e7353431bf88daeeb91d4892ca55a7 (patch) | |
tree | 82730422481da45d2d9429a320113a2d22856f65 /src-qt5/core/lumina-desktop/panel-plugins/systemtray | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-cebca8cef5e7353431bf88daeeb91d4892ca55a7.tar.gz lumina-cebca8cef5e7353431bf88daeeb91d4892ca55a7.tar.bz2 lumina-cebca8cef5e7353431bf88daeeb91d4892ca55a7.zip |
Fix up the high-DPI scaling of the system tray icons.
Diffstat (limited to 'src-qt5/core/lumina-desktop/panel-plugins/systemtray')
-rw-r--r-- | src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp | 9 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.h | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp index 6736359c..b20eb64e 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp @@ -15,6 +15,9 @@ TrayIcon::TrayIcon(QWidget *parent) : QWidget(parent){ IID = 0; dmgID = 0; badpaints = 0; + if("1" == QString(getenv("QT_AUTO_SCREEN_SCALE_FACTOR")) ){ + scalefactor = 2; //Auto-adjust this later to the physicalDotsPerInch of the current screen + }else{ scalefactor = 1; } //this->setLayout(new QHBoxLayout); //this->layout()->setContentsMargins(0,0,0,0); } @@ -79,8 +82,8 @@ void TrayIcon::updateIcon(){ if(AID==0){ return; } //Make sure the icon is square QSize icosize = this->size(); - LSession::handle()->XCB->ResizeWindow(AID, icosize.width()*2, icosize.height()*2); - QTimer::singleShot(500, this, SLOT(update()) ); //make sure to re-draw the window in a moment + LSession::handle()->XCB->ResizeWindow(AID, icosize.width()*scalefactor, icosize.height()*scalefactor); + QTimer::singleShot(500, this, SLOT(repaint()) ); //make sure to re-draw the window in a moment } // ============= @@ -103,7 +106,7 @@ void TrayIcon::paintEvent(QPaintEvent *event){ //qDebug() << " - Pix size:" << pix.size().width() << pix.size().height(); //qDebug() << " - Geom:" << this->geometry().x() << this->geometry().y() << this->geometry().width() << this->geometry().height(); if(!pix.isNull()){ - if((this->size()*2) != pix.size()){ QTimer::singleShot(10, this, SLOT(updateIcon())); } + if((this->size()*scalefactor) != pix.size()){ QTimer::singleShot(10, this, SLOT(updateIcon())); } painter.drawPixmap(0,0,this->width(), this->height(), pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation) ); badpaints = 0; //good paint }else{ diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.h b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.h index 5d072cc1..e9c6e4d9 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.h +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.h @@ -44,6 +44,7 @@ private: WId IID, AID; //icon ID and app ID int badpaints; uint dmgID; + int scalefactor; protected: void paintEvent(QPaintEvent *event); @@ -52,4 +53,4 @@ protected: signals: void BadIcon(); }; -#endif
\ No newline at end of file +#endif |