Skip to content
Snippets Groups Projects
Commit 80457082 authored by dt's avatar dt
Browse files

Add a name filed to the custom executable runconfiguration widget

Reported on irc, and probably also have a task for that. Simply
forgotten when i first implemented it.
parent 78fde8db
No related branches found
No related tags found
No related merge requests found
......@@ -51,23 +51,29 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
QFormLayout *layout = new QFormLayout();
layout->setMargin(0);
m_executableChooser = new Core::Utils::PathChooser();
m_userName = new QLineEdit(this);
layout->addRow("Name:", m_userName);
m_executableChooser = new Core::Utils::PathChooser(this);
m_executableChooser->setExpectedKind(Core::Utils::PathChooser::File);
layout->addRow("Executable:", m_executableChooser);
m_commandLineArgumentsLineEdit = new QLineEdit;
m_commandLineArgumentsLineEdit = new QLineEdit(this);
m_commandLineArgumentsLineEdit->setMinimumWidth(200); // this shouldn't be fixed here...
layout->addRow("Arguments:", m_commandLineArgumentsLineEdit);
m_workingDirectory = new Core::Utils::PathChooser();
m_workingDirectory = new Core::Utils::PathChooser(this);
layout->addRow("Working Directory:", m_workingDirectory);
m_useTerminalCheck = new QCheckBox(tr("Run in &Terminal"));
m_useTerminalCheck = new QCheckBox(tr("Run in &Terminal"), this);
layout->addRow(QString(), m_useTerminalCheck);
setLayout(layout);
changed();
connect(m_userName, SIGNAL(textEdited(QString)),
this, SLOT(setUserName(QString)));
connect(m_executableChooser, SIGNAL(changed()),
this, SLOT(setExecutable()));
connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(const QString&)),
......@@ -99,6 +105,13 @@ void CustomExecutableConfigurationWidget::setWorkingDirectory()
m_ignoreChange = false;
}
void CustomExecutableConfigurationWidget::setUserName(const QString &name)
{
m_ignoreChange = true;
m_runConfiguration->setUserName(name);
m_ignoreChange = false;
}
void CustomExecutableConfigurationWidget::termToggled(bool on)
{
m_ignoreChange = true;
......@@ -116,10 +129,12 @@ void CustomExecutableConfigurationWidget::changed()
m_commandLineArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(m_runConfiguration->commandLineArguments()));
m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory());
m_useTerminalCheck->setChecked(m_runConfiguration->runMode() == ApplicationRunConfiguration::Console);
m_userName->setText(m_runConfiguration->userName());
}
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro)
: ApplicationRunConfiguration(pro)
: ApplicationRunConfiguration(pro),
m_userSetName(false)
{
m_workingDirectory = "$BUILDDIR";
setName("Custom Executable");
......@@ -139,6 +154,11 @@ QString CustomExecutableRunConfiguration::baseExecutable() const
return m_executable;
}
QString CustomExecutableRunConfiguration::userName() const
{
return m_userName;
}
QString CustomExecutableRunConfiguration::executable() const
{
QString exec;
......@@ -213,6 +233,8 @@ void CustomExecutableRunConfiguration::save(PersistentSettingsWriter &writer) co
writer.saveValue("Arguments", m_cmdArguments);
writer.saveValue("WorkingDirectory", m_workingDirectory);
writer.saveValue("UseTerminal", m_runMode == Console);
writer.saveValue("UserSetName", m_userSetName);
writer.saveValue("UserName", m_userName);
ApplicationRunConfiguration::save(writer);
}
......@@ -222,13 +244,16 @@ void CustomExecutableRunConfiguration::restore(const PersistentSettingsReader &r
m_cmdArguments = reader.restoreValue("Arguments").toStringList();
m_workingDirectory = reader.restoreValue("WorkingDirectory").toString();
m_runMode = reader.restoreValue("UseTerminal").toBool() ? Console : Gui;
m_userSetName = reader.restoreValue("UserSetName").toBool();
m_userName = reader.restoreValue("UserName").toString();
ApplicationRunConfiguration::restore(reader);
}
void CustomExecutableRunConfiguration::setExecutable(const QString &executable)
{
m_executable = executable;
setName(tr("Run %1").arg(m_executable));
if (!m_userSetName)
setName(tr("Run %1").arg(m_executable));
emit changed();
}
......@@ -255,6 +280,20 @@ QWidget *CustomExecutableRunConfiguration::configurationWidget()
return new CustomExecutableConfigurationWidget(this);
}
void CustomExecutableRunConfiguration::setUserName(const QString &name)
{
if (name.isEmpty()) {
m_userName = name;
m_userSetName = false;
setName(tr("Run %1").arg(m_executable));
} else {
m_userName = name;
m_userSetName = true;
setName(name);
}
emit changed();
}
// Factory
CustomExecutableRunConfigurationFactory::CustomExecutableRunConfigurationFactory()
......
......@@ -71,6 +71,11 @@ public:
*/
QString baseExecutable() const;
/**
* Returns the name the user has set, if he has set one
*/
QString userName() const;
virtual ApplicationRunConfiguration::RunMode runMode() const;
virtual QString workingDirectory() const;
QString baseWorkingDirectory() const;
......@@ -89,11 +94,14 @@ private:
void setExecutable(const QString &executable);
void setCommandLineArguments(const QString &commandLineArguments);
void setWorkingDirectory(const QString &workingDirectory);
void setUserName(const QString &name);
void setRunMode(RunMode runMode);
QString m_executable;
QString m_workingDirectory;
QStringList m_cmdArguments;
RunMode m_runMode;
bool m_userSetName;
QString m_userName;
};
class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory
......@@ -124,6 +132,7 @@ private slots:
void setExecutable();
void setCommandLineArguments(const QString &commandLineArguments);
void setUserName(const QString &name);
void setWorkingDirectory();
void termToggled(bool);
......@@ -131,6 +140,7 @@ private:
bool m_ignoreChange;
CustomExecutableRunConfiguration *m_runConfiguration;
Core::Utils::PathChooser *m_executableChooser;
QLineEdit *m_userName;
QLineEdit *m_commandLineArgumentsLineEdit;
Core::Utils::PathChooser *m_workingDirectory;
QCheckBox *m_useTerminalCheck;
......
......@@ -174,8 +174,6 @@ void ProFileReader::errorMessage(const QString &message)
ProFile *ProFileReader::proFileFor(const QString &name)
{
qDebug()<<"Asking for "<<name;
qDebug()<<"in "<<m_includeFiles.keys();
QMap<QString, ProFile *>::const_iterator it = m_includeFiles.constFind(name);
if (it == m_includeFiles.constEnd())
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment