forked from qt-creator/qt-creator
ProjectExplorer: Use FilePathAspect(s) in ExecutableAspect
In the read-only case, make it look like the previously used StringAspect with LabelDisplay. Change-Id: Ica76c1ba23bf9b3946c227e303cc1336f3f8d5b4 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -329,6 +329,8 @@ void BaseAspect::setReadOnly(bool readOnly)
|
|||||||
lineEdit->setReadOnly(readOnly);
|
lineEdit->setReadOnly(readOnly);
|
||||||
else if (auto textEdit = qobject_cast<QTextEdit *>(w))
|
else if (auto textEdit = qobject_cast<QTextEdit *>(w))
|
||||||
textEdit->setReadOnly(readOnly);
|
textEdit->setReadOnly(readOnly);
|
||||||
|
else if (auto pathChooser = qobject_cast<PathChooser *>(w))
|
||||||
|
pathChooser->setReadOnly(readOnly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,28 +808,6 @@ QString StringAspect::value() const
|
|||||||
return TypedAspect::value();
|
return TypedAspect::value();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Sets the value, \a val, of this StringAspect from an ordinary \c QString.
|
|
||||||
*/
|
|
||||||
void StringAspect::setValue(const QString &val)
|
|
||||||
{
|
|
||||||
const bool isSame = val == value();
|
|
||||||
if (isSame)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QString processedValue = val;
|
|
||||||
if (d->m_valueAcceptor) {
|
|
||||||
const std::optional<QString> tmp = d->m_valueAcceptor(value(), val);
|
|
||||||
if (!tmp) {
|
|
||||||
internalToGui(); // Make sure the original value is retained in the UI
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
processedValue = tmp.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
TypedAspect::setValue(processedValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\reimp
|
\reimp
|
||||||
*/
|
*/
|
||||||
@@ -1124,6 +1104,7 @@ void StringAspect::addToLayout(LayoutItem &parent)
|
|||||||
d->m_pathChooserDisplay->setPromptDialogTitle(d->m_prompDialogTitle);
|
d->m_pathChooserDisplay->setPromptDialogTitle(d->m_prompDialogTitle);
|
||||||
d->m_pathChooserDisplay->setCommandVersionArguments(d->m_commandVersionArguments);
|
d->m_pathChooserDisplay->setCommandVersionArguments(d->m_commandVersionArguments);
|
||||||
d->m_pathChooserDisplay->setAllowPathFromDevice(d->m_allowPathFromDevice);
|
d->m_pathChooserDisplay->setAllowPathFromDevice(d->m_allowPathFromDevice);
|
||||||
|
d->m_pathChooserDisplay->setReadOnly(isReadOnly());
|
||||||
d->m_pathChooserDisplay->lineEdit()->setValidatePlaceHolder(d->m_validatePlaceHolder);
|
d->m_pathChooserDisplay->lineEdit()->setValidatePlaceHolder(d->m_validatePlaceHolder);
|
||||||
if (defaultValue() == value())
|
if (defaultValue() == value())
|
||||||
d->m_pathChooserDisplay->setDefaultValue(defaultValue());
|
d->m_pathChooserDisplay->setDefaultValue(defaultValue());
|
||||||
@@ -1141,7 +1122,7 @@ void StringAspect::addToLayout(LayoutItem &parent)
|
|||||||
if (d->m_blockAutoApply)
|
if (d->m_blockAutoApply)
|
||||||
return;
|
return;
|
||||||
d->m_blockAutoApply = true;
|
d->m_blockAutoApply = true;
|
||||||
setValueQuietly(d->m_pathChooserDisplay->filePath().toString());
|
setValue(d->m_pathChooserDisplay->filePath().toString());
|
||||||
d->m_blockAutoApply = false;
|
d->m_blockAutoApply = false;
|
||||||
};
|
};
|
||||||
connect(d->m_pathChooserDisplay, &PathChooser::editingFinished, this, setPathChooserValue);
|
connect(d->m_pathChooserDisplay, &PathChooser::editingFinished, this, setPathChooserValue);
|
||||||
@@ -1149,7 +1130,7 @@ void StringAspect::addToLayout(LayoutItem &parent)
|
|||||||
} else {
|
} else {
|
||||||
connect(d->m_pathChooserDisplay, &PathChooser::textChanged,
|
connect(d->m_pathChooserDisplay, &PathChooser::textChanged,
|
||||||
this, [this](const QString &path) {
|
this, [this](const QString &path) {
|
||||||
setValueQuietly(path);
|
setValue(path);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1234,21 +1215,30 @@ void StringAspect::addToLayout(LayoutItem &parent)
|
|||||||
|
|
||||||
void StringAspect::guiToInternal()
|
void StringAspect::guiToInternal()
|
||||||
{
|
{
|
||||||
|
QString val;
|
||||||
switch (d->m_displayStyle) {
|
switch (d->m_displayStyle) {
|
||||||
case PathChooserDisplay:
|
case PathChooserDisplay:
|
||||||
if (d->m_pathChooserDisplay)
|
if (d->m_pathChooserDisplay)
|
||||||
m_internal = d->m_pathChooserDisplay->lineEdit()->text();
|
val = d->m_pathChooserDisplay->lineEdit()->text();
|
||||||
break;
|
break;
|
||||||
case LineEditDisplay:
|
case LineEditDisplay:
|
||||||
if (d->m_lineEditDisplay)
|
if (d->m_lineEditDisplay)
|
||||||
m_internal = d->m_lineEditDisplay->text();
|
val = d->m_lineEditDisplay->text();
|
||||||
break;
|
break;
|
||||||
case TextEditDisplay:
|
case TextEditDisplay:
|
||||||
if (d->m_textEditDisplay)
|
if (d->m_textEditDisplay)
|
||||||
m_internal = d->m_textEditDisplay->document()->toPlainText();
|
val = d->m_textEditDisplay->document()->toPlainText();
|
||||||
case LabelDisplay:
|
case LabelDisplay:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (d->m_valueAcceptor) {
|
||||||
|
const std::optional<QString> tmp = d->m_valueAcceptor(m_internal, val);
|
||||||
|
if (tmp)
|
||||||
|
m_internal = *tmp;
|
||||||
|
} else {
|
||||||
|
m_internal = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringAspect::internalToGui()
|
void StringAspect::internalToGui()
|
||||||
|
@@ -456,7 +456,6 @@ public:
|
|||||||
void setValueAcceptor(ValueAcceptor &&acceptor);
|
void setValueAcceptor(ValueAcceptor &&acceptor);
|
||||||
|
|
||||||
QString value() const;
|
QString value() const;
|
||||||
void setValue(const QString &val);
|
|
||||||
|
|
||||||
void setShowToolTipOnLabel(bool show);
|
void setShowToolTipOnLabel(bool show);
|
||||||
|
|
||||||
|
@@ -377,9 +377,10 @@ bool PathChooser::isReadOnly() const
|
|||||||
void PathChooser::setReadOnly(bool b)
|
void PathChooser::setReadOnly(bool b)
|
||||||
{
|
{
|
||||||
d->m_lineEdit->setReadOnly(b);
|
d->m_lineEdit->setReadOnly(b);
|
||||||
|
d->m_lineEdit->setFrame(!b);
|
||||||
const auto buttons = d->m_buttons;
|
const auto buttons = d->m_buttons;
|
||||||
for (QAbstractButton *button : buttons)
|
for (QAbstractButton *button : buttons)
|
||||||
button->setEnabled(!b);
|
button->setVisible(!b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathChooser::slotBrowse(bool remote)
|
void PathChooser::slotBrowse(bool remote)
|
||||||
|
@@ -26,7 +26,6 @@ public:
|
|||||||
: RunConfiguration(target, id)
|
: RunConfiguration(target, id)
|
||||||
{
|
{
|
||||||
const auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
|
const auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
|
||||||
exeAspect->setDisplayStyle(StringAspect::LabelDisplay);
|
|
||||||
exeAspect->setPlaceHolderText(Tr::tr("Unknown"));
|
exeAspect->setPlaceHolderText(Tr::tr("Unknown"));
|
||||||
|
|
||||||
addAspect<ArgumentsAspect>(macroExpander());
|
addAspect<ArgumentsAspect>(macroExpander());
|
||||||
@@ -50,7 +49,7 @@ public:
|
|||||||
const auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
|
const auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
|
||||||
exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable");
|
exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable");
|
||||||
exeAspect->setPlaceHolderText(Tr::tr("Unknown"));
|
exeAspect->setPlaceHolderText(Tr::tr("Unknown"));
|
||||||
exeAspect->setDisplayStyle(StringAspect::PathChooserDisplay);
|
exeAspect->setReadOnly(false);
|
||||||
exeAspect->setHistoryCompleter("BareMetal.CustomRunConfig.History");
|
exeAspect->setHistoryCompleter("BareMetal.CustomRunConfig.History");
|
||||||
exeAspect->setExpectedKind(PathChooser::Any);
|
exeAspect->setExpectedKind(PathChooser::Any);
|
||||||
|
|
||||||
|
@@ -59,7 +59,6 @@ IosRunConfiguration::IosRunConfiguration(Target *target, Id id)
|
|||||||
: RunConfiguration(target, id)
|
: RunConfiguration(target, id)
|
||||||
{
|
{
|
||||||
auto executableAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
|
auto executableAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
|
||||||
executableAspect->setDisplayStyle(StringAspect::LabelDisplay);
|
|
||||||
|
|
||||||
addAspect<ArgumentsAspect>(macroExpander());
|
addAspect<ArgumentsAspect>(macroExpander());
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe
|
|||||||
|
|
||||||
auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::HostDevice);
|
auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::HostDevice);
|
||||||
exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable");
|
exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable");
|
||||||
exeAspect->setDisplayStyle(StringAspect::PathChooserDisplay);
|
exeAspect->setReadOnly(false);
|
||||||
exeAspect->setHistoryCompleter("Qt.CustomExecutable.History");
|
exeAspect->setHistoryCompleter("Qt.CustomExecutable.History");
|
||||||
exeAspect->setExpectedKind(PathChooser::ExistingCommand);
|
exeAspect->setExpectedKind(PathChooser::ExistingCommand);
|
||||||
exeAspect->setEnvironment(envAspect->environment());
|
exeAspect->setEnvironment(envAspect->environment());
|
||||||
|
@@ -500,11 +500,11 @@ ExecutableAspect::ExecutableAspect(Target *target, ExecutionDeviceSelector selec
|
|||||||
{
|
{
|
||||||
setDisplayName(Tr::tr("Executable"));
|
setDisplayName(Tr::tr("Executable"));
|
||||||
setId("ExecutableAspect");
|
setId("ExecutableAspect");
|
||||||
|
setReadOnly(true);
|
||||||
addDataExtractor(this, &ExecutableAspect::executable, &Data::executable);
|
addDataExtractor(this, &ExecutableAspect::executable, &Data::executable);
|
||||||
|
|
||||||
m_executable.setPlaceHolderText(Tr::tr("Enter the path to the executable"));
|
m_executable.setPlaceHolderText(Tr::tr("Enter the path to the executable"));
|
||||||
m_executable.setLabelText(Tr::tr("Executable:"));
|
m_executable.setLabelText(Tr::tr("Executable:"));
|
||||||
m_executable.setDisplayStyle(StringAspect::LabelDisplay);
|
|
||||||
|
|
||||||
updateDevice();
|
updateDevice();
|
||||||
|
|
||||||
@@ -579,14 +579,9 @@ void ExecutableAspect::setEnvironment(const Environment &env)
|
|||||||
m_alternativeExecutable->setEnvironment(env);
|
m_alternativeExecutable->setEnvironment(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
void ExecutableAspect::setReadOnly(bool readOnly)
|
||||||
Sets the display \a style for aspect.
|
|
||||||
|
|
||||||
\sa Utils::StringAspect::setDisplayStyle()
|
|
||||||
*/
|
|
||||||
void ExecutableAspect::setDisplayStyle(StringAspect::DisplayStyle style)
|
|
||||||
{
|
{
|
||||||
m_executable.setDisplayStyle(style);
|
m_executable.setReadOnly(readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -601,7 +596,7 @@ void ExecutableAspect::setDisplayStyle(StringAspect::DisplayStyle style)
|
|||||||
void ExecutableAspect::makeOverridable(const QString &overridingKey, const QString &useOverridableKey)
|
void ExecutableAspect::makeOverridable(const QString &overridingKey, const QString &useOverridableKey)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!m_alternativeExecutable, return);
|
QTC_ASSERT(!m_alternativeExecutable, return);
|
||||||
m_alternativeExecutable = new StringAspect;
|
m_alternativeExecutable = new FilePathAspect;
|
||||||
m_alternativeExecutable->setDisplayStyle(StringAspect::LineEditDisplay);
|
m_alternativeExecutable->setDisplayStyle(StringAspect::LineEditDisplay);
|
||||||
m_alternativeExecutable->setLabelText(Tr::tr("Alternate executable on device:"));
|
m_alternativeExecutable->setLabelText(Tr::tr("Alternate executable on device:"));
|
||||||
m_alternativeExecutable->setSettingsKey(overridingKey);
|
m_alternativeExecutable->setSettingsKey(overridingKey);
|
||||||
|
@@ -169,7 +169,7 @@ public:
|
|||||||
void setHistoryCompleter(const QString &historyCompleterKey);
|
void setHistoryCompleter(const QString &historyCompleterKey);
|
||||||
void setExpectedKind(const Utils::PathChooser::Kind expectedKind);
|
void setExpectedKind(const Utils::PathChooser::Kind expectedKind);
|
||||||
void setEnvironment(const Utils::Environment &env);
|
void setEnvironment(const Utils::Environment &env);
|
||||||
void setDisplayStyle(Utils::StringAspect::DisplayStyle style);
|
void setReadOnly(bool readOnly);
|
||||||
|
|
||||||
struct Data : BaseAspect::Data
|
struct Data : BaseAspect::Data
|
||||||
{
|
{
|
||||||
@@ -184,8 +184,8 @@ private:
|
|||||||
QString executableText() const;
|
QString executableText() const;
|
||||||
void updateDevice();
|
void updateDevice();
|
||||||
|
|
||||||
Utils::StringAspect m_executable;
|
Utils::FilePathAspect m_executable;
|
||||||
Utils::StringAspect *m_alternativeExecutable = nullptr;
|
Utils::FilePathAspect *m_alternativeExecutable = nullptr;
|
||||||
Target *m_target = nullptr;
|
Target *m_target = nullptr;
|
||||||
ExecutionDeviceSelector m_selector = RunDevice;
|
ExecutionDeviceSelector m_selector = RunDevice;
|
||||||
};
|
};
|
||||||
|
@@ -65,7 +65,7 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent
|
|||||||
ExecutableAspect::BuildDevice);
|
ExecutableAspect::BuildDevice);
|
||||||
makeAspect->setId(MakeAspectId);
|
makeAspect->setId(MakeAspectId);
|
||||||
makeAspect->setSettingsKey(MakeAspectId);
|
makeAspect->setSettingsKey(MakeAspectId);
|
||||||
makeAspect->setDisplayStyle(StringAspect::PathChooserDisplay);
|
makeAspect->setReadOnly(false);
|
||||||
makeAspect->setLabelText(Tr::tr("Command:"));
|
makeAspect->setLabelText(Tr::tr("Command:"));
|
||||||
connect(makeAspect, &ExecutableAspect::changed,
|
connect(makeAspect, &ExecutableAspect::changed,
|
||||||
this, &MakeInstallStep::updateCommandFromAspect);
|
this, &MakeInstallStep::updateCommandFromAspect);
|
||||||
|
@@ -37,7 +37,7 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar
|
|||||||
auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
|
auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
|
||||||
exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable");
|
exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable");
|
||||||
exeAspect->setLabelText(Tr::tr("Remote executable:"));
|
exeAspect->setLabelText(Tr::tr("Remote executable:"));
|
||||||
exeAspect->setDisplayStyle(StringAspect::LineEditDisplay);
|
exeAspect->setReadOnly(false);
|
||||||
exeAspect->setHistoryCompleter("RemoteLinux.CustomExecutable.History");
|
exeAspect->setHistoryCompleter("RemoteLinux.CustomExecutable.History");
|
||||||
exeAspect->setExpectedKind(PathChooser::Any);
|
exeAspect->setExpectedKind(PathChooser::Any);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user