1 /* 2 SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com> 3 SPDX-License-Identifier: GPL-2.0-or-later 4 */ 5 6 #ifndef PLASMATHEMEEXTENDEDPANELBACKGROUND_H 7 #define PLASMATHEMEEXTENDEDPANELBACKGROUND_H 8 9 // Qt 10 #include <QObject> 11 12 // Plasma 13 #include <Plasma> 14 #include <Plasma/FrameSvg> 15 16 namespace Latte { 17 namespace PlasmaExtended { 18 class Theme; 19 } 20 } 21 22 namespace Latte { 23 namespace PlasmaExtended { 24 25 class PanelBackground: public QObject 26 { 27 Q_OBJECT 28 Q_PROPERTY(int paddingTop READ paddingTop NOTIFY paddingsChanged) 29 Q_PROPERTY(int paddingLeft READ paddingLeft NOTIFY paddingsChanged) 30 Q_PROPERTY(int paddingBottom READ paddingBottom NOTIFY paddingsChanged) 31 Q_PROPERTY(int paddingRight READ paddingRight NOTIFY paddingsChanged) 32 Q_PROPERTY(int shadowSize READ shadowSize NOTIFY shadowSizeChanged) 33 34 Q_PROPERTY(int roundness READ roundness NOTIFY roundnessChanged) 35 36 Q_PROPERTY(float maxOpacity READ maxOpacity NOTIFY maxOpacityChanged) 37 38 Q_PROPERTY(QColor shadowColor READ shadowColor NOTIFY shadowColorChanged) 39 40 public: 41 PanelBackground(Plasma::Types::Location edge, Theme *parent); 42 ~PanelBackground(); 43 44 int paddingTop() const; 45 int paddingLeft() const; 46 int paddingBottom() const; 47 int paddingRight() const; 48 int shadowSize() const; 49 50 int roundness() const; 51 52 float maxOpacity() const; 53 54 QColor shadowColor() const; 55 56 public slots: 57 void update(); 58 59 signals: 60 void paddingsChanged(); 61 void roundnessChanged(); 62 void shadowColorChanged(); 63 void shadowSizeChanged(); 64 void maxOpacityChanged(); 65 66 private: 67 bool hasMask(Plasma::Svg *svg) const; 68 69 QString prefixed(const QString &id); 70 QString element(Plasma::Svg *svg, const QString &id); 71 72 void updateMaxOpacity(Plasma::Svg *svg); 73 void updatePaddings(Plasma::Svg *svg); 74 void updateRoundness(Plasma::Svg *svg); 75 void updateShadow(Plasma::Svg *svg); 76 77 void updateRoundnessFromMask(Plasma::Svg *svg); 78 void updateRoundnessFromShadows(Plasma::Svg *svg); 79 void updateRoundnessFallback(Plasma::Svg *svg); 80 81 private: 82 int m_paddingTop{0}; 83 int m_paddingLeft{0}; 84 int m_paddingBottom{0}; 85 int m_paddingRight{0}; 86 87 int m_shadowSize{0}; 88 int m_roundness{0}; 89 90 float m_maxOpacity{1.0}; 91 92 QColor m_shadowColor; 93 94 Plasma::Types::Location m_location{Plasma::Types::BottomEdge}; 95 96 Theme *m_parentTheme{nullptr}; 97 }; 98 99 } 100 } 101 102 #endif 103