File indexing completed on 2024-12-08 08:00:01

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef SETTINGSPATTERNWIDGET_H
0007 #define SETTINGSPATTERNWIDGET_H
0008 
0009 // Qt
0010 #include <QLabel>
0011 #include <QGraphicsDropShadowEffect>
0012 #include <QWidget>
0013 
0014 
0015 namespace Latte {
0016 namespace Settings {
0017 namespace Widget {
0018 
0019 class PatternWidget : public QWidget
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     explicit PatternWidget(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
0025 
0026     QString background() const;
0027     void setBackground(const QString &file);
0028 
0029     void setText(const QString &text);
0030 
0031     QString textColor() const;
0032     void setTextColor(const QString &color);
0033 
0034 signals:
0035     void backgroundChanged();
0036     void textColorChanged();
0037     void mouseReleased();
0038 
0039 protected:
0040     void enterEvent(QEvent *event) override;
0041     void mouseMoveEvent(QMouseEvent *event ) override;
0042     void mouseReleaseEvent(QMouseEvent *event) override;
0043     void paintEvent(QPaintEvent *event) override;
0044 
0045 private slots:
0046     void updateUi();
0047 
0048 private:
0049     void initUi();
0050 
0051 private:
0052     QLabel *m_label{nullptr};
0053 
0054     QString m_background;
0055     QString m_textColor;
0056 
0057     float m_textColorBrightness;
0058 
0059     QGraphicsDropShadowEffect* m_shadowEffect{nullptr};
0060 };
0061 
0062 }
0063 }
0064 }
0065 
0066 #endif