File indexing completed on 2024-05-19 05:29:32

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