File indexing completed on 2024-10-06 10:55:42
0001 /* 0002 SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "schemecmbitemdelegate.h" 0007 0008 // local 0009 #include "../schemesmodel.h" 0010 #include "../../generic/generictools.h" 0011 0012 // Qt 0013 #include <QColor> 0014 #include <QDebug> 0015 #include <QModelIndex> 0016 #include <QPainter> 0017 #include <QString> 0018 0019 0020 namespace Latte { 0021 namespace Settings { 0022 namespace Details { 0023 namespace Delegate { 0024 0025 SchemeCmbItemDelegate::SchemeCmbItemDelegate(QObject *parent) 0026 : QStyledItemDelegate(parent) 0027 { 0028 } 0029 0030 void SchemeCmbItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 0031 { 0032 QStyleOptionViewItem myOptions = option; 0033 0034 //! background 0035 Latte::drawBackground(painter, option); 0036 0037 QColor backcolor = index.data(Model::Schemes::BACKGROUNDCOLORROLE).value<QColor>(); 0038 QColor textcolor = index.data(Model::Schemes::TEXTCOLORROLE).value<QColor>(); 0039 0040 //! icon 0041 QRect remained = Latte::remainedFromColorSchemeIcon(myOptions, Qt::AlignLeft, 4, 2); 0042 Latte::drawColorSchemeIcon(painter, myOptions, textcolor, backcolor, Qt::AlignLeft, 5, 2); //+1px in order to take into account popup window border 0043 myOptions.rect = remained; 0044 0045 //! 0046 QStyledItemDelegate::paint(painter, myOptions, index); 0047 } 0048 0049 } 0050 } 0051 } 0052 } 0053