mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 04:40:56 -06:00
Merge topic 'cmake-gui-reload-presets'
74be7f5d79 cmake-gui: Add 'Reload Presets' button, replacing reload timer
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10361
This commit is contained in:
@@ -275,6 +275,8 @@ void CMakeSetupDialog::initialize()
|
||||
QObject::connect(this->BrowseSourceDirectoryButton,
|
||||
&QAbstractButton::clicked, this,
|
||||
&CMakeSetupDialog::doSourceBrowse);
|
||||
QObject::connect(this->ReloadPresetsButton, &QAbstractButton::clicked,
|
||||
this->CMakeThread->cmakeInstance(), &QCMake::loadPresets);
|
||||
QObject::connect(this->BrowseBinaryDirectoryButton,
|
||||
&QAbstractButton::clicked, this,
|
||||
&CMakeSetupDialog::doBinaryBrowse);
|
||||
|
||||
@@ -74,6 +74,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="ReloadPresetsButton">
|
||||
<property name="text">
|
||||
<string>Reload &presets</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="BinaryLabel">
|
||||
<property name="text">
|
||||
|
||||
@@ -64,17 +64,6 @@ QCMake::QCMake(QObject* p)
|
||||
for (cmake::GeneratorInfo const& gen : generators) {
|
||||
this->AvailableGenerators.push_back(gen);
|
||||
}
|
||||
|
||||
connect(&this->LoadPresetsTimer, &QTimer::timeout, this, [this]() {
|
||||
this->loadPresets();
|
||||
if (!this->PresetName.isEmpty() &&
|
||||
this->CMakePresetsGraph.ConfigurePresets.find(
|
||||
std::string(this->PresetName.toStdString())) ==
|
||||
this->CMakePresetsGraph.ConfigurePresets.end()) {
|
||||
this->setPreset(QString{});
|
||||
}
|
||||
});
|
||||
this->LoadPresetsTimer.start(1000);
|
||||
}
|
||||
|
||||
QCMake::~QCMake() = default;
|
||||
@@ -572,13 +561,12 @@ void QCMake::loadPresets()
|
||||
{
|
||||
auto result = this->CMakePresetsGraph.ReadProjectPresets(
|
||||
this->SourceDirectory.toStdString(), true);
|
||||
if (result != this->LastLoadPresetsResult && !result) {
|
||||
if (!result) {
|
||||
emit this->presetLoadError(
|
||||
this->SourceDirectory,
|
||||
QString::fromStdString(
|
||||
this->CMakePresetsGraph.parseState.GetErrorMessage(false)));
|
||||
}
|
||||
this->LastLoadPresetsResult = result;
|
||||
|
||||
QVector<QCMakePreset> presets;
|
||||
for (auto const& name : this->CMakePresetsGraph.ConfigurePresetOrder) {
|
||||
|
||||
@@ -124,6 +124,8 @@ public slots:
|
||||
void setWarnUninitializedMode(bool value);
|
||||
/// check if project IDE open is possible and emit openPossible signal
|
||||
void checkOpenPossible();
|
||||
/// Reload the preset files and tree
|
||||
void loadPresets();
|
||||
|
||||
public:
|
||||
/// get the list of cache properties
|
||||
@@ -193,8 +195,6 @@ protected:
|
||||
void stderrCallback(std::string const& msg);
|
||||
void setUpEnvironment() const;
|
||||
|
||||
void loadPresets();
|
||||
|
||||
bool WarnUninitializedMode;
|
||||
QString SourceDirectory;
|
||||
QString BinaryDirectory;
|
||||
@@ -204,11 +204,9 @@ protected:
|
||||
QString Toolset;
|
||||
std::vector<cmake::GeneratorInfo> AvailableGenerators;
|
||||
cmCMakePresetsGraph CMakePresetsGraph;
|
||||
bool LastLoadPresetsResult = true;
|
||||
QString PresetName;
|
||||
QString CMakeExecutable;
|
||||
QAtomicInt InterruptFlag;
|
||||
QProcessEnvironment StartEnvironment;
|
||||
QProcessEnvironment Environment;
|
||||
QTimer LoadPresetsTimer;
|
||||
};
|
||||
|
||||
@@ -360,13 +360,15 @@ void CMakeGUITest::changingPresets()
|
||||
QCOMPARE(this->m_window->Preset->isEnabled(), false);
|
||||
|
||||
writePresets("build1", { "preset" });
|
||||
loopSleep(1500);
|
||||
this->m_window->ReloadPresetsButton->click();
|
||||
loopSleep();
|
||||
QCOMPARE(this->m_window->Preset->presetName(), QString{});
|
||||
QCOMPARE(this->m_window->Preset->presets().size(), 1);
|
||||
QCOMPARE(this->m_window->BinaryDirectory->currentText(), "");
|
||||
QCOMPARE(this->m_window->Preset->isEnabled(), true);
|
||||
|
||||
this->m_window->Preset->setPresetName("preset");
|
||||
this->m_window->ReloadPresetsButton->click();
|
||||
loopSleep();
|
||||
QCOMPARE(this->m_window->Preset->presetName(), "preset");
|
||||
QCOMPARE(this->m_window->Preset->presets().size(), 1);
|
||||
@@ -375,7 +377,8 @@ void CMakeGUITest::changingPresets()
|
||||
QCOMPARE(this->m_window->Preset->isEnabled(), true);
|
||||
|
||||
writePresets("build2", { "preset2", "preset" });
|
||||
loopSleep(1500);
|
||||
this->m_window->ReloadPresetsButton->click();
|
||||
loopSleep();
|
||||
QCOMPARE(this->m_window->Preset->presetName(), "preset");
|
||||
QCOMPARE(this->m_window->Preset->presets().size(), 2);
|
||||
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
|
||||
@@ -383,7 +386,8 @@ void CMakeGUITest::changingPresets()
|
||||
QCOMPARE(this->m_window->Preset->isEnabled(), true);
|
||||
|
||||
writePresets("build3", { "preset2" });
|
||||
loopSleep(1500);
|
||||
this->m_window->ReloadPresetsButton->click();
|
||||
loopSleep();
|
||||
QCOMPARE(this->m_window->Preset->presetName(), QString{});
|
||||
QCOMPARE(this->m_window->Preset->presets().size(), 1);
|
||||
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
|
||||
@@ -421,7 +425,8 @@ void CMakeGUITest::changingPresets()
|
||||
|
||||
QFile(CMakeGUITest_BINARY_DIR "/changingPresets/src2/CMakePresets.json")
|
||||
.remove();
|
||||
loopSleep(1500);
|
||||
this->m_window->ReloadPresetsButton->click();
|
||||
loopSleep();
|
||||
QCOMPARE(this->m_window->Preset->presetName(), QString{});
|
||||
QCOMPARE(this->m_window->Preset->presets().size(), 0);
|
||||
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
|
||||
|
||||
Reference in New Issue
Block a user