File indexing completed on 2025-01-19 11:19:01
0001 /* 0002 SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "layoutcmbitemdelegate.h" 0007 0008 // local 0009 #include "../layoutsmodel.h" 0010 #include "../../generic/generictools.h" 0011 0012 // Qt 0013 #include <QDebug> 0014 #include <QModelIndex> 0015 #include <QPainter> 0016 #include <QString> 0017 0018 0019 namespace Latte { 0020 namespace Settings { 0021 namespace Layout { 0022 namespace Delegate { 0023 0024 LayoutCmbItemDelegate::LayoutCmbItemDelegate(QObject *parent) 0025 : QStyledItemDelegate(parent) 0026 { 0027 } 0028 0029 void LayoutCmbItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 0030 { 0031 QStyleOptionViewItem myOptions = option; 0032 0033 //! background 0034 Latte::drawBackground(painter, option); 0035 Latte::Data::LayoutIcon icon = index.data(Model::Layouts::BACKGROUNDUSERROLE).value<Latte::Data::LayoutIcon>(); 0036 0037 //! icon 0038 QRect remained = Latte::remainedFromLayoutIcon(myOptions, Qt::AlignLeft, 4, 2); 0039 Latte::drawLayoutIcon(painter, myOptions, icon.isBackgroundFile, icon.name, Qt::AlignLeft, 5, 2); //+1px in order to take into account popup window border 0040 myOptions.rect = remained; 0041 0042 //! 0043 QStyledItemDelegate::paint(painter, myOptions, index); 0044 } 0045 0046 } 0047 } 0048 } 0049 } 0050