mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Enable KRun's script execution prompt.
This commit enables KRun's script/desktop file execution prompts, which is shown when the user launches an executable script or a desktop file. This is done so as to prevent the user from accidentaly executing programs. A checkbox to enable or disable the prompts is also being added to the preferences window REVIEW: 120171 BUG: 275405
This commit is contained in:
parent
422dc4e921
commit
e256daa569
|
@ -504,7 +504,8 @@ void DolphinViewContainer::slotItemActivated(const KFileItem& item)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new KRun(item.targetUrl(), this);
|
KRun *run = new KRun(item.targetUrl(), this);
|
||||||
|
run->setShowScriptExecutionPrompt(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
|
void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
namespace {
|
namespace {
|
||||||
const bool ConfirmTrash = false;
|
const bool ConfirmTrash = false;
|
||||||
const bool ConfirmDelete = true;
|
const bool ConfirmDelete = true;
|
||||||
|
const bool ConfirmScriptExecution = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
||||||
|
@ -48,6 +49,8 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
||||||
"Moving files or folders to trash"), this);
|
"Moving files or folders to 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 when:"), this);
|
QLabel* confirmLabelDolphin = new QLabel(i18nc("@title:group", "Ask for confirmation when:"), this);
|
||||||
confirmLabelDolphin->setWordWrap(true);
|
confirmLabelDolphin->setWordWrap(true);
|
||||||
|
@ -60,6 +63,7 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
||||||
topLayout->addSpacing(KDialog::spacingHint());
|
topLayout->addSpacing(KDialog::spacingHint());
|
||||||
topLayout->addWidget(m_confirmMoveToTrash);
|
topLayout->addWidget(m_confirmMoveToTrash);
|
||||||
topLayout->addWidget(m_confirmDelete);
|
topLayout->addWidget(m_confirmDelete);
|
||||||
|
topLayout->addWidget(m_confirmScriptExecution);
|
||||||
topLayout->addSpacing(KDialog::spacingHint());
|
topLayout->addSpacing(KDialog::spacingHint());
|
||||||
topLayout->addWidget(confirmLabelDolphin);
|
topLayout->addWidget(confirmLabelDolphin);
|
||||||
topLayout->addSpacing(KDialog::spacingHint());
|
topLayout->addSpacing(KDialog::spacingHint());
|
||||||
|
@ -70,6 +74,7 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
|
||||||
|
|
||||||
connect(m_confirmMoveToTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
connect(m_confirmMoveToTrash, &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_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +90,12 @@ void ConfirmationsSettingsPage::applySettings()
|
||||||
confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked());
|
confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked());
|
||||||
confirmationGroup.sync();
|
confirmationGroup.sync();
|
||||||
|
|
||||||
|
if (m_confirmScriptExecution->isChecked()) {
|
||||||
|
KConfigGroup scriptExecutionGroup(kioConfig, "Executable scripts");
|
||||||
|
scriptExecutionGroup.writeEntry("behaviourOnLaunch", "alwaysAsk");
|
||||||
|
scriptExecutionGroup.sync();
|
||||||
|
}
|
||||||
|
|
||||||
GeneralSettings* settings = GeneralSettings::self();
|
GeneralSettings* settings = GeneralSettings::self();
|
||||||
settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked());
|
settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked());
|
||||||
settings->writeConfig();
|
settings->writeConfig();
|
||||||
|
@ -99,6 +110,7 @@ void ConfirmationsSettingsPage::restoreDefaults()
|
||||||
|
|
||||||
m_confirmMoveToTrash->setChecked(ConfirmTrash);
|
m_confirmMoveToTrash->setChecked(ConfirmTrash);
|
||||||
m_confirmDelete->setChecked(ConfirmDelete);
|
m_confirmDelete->setChecked(ConfirmDelete);
|
||||||
|
m_confirmScriptExecution->setChecked(ConfirmScriptExecution);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmationsSettingsPage::loadSettings()
|
void ConfirmationsSettingsPage::loadSettings()
|
||||||
|
@ -108,6 +120,10 @@ void ConfirmationsSettingsPage::loadSettings()
|
||||||
m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", ConfirmTrash));
|
m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", ConfirmTrash));
|
||||||
m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", ConfirmDelete));
|
m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", ConfirmDelete));
|
||||||
|
|
||||||
|
const KConfigGroup scriptExecutionGroup(KSharedConfig::openConfig("kiorc"), "Executable scripts");
|
||||||
|
const QString value = scriptExecutionGroup.readEntry("behaviourOnLaunch", "alwaysAsk");
|
||||||
|
m_confirmScriptExecution->setChecked(value == "alwaysAsk");
|
||||||
|
|
||||||
m_confirmClosingMultipleTabs->setChecked(GeneralSettings::confirmClosingMultipleTabs());
|
m_confirmClosingMultipleTabs->setChecked(GeneralSettings::confirmClosingMultipleTabs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ private:
|
||||||
QCheckBox* m_confirmMoveToTrash;
|
QCheckBox* m_confirmMoveToTrash;
|
||||||
QCheckBox* m_confirmDelete;
|
QCheckBox* m_confirmDelete;
|
||||||
QCheckBox* m_confirmClosingMultipleTabs;
|
QCheckBox* m_confirmClosingMultipleTabs;
|
||||||
|
QCheckBox* m_confirmScriptExecution;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue