Commit 3c018ad1 authored by Christoph Roick's avatar Christoph Roick
Browse files

Merge branch '5.6' into master

parents 52ab55fb a48287f4
......@@ -55,6 +55,7 @@ QString ExecutePlugin::userIdToRunEntry = QStringLiteral("User Id to Run");
QString ExecutePlugin::dependencyActionEntry = QStringLiteral("Dependency Action");
QString ExecutePlugin::projectTargetEntry = QStringLiteral("Project Target");
QString ExecutePlugin::killBeforeExecutingAgain = QStringLiteral("Kill Before Executing Again");
QString ExecutePlugin::configuredByCTest = QStringLiteral("ConfiguredByCTest");
using namespace KDevelop;
......
......@@ -53,6 +53,7 @@ class ExecutePlugin : public KDevelop::IPlugin, public IExecutePlugin
static QString dependencyActionEntry;
static QString projectTargetEntry;
static QString killBeforeExecutingAgain;
static QString configuredByCTest;
void unload() override;
......
......@@ -40,7 +40,6 @@
#include <QIcon>
#include <QMenu>
#include <QMessageBox>
#include <KConfigGroup>
#include <KLineEdit>
......@@ -96,7 +95,12 @@ void NativeAppConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelo
dependencyAction->setCurrentIndex( dependencyAction->findData( cfg.readEntry( ExecutePlugin::dependencyActionEntry, "Nothing" ) ) );
killBeforeStartingAgain->setCurrentIndex(killBeforeStartingAgain->findData( cfg.readEntry<int>( ExecutePlugin::killBeforeExecutingAgain, QMessageBox::Cancel ) ));
if (cfg.readEntry<bool>(ExecutePlugin::configuredByCTest, false)) {
killBeforeStartingAgain->setCurrentIndex(killBeforeStartingAgain->findData(NativeAppJob::startAnother));
killBeforeStartingAgain->setDisabled(true);
} else {
killBeforeStartingAgain->setCurrentIndex(killBeforeStartingAgain->findData(cfg.readEntry<int>(ExecutePlugin::killBeforeExecutingAgain, NativeAppJob::askIfRunning)));
}
}
NativeAppConfigPage::NativeAppConfigPage( QWidget* parent )
......@@ -109,9 +113,9 @@ NativeAppConfigPage::NativeAppConfigPage( QWidget* parent )
dependencyAction->setItemData(2, QStringLiteral("Install"));
dependencyAction->setItemData(3, QStringLiteral("SudoInstall"));
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Ask If Running"), QMessageBox::Cancel);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Kill All Instances"), QMessageBox::No);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Start Another"), QMessageBox::Yes);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Ask If Running"), NativeAppJob::askIfRunning);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Kill All Instances"), NativeAppJob::killAllInstances);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Start Another"), NativeAppJob::startAnother);
//Set workingdirectory widget to ask for directories rather than files
workingDirectory->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
......
......@@ -53,7 +53,9 @@ NativeAppJob::NativeAppJob(QObject* parent, KDevelop::ILaunchConfiguration* cfg)
if (cfgGroup.readEntry(ExecutePlugin::isExecutableEntry, false)) {
m_name = cfgGroup.readEntry(ExecutePlugin::executableEntry, cfg->name()).section(QLatin1Char('/'), -1);
}
m_killBeforeExecutingAgain = cfgGroup.readEntry<int>(ExecutePlugin::killBeforeExecutingAgain, QMessageBox::Cancel);
if (!cfgGroup.readEntry<bool>(ExecutePlugin::configuredByCTest, false)) {
m_killBeforeExecutingAgain = cfgGroup.readEntry<int>(ExecutePlugin::killBeforeExecutingAgain, askIfRunning);
}
}
setCapabilities(Killable);
......@@ -147,29 +149,29 @@ void NativeAppJob::start()
}
if (!currentJobs.isEmpty()) {
int killAllInstances = m_killBeforeExecutingAgain;
if (killAllInstances == QMessageBox::Cancel) {
int oldJobAction = m_killBeforeExecutingAgain;
if (oldJobAction == askIfRunning) {
QMessageBox msgBox(QMessageBox::Question,
i18nc("@title:window", "Job Already Running"),
i18n("'%1' is already being executed.", m_name),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
msgBox.button(QMessageBox::No)->setText(i18nc("@action:button", "Kill All Instances"));
msgBox.button(QMessageBox::Yes)->setText(i18nc("@action:button", "Start Another"));
startAnother | killAllInstances | QMessageBox::Cancel /* aka askIfRunning */);
msgBox.button(killAllInstances)->setText(i18nc("@action:button", "Kill All Instances"));
msgBox.button(startAnother)->setText(i18nc("@action:button", "Start Another"));
msgBox.setDefaultButton(QMessageBox::Cancel);
QCheckBox* remember = new QCheckBox(i18nc("@option:check", "Remember choice"));
msgBox.setCheckBox(remember);
killAllInstances = msgBox.exec();
if (remember->isChecked() && killAllInstances != QMessageBox::Cancel) {
Q_EMIT killBeforeExecutingAgainChanged(killAllInstances);
oldJobAction = msgBox.exec();
if (remember->isChecked() && oldJobAction != QMessageBox::Cancel) {
Q_EMIT killBeforeExecutingAgainChanged(oldJobAction);
}
}
switch (killAllInstances) {
case QMessageBox::Yes: // simply start another job
switch (oldJobAction) {
case startAnother:
break;
case QMessageBox::No: // kill the running instance
case killAllInstances:
for (auto & job : currentJobs) {
if (job)
job->kill(EmitResult);
......
......@@ -22,6 +22,8 @@
#include <outputview/outputexecutejob.h>
#include <QMessageBox>
namespace KDevelop
{
class ILaunchConfiguration;
......@@ -36,11 +38,16 @@ public:
void start() override;
// Actions for what to do when a job is already running
static constexpr auto startAnother = QMessageBox::Yes;
static constexpr auto killAllInstances = QMessageBox::No;
static constexpr auto askIfRunning = QMessageBox::Cancel;
Q_SIGNALS:
void killBeforeExecutingAgainChanged(int killBeforeExecutingAgainChanged);
private:
QString m_name;
int m_killBeforeExecutingAgain = -1;
int m_killBeforeExecutingAgain = startAnother;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment