Commit cb501d48 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

ProjectExplorer: Use FileName in WorkingDirectoryAspect

+ use native separators for user visible strings

Change-Id: Id6e4e27db369314f70e355a395cfddca12b8ea90
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 44539772
......@@ -322,7 +322,12 @@ QString PathChooser::path() const
QString PathChooser::rawPath() const
{
return FileName::fromUserInput(QDir::fromNativeSeparators(d->m_lineEdit->text())).toString();
return rawFileName().toString();
}
FileName PathChooser::rawFileName() const
{
return FileName::fromUserInput(d->m_lineEdit->text());
}
FileName PathChooser::fileName() const
......
......@@ -98,6 +98,7 @@ public:
QString path() const;
QString rawPath() const; // The raw unexpanded input.
FileName rawFileName() const; // The raw unexpanded input.
FileName fileName() const;
QString baseDirectory() const;
......
......@@ -162,10 +162,10 @@ void WorkingDirectoryAspect::addToMainConfigurationWidget(QWidget *parent, QForm
m_chooser->setHistoryCompleter(m_key);
m_chooser->setExpectedKind(Utils::PathChooser::Directory);
m_chooser->setPromptDialogTitle(tr("Select Working Directory"));
m_chooser->lineEdit()->setPlaceholderText(m_defaultWorkingDirectory);
m_chooser->setPath(m_workingDirectory);
m_chooser->lineEdit()->setPlaceholderText(m_defaultWorkingDirectory.toUserOutput());
m_chooser->setFileName(m_workingDirectory);
connect(m_chooser.data(), &PathChooser::pathChanged, this,
[this]() { m_workingDirectory = m_chooser->rawPath(); });
[this]() { m_workingDirectory = m_chooser->rawFileName(); });
auto resetButton = new QToolButton(parent);
resetButton->setToolTip(tr("Reset to Default"));
......@@ -197,39 +197,40 @@ void WorkingDirectoryAspect::resetPath()
void WorkingDirectoryAspect::fromMap(const QVariantMap &map)
{
m_workingDirectory = map.value(m_key).toString();
m_defaultWorkingDirectory = map.value(keyForDefaultWd()).toString();
m_workingDirectory = FileName::fromString(map.value(m_key).toString());
m_defaultWorkingDirectory = FileName::fromString(map.value(keyForDefaultWd()).toString());
}
void WorkingDirectoryAspect::toMap(QVariantMap &data) const
{
data.insert(m_key, m_workingDirectory);
data.insert(keyForDefaultWd(), m_defaultWorkingDirectory);
data.insert(m_key, m_workingDirectory.toString());
data.insert(keyForDefaultWd(), m_defaultWorkingDirectory.toString());
}
QString WorkingDirectoryAspect::workingDirectory() const
FileName WorkingDirectoryAspect::workingDirectory() const
{
QTC_ASSERT(m_chooser, return m_defaultWorkingDirectory);
return m_workingDirectory.isEmpty()
? m_defaultWorkingDirectory
: runConfiguration()->macroExpander()->expandProcessArgs(m_chooser->path());
if (m_workingDirectory.isEmpty())
return m_defaultWorkingDirectory;
return FileName::fromString(
runConfiguration()->macroExpander()->expandProcessArgs(m_chooser->path()));
}
QString WorkingDirectoryAspect::defaultWorkingDirectory() const
FileName WorkingDirectoryAspect::defaultWorkingDirectory() const
{
return m_defaultWorkingDirectory;
}
QString WorkingDirectoryAspect::unexpandedWorkingDirectory() const
FileName WorkingDirectoryAspect::unexpandedWorkingDirectory() const
{
return m_workingDirectory;
}
void WorkingDirectoryAspect::setDefaultWorkingDirectory(const QString &defaultWorkingDir)
void WorkingDirectoryAspect::setDefaultWorkingDirectory(const FileName &defaultWorkingDir)
{
m_defaultWorkingDirectory = defaultWorkingDir;
if (m_chooser)
m_chooser->lineEdit()->setPlaceholderText(m_defaultWorkingDirectory);
m_chooser->lineEdit()->setPlaceholderText(m_defaultWorkingDirectory.toUserOutput());
}
PathChooser *WorkingDirectoryAspect::pathChooser() const
......
......@@ -34,6 +34,8 @@
#include "runconfiguration.h"
#include "applicationlauncher.h"
#include <utils/fileutils.h>
QT_BEGIN_NAMESPACE
class QCheckBox;
class QFormLayout;
......@@ -92,10 +94,10 @@ public:
void addToMainConfigurationWidget(QWidget *parent, QFormLayout *layout);
QString workingDirectory() const;
QString defaultWorkingDirectory() const;
QString unexpandedWorkingDirectory() const;
void setDefaultWorkingDirectory(const QString &defaultWorkingDir);
Utils::FileName workingDirectory() const;
Utils::FileName defaultWorkingDirectory() const;
Utils::FileName unexpandedWorkingDirectory() const;
void setDefaultWorkingDirectory(const Utils::FileName &defaultWorkingDir);
Utils::PathChooser *pathChooser() const;
private:
......@@ -105,8 +107,8 @@ private:
void resetPath();
QString keyForDefaultWd() const;
QString m_workingDirectory;
QString m_defaultWorkingDirectory;
Utils::FileName m_workingDirectory;
Utils::FileName m_defaultWorkingDirectory;
QPointer<Utils::PathChooser> m_chooser;
QString m_key;
};
......
......@@ -248,7 +248,7 @@ QString QbsRunConfiguration::workingDirectory() const
{
const auto *wdAspect = extraAspect<WorkingDirectoryAspect>();
QTC_ASSERT(wdAspect, return baseWorkingDirectory());
return wdAspect->workingDirectory();
return wdAspect->workingDirectory().toString();
}
QString QbsRunConfiguration::baseWorkingDirectory() const
......@@ -393,7 +393,7 @@ void QbsRunConfigurationWidget::targetInformationHasChanged()
setExecutableLineText(m_rc->executable());
WorkingDirectoryAspect *aspect = m_rc->extraAspect<WorkingDirectoryAspect>();
aspect->setDefaultWorkingDirectory(m_rc->baseWorkingDirectory());
aspect->setDefaultWorkingDirectory(Utils::FileName::fromString(m_rc->baseWorkingDirectory()));
aspect->pathChooser()->setBaseFileName(m_rc->target()->project()->projectDirectory());
m_ignoreChange = false;
}
......
......@@ -316,7 +316,7 @@ void DesktopQmakeRunConfigurationWidget::effectiveTargetInformationChanged()
m_ignoreChange = true;
auto aspect = m_qmakeRunConfiguration->extraAspect<WorkingDirectoryAspect>();
aspect->setDefaultWorkingDirectory(m_qmakeRunConfiguration->baseWorkingDirectory());
aspect->setDefaultWorkingDirectory(FileName::fromString(m_qmakeRunConfiguration->baseWorkingDirectory()));
aspect->pathChooser()->setBaseFileName(m_qmakeRunConfiguration->target()->project()->projectDirectory());
m_ignoreChange = false;
}
......@@ -393,7 +393,7 @@ void DesktopQmakeRunConfiguration::setUsingLibrarySearchPath(bool state)
QString DesktopQmakeRunConfiguration::workingDirectory() const
{
return extraAspect<WorkingDirectoryAspect>()->workingDirectory();
return extraAspect<WorkingDirectoryAspect>()->workingDirectory().toString();
}
QString DesktopQmakeRunConfiguration::baseWorkingDirectory() const
......
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