aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h')
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h14
1 files changed, 9 insertions, 5 deletions
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
}
bgstack15