mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-27 06:03:51 +03:00
validate layout name icons colors
This commit is contained in:
parent
5323e7832c
commit
b6b34b06de
@ -81,6 +81,7 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co
|
||||
bool showTwoIcons = isLocked && isShared;
|
||||
|
||||
QStyleOptionViewItem adjustedOption = option;
|
||||
|
||||
//! Remove the focus dotted lines
|
||||
adjustedOption.state = (adjustedOption.state & ~QStyle::State_HasFocus);
|
||||
adjustedOption.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
@ -88,7 +89,12 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co
|
||||
if (isLocked || isShared) {
|
||||
QStandardItemModel *model = (QStandardItemModel *) index.model();
|
||||
QString nameText = index.data(Qt::DisplayRole).toString();
|
||||
|
||||
bool active = Latte::isActive(option);
|
||||
bool enabled = Latte::isEnabled(option);
|
||||
bool selected = Latte::isSelected(option);
|
||||
bool focused = Latte::isFocused(option);
|
||||
bool hovered = Latte::isHovered(option);
|
||||
|
||||
//! font metrics
|
||||
QFontMetrics fm(option.font);
|
||||
@ -122,7 +128,8 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co
|
||||
|
||||
//! Lock Icon
|
||||
QIcon firstIcon = isLocked && !showTwoIcons ? QIcon::fromTheme("object-locked") : QIcon::fromTheme("document-share");
|
||||
QIcon::Mode mode = selected && (Latte::colorGroup(option) == QPalette::Active) ? QIcon::Selected : QIcon::Normal;
|
||||
|
||||
QIcon::Mode mode = ((active && (selected || focused)) ? QIcon::Selected : QIcon::Normal);
|
||||
|
||||
if (qApp->layoutDirection() == Qt::RightToLeft) {
|
||||
painter->drawPixmap(QRect(option.rect.x(), option.rect.y(), thick, thick), firstIcon.pixmap(thick, thick, mode));
|
||||
|
@ -25,6 +25,24 @@
|
||||
|
||||
namespace Latte {
|
||||
|
||||
bool isEnabled(const QStyleOptionViewItem &option)
|
||||
{
|
||||
if (option.state & QStyle::State_Enabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isActive(const QStyleOptionViewItem &option)
|
||||
{
|
||||
if (option.state & QStyle::State_Active) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isSelected(const QStyleOptionViewItem &option)
|
||||
{
|
||||
if (option.state & QStyle::State_Selected) {
|
||||
@ -43,13 +61,30 @@ bool isHovered(const QStyleOptionViewItem &option)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isFocused(const QStyleOptionViewItem &option)
|
||||
{
|
||||
if (option.state & QStyle::State_HasFocus) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QPalette::ColorGroup colorGroup(const QStyleOptionViewItem &option)
|
||||
{
|
||||
if (option.state & QStyle::State_Active) {
|
||||
if (!isEnabled(option)) {
|
||||
return QPalette::Disabled;
|
||||
}
|
||||
|
||||
if (isActive(option) || isFocused(option)) {
|
||||
return QPalette::Active;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!isActive(option) && isSelected(option)) {
|
||||
return QPalette::Inactive;
|
||||
}
|
||||
|
||||
return QPalette::Normal;
|
||||
}
|
||||
|
||||
QStringList subtracted(const QStringList &original, const QStringList ¤t)
|
||||
|
@ -27,8 +27,12 @@
|
||||
|
||||
namespace Latte {
|
||||
|
||||
bool isActive(const QStyleOptionViewItem &option);
|
||||
bool isEnabled(const QStyleOptionViewItem &option);
|
||||
bool isFocused(const QStyleOptionViewItem &option);
|
||||
bool isSelected(const QStyleOptionViewItem &option);
|
||||
bool isHovered(const QStyleOptionViewItem &option);
|
||||
|
||||
QPalette::ColorGroup colorGroup(const QStyleOptionViewItem &option);
|
||||
|
||||
//! strings that even though they were initially at original list
|
||||
|
Loading…
x
Reference in New Issue
Block a user