File indexing completed on 2024-12-01 08:07:20
0001 /* 0002 SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef ABSTRACTLAYOUT_H 0007 #define ABSTRACTLAYOUT_H 0008 0009 // Qt 0010 #include <QObject> 0011 0012 // KDE 0013 #include <KConfigGroup> 0014 0015 // Plasma 0016 #include <Plasma> 0017 0018 namespace Plasma { 0019 class Types; 0020 } 0021 0022 namespace Latte { 0023 namespace Layout { 0024 Q_NAMESPACE 0025 0026 enum Type { 0027 Abstract = 0, 0028 Generic, 0029 Central, 0030 Shared 0031 }; 0032 Q_ENUM_NS(Type); 0033 0034 enum BackgroundStyle 0035 { 0036 ColorBackgroundStyle = 0, 0037 PatternBackgroundStyle 0038 }; 0039 Q_ENUM_NS(BackgroundStyle); 0040 0041 } 0042 } 0043 0044 namespace Latte { 0045 namespace Layout { 0046 0047 const char MULTIPLELAYOUTSHIDDENNAME[] = ".multiple-layouts_hidden"; 0048 0049 class AbstractLayout : public QObject 0050 { 0051 Q_OBJECT 0052 Q_PROPERTY(QString name READ name NOTIFY nameChanged) 0053 0054 Q_PROPERTY(bool preferredForShortcutsTouched READ preferredForShortcutsTouched WRITE setPreferredForShortcutsTouched NOTIFY preferredForShortcutsTouchedChanged) 0055 0056 Q_PROPERTY(int popUpMargin READ popUpMargin WRITE setPopUpMargin NOTIFY popUpMarginChanged) 0057 0058 Q_PROPERTY(QString icon READ icon NOTIFY iconChanged) 0059 Q_PROPERTY(QString background READ background NOTIFY backgroundChanged) 0060 Q_PROPERTY(QString textColor READ textColor NOTIFY textColorChanged) 0061 0062 Q_PROPERTY(QString schemeFile READ schemeFile WRITE setSchemeFile NOTIFY schemeFileChanged) 0063 0064 Q_PROPERTY(QStringList launchers READ launchers WRITE setLaunchers NOTIFY launchersChanged) 0065 Q_PROPERTY(QString lastUsedActivity READ lastUsedActivity NOTIFY lastUsedActivityChanged) 0066 0067 public: 0068 AbstractLayout(QObject *parent, QString layoutFile, QString assignedName = QString()); 0069 ~AbstractLayout() override; 0070 0071 int version() const; 0072 void setVersion(int ver); 0073 0074 bool preferredForShortcutsTouched() const; 0075 void setPreferredForShortcutsTouched(bool touched); 0076 0077 int popUpMargin() const; 0078 void setPopUpMargin(const int &margin); 0079 0080 QString lastUsedActivity() const; 0081 void clearLastUsedActivity(); //!e.g. when we export a layout 0082 0083 QString name() const; 0084 QString file() const; 0085 0086 virtual QString background() const; 0087 0088 QString color() const; 0089 void setColor(QString color); 0090 0091 QString customBackground() const; 0092 void setCustomBackground(const QString &background); 0093 0094 QString customTextColor() const; 0095 void setCustomTextColor(const QString &customColor); 0096 0097 QString icon() const; 0098 void setIcon(const QString &icon); 0099 0100 QString predefinedTextColor() const; 0101 0102 QString schemeFile() const; 0103 void setSchemeFile(const QString &file); 0104 0105 virtual QString textColor() const; 0106 void setTextColor(QString color); 0107 0108 BackgroundStyle backgroundStyle() const; 0109 void setBackgroundStyle(const BackgroundStyle &style); 0110 0111 QStringList launchers() const; 0112 void setLaunchers(QStringList launcherList); 0113 0114 virtual Type type() const; 0115 0116 void syncSettings(); 0117 0118 // STATIC 0119 static QString defaultCustomTextColor(); 0120 static QString defaultCustomBackground(); 0121 static QString defaultTextColor(const QString &color); 0122 static QString layoutName(const QString &fileName); 0123 static QList<Plasma::Types::Location> combinedFreeEdges(const QList<Plasma::Types::Location> &edges1, 0124 const QList<Plasma::Types::Location> &edges2); 0125 0126 signals: 0127 void backgroundChanged(); 0128 void backgroundStyleChanged(); 0129 void customBackgroundChanged(); 0130 void customTextColorChanged(); 0131 void colorChanged(); 0132 void fileChanged(); 0133 void iconChanged(); 0134 void lastUsedActivityChanged(); 0135 void launchersChanged(); 0136 void nameChanged(); 0137 void popUpMarginChanged(); 0138 void preferredForShortcutsTouchedChanged(); 0139 void schemeFileChanged(); 0140 void textColorChanged(); 0141 void versionChanged(); 0142 0143 protected slots: 0144 void loadConfig(); 0145 void saveConfig(); 0146 0147 protected: 0148 void init(); 0149 void setName(QString name); 0150 void setFile(QString file); 0151 0152 protected: 0153 bool m_loadedCorrectly{false}; 0154 bool m_preferredForShortcutsTouched{false}; 0155 0156 //if version doesn't exist it is and old layout file 0157 int m_version{2}; 0158 0159 int m_popUpMargin{-1}; //default 0160 0161 QString m_customBackground; 0162 QString m_customTextColor; 0163 QString m_color; 0164 QString m_lastUsedActivity; //the last used activity for this layout 0165 QString m_icon; 0166 QString m_schemeFile; 0167 0168 BackgroundStyle m_backgroundStyle{ColorBackgroundStyle}; 0169 0170 QString m_layoutFile; 0171 QString m_layoutName; 0172 0173 QStringList m_launchers; 0174 0175 KConfigGroup m_layoutGroup; 0176 0177 }; 0178 0179 } 0180 } 0181 0182 #endif