Squish: Cancel wizard early if settings are wrong

Add an error label for the user and stop internal actions
to avoid displaying error message dialogs with less helpful
information.

Change-Id: Ie0d075121fabb56b67300eaf6c0ebde674475b9c
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2022-09-30 11:02:49 +02:00
parent bea4dd861d
commit 60d78e4bb0
2 changed files with 22 additions and 2 deletions

View File

@@ -4,10 +4,12 @@
#include "squishwizardpages.h"
#include "squishfilehandler.h"
#include "squishplugin.h"
#include "squishsettings.h"
#include "squishtools.h"
#include "squishtr.h"
#include <utils/infolabel.h>
#include <utils/qtcassert.h>
#include <QApplication>
@@ -47,7 +49,7 @@ SquishToolkitsPage::SquishToolkitsPage()
resize(400, 300);
setTitle(Tr::tr("Create New Squish Test Suite"));
auto layout = new QHBoxLayout(this);
auto layout = new QVBoxLayout(this);
auto groupBox = new QGroupBox(Tr::tr("Available GUI toolkits:"), this);
auto buttonLayout = new QVBoxLayout(groupBox);
@@ -63,6 +65,15 @@ SquishToolkitsPage::SquishToolkitsPage()
}
groupBox->setLayout(buttonLayout);
layout->addWidget(groupBox);
m_errorLabel = new Utils::InfoLabel(Tr::tr("Invalid Squish settings. Configure Squish "
"installation path inside "
"Preferences... > Squish > General to use "
"this wizard."),
Utils::InfoLabel::Error, this);
m_errorLabel->setVisible(false);
layout->addWidget(m_errorLabel);
auto hiddenLineEdit = new QLineEdit(this);
hiddenLineEdit->setVisible(false);
layout->addWidget(hiddenLineEdit);
@@ -99,7 +110,13 @@ bool SquishToolkitsPage::handleReject()
void SquishToolkitsPage::delayedInitialize()
{
fetchServerSettings();
const auto s = SquishPlugin::squishSettings();
const Utils::FilePath server = s->squishPath.filePath().pathAppended(
Utils::HostOsInfo::withExecutableSuffix("bin/squishserver"));
if (server.isExecutableFile())
fetchServerSettings();
else
m_errorLabel->setVisible(true);
}
void SquishToolkitsPage::fetchServerSettings()

View File

@@ -13,6 +13,8 @@ class QComboBox;
class QLineEdit;
QT_END_NAMESPACE
namespace Utils { class InfoLabel; }
namespace Squish {
namespace Internal {
@@ -43,6 +45,7 @@ private:
QButtonGroup *m_buttonGroup = nullptr;
QLineEdit *m_hiddenLineEdit = nullptr;
Utils::InfoLabel *m_errorLabel = nullptr;
};
class SquishScriptLanguagePageFactory : public ProjectExplorer::JsonWizardPageFactory