ui improvements for Layouts editor

--lock icon takes into account the selected state
in order to draw itself
--focus dotted lines for tableview cells were disabled
until something less noisy is introduced
pull/5/head
Michail Vourlakos 6 years ago
parent 70640ae2e5
commit b7cb41e322

@ -133,6 +133,8 @@ void ActivityCmbBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleO
void ActivityCmbBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItem myOptions = option;
//! Remove the focus dotted lines
myOptions.state = (myOptions.state & ~QStyle::State_HasFocus);
painter->save();
QStringList assignedActivities = index.model()->data(index, Qt::UserRole).toStringList();

@ -37,10 +37,14 @@ CheckBoxDelegate::CheckBoxDelegate(QObject *parent)
void CheckBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItem adjustedOption = option;
//! Remove the focus dotted lines
adjustedOption.state = (adjustedOption.state & ~QStyle::State_HasFocus);
QStandardItemModel *model = (QStandardItemModel *) index.model();
QStyledItemDelegate::paint(painter, option, model->index(index.row(), HIDDENTEXTCOLUMN));
QStyledItemDelegate::paint(painter, adjustedOption, model->index(index.row(), HIDDENTEXTCOLUMN));
QStyledItemDelegate::paint(painter, option, index);
QStyledItemDelegate::paint(painter, adjustedOption, index);
}
bool CheckBoxDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,

@ -40,9 +40,14 @@ void LayoutNameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
{
bool isLocked = index.data(Qt::UserRole).toBool();
QStyleOptionViewItem adjustedOption = option;
//! Remove the focus dotted lines
adjustedOption.state = (adjustedOption.state & ~QStyle::State_HasFocus);
if (isLocked) {
QStandardItemModel *model = (QStandardItemModel *) index.model();
QString nameText = index.data(Qt::DisplayRole).toString();
bool selected = ((option.state & QStyle::State_Active) && (option.state & QStyle::State_Selected));
//! font metrics
QFontMetrics fm(option.font);
@ -54,9 +59,9 @@ void LayoutNameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
QRect destinationS(option.rect.x(), option.rect.y(), startWidth, thick);
QRect destinationE(option.rect.x() + option.rect.width() - thick, option.rect.y(), endWidth, thick);
QStyleOptionViewItem myOptionS = option;
QStyleOptionViewItem myOptionE = option;
QStyleOptionViewItem myOptionMain = option;
QStyleOptionViewItem myOptionS = adjustedOption;
QStyleOptionViewItem myOptionE = adjustedOption;
QStyleOptionViewItem myOptionMain = adjustedOption;
myOptionS.rect = destinationS;
myOptionE.rect = destinationE;
myOptionMain.rect.setX(option.rect.x() + startWidth);
@ -67,82 +72,22 @@ void LayoutNameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
//! draw background at edges
QStyledItemDelegate::paint(painter, myOptionS, model->index(index.row(), HIDDENTEXTCOLUMN));
//! Lock Icon 1: Unicode character attempt
/*QString s = QChar(0x2318);
QString s = QChar(0x2757);
myOptionE.text = s;*/
QStyledItemDelegate::paint(painter, myOptionE, model->index(index.row(), HIDDENTEXTCOLUMN));
//! Lock Icon 2: QIcon attempt that doesn't change color
//! Lock Icon
QIcon lockIcon = QIcon::fromTheme("object-locked");
if (qApp->layoutDirection() == Qt::RightToLeft) {
painter->drawPixmap(destinationS, lockIcon.pixmap(thick, thick));
} else {
painter->drawPixmap(destinationE, lockIcon.pixmap(thick, thick));
}
//! Lock Icon 3: QIcon and change colors attempt
/*QIcon lockIcon = QIcon::fromTheme("object-locked");
QPixmap origPixmap = lockIcon.pixmap(thick, thick);
QPixmap lockPixmap = origPixmap;
QBrush nBrush;
if ((option.state & QStyle::State_Active) && (option.state & QStyle::State_Selected)) {
nBrush = option.palette.brush(QPalette::Active, QPalette::HighlightedText);
} else {
nBrush = option.palette.brush(QPalette::Inactive, QPalette::Text);
}
lockPixmap.fill(nBrush.color());
lockPixmap.setMask(origPixmap.createMaskFromColor(Qt::transparent));
painter->drawPixmap(destinationE, lockPixmap);*/
QIcon::Mode mode = selected ? QIcon::Selected : QIcon::Normal;
//! Lock Icon 4: Plasma::Svg and change color group attempt
/*Plasma::Svg svgIcon;
svgIcon.setStatus(Plasma::Svg::Normal);
svgIcon.setUsingRenderingCache(false);
svgIcon.setDevicePixelRatio(qApp->devicePixelRatio());
//! find path
//try to load from iconloader an svg with Plasma::Svg
const auto *iconTheme = KIconLoader::global()->theme();
QString iconPath;
if (iconTheme) {
iconPath = iconTheme->iconPath("object-locked" + QLatin1String(".svg")
, thick
, KIconLoader::MatchBest);
if (iconPath.isEmpty()) {
iconPath = iconTheme->iconPath("object-locked" + QLatin1String(".svgz")
, thick
, KIconLoader::MatchBest);
}
if (qApp->layoutDirection() == Qt::RightToLeft) {
painter->drawPixmap(destinationS, lockIcon.pixmap(thick, thick, mode));
} else {
qWarning() << "KIconLoader has no theme set";
painter->drawPixmap(destinationE, lockIcon.pixmap(thick, thick, mode));
}
if (!iconPath.isEmpty()) {
svgIcon.setImagePath(iconPath);
if ((option.state & QStyle::State_Active) && (option.state & QStyle::State_Selected)) {
svgIcon.setColorGroup(Plasma::Theme::ComplementaryColorGroup);
} else {
svgIcon.setColorGroup(Plasma::Theme::NormalColorGroup);
}
svgIcon.resize(thick, thick);
}
painter->drawPixmap(destinationE, svgIcon.pixmap());*/
return;
}
QStyledItemDelegate::paint(painter, option, index);
QStyledItemDelegate::paint(painter, adjustedOption, index);
}

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>936</width>
<height>710</height>
<width>850</width>
<height>636</height>
</rect>
</property>
<property name="windowTitle">
@ -95,6 +95,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTableView" name="layoutsView">
<property name="showDropIndicator" stdset="0">
<bool>true</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
@ -444,8 +447,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>496</width>
<height>575</height>
<width>894</width>
<height>594</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_9">

Loading…
Cancel
Save