1 /*
2     SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com>
3     SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #ifndef GENERICSETTINGSTOOLS_H
7 #define GENERICSETTINGSTOOLS_H
8 
9 // Qt
10 #include <QColor>
11 #include <QPainter>
12 #include <QPalette>
13 #include <QRect>
14 #include <QStyleOption>
15 #include <QStyleOptionViewItem>
16 
17 namespace Latte {
18 
19 bool isActive(const QStyleOption &option);
20 bool isEnabled(const QStyleOption &option);
21 bool isFocused(const QStyleOption &option);
22 bool isSelected(const QStyleOption &option);
23 bool isHovered(const QStyleOption &option);
24 bool isTextCentered(const QStyleOptionViewItem &option);
25 
26 QPalette::ColorGroup colorGroup(const QStyleOption &option);
27 Qt::AlignmentFlag horizontalAlignment(Qt::Alignment alignments);
28 
29 //! strings that even though they were initially at original list
30 //! now they are not present to current list
31 QStringList subtracted(const QStringList &original, const QStringList &current);
32 
33 QRect remainedFromFormattedText(const QStyleOption &option, const QString &text, Qt::AlignmentFlag alignment = Qt::AlignLeft);
34 void drawFormattedText(QPainter *painter, const QStyleOptionViewItem &option, const float textOpacity = 1.0);
35 void drawFormattedText(QPainter *painter, const QStyleOptionMenuItem &option, const float textOpacity = 1.0);
36 void drawFormattedText(QPainter *painter, const QStyleOption &option, const QString &text, Qt::AlignmentFlag alignment = Qt::AlignLeft, const float textOpacity = 1.0);
37 
38 //! background
39 void drawBackground(QPainter *painter, const QStyleOptionViewItem &option);
40 void drawBackground(QPainter *painter, const QStyle *style, const QStyleOptionMenuItem &option);
41 
42 //! simple icon
43 QRect remainedFromIcon(const QStyleOption &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
44 void drawIcon(QPainter *painter, const QStyleOption &option, const QString &icon, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
45 
46 //! layout icon
47 QRect remainedFromLayoutIcon(const QStyleOption &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
48 void drawLayoutIcon(QPainter *painter, const QStyleOption &option, const bool &isBackgroundFile, const QString &iconName, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
49 
50 //! color scheme icon
51 QRect remainedFromColorSchemeIcon(const QStyleOption &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
52 void drawColorSchemeIcon(QPainter *painter, const QStyleOption &option, const QColor &textColor, const QColor &backgroundColor,Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
53 
54 //! changes indicator
55 QRect remainedFromChangesIndicator(const QStyleOptionViewItem &option);
56 void drawChangesIndicator(QPainter *painter, const QStyleOptionViewItem &option);
57 
58 int primitiveCheckBoxWidth(const QStyleOptionButton &option, const QWidget *widget = nullptr);
59 QRect remainedFromCheckBox(const QStyleOptionButton &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, const QWidget *widget = nullptr);
60 void drawCheckBox(QPainter *painter, const QStyleOptionButton &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, const QWidget *widget = nullptr);
61 
62 //! screen icon
63 QRect remainedFromScreenDrawing(const QStyleOption &option, const int &maxIconSize = -1);
64 QRect drawScreen(QPainter *painter, const QStyleOption &option, QRect screenGeometry, const int &maxIconSize = -1, const float brushOpacity = 1.0); // returns screen available rect
65 
66 int screenMaxLength(const QStyleOption &option, const int &maxIconSize = -1);
67 
68 }
69 
70 #endif
71