mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Expose full set of script execution options in settings window
Summary: Right now the script execution setting is a checkbox, capable only of handling boolean input. This is not appropriate because there are actually three options available. Accordingly, this patch replaces the checkbox with a combobox (to save space compared to radio buttons) that clearly exposes all three options. BUG: 371837 FIXED-IN: 19.12.0 Test Plan: {F7440559} - All three options do what they say they'll do - All options get saved properly - The combobox displays the correct option when the window is loaded - The {nav Defaults} button resets it to "always ask" as expected Reviewers: elvisangelaccio, #dolphin, #vdg Reviewed By: elvisangelaccio, #dolphin Subscribers: kfm-devel Tags: #dolphin Maniphest Tasks: T9932 Differential Revision: https://phabricator.kde.org/D24247
This commit is contained in:
parent
eec49bc38f
commit
983273924d
|
@ -25,14 +25,23 @@
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
enum ScriptExecution
|
||||||
|
{
|
||||||
|
AlwaysAsk = 0,
|
||||||
|
Open = 1,
|
||||||
|
Execute = 2
|
||||||
|
};
|
||||||
|
|
||||||
const bool ConfirmEmptyTrash = true;
|
const bool ConfirmEmptyTrash = true;
|
||||||
const bool ConfirmTrash = false;
|
const bool ConfirmTrash = false;
|
||||||
const bool ConfirmDelete = true;
|
const bool ConfirmDelete = true;
|
||||||
const bool ConfirmScriptExecution = true;
|
const int ConfirmScriptExecution = ScriptExecution::AlwaysAsk;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
||||||
|
@ -58,8 +67,6 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
||||||
"Emptying trash"), this);
|
"Emptying trash"), this);
|
||||||
m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for confirmation when",
|
m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for confirmation when",
|
||||||
"Deleting files or folders"), this);
|
"Deleting files or folders"), this);
|
||||||
m_confirmScriptExecution = new QCheckBox(i18nc("@option:check Ask for confirmation when",
|
|
||||||
"Executing scripts or desktop files"), this);
|
|
||||||
|
|
||||||
QLabel* confirmLabelDolphin = new QLabel(i18nc("@title:group", "Ask for confirmation in Dolphin when:"), this);
|
QLabel* confirmLabelDolphin = new QLabel(i18nc("@title:group", "Ask for confirmation in Dolphin when:"), this);
|
||||||
confirmLabelDolphin->setWordWrap(true);
|
confirmLabelDolphin->setWordWrap(true);
|
||||||
|
@ -72,11 +79,19 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
||||||
"Closing windows with a program running in the Terminal panel"), this);
|
"Closing windows with a program running in the Terminal panel"), this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QHBoxLayout* executableScriptLayout = new QHBoxLayout();
|
||||||
|
QLabel* executableScriptLabel = new QLabel(i18nc("@title:group", "When opening an executable file:"), this);
|
||||||
|
confirmLabelKde->setWordWrap(true);
|
||||||
|
executableScriptLayout->addWidget(executableScriptLabel);
|
||||||
|
|
||||||
|
m_confirmScriptExecution = new QComboBox(this);
|
||||||
|
m_confirmScriptExecution->addItems({i18n("Always ask"), i18n("Open in application"), i18n("Run script")});
|
||||||
|
executableScriptLayout->addWidget(m_confirmScriptExecution);
|
||||||
|
|
||||||
topLayout->addWidget(confirmLabelKde);
|
topLayout->addWidget(confirmLabelKde);
|
||||||
topLayout->addWidget(m_confirmMoveToTrash);
|
topLayout->addWidget(m_confirmMoveToTrash);
|
||||||
topLayout->addWidget(m_confirmEmptyTrash);
|
topLayout->addWidget(m_confirmEmptyTrash);
|
||||||
topLayout->addWidget(m_confirmDelete);
|
topLayout->addWidget(m_confirmDelete);
|
||||||
topLayout->addWidget(m_confirmScriptExecution);
|
|
||||||
topLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT);
|
topLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT);
|
||||||
topLayout->addWidget(confirmLabelDolphin);
|
topLayout->addWidget(confirmLabelDolphin);
|
||||||
topLayout->addWidget(m_confirmClosingMultipleTabs);
|
topLayout->addWidget(m_confirmClosingMultipleTabs);
|
||||||
|
@ -85,6 +100,9 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
||||||
topLayout->addWidget(m_confirmClosingTerminalRunningProgram);
|
topLayout->addWidget(m_confirmClosingTerminalRunningProgram);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
topLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT);
|
||||||
|
topLayout->addLayout(executableScriptLayout);
|
||||||
|
|
||||||
topLayout->addStretch();
|
topLayout->addStretch();
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
@ -92,7 +110,7 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
||||||
connect(m_confirmMoveToTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
connect(m_confirmMoveToTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
||||||
connect(m_confirmEmptyTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
connect(m_confirmEmptyTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
||||||
connect(m_confirmDelete, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
connect(m_confirmDelete, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
||||||
connect(m_confirmScriptExecution, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
connect(m_confirmScriptExecution, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ConfirmationsSettingsPage::changed);
|
||||||
connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
||||||
|
|
||||||
#ifdef HAVE_TERMINAL
|
#ifdef HAVE_TERMINAL
|
||||||
|
@ -113,10 +131,17 @@ void ConfirmationsSettingsPage::applySettings()
|
||||||
confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked());
|
confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked());
|
||||||
|
|
||||||
KConfigGroup scriptExecutionGroup(kioConfig, "Executable scripts");
|
KConfigGroup scriptExecutionGroup(kioConfig, "Executable scripts");
|
||||||
if (m_confirmScriptExecution->isChecked()) {
|
const int index = m_confirmScriptExecution->currentIndex();
|
||||||
|
switch (index) {
|
||||||
|
case ScriptExecution::AlwaysAsk:
|
||||||
scriptExecutionGroup.writeEntry("behaviourOnLaunch", "alwaysAsk");
|
scriptExecutionGroup.writeEntry("behaviourOnLaunch", "alwaysAsk");
|
||||||
} else {
|
break;
|
||||||
|
case ScriptExecution::Open:
|
||||||
scriptExecutionGroup.writeEntry("behaviourOnLaunch", "dontAsk");
|
scriptExecutionGroup.writeEntry("behaviourOnLaunch", "dontAsk");
|
||||||
|
break;
|
||||||
|
case ScriptExecution::Execute:
|
||||||
|
scriptExecutionGroup.writeEntry("behaviourOnLaunch", "execute");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
kioConfig->sync();
|
kioConfig->sync();
|
||||||
|
|
||||||
|
@ -140,7 +165,7 @@ void ConfirmationsSettingsPage::restoreDefaults()
|
||||||
m_confirmMoveToTrash->setChecked(ConfirmTrash);
|
m_confirmMoveToTrash->setChecked(ConfirmTrash);
|
||||||
m_confirmEmptyTrash->setChecked(ConfirmEmptyTrash);
|
m_confirmEmptyTrash->setChecked(ConfirmEmptyTrash);
|
||||||
m_confirmDelete->setChecked(ConfirmDelete);
|
m_confirmDelete->setChecked(ConfirmDelete);
|
||||||
m_confirmScriptExecution->setChecked(ConfirmScriptExecution);
|
m_confirmScriptExecution->setCurrentIndex(ConfirmScriptExecution);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmationsSettingsPage::loadSettings()
|
void ConfirmationsSettingsPage::loadSettings()
|
||||||
|
@ -153,7 +178,13 @@ void ConfirmationsSettingsPage::loadSettings()
|
||||||
|
|
||||||
const KConfigGroup scriptExecutionGroup(KSharedConfig::openConfig(QStringLiteral("kiorc")), "Executable scripts");
|
const KConfigGroup scriptExecutionGroup(KSharedConfig::openConfig(QStringLiteral("kiorc")), "Executable scripts");
|
||||||
const QString value = scriptExecutionGroup.readEntry("behaviourOnLaunch", "alwaysAsk");
|
const QString value = scriptExecutionGroup.readEntry("behaviourOnLaunch", "alwaysAsk");
|
||||||
m_confirmScriptExecution->setChecked(value == QLatin1String("alwaysAsk"));
|
if (value == QLatin1String("dontAsk")) {
|
||||||
|
m_confirmScriptExecution->setCurrentIndex(ScriptExecution::Open);
|
||||||
|
} else if (value == QLatin1String("execute")) {
|
||||||
|
m_confirmScriptExecution->setCurrentIndex(ScriptExecution::Execute);
|
||||||
|
} else /* if (value == QLatin1String("alwaysAsk"))*/ {
|
||||||
|
m_confirmScriptExecution->setCurrentIndex(ScriptExecution::AlwaysAsk);
|
||||||
|
}
|
||||||
|
|
||||||
m_confirmClosingMultipleTabs->setChecked(GeneralSettings::confirmClosingMultipleTabs());
|
m_confirmClosingMultipleTabs->setChecked(GeneralSettings::confirmClosingMultipleTabs());
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "settings/settingspagebase.h"
|
#include "settings/settingspagebase.h"
|
||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
class QComboBox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Page for the enabling or disabling confirmation dialogs.
|
* @brief Page for the enabling or disabling confirmation dialogs.
|
||||||
|
@ -54,7 +55,7 @@ private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QCheckBox* m_confirmClosingMultipleTabs;
|
QCheckBox* m_confirmClosingMultipleTabs;
|
||||||
QCheckBox* m_confirmScriptExecution;
|
QComboBox* m_confirmScriptExecution;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue