1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 13:33:50 +03:00

viewsdialog:color properly optional name text

This commit is contained in:
Michail Vourlakos 2021-04-10 20:06:27 +03:00
parent 16280a3a53
commit 25c0a22e6a

View File

@ -23,6 +23,9 @@
#include "../viewsmodel.h"
#include "../../generic/generictools.h"
// KDE
#include <KLocalizedString>
namespace Latte {
namespace Settings {
namespace View {
@ -41,9 +44,32 @@ void NameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
myOptions.text = index.model()->data(index, Qt::DisplayRole).toString();
myOptions.displayAlignment = static_cast<Qt::Alignment>(index.model()->data(index, Qt::TextAlignmentRole).toInt());
bool isEmpty = myOptions.text.isEmpty();
bool isActive = index.data(Model::Views::ISACTIVEROLE).toBool();
bool isChanged = (index.data(Model::Views::ISCHANGEDROLE).toBool() || index.data(Model::Views::HASCHANGEDVIEWROLE).toBool());
if (isEmpty) {
myOptions.displayAlignment = (Qt::AlignHCenter | Qt::AlignVCenter);
myOptions.text = " &lt;" + i18n("optional") + "&gt; ";
// QBrush placeholderBrush = option.palette.placeholderText();
//style="color:blue;"
QPalette::ColorRole applyColor = Latte::isSelected(option) ? QPalette::HighlightedText : QPalette::Text;
QBrush placeholderBrush = option.palette.brush(Latte::colorGroup(option), applyColor);
QColor placeholderColor = placeholderBrush.color();
placeholderColor.setAlpha(125);
QString cssplaceholdercolor = "rgba(";
cssplaceholdercolor += QString::number(placeholderColor.red()) + ",";
cssplaceholdercolor += QString::number(placeholderColor.green()) + ", ";
cssplaceholdercolor += QString::number(placeholderColor.blue()) + ", ";
cssplaceholdercolor += "110)";
myOptions.text = "<label style='color:" + cssplaceholdercolor + ";'>" + myOptions.text + "</label>";
qDebug() << "org.kde.latte :: " <<myOptions.text;
}
if (isActive) {
myOptions.text = "<b>" + myOptions.text + "</b>";
}