aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h26
1 files changed, 11 insertions, 15 deletions
diff --git a/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h b/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h
index 65a2edec..ecec3ea6 100644
--- a/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h
+++ b/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h
@@ -41,18 +41,18 @@ protected:
QStyleOptionToolButton opt;
initStyleOption(&opt);
opt.font.setStyleStrategy(QFont::PreferAntialias); //Always set the font strategy (just in case it starts working down the road)
- opt.font.setWeight(2*opt.font.weight()); //need a slightly heavier weight due to outlining later
+ opt.font.setWeight(2.5*opt.font.weight()); //need a slightly heavier weight due to outlining later
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
QRect box = p.style()->itemTextRect(opt.fontMetrics, opt.rect, Qt::AlignHCenter | Qt::AlignBottom, true, this->text());
//Get the QColors for the outline/text
- /*QColor textC = opt.palette.text().color().toHsl(); //need the lightness value in a moment
- QColor outC;
- qDebug() << "Font Color Values:" << textC << textC.lightness() << textC.lightnessF();
- if(textC.lightnessF() > 0.5){ outC = textC.darker(1000); } //1000% darker
- else{ outC = textC.lighter(1000); } //1000% lighter
- qDebug() << "Outline Color Values:" << outC;*/
+ 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); }
+ else{outC.setHsl(textC.hue(), textC.hslSaturation(), 255); } //1000% lighter
+ //qDebug() << "Outline Color Values:" << outC;
//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
@@ -60,15 +60,11 @@ protected:
path.addText(box.center().x() - (opt.fontMetrics.width(txt[i])/2), box.y()+((i+1)*(box.height()/txt.length()))-opt.fontMetrics.descent(), opt.font, txt[i] );
}
path.setFillRule(Qt::WindingFill);
- //Now paint them
- p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
- p.strokePath(path, QPen(QColor(Qt::white)));//outC)) ); //This will be the outline - 1pixel thick
- p.fillPath(path, QBrush(Qt::black));//textC)); //this will be the inside/text color
+ //Now paint the text
+ p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); //need antialiasing for this to work well (sub-pixel painting)
+ p.strokePath(path, QPen(outC) ); //This will be the outline - 1pixel thick
+ p.fillPath(path, QBrush(textC)); //this will be the inside/text color
-
- /*opt.font.setWeight(50); //reset back to the normal text size
- opt.palette = QPalette(Qt::white);
- p.drawControl(QStyle::CE_ToolButtonLabel, opt); //don't do the full background on top again - just the labels (icon/text)*/
}
};
bgstack15