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 ...@@ -51,23 +51,29 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
QFormLayout *layout = new QFormLayout(); QFormLayout *layout = new QFormLayout();
layout->setMargin(0); 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); m_executableChooser->setExpectedKind(Core::Utils::PathChooser::File);
layout->addRow("Executable:", m_executableChooser); layout->addRow("Executable:", m_executableChooser);
m_commandLineArgumentsLineEdit = new QLineEdit; m_commandLineArgumentsLineEdit = new QLineEdit(this);
m_commandLineArgumentsLineEdit->setMinimumWidth(200); // this shouldn't be fixed here... m_commandLineArgumentsLineEdit->setMinimumWidth(200); // this shouldn't be fixed here...
layout->addRow("Arguments:", m_commandLineArgumentsLineEdit); layout->addRow("Arguments:", m_commandLineArgumentsLineEdit);
m_workingDirectory = new Core::Utils::PathChooser(); m_workingDirectory = new Core::Utils::PathChooser(this);
layout->addRow("Working Directory:", m_workingDirectory); 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); layout->addRow(QString(), m_useTerminalCheck);
setLayout(layout); setLayout(layout);
changed(); changed();
connect(m_userName, SIGNAL(textEdited(QString)),
this, SLOT(setUserName(QString)));
connect(m_executableChooser, SIGNAL(changed()), connect(m_executableChooser, SIGNAL(changed()),
this, SLOT(setExecutable())); this, SLOT(setExecutable()));
connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(const QString&)), connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(const QString&)),
...@@ -99,6 +105,13 @@ void CustomExecutableConfigurationWidget::setWorkingDirectory() ...@@ -99,6 +105,13 @@ void CustomExecutableConfigurationWidget::setWorkingDirectory()
m_ignoreChange = false; m_ignoreChange = false;
} }
void CustomExecutableConfigurationWidget::setUserName(const QString &name)
{
m_ignoreChange = true;
m_runConfiguration->setUserName(name);
m_ignoreChange = false;
}
void CustomExecutableConfigurationWidget::termToggled(bool on) void CustomExecutableConfigurationWidget::termToggled(bool on)
{ {
m_ignoreChange = true; m_ignoreChange = true;
...@@ -116,10 +129,12 @@ void CustomExecutableConfigurationWidget::changed() ...@@ -116,10 +129,12 @@ void CustomExecutableConfigurationWidget::changed()
m_commandLineArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(m_runConfiguration->commandLineArguments())); m_commandLineArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(m_runConfiguration->commandLineArguments()));
m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory()); m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory());
m_useTerminalCheck->setChecked(m_runConfiguration->runMode() == ApplicationRunConfiguration::Console); m_useTerminalCheck->setChecked(m_runConfiguration->runMode() == ApplicationRunConfiguration::Console);
m_userName->setText(m_runConfiguration->userName());
} }
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro) CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro)
: ApplicationRunConfiguration(pro) : ApplicationRunConfiguration(pro),
m_userSetName(false)
{ {
m_workingDirectory = "$BUILDDIR"; m_workingDirectory = "$BUILDDIR";
setName("Custom Executable"); setName("Custom Executable");
...@@ -139,6 +154,11 @@ QString CustomExecutableRunConfiguration::baseExecutable() const ...@@ -139,6 +154,11 @@ QString CustomExecutableRunConfiguration::baseExecutable() const
return m_executable; return m_executable;
} }
QString CustomExecutableRunConfiguration::userName() const
{
return m_userName;
}
QString CustomExecutableRunConfiguration::executable() const QString CustomExecutableRunConfiguration::executable() const
{ {
QString exec; QString exec;
...@@ -213,6 +233,8 @@ void CustomExecutableRunConfiguration::save(PersistentSettingsWriter &writer) co ...@@ -213,6 +233,8 @@ void CustomExecutableRunConfiguration::save(PersistentSettingsWriter &writer) co
writer.saveValue("Arguments", m_cmdArguments); writer.saveValue("Arguments", m_cmdArguments);
writer.saveValue("WorkingDirectory", m_workingDirectory); writer.saveValue("WorkingDirectory", m_workingDirectory);
writer.saveValue("UseTerminal", m_runMode == Console); writer.saveValue("UseTerminal", m_runMode == Console);
writer.saveValue("UserSetName", m_userSetName);
writer.saveValue("UserName", m_userName);
ApplicationRunConfiguration::save(writer); ApplicationRunConfiguration::save(writer);
} }
...@@ -222,13 +244,16 @@ void CustomExecutableRunConfiguration::restore(const PersistentSettingsReader &r ...@@ -222,13 +244,16 @@ void CustomExecutableRunConfiguration::restore(const PersistentSettingsReader &r
m_cmdArguments = reader.restoreValue("Arguments").toStringList(); m_cmdArguments = reader.restoreValue("Arguments").toStringList();
m_workingDirectory = reader.restoreValue("WorkingDirectory").toString(); m_workingDirectory = reader.restoreValue("WorkingDirectory").toString();
m_runMode = reader.restoreValue("UseTerminal").toBool() ? Console : Gui; m_runMode = reader.restoreValue("UseTerminal").toBool() ? Console : Gui;
m_userSetName = reader.restoreValue("UserSetName").toBool();
m_userName = reader.restoreValue("UserName").toString();
ApplicationRunConfiguration::restore(reader); ApplicationRunConfiguration::restore(reader);
} }
void CustomExecutableRunConfiguration::setExecutable(const QString &executable) void CustomExecutableRunConfiguration::setExecutable(const QString &executable)
{ {
m_executable = executable; m_executable = executable;
setName(tr("Run %1").arg(m_executable)); if (!m_userSetName)
setName(tr("Run %1").arg(m_executable));
emit changed(); emit changed();
} }
...@@ -255,6 +280,20 @@ QWidget *CustomExecutableRunConfiguration::configurationWidget() ...@@ -255,6 +280,20 @@ QWidget *CustomExecutableRunConfiguration::configurationWidget()
return new CustomExecutableConfigurationWidget(this); 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 // Factory
CustomExecutableRunConfigurationFactory::CustomExecutableRunConfigurationFactory() CustomExecutableRunConfigurationFactory::CustomExecutableRunConfigurationFactory()
......
...@@ -71,6 +71,11 @@ public: ...@@ -71,6 +71,11 @@ public:
*/ */
QString baseExecutable() const; QString baseExecutable() const;
/**
* Returns the name the user has set, if he has set one
*/
QString userName() const;
virtual ApplicationRunConfiguration::RunMode runMode() const; virtual ApplicationRunConfiguration::RunMode runMode() const;
virtual QString workingDirectory() const; virtual QString workingDirectory() const;
QString baseWorkingDirectory() const; QString baseWorkingDirectory() const;
...@@ -89,11 +94,14 @@ private: ...@@ -89,11 +94,14 @@ private:
void setExecutable(const QString &executable); void setExecutable(const QString &executable);
void setCommandLineArguments(const QString &commandLineArguments); void setCommandLineArguments(const QString &commandLineArguments);
void setWorkingDirectory(const QString &workingDirectory); void setWorkingDirectory(const QString &workingDirectory);
void setUserName(const QString &name);
void setRunMode(RunMode runMode); void setRunMode(RunMode runMode);
QString m_executable; QString m_executable;
QString m_workingDirectory; QString m_workingDirectory;
QStringList m_cmdArguments; QStringList m_cmdArguments;
RunMode m_runMode; RunMode m_runMode;
bool m_userSetName;
QString m_userName;
}; };
class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory
...@@ -124,6 +132,7 @@ private slots: ...@@ -124,6 +132,7 @@ private slots:
void setExecutable(); void setExecutable();
void setCommandLineArguments(const QString &commandLineArguments); void setCommandLineArguments(const QString &commandLineArguments);
void setUserName(const QString &name);
void setWorkingDirectory(); void setWorkingDirectory();
void termToggled(bool); void termToggled(bool);
...@@ -131,6 +140,7 @@ private: ...@@ -131,6 +140,7 @@ private:
bool m_ignoreChange; bool m_ignoreChange;
CustomExecutableRunConfiguration *m_runConfiguration; CustomExecutableRunConfiguration *m_runConfiguration;
Core::Utils::PathChooser *m_executableChooser; Core::Utils::PathChooser *m_executableChooser;
QLineEdit *m_userName;
QLineEdit *m_commandLineArgumentsLineEdit; QLineEdit *m_commandLineArgumentsLineEdit;
Core::Utils::PathChooser *m_workingDirectory; Core::Utils::PathChooser *m_workingDirectory;
QCheckBox *m_useTerminalCheck; QCheckBox *m_useTerminalCheck;
......
...@@ -174,8 +174,6 @@ void ProFileReader::errorMessage(const QString &message) ...@@ -174,8 +174,6 @@ void ProFileReader::errorMessage(const QString &message)
ProFile *ProFileReader::proFileFor(const QString &name) 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); QMap<QString, ProFile *>::const_iterator it = m_includeFiles.constFind(name);
if (it == m_includeFiles.constEnd()) if (it == m_includeFiles.constEnd())
return 0; 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