File indexing completed on 2024-12-01 11:10:31

0001 /*
0002     SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef GENERICSETTINGSTOOLS_H
0007 #define GENERICSETTINGSTOOLS_H
0008 
0009 // Qt
0010 #include <QColor>
0011 #include <QPainter>
0012 #include <QPalette>
0013 #include <QRect>
0014 #include <QStyleOption>
0015 #include <QStyleOptionViewItem>
0016 
0017 namespace Latte {
0018 
0019 bool isActive(const QStyleOption &option);
0020 bool isEnabled(const QStyleOption &option);
0021 bool isFocused(const QStyleOption &option);
0022 bool isSelected(const QStyleOption &option);
0023 bool isHovered(const QStyleOption &option);
0024 bool isTextCentered(const QStyleOptionViewItem &option);
0025 
0026 QPalette::ColorGroup colorGroup(const QStyleOption &option);
0027 Qt::AlignmentFlag horizontalAlignment(Qt::Alignment alignments);
0028 
0029 //! strings that even though they were initially at original list
0030 //! now they are not present to current list
0031 QStringList subtracted(const QStringList &original, const QStringList &current);
0032 
0033 QRect remainedFromFormattedText(const QStyleOption &option, const QString &text, Qt::AlignmentFlag alignment = Qt::AlignLeft);
0034 void drawFormattedText(QPainter *painter, const QStyleOptionViewItem &option, const float textOpacity = 1.0);
0035 void drawFormattedText(QPainter *painter, const QStyleOptionMenuItem &option, const float textOpacity = 1.0);
0036 void drawFormattedText(QPainter *painter, const QStyleOption &option, const QString &text, Qt::AlignmentFlag alignment = Qt::AlignLeft, const float textOpacity = 1.0);
0037 
0038 //! background
0039 void drawBackground(QPainter *painter, const QStyleOptionViewItem &option);
0040 void drawBackground(QPainter *painter, const QStyle *style, const QStyleOptionMenuItem &option);
0041 
0042 //! simple icon
0043 QRect remainedFromIcon(const QStyleOption &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
0044 void drawIcon(QPainter *painter, const QStyleOption &option, const QString &icon, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
0045 
0046 //! layout icon
0047 QRect remainedFromLayoutIcon(const QStyleOption &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
0048 void drawLayoutIcon(QPainter *painter, const QStyleOption &option, const bool &isBackgroundFile, const QString &iconName, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
0049 
0050 //! color scheme icon
0051 QRect remainedFromColorSchemeIcon(const QStyleOption &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
0052 void drawColorSchemeIcon(QPainter *painter, const QStyleOption &option, const QColor &textColor, const QColor &backgroundColor,Qt::AlignmentFlag alignment = Qt::AlignLeft, int lengthMargin = -1, int thickMargin = -1);
0053 
0054 //! changes indicator
0055 QRect remainedFromChangesIndicator(const QStyleOptionViewItem &option);
0056 void drawChangesIndicator(QPainter *painter, const QStyleOptionViewItem &option);
0057 
0058 int primitiveCheckBoxWidth(const QStyleOptionButton &option, const QWidget *widget = nullptr);
0059 QRect remainedFromCheckBox(const QStyleOptionButton &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, const QWidget *widget = nullptr);
0060 void drawCheckBox(QPainter *painter, const QStyleOptionButton &option, Qt::AlignmentFlag alignment = Qt::AlignLeft, const QWidget *widget = nullptr);
0061 
0062 //! screen icon
0063 QRect remainedFromScreenDrawing(const QStyleOption &option, bool drawMultipleScreens, const int &maxIconSize = -1);
0064 QRect drawScreen(QPainter *painter, const QStyleOption &option, bool drawMultipleScreens, QRect screenGeometry, const int &maxIconSize = -1, const float brushOpacity = 1.0); // returns screen available rect
0065 
0066 int screenMaxLength(const QStyleOption &option, const int &maxIconSize = -1);
0067 
0068 }
0069 
0070 #endif