From 9a3918763bf3b6438d70065e68be97679582a8f4 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 16 Mar 2020 14:35:39 +0200 Subject: [PATCH] settings,improve layouts header visual --- .../controllers/layoutscontroller.cpp | 1 + app/settings/delegates/layoutnamedelegate.cpp | 10 ++++---- app/settings/models/layoutsmodel.cpp | 24 ++++++++++++++----- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/settings/controllers/layoutscontroller.cpp b/app/settings/controllers/layoutscontroller.cpp index e3c167ebb..c68d63c50 100644 --- a/app/settings/controllers/layoutscontroller.cpp +++ b/app/settings/controllers/layoutscontroller.cpp @@ -541,6 +541,7 @@ void Layouts::copySelectedLayout() copied.isActive = false; copied.isLocked = false; copied.activities = QStringList(); + copied.shares = QStringList(); QFile(selected.id).copy(copied.id); QFileInfo newFileInfo(copied.id); diff --git a/app/settings/delegates/layoutnamedelegate.cpp b/app/settings/delegates/layoutnamedelegate.cpp index ebd3ba127..3327e0a5b 100644 --- a/app/settings/delegates/layoutnamedelegate.cpp +++ b/app/settings/delegates/layoutnamedelegate.cpp @@ -83,7 +83,7 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co QStyleOptionViewItem adjustedOption = option; //! Remove the focus dotted lines adjustedOption.state = (adjustedOption.state & ~QStyle::State_HasFocus); - adjustedOption.displayAlignment = Qt::AlignHCenter; + adjustedOption.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter; if (isLocked || isShared) { QStandardItemModel *model = (QStandardItemModel *) index.model(); @@ -96,8 +96,8 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co int thick = option.rect.height(); int length = showTwoIcons ? (2 * thick + 2) : thick; - int startWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? length : qBound(0, option.rect.width() - textWidth - length, length); - int endWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? qBound(0, option.rect.width() - textWidth - length, length) : length; + int startWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? length : 0; + int endWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? 0 : length; QRect destinationS(option.rect.x(), option.rect.y(), startWidth, thick); QRect destinationE(option.rect.x() + option.rect.width() - endWidth, option.rect.y(), endWidth, thick); @@ -115,9 +115,9 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co QStyledItemDelegate::paint(painter, myOptionMain, index); - //! draw background at edges + //! draw background below icons + //! HIDDENTEXTCOLUMN is just needed to draw empty background rectangles QStyledItemDelegate::paint(painter, myOptionS, model->index(index.row(), Model::Layouts::HIDDENTEXTCOLUMN)); - QStyledItemDelegate::paint(painter, myOptionE, model->index(index.row(), Model::Layouts::HIDDENTEXTCOLUMN)); //! Lock Icon diff --git a/app/settings/models/layoutsmodel.cpp b/app/settings/models/layoutsmodel.cpp index fd98df62c..4e584b7c4 100644 --- a/app/settings/models/layoutsmodel.cpp +++ b/app/settings/models/layoutsmodel.cpp @@ -230,39 +230,51 @@ QVariant Layouts::headerData(int section, Qt::Orientation orientation, int role) break; case BACKGROUNDCOLUMN: if (role == Qt::DisplayRole) { - return QString("#");//(i18nc("column for layout background", "Background")); + return QString("");//(i18nc("column for layout background", "Background")); } else if (role == Qt::DecorationRole) { - return QString();//QIcon::fromTheme("games-config-background"); + return QIcon::fromTheme("games-config-background");//QString();//QIcon::fromTheme("games-config-background"); + } else if (role == Qt::TextAlignmentRole ){ + return QVariant::fromValue(Qt::AlignHCenter | Qt::AlignVCenter); } break; case NAMECOLUMN: if (role == Qt::DisplayRole) { return QString(i18nc("column for layout name", "Name")); + } else if (role == Qt::TextAlignmentRole) { + return QVariant::fromValue(Qt::AlignLeft | Qt::AlignVCenter); } break; case MENUCOLUMN: if (role == Qt::DisplayRole) { return QString(i18nc("column for layout to show in menu", "In Menu")); - } + }/* else if (role == Qt::TextAlignmentRole ){ + return QVariant::fromValue(Qt::AlignHCenter | Qt::AlignVCenter); + }*/ break; case BORDERSCOLUMN: if (role == Qt::DisplayRole) { return QString(i18nc("column for layout to hide borders for maximized windows", "Borderless")); - } + }/* else if (role == Qt::TextAlignmentRole ){ + return QVariant::fromValue(Qt::AlignHCenter | Qt::AlignVCenter); + }*/ break; case ACTIVITYCOLUMN: if (role == Qt::DisplayRole) { return QString(i18nc("column for layout to show which activities is assigned to", "Activities")); } else if (role == Qt::DecorationRole) { return QIcon::fromTheme("activities"); - } + }/* else if (role == Qt::TextAlignmentRole ){ + return QVariant::fromValue(Qt::AlignLeft | Qt::AlignVCenter); + }*/ break; case SHAREDCOLUMN: if (role == Qt::DisplayRole) { return QString(i18nc("column for shared layout to show which layouts is assigned to", "Shared To")); } else if (role == Qt::DecorationRole) { return QIcon::fromTheme("document-share"); - } + }/* else if (role == Qt::TextAlignmentRole ){ + return QVariant::fromValue(Qt::AlignLeft | Qt::AlignVCenter); + }*/ break; default: break;