diff --git a/src/widgets/kpropertiesdesktopbase.ui b/src/widgets/kpropertiesdesktopbase.ui
index a87a4ca0dee9b75ec751a96535ca1e8a63a2eb32..461563dc43253dd7991fef705badc77ff088e513 100644
--- a/src/widgets/kpropertiesdesktopbase.ui
+++ b/src/widgets/kpropertiesdesktopbase.ui
@@ -77,6 +77,19 @@
-
+
+
+ Environment Variables:
+
+
+ envarsEdit
+
+
+
+ -
+
+
+ -
Type the command to start this application here.
@@ -99,7 +112,7 @@ Following the command, you can have several placeholders which will be replaced
- -
+
-
-
@@ -130,7 +143,7 @@ Following the command, you can have several placeholders which will be replaced
- -
+
-
Sets the working directory for your application.
@@ -143,21 +156,21 @@ Following the command, you can have several placeholders which will be replaced
- -
+
-
Sets the working directory for your application.
- -
+
-
Arguments:
- -
+
-
diff --git a/src/widgets/kpropertiesdialog.cpp b/src/widgets/kpropertiesdialog.cpp
index abd79163c0db7dfd913eac31c6582e0767dbc641..88ecf0de4e243ffac29cb0bfad61ec2085428539 100644
--- a/src/widgets/kpropertiesdialog.cpp
+++ b/src/widgets/kpropertiesdialog.cpp
@@ -3305,6 +3305,7 @@ KDesktopPropsPlugin::KDesktopPropsPlugin(KPropertiesDialog *_props)
connect(d->w->nameEdit, &QLineEdit::textChanged, this, &KPropertiesDialogPlugin::changed);
connect(d->w->genNameEdit, &QLineEdit::textChanged, this, &KPropertiesDialogPlugin::changed);
connect(d->w->commentEdit, &QLineEdit::textChanged, this, &KPropertiesDialogPlugin::changed);
+ connect(d->w->envarsEdit, &QLineEdit::textChanged, this, &KPropertiesDialogPlugin::changed);
connect(d->w->programEdit, &QLineEdit::textChanged, this, &KPropertiesDialogPlugin::changed);
connect(d->w->argumentsEdit, &QLineEdit::textChanged, this, &KPropertiesDialogPlugin::changed);
connect(d->w->pathEdit, &KUrlRequester::textChanged, this, &KPropertiesDialogPlugin::changed);
@@ -3397,13 +3398,28 @@ KDesktopPropsPlugin::KDesktopPropsPlugin(KPropertiesDialog *_props)
d->w->commentEdit->setText(commentStr);
QStringList execLine = KShell::splitArgs(commandStr);
+ QStringList enVars = {};
if (!execLine.isEmpty()) {
+ // check for apps that use the env executable
+ // to set the environment
+ if (execLine[0] == QLatin1String("env")) {
+ execLine.pop_front();
+ }
+ for (auto env : execLine) {
+ if (!env.contains(QLatin1String("="))) {
+ break;
+ }
+ enVars += env;
+ execLine.pop_front();
+ }
+
d->w->programEdit->setText(execLine.takeFirst());
} else {
d->w->programEdit->clear();
}
d->w->argumentsEdit->setText(KShell::joinArgs(execLine));
+ d->w->envarsEdit->setText(KShell::joinArgs(enVars));
d->w->pathEdit->lineEdit()->setText(pathStr);
@@ -3742,7 +3758,12 @@ bool KDesktopPropsPlugin::supports(const KFileItemList &_items)
QString KDesktopPropsPlugin::KDesktopPropsPluginPrivate::command() const
{
- QStringList execSplit = QStringList(w->programEdit->text()) + KShell::splitArgs(w->argumentsEdit->text());
+ QStringList execSplit = KShell::splitArgs(w->envarsEdit->text()) + QStringList(w->programEdit->text()) + KShell::splitArgs(w->argumentsEdit->text());
+
+ if (KShell::splitArgs(w->envarsEdit->text()).length()) {
+ execSplit.push_front(QLatin1String("env"));
+ }
+
return KShell::joinArgs(execSplit);
}