@@ -28,8 +28,19 @@ class DesktopEntry: public QObject {
28
28
Q_PROPERTY (QString comment MEMBER mComment CONSTANT);
29
29
// / Name of the icon associated with this application. May be empty.
30
30
Q_PROPERTY (QString icon MEMBER mIcon CONSTANT);
31
- // / The raw `Exec` string from the desktop entry. You probably want @@execute().
31
+ // / The raw `Exec` string from the desktop entry.
32
+ // /
33
+ // / > [!WARNING] This cannot be reliably run as a command. See @@command for one you can run.
32
34
Q_PROPERTY (QString execString MEMBER mExecString CONSTANT);
35
+ // / The parsed `Exec` command in the desktop entry.
36
+ // /
37
+ // / The entry can be run with @@execute(), or by using this command in
38
+ // / @@Quickshell.Quickshell.execDetached() or @@Quickshell.Io.Process.
39
+ // / If used in `execDetached` or a `Process`, @@workingDirectory should also be passed to
40
+ // / the invoked process. See @@execute() for details.
41
+ // /
42
+ // / > [!NOTE] The provided command does not invoke a terminal even if @@runInTerminal is true.
43
+ Q_PROPERTY (QVector<QString> command MEMBER mCommand CONSTANT);
33
44
// / The working directory to execute from.
34
45
Q_PROPERTY (QString workingDirectory MEMBER mWorkingDirectory CONSTANT);
35
46
// / If the application should run in a terminal.
@@ -46,6 +57,16 @@ class DesktopEntry: public QObject {
46
57
void parseEntry (const QString& text);
47
58
48
59
// / Run the application. Currently ignores @@runInTerminal and field codes.
60
+ // /
61
+ // / This is equivalent to calling @@Quickshell.Quickshell.execDetached() with @@command
62
+ // / and @@DesktopEntry.workingDirectory as shown below:
63
+ // /
64
+ // / ```qml
65
+ // / Quickshell.execDetached({
66
+ // / command: desktopEntry.command,
67
+ // / workingDirectory: desktopEntry.workingDirectory,
68
+ // / });
69
+ // / ```
49
70
Q_INVOKABLE void execute () const ;
50
71
51
72
[[nodiscard]] bool isValid () const ;
@@ -54,7 +75,7 @@ class DesktopEntry: public QObject {
54
75
55
76
// currently ignores all field codes.
56
77
static QVector<QString> parseExecString (const QString& execString);
57
- static void doExec (const QString& execString, const QString& workingDirectory);
78
+ static void doExec (const QList< QString> & execString, const QString& workingDirectory);
58
79
59
80
public:
60
81
QString mId ;
@@ -64,6 +85,7 @@ class DesktopEntry: public QObject {
64
85
QString mComment ;
65
86
QString mIcon ;
66
87
QString mExecString ;
88
+ QVector<QString> mCommand ;
67
89
QString mWorkingDirectory ;
68
90
bool mTerminal = false ;
69
91
QVector<QString> mCategories ;
@@ -82,8 +104,19 @@ class DesktopAction: public QObject {
82
104
Q_PROPERTY (QString id MEMBER mId CONSTANT);
83
105
Q_PROPERTY (QString name MEMBER mName CONSTANT);
84
106
Q_PROPERTY (QString icon MEMBER mIcon CONSTANT);
85
- // / The raw `Exec` string from the desktop entry. You probably want @@execute().
107
+ // / The raw `Exec` string from the action.
108
+ // /
109
+ // / > [!WARNING] This cannot be reliably run as a command. See @@command for one you can run.
86
110
Q_PROPERTY (QString execString MEMBER mExecString CONSTANT);
111
+ // / The parsed `Exec` command in the action.
112
+ // /
113
+ // / The entry can be run with @@execute(), or by using this command in
114
+ // / @@Quickshell.Quickshell.execDetached() or @@Quickshell.Io.Process.
115
+ // / If used in `execDetached` or a `Process`, @@DesktopEntry.workingDirectory should also be passed to
116
+ // / the invoked process.
117
+ // /
118
+ // / > [!NOTE] The provided command does not invoke a terminal even if @@runInTerminal is true.
119
+ Q_PROPERTY (QVector<QString> command MEMBER mCommand CONSTANT);
87
120
QML_ELEMENT;
88
121
QML_UNCREATABLE (" DesktopAction instances must be retrieved from a DesktopEntry" );
89
122
@@ -94,6 +127,9 @@ class DesktopAction: public QObject {
94
127
, mId(std::move(id)) {}
95
128
96
129
// / Run the application. Currently ignores @@DesktopEntry.runInTerminal and field codes.
130
+ // /
131
+ // / This is equivalent to calling @@Quickshell.Quickshell.execDetached() with @@command
132
+ // / and @@DesktopEntry.workingDirectory.
97
133
Q_INVOKABLE void execute () const ;
98
134
99
135
private:
@@ -102,6 +138,7 @@ class DesktopAction: public QObject {
102
138
QString mName ;
103
139
QString mIcon ;
104
140
QString mExecString ;
141
+ QVector<QString> mCommand ;
105
142
QHash<QString, QString> mEntries ;
106
143
107
144
friend class DesktopEntry ;
0 commit comments