forked from qt-creator/qt-creator
Debugger: Use StandardRunnable in StartApplicationDialog
Change-Id: I5f8936d887c43ee644ad175d9d4c53857bc00436 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -32,8 +32,9 @@
|
|||||||
#include "cdb/cdbengine.h"
|
#include "cdb/cdbengine.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/runnables.h>
|
||||||
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -131,7 +132,6 @@ QString DebuggerKitChooser::kitToolTip(Kit *k) const
|
|||||||
class StartApplicationParameters
|
class StartApplicationParameters
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StartApplicationParameters();
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
bool equals(const StartApplicationParameters &rhs) const;
|
bool equals(const StartApplicationParameters &rhs) const;
|
||||||
void toSettings(QSettings *) const;
|
void toSettings(QSettings *) const;
|
||||||
@@ -143,28 +143,20 @@ public:
|
|||||||
Id kitId;
|
Id kitId;
|
||||||
uint serverPort;
|
uint serverPort;
|
||||||
QString serverAddress;
|
QString serverAddress;
|
||||||
QString localExecutable;
|
StandardRunnable runnable;
|
||||||
QString processArgs;
|
bool breakAtMain = false;
|
||||||
QString workingDirectory;
|
|
||||||
bool breakAtMain;
|
|
||||||
bool runInTerminal;
|
|
||||||
QString serverStartScript;
|
QString serverStartScript;
|
||||||
QString debugInfoLocation;
|
QString debugInfoLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
StartApplicationParameters::StartApplicationParameters() :
|
|
||||||
breakAtMain(false), runInTerminal(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StartApplicationParameters::equals(const StartApplicationParameters &rhs) const
|
bool StartApplicationParameters::equals(const StartApplicationParameters &rhs) const
|
||||||
{
|
{
|
||||||
return localExecutable == rhs.localExecutable
|
return runnable.executable == rhs.runnable.executable
|
||||||
&& serverPort == rhs.serverPort
|
&& serverPort == rhs.serverPort
|
||||||
&& processArgs == rhs.processArgs
|
&& runnable.commandLineArguments == rhs.runnable.commandLineArguments
|
||||||
&& workingDirectory == rhs.workingDirectory
|
&& runnable.workingDirectory == rhs.runnable.workingDirectory
|
||||||
&& breakAtMain == rhs.breakAtMain
|
&& breakAtMain == rhs.breakAtMain
|
||||||
&& runInTerminal == rhs.runInTerminal
|
&& runnable.runMode == rhs.runnable.runMode
|
||||||
&& serverStartScript == rhs.serverStartScript
|
&& serverStartScript == rhs.serverStartScript
|
||||||
&& kitId == rhs.kitId
|
&& kitId == rhs.kitId
|
||||||
&& debugInfoLocation == rhs.debugInfoLocation
|
&& debugInfoLocation == rhs.debugInfoLocation
|
||||||
@@ -175,7 +167,8 @@ QString StartApplicationParameters::displayName() const
|
|||||||
{
|
{
|
||||||
const int maxLength = 60;
|
const int maxLength = 60;
|
||||||
|
|
||||||
QString name = FileName::fromString(localExecutable).fileName() + QLatin1Char(' ') + processArgs;
|
QString name = FileName::fromString(runnable.executable).fileName()
|
||||||
|
+ QLatin1Char(' ') + runnable.commandLineArguments;
|
||||||
if (name.size() > 60) {
|
if (name.size() > 60) {
|
||||||
int index = name.lastIndexOf(QLatin1Char(' '), maxLength);
|
int index = name.lastIndexOf(QLatin1Char(' '), maxLength);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
@@ -195,11 +188,11 @@ void StartApplicationParameters::toSettings(QSettings *settings) const
|
|||||||
settings->setValue(_("LastKitId"), kitId.toSetting());
|
settings->setValue(_("LastKitId"), kitId.toSetting());
|
||||||
settings->setValue(_("LastServerPort"), serverPort);
|
settings->setValue(_("LastServerPort"), serverPort);
|
||||||
settings->setValue(_("LastServerAddress"), serverAddress);
|
settings->setValue(_("LastServerAddress"), serverAddress);
|
||||||
settings->setValue(_("LastExternalExecutable"), localExecutable);
|
settings->setValue(_("LastExternalExecutable"), runnable.executable);
|
||||||
settings->setValue(_("LastExternalExecutableArguments"), processArgs);
|
settings->setValue(_("LastExternalExecutableArguments"), runnable.commandLineArguments);
|
||||||
settings->setValue(_("LastExternalWorkingDirectory"), workingDirectory);
|
settings->setValue(_("LastExternalWorkingDirectory"), runnable.workingDirectory);
|
||||||
settings->setValue(_("LastExternalBreakAtMain"), breakAtMain);
|
settings->setValue(_("LastExternalBreakAtMain"), breakAtMain);
|
||||||
settings->setValue(_("LastExternalRunInTerminal"), runInTerminal);
|
settings->setValue(_("LastExternalRunInTerminal"), runnable.runMode == ApplicationLauncher::Console);
|
||||||
settings->setValue(_("LastServerStartScript"), serverStartScript);
|
settings->setValue(_("LastServerStartScript"), serverStartScript);
|
||||||
settings->setValue(_("LastDebugInfoLocation"), debugInfoLocation);
|
settings->setValue(_("LastDebugInfoLocation"), debugInfoLocation);
|
||||||
}
|
}
|
||||||
@@ -209,11 +202,12 @@ void StartApplicationParameters::fromSettings(const QSettings *settings)
|
|||||||
kitId = Id::fromSetting(settings->value(_("LastKitId")));
|
kitId = Id::fromSetting(settings->value(_("LastKitId")));
|
||||||
serverPort = settings->value(_("LastServerPort")).toUInt();
|
serverPort = settings->value(_("LastServerPort")).toUInt();
|
||||||
serverAddress = settings->value(_("LastServerAddress")).toString();
|
serverAddress = settings->value(_("LastServerAddress")).toString();
|
||||||
localExecutable = settings->value(_("LastExternalExecutable")).toString();
|
runnable.executable = settings->value(_("LastExternalExecutable")).toString();
|
||||||
processArgs = settings->value(_("LastExternalExecutableArguments")).toString();
|
runnable.commandLineArguments = settings->value(_("LastExternalExecutableArguments")).toString();
|
||||||
workingDirectory = settings->value(_("LastExternalWorkingDirectory")).toString();
|
runnable.workingDirectory = settings->value(_("LastExternalWorkingDirectory")).toString();
|
||||||
breakAtMain = settings->value(_("LastExternalBreakAtMain")).toBool();
|
breakAtMain = settings->value(_("LastExternalBreakAtMain")).toBool();
|
||||||
runInTerminal = settings->value(_("LastExternalRunInTerminal")).toBool();
|
runnable.runMode = settings->value(_("LastExternalRunInTerminal")).toBool()
|
||||||
|
? ApplicationLauncher::Console : ApplicationLauncher::Gui;
|
||||||
serverStartScript = settings->value(_("LastServerStartScript")).toString();
|
serverStartScript = settings->value(_("LastServerStartScript")).toString();
|
||||||
debugInfoLocation = settings->value(_("LastDebugInfoLocation")).toString();
|
debugInfoLocation = settings->value(_("LastDebugInfoLocation")).toString();
|
||||||
}
|
}
|
||||||
@@ -331,7 +325,7 @@ void StartApplicationDialog::setHistory(const QList<StartApplicationParameters>
|
|||||||
d->historyComboBox->clear();
|
d->historyComboBox->clear();
|
||||||
for (int i = l.size(); --i >= 0; ) {
|
for (int i = l.size(); --i >= 0; ) {
|
||||||
const StartApplicationParameters &p = l.at(i);
|
const StartApplicationParameters &p = l.at(i);
|
||||||
if (!p.localExecutable.isEmpty())
|
if (!p.runnable.executable.isEmpty())
|
||||||
d->historyComboBox->addItem(p.displayName(), QVariant::fromValue(p));
|
d->historyComboBox->addItem(p.displayName(), QVariant::fromValue(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,7 +396,7 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp, Kit
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
rp->executable = newParameters.localExecutable;
|
rp->executable = newParameters.runnable.executable;
|
||||||
const QString inputAddress = dialog.d->serverAddressEdit->text();
|
const QString inputAddress = dialog.d->serverAddressEdit->text();
|
||||||
if (!inputAddress.isEmpty())
|
if (!inputAddress.isEmpty())
|
||||||
rp->remoteChannel = inputAddress;
|
rp->remoteChannel = inputAddress;
|
||||||
@@ -410,10 +404,10 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp, Kit
|
|||||||
rp->remoteChannel = rp->connParams.host;
|
rp->remoteChannel = rp->connParams.host;
|
||||||
rp->remoteChannel += QLatin1Char(':') + QString::number(newParameters.serverPort);
|
rp->remoteChannel += QLatin1Char(':') + QString::number(newParameters.serverPort);
|
||||||
rp->displayName = newParameters.displayName();
|
rp->displayName = newParameters.displayName();
|
||||||
rp->workingDirectory = newParameters.workingDirectory;
|
rp->workingDirectory = newParameters.runnable.workingDirectory;
|
||||||
rp->useTerminal = newParameters.runInTerminal;
|
rp->useTerminal = newParameters.runnable.runMode == ApplicationLauncher::Console;
|
||||||
if (!newParameters.processArgs.isEmpty())
|
if (!newParameters.runnable.commandLineArguments.isEmpty())
|
||||||
rp->processArgs = newParameters.processArgs;
|
rp->processArgs = newParameters.runnable.commandLineArguments;
|
||||||
rp->breakOnMain = newParameters.breakAtMain;
|
rp->breakOnMain = newParameters.breakAtMain;
|
||||||
rp->serverStartScript = newParameters.serverStartScript;
|
rp->serverStartScript = newParameters.serverStartScript;
|
||||||
rp->debugInfoLocation = newParameters.debugInfoLocation;
|
rp->debugInfoLocation = newParameters.debugInfoLocation;
|
||||||
@@ -433,14 +427,15 @@ StartApplicationParameters StartApplicationDialog::parameters() const
|
|||||||
StartApplicationParameters result;
|
StartApplicationParameters result;
|
||||||
result.serverPort = d->serverPortSpinBox->value();
|
result.serverPort = d->serverPortSpinBox->value();
|
||||||
result.serverAddress = d->serverAddressEdit->text();
|
result.serverAddress = d->serverAddressEdit->text();
|
||||||
result.localExecutable = d->localExecutablePathChooser->path();
|
result.runnable.executable = d->localExecutablePathChooser->path();
|
||||||
result.serverStartScript = d->serverStartScriptPathChooser->path();
|
result.serverStartScript = d->serverStartScriptPathChooser->path();
|
||||||
result.kitId = d->kitChooser->currentKitId();
|
result.kitId = d->kitChooser->currentKitId();
|
||||||
result.debugInfoLocation = d->debuginfoPathChooser->path();
|
result.debugInfoLocation = d->debuginfoPathChooser->path();
|
||||||
result.processArgs = d->arguments->text();
|
result.runnable.commandLineArguments = d->arguments->text();
|
||||||
result.workingDirectory = d->workingDirectory->path();
|
result.runnable.workingDirectory = d->workingDirectory->path();
|
||||||
result.breakAtMain = d->breakAtMainCheckBox->isChecked();
|
result.breakAtMain = d->breakAtMainCheckBox->isChecked();
|
||||||
result.runInTerminal = d->runInTerminalCheckBox->isChecked();
|
result.runnable.runMode = d->runInTerminalCheckBox->isChecked()
|
||||||
|
? ApplicationLauncher::Console : ApplicationLauncher::Gui;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,12 +444,12 @@ void StartApplicationDialog::setParameters(const StartApplicationParameters &p)
|
|||||||
d->kitChooser->setCurrentKitId(p.kitId);
|
d->kitChooser->setCurrentKitId(p.kitId);
|
||||||
d->serverPortSpinBox->setValue(p.serverPort);
|
d->serverPortSpinBox->setValue(p.serverPort);
|
||||||
d->serverAddressEdit->setText(p.serverAddress);
|
d->serverAddressEdit->setText(p.serverAddress);
|
||||||
d->localExecutablePathChooser->setPath(p.localExecutable);
|
d->localExecutablePathChooser->setPath(p.runnable.executable);
|
||||||
d->serverStartScriptPathChooser->setPath(p.serverStartScript);
|
d->serverStartScriptPathChooser->setPath(p.serverStartScript);
|
||||||
d->debuginfoPathChooser->setPath(p.debugInfoLocation);
|
d->debuginfoPathChooser->setPath(p.debugInfoLocation);
|
||||||
d->arguments->setText(p.processArgs);
|
d->arguments->setText(p.runnable.commandLineArguments);
|
||||||
d->workingDirectory->setPath(p.workingDirectory);
|
d->workingDirectory->setPath(p.runnable.workingDirectory);
|
||||||
d->runInTerminalCheckBox->setChecked(p.runInTerminal);
|
d->runInTerminalCheckBox->setChecked(p.runnable.runMode == ApplicationLauncher::Console);
|
||||||
d->breakAtMainCheckBox->setChecked(p.breakAtMain);
|
d->breakAtMainCheckBox->setChecked(p.breakAtMain);
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user