File indexing completed on 2024-05-19 16:31:23
0001 /* 0002 * SPDX-FileCopyrightText: 2010-2016 Ivan Cukic <ivan.cukic@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #ifndef ACTIVITIES_H 0008 #define ACTIVITIES_H 0009 0010 // Qt 0011 #include <QString> 0012 #include <QStringList> 0013 0014 // Utils 0015 #include <utils/d_ptr.h> 0016 0017 // Local 0018 #include "Module.h" 0019 #include <common/dbus/org.kde.ActivityManager.Activities.h> 0020 0021 /** 0022 * Service for tracking the user actions and managing the 0023 * activities 0024 */ 0025 class Activities : public Module 0026 { 0027 Q_OBJECT 0028 Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.Activities") 0029 Q_PROPERTY(QString CurrentActivity READ CurrentActivity WRITE SetCurrentActivity NOTIFY CurrentActivityChanged) 0030 0031 public: 0032 /** 0033 * Activity state 0034 * @note: Do not change the values, needed for bit-operations 0035 */ 0036 enum State { 0037 Invalid = 0, 0038 Running = 2, 0039 Starting = 3, 0040 Stopped = 4, 0041 Stopping = 5, 0042 }; 0043 0044 /** 0045 * Creates new Activities object 0046 */ 0047 explicit Activities(QObject *parent = nullptr); 0048 0049 /** 0050 * Destroys this interface 0051 */ 0052 ~Activities() override; 0053 0054 // workspace activities control 0055 public Q_SLOTS: 0056 /** 0057 * @returns the id of the current activity, empty string if none 0058 */ 0059 QString CurrentActivity() const; 0060 0061 /** 0062 * Sets the current activity 0063 * @param activity id of the activity to make current 0064 */ 0065 bool SetCurrentActivity(const QString &activity); 0066 0067 /** 0068 * Switches to the previous activity 0069 */ 0070 bool PreviousActivity(); 0071 0072 /** 0073 * Switches to the next activity 0074 */ 0075 bool NextActivity(); 0076 0077 /** 0078 * Adds a new activity 0079 * @param name name of the activity 0080 * @returns id of the newly created activity 0081 */ 0082 QString AddActivity(const QString &name); 0083 0084 /** 0085 * Starts the specified activity 0086 * @param activity id of the activity to stash 0087 */ 0088 void StartActivity(const QString &activity); 0089 0090 /** 0091 * Stops the specified activity 0092 * @param activity id of the activity to stash 0093 */ 0094 void StopActivity(const QString &activity); 0095 0096 /** 0097 * @returns the state of the activity 0098 * @param activity id of the activity 0099 */ 0100 int ActivityState(const QString &activity) const; 0101 0102 /** 0103 * Removes the specified activity 0104 * @param activity id of the activity to delete 0105 */ 0106 void RemoveActivity(const QString &activity); 0107 0108 /** 0109 * @returns the list of all existing activities 0110 */ 0111 QStringList ListActivities() const; 0112 0113 /** 0114 * @returns the list of activities with the specified state 0115 * @param state state 0116 */ 0117 QStringList ListActivities(int state) const; 0118 0119 /** 0120 * @returns the name of the specified activity 0121 * @param activity id of the activity 0122 */ 0123 QString ActivityName(const QString &activity) const; 0124 0125 /** 0126 * Sets the name of the specified activity 0127 * @param activity id of the activity 0128 * @param name name to be set 0129 */ 0130 void SetActivityName(const QString &activity, const QString &name); 0131 0132 /** 0133 * @returns the description of the specified activity 0134 * @param activity id of the activity 0135 */ 0136 QString ActivityDescription(const QString &activity) const; 0137 0138 /** 0139 * Sets the description of the specified activity 0140 * @param activity id of the activity 0141 * @param description description to be set 0142 */ 0143 void SetActivityDescription(const QString &activity, const QString &description); 0144 0145 /** 0146 * @returns the icon of the specified activity 0147 * @param activity id of the activity 0148 */ 0149 QString ActivityIcon(const QString &activity) const; 0150 0151 /** 0152 * Sets the icon of the specified activity 0153 * @param activity id of the activity 0154 * @param icon icon to be set 0155 */ 0156 void SetActivityIcon(const QString &activity, const QString &icon); 0157 0158 public Q_SLOTS: 0159 /** 0160 * @returns a list of activities with basic info about them 0161 */ 0162 ActivityInfoList ListActivitiesWithInformation() const; 0163 0164 /** 0165 * @returns the info about an activity 0166 */ 0167 ActivityInfo ActivityInformation(const QString &activity) const; 0168 0169 Q_SIGNALS: 0170 /** 0171 * This signal is emitted when the global 0172 * activity is changed 0173 * @param activity id of the new current activity 0174 */ 0175 void CurrentActivityChanged(const QString &activity); 0176 0177 /** 0178 * This signal is emitted when a new activity is created 0179 * @param activity id of the activity 0180 */ 0181 void ActivityAdded(const QString &activity); 0182 0183 /** 0184 * This signal is emitted when an activity is started 0185 * @param activity id of the activity 0186 */ 0187 void ActivityStarted(const QString &activity); 0188 0189 /** 0190 * This signal is emitted when an activity is stashed 0191 * @param activity id of the activity 0192 */ 0193 void ActivityStopped(const QString &activity); 0194 0195 /** 0196 * This signal is emitted when an activity is deleted 0197 * @param activity id of the activity 0198 */ 0199 void ActivityRemoved(const QString &activity); 0200 0201 /** 0202 * Emitted when an activity name is changed 0203 * @param activity id of the changed activity 0204 * @param name name of the changed activity 0205 */ 0206 void ActivityNameChanged(const QString &activity, const QString &name); 0207 0208 /** 0209 * Emitted when an activity description is changed 0210 * @param activity id of the changed activity 0211 * @param description description of the changed activity 0212 */ 0213 void ActivityDescriptionChanged(const QString &activity, const QString &description); 0214 0215 /** 0216 * Emitted when an activity icon is changed 0217 * @param activity id of the changed activity 0218 * @param icon name of the changed activity 0219 */ 0220 void ActivityIconChanged(const QString &activity, const QString &icon); 0221 0222 /** 0223 * Emitted when an activity is changed (name, icon, or some other property) 0224 * @param activity id of the changed activity 0225 */ 0226 void ActivityChanged(const QString &activity); 0227 0228 /** 0229 * Emitted when the state of activity is changed 0230 */ 0231 void ActivityStateChanged(const QString &activity, int state); 0232 0233 private: 0234 D_PTR; 0235 }; 0236 0237 #endif // ACTIVITIES_H