File indexing completed on 2024-12-22 05:13:39
0001 /* 0002 SPDX-FileCopyrightText: 2010-2016 Ivan Cukic <ivan.cukic(at)kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef ACTIVITIES_CONTROLLER_H 0008 #define ACTIVITIES_CONTROLLER_H 0009 0010 #include <QFuture> 0011 #include <QObject> 0012 #include <QString> 0013 0014 #include "consumer.h" 0015 0016 #include "plasma_activities_export.h" 0017 0018 #include <memory> 0019 0020 namespace KActivities 0021 { 0022 class ControllerPrivate; 0023 0024 /** 0025 * This class provides methods for controlling and managing 0026 * the activities. 0027 * 0028 * @note The QFuture objects returned by these methods are not thread-based, 0029 * you can not call synchronous methods like waitForFinished, cancel, pause on 0030 * them. You need either to register watchers to check when those have finished, 0031 * or to check whether they are ready from time to time manually. 0032 * 0033 * @see Consumer for info about activities 0034 * 0035 * @since 5.0 0036 */ 0037 class PLASMA_ACTIVITIES_EXPORT Controller : public Consumer 0038 { 0039 Q_OBJECT 0040 0041 Q_PROPERTY(QString currentActivity READ currentActivity WRITE setCurrentActivity) 0042 0043 public: 0044 explicit Controller(QObject *parent = nullptr); 0045 0046 ~Controller() override; 0047 0048 /** 0049 * Sets the name of the specified activity 0050 * @param id id of the activity 0051 * @param name name to be set 0052 */ 0053 QFuture<void> setActivityName(const QString &id, const QString &name); 0054 0055 /** 0056 * Sets the description of the specified activity 0057 * @param id id of the activity 0058 * @param description description to be set 0059 */ 0060 QFuture<void> setActivityDescription(const QString &id, const QString &description); 0061 0062 /** 0063 * Sets the icon of the specified activity 0064 * @param id id of the activity 0065 * @param icon icon to be set - freedesktop.org name or file path 0066 */ 0067 QFuture<void> setActivityIcon(const QString &id, const QString &icon); 0068 0069 /** 0070 * Sets the current activity 0071 * @param id id of the activity to make current 0072 * @returns true if successful 0073 */ 0074 QFuture<bool> setCurrentActivity(const QString &id); 0075 0076 /** 0077 * Adds a new activity 0078 * @param name name of the activity 0079 * @returns id of the newly created activity 0080 */ 0081 QFuture<QString> addActivity(const QString &name); 0082 0083 /** 0084 * Removes the specified activity 0085 * @param id id of the activity to delete 0086 */ 0087 QFuture<void> removeActivity(const QString &id); 0088 0089 /** 0090 * Stops the activity 0091 * @param id id of the activity to stop 0092 */ 0093 QFuture<void> stopActivity(const QString &id); 0094 0095 /** 0096 * Starts the activity 0097 * @param id id of the activity to start 0098 */ 0099 QFuture<void> startActivity(const QString &id); 0100 0101 /** 0102 * Switches to the previous activity 0103 */ 0104 QFuture<void> previousActivity(); 0105 0106 /** 0107 * Switches to the next activity 0108 */ 0109 QFuture<void> nextActivity(); 0110 0111 private: 0112 const std::unique_ptr<ControllerPrivate> d; 0113 }; 0114 0115 } // namespace KActivities 0116 0117 #endif // ACTIVITIES_CONTROLLER_H