diff options
Diffstat (limited to 'lumina-desktop/desktop-plugins/applauncher')
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp | 8 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h | 14 |
2 files changed, 16 insertions, 6 deletions
diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index cf7f84d4..f2fd2206 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -34,7 +34,7 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par //QSize sz(qRound(1.1*icosize), icosize+qRound(2.7*button->fontMetrics().height()) ); //button->setFixedSize(sz); //make sure to adjust the button on first show. this->setInitialSize(120, 100); //give the container a bit of a buffer - QTimer::singleShot(100,this, SLOT(loadButton()) ); + QTimer::singleShot(200,this, SLOT(loadButton()) ); } void AppLauncherPlugin::Cleanup(){ @@ -89,6 +89,12 @@ void AppLauncherPlugin::loadButton(){ } //Now adjust the visible text as necessary based on font/grid sizing button->setToolTip(txt); + //Double check that the visual icon size matches the requested size - otherwise upscale the icon + if(button->icon().actualSize(button->iconSize()) != button->iconSize()){ + QIcon ico = button->icon(); + ico.addPixmap( ico.pixmap(button->iconSize()).scaled(button->iconSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation) ); + button->setIcon(ico); + } //int icosize = this->readSetting("iconsize",64).toInt(); //int bwid = qRound(1.1*icosize); //this->setFixedSize(bwid, icosize+qRound(2.5*button->fontMetrics().height()) ); //make sure to adjust the button on first show. diff --git a/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h b/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h index 7a0f28cf..7c8c012d 100644 --- a/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h +++ b/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h @@ -27,7 +27,6 @@ public: //This button needs slightly different font settings - do this in the constructor so that other widgets can take it into account. QFont font = this->font(); font.setStyleStrategy(QFont::PreferAntialias); //Always set the font strategy (just in case it starts working down the road) - font.setWeight(70); //need a slightly heavier weight due to outlining later this->setFont(font); } ~OutlineToolButton(){} @@ -45,8 +44,10 @@ protected: QStylePainter p(this); QStyleOptionToolButton opt; initStyleOption(&opt); + opt.font = this->property("font").value<QFont>(); //This ensures that the stylesheet values are incorporated opt.font.setStyleStrategy(QFont::PreferAntialias); //Always set the font strategy (just in case it starts working down the road) - opt.font.setWeight(65); //need a slightly heavier weight due to outlining later + opt.font.setKerning(true); + opt.fontMetrics = QFontMetrics(opt.font); opt.text.clear(); //Don't paint the text yet - just the background/icon p.drawComplexControl(QStyle::CC_ToolButton, opt); //This does all the normal QToolButton stuff - just not text //Now get the text rectangle for the widget @@ -55,9 +56,12 @@ protected: QColor textC = opt.palette.text().color().toHsl(); //need the lightness value in a moment QColor outC = textC; //qDebug() << "Font Color Values:" << textC << textC.lightness() << textC.lightnessF(); - if(textC.lightnessF() > 0.5){ outC.setHsl(textC.hue(), textC.hslSaturation(), 0, 80); } - else{outC.setHsl(textC.hue(), textC.hslSaturation(), 255, 80); } + if(textC.lightnessF() > 0.5){ outC.setHsl(textC.hue(), textC.hslSaturation(), 0, 110); } + else{outC.setHsl(textC.hue(), textC.hslSaturation(), 255, 110); } //qDebug() << "Outline Color Values:" << outC; + //Now get the size of the outline border (need to scale for high-res monitors) + qreal OWidth = opt.fontMetrics.width("o")/3.0; + //qDebug() << "Outline Width:" << OWidth; //Now generate a QPainterPath for the text QPainterPath path; QStringList txt = this->text().split("\n"); //need each line independently, the newline actually gets painted otherwise @@ -67,7 +71,7 @@ protected: path.setFillRule(Qt::WindingFill); //Now paint the text p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); //need antialiasing for this to work well (sub-pixel painting) - p.strokePath(path, QPen(QBrush(outC),1.8, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin) ); //This will be the outline - 1pixel thick, semi-transparent + p.strokePath(path, QPen(QBrush(outC),OWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin) ); //This will be the outline - 1pixel thick, semi-transparent p.fillPath(path, QBrush(textC)); //this will be the inside/text color } |