forked from qt-creator/qt-creator
CMake: Apply build directory change on editingFinished
Otherwise every time a character is typed, a dialog pops up, and that dialog is closed without triggering a cmake run, the value is reset. Add that behavior optionally to StringAspect. Change-Id: I6831d1622f08acae6df43d4ceb2bf7367c96a747 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -658,6 +658,10 @@ public:
|
|||||||
bool m_showToolTipOnLabel = false;
|
bool m_showToolTipOnLabel = false;
|
||||||
bool m_fileDialogOnly = false;
|
bool m_fileDialogOnly = false;
|
||||||
bool m_useResetButton = false;
|
bool m_useResetButton = false;
|
||||||
|
bool m_autoApplyOnEditingFinished = false;
|
||||||
|
// Used to block recursive editingFinished signals for example when return is pressed, and
|
||||||
|
// the validation changes focus by opening a dialog
|
||||||
|
bool m_blockAutoApply = false;
|
||||||
|
|
||||||
template<class Widget> void updateWidgetFromCheckStatus(StringAspect *aspect, Widget *w)
|
template<class Widget> void updateWidgetFromCheckStatus(StringAspect *aspect, Widget *w)
|
||||||
{
|
{
|
||||||
@@ -1015,6 +1019,11 @@ void StringAspect::setOpenTerminalHandler(const std::function<void ()> &openTerm
|
|||||||
d->m_pathChooserDisplay->setOpenTerminalHandler(openTerminal);
|
d->m_pathChooserDisplay->setOpenTerminalHandler(openTerminal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StringAspect::setAutoApplyOnEditingFinished(bool applyOnEditingFinished)
|
||||||
|
{
|
||||||
|
d->m_autoApplyOnEditingFinished = applyOnEditingFinished;
|
||||||
|
}
|
||||||
|
|
||||||
void StringAspect::validateInput()
|
void StringAspect::validateInput()
|
||||||
{
|
{
|
||||||
if (d->m_pathChooserDisplay)
|
if (d->m_pathChooserDisplay)
|
||||||
@@ -1059,8 +1068,19 @@ void StringAspect::addToLayout(LayoutBuilder &builder)
|
|||||||
addLabeledItem(builder, d->m_pathChooserDisplay);
|
addLabeledItem(builder, d->m_pathChooserDisplay);
|
||||||
useMacroExpander(d->m_pathChooserDisplay->lineEdit());
|
useMacroExpander(d->m_pathChooserDisplay->lineEdit());
|
||||||
if (isAutoApply()) {
|
if (isAutoApply()) {
|
||||||
connect(d->m_pathChooserDisplay, &PathChooser::pathChanged, this, [this] {
|
if (d->m_autoApplyOnEditingFinished) {
|
||||||
setValue(d->m_pathChooserDisplay->path()); });
|
connect(d->m_pathChooserDisplay, &PathChooser::editingFinished, this, [this] {
|
||||||
|
if (d->m_blockAutoApply)
|
||||||
|
return;
|
||||||
|
d->m_blockAutoApply = true;
|
||||||
|
setValue(d->m_pathChooserDisplay->path());
|
||||||
|
d->m_blockAutoApply = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
connect(d->m_pathChooserDisplay, &PathChooser::pathChanged, this, [this] {
|
||||||
|
setValue(d->m_pathChooserDisplay->path());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LineEditDisplay:
|
case LineEditDisplay:
|
||||||
@@ -1075,8 +1095,20 @@ void StringAspect::addToLayout(LayoutBuilder &builder)
|
|||||||
addLabeledItem(builder, d->m_lineEditDisplay);
|
addLabeledItem(builder, d->m_lineEditDisplay);
|
||||||
useMacroExpander(d->m_lineEditDisplay);
|
useMacroExpander(d->m_lineEditDisplay);
|
||||||
if (isAutoApply()) {
|
if (isAutoApply()) {
|
||||||
connect(d->m_lineEditDisplay, &FancyLineEdit::textEdited,
|
if (d->m_autoApplyOnEditingFinished) {
|
||||||
this, &StringAspect::setValue);
|
connect(d->m_lineEditDisplay, &FancyLineEdit::editingFinished, this, [this] {
|
||||||
|
if (d->m_blockAutoApply)
|
||||||
|
return;
|
||||||
|
d->m_blockAutoApply = true;
|
||||||
|
setValue(d->m_lineEditDisplay->text());
|
||||||
|
d->m_blockAutoApply = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
connect(d->m_lineEditDisplay,
|
||||||
|
&FancyLineEdit::textEdited,
|
||||||
|
this,
|
||||||
|
&StringAspect::setValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (d->m_useResetButton) {
|
if (d->m_useResetButton) {
|
||||||
auto resetButton = createSubWidget<QPushButton>(tr("Reset"));
|
auto resetButton = createSubWidget<QPushButton>(tr("Reset"));
|
||||||
|
@@ -307,6 +307,7 @@ public:
|
|||||||
void setUseResetButton();
|
void setUseResetButton();
|
||||||
void setValidationFunction(const Utils::FancyLineEdit::ValidationFunction &validator);
|
void setValidationFunction(const Utils::FancyLineEdit::ValidationFunction &validator);
|
||||||
void setOpenTerminalHandler(const std::function<void()> &openTerminal);
|
void setOpenTerminalHandler(const std::function<void()> &openTerminal);
|
||||||
|
void setAutoApplyOnEditingFinished(bool applyOnEditingFinished);
|
||||||
|
|
||||||
void validateInput();
|
void validateInput();
|
||||||
|
|
||||||
|
@@ -182,6 +182,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
container->setWidget(details);
|
container->setWidget(details);
|
||||||
|
|
||||||
auto buildDirAspect = bc->buildDirectoryAspect();
|
auto buildDirAspect = bc->buildDirectoryAspect();
|
||||||
|
buildDirAspect->setAutoApplyOnEditingFinished(true);
|
||||||
connect(buildDirAspect, &BaseAspect::changed, this, [this]() {
|
connect(buildDirAspect, &BaseAspect::changed, this, [this]() {
|
||||||
m_configModel->flush(); // clear out config cache...;
|
m_configModel->flush(); // clear out config cache...;
|
||||||
});
|
});
|
||||||
@@ -851,7 +852,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
|
|||||||
return newDir;
|
return newDir;
|
||||||
|
|
||||||
if (QDir(oldDir).exists("CMakeCache.txt") && !QDir(newDir).exists("CMakeCache.txt")) {
|
if (QDir(oldDir).exists("CMakeCache.txt") && !QDir(newDir).exists("CMakeCache.txt")) {
|
||||||
if (QMessageBox::information(nullptr,
|
if (QMessageBox::information(Core::ICore::dialogParent(),
|
||||||
tr("Changing Build Directory"),
|
tr("Changing Build Directory"),
|
||||||
tr("Change the build directory and start with a "
|
tr("Change the build directory and start with a "
|
||||||
"basic CMake configuration?"),
|
"basic CMake configuration?"),
|
||||||
|
Reference in New Issue
Block a user