forked from qt-creator/qt-creator
Squish: Use new settings scheme
Change-Id: I262342c2797a03a774c89f7b7caae3f9d8c79a6c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "objectsmaptreeitem.h"
|
||||
#include "squishconstants.h"
|
||||
#include "squishplugin.h"
|
||||
#include "squishsettings.h"
|
||||
#include "squishtr.h"
|
||||
|
||||
@@ -197,7 +196,7 @@ Core::IDocument::OpenResult ObjectsMapDocument::openImpl(QString *error,
|
||||
|
||||
text = reader.data();
|
||||
} else {
|
||||
const Utils::FilePath base = SquishPlugin::squishSettings()->squishPath();
|
||||
const Utils::FilePath base = settings().squishPath();
|
||||
if (base.isEmpty()) {
|
||||
if (error)
|
||||
error->append(Tr::tr("Incomplete Squish settings. "
|
||||
@@ -235,7 +234,7 @@ bool ObjectsMapDocument::writeFile(const Utils::FilePath &fileName) const
|
||||
}
|
||||
|
||||
// otherwise we need the objectmaptool to write the scripted object map again
|
||||
const Utils::FilePath base = SquishPlugin::squishSettings()->squishPath();
|
||||
const Utils::FilePath base = settings().squishPath();
|
||||
if (base.isEmpty())
|
||||
return false;
|
||||
const Utils::FilePath exe = base.pathAppended("lib/exec/objectmaptool").withExecutableSuffix();
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "squishconstants.h"
|
||||
#include "squishfilehandler.h"
|
||||
#include "squishmessages.h"
|
||||
#include "squishplugin.h"
|
||||
#include "squishsettings.h"
|
||||
#include "squishtesttreemodel.h"
|
||||
#include "squishtesttreeview.h"
|
||||
@@ -311,10 +310,7 @@ void SquishNavigationWidget::onRecordTestCase(const QString &suiteName, const QS
|
||||
|
||||
void SquishNavigationWidget::onNewTestCaseTriggered(const QModelIndex &index)
|
||||
{
|
||||
auto settings = SquishPlugin::squishSettings();
|
||||
QTC_ASSERT(settings, return);
|
||||
|
||||
if (!settings->squishPath().pathAppended("scriptmodules").exists()) {
|
||||
if (!settings().squishPath().pathAppended("scriptmodules").exists()) {
|
||||
SquishMessages::criticalMessage(Tr::tr("Set up a valid Squish path to be able to create "
|
||||
"a new test case.\n(Edit > Preferences > Squish)"));
|
||||
return;
|
||||
|
@@ -27,9 +27,9 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QMenu>
|
||||
#include <QtPlugin>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Squish {
|
||||
namespace Internal {
|
||||
@@ -43,7 +43,6 @@ public:
|
||||
void initializeMenuEntries();
|
||||
bool initializeGlobalScripts();
|
||||
|
||||
SquishSettings m_squishSettings;
|
||||
SquishTestTreeModel m_treeModel;
|
||||
SquishNavigationWidgetFactory m_navigationWidgetFactory;
|
||||
ObjectsMapEditorFactory m_objectsMapEditorFactory;
|
||||
@@ -79,12 +78,6 @@ SquishPlugin::~SquishPlugin()
|
||||
dd = nullptr;
|
||||
}
|
||||
|
||||
SquishSettings *SquishPlugin::squishSettings()
|
||||
{
|
||||
QTC_ASSERT(dd, return nullptr);
|
||||
return &dd->m_squishSettings;
|
||||
}
|
||||
|
||||
void SquishPluginPrivate::initializeMenuEntries()
|
||||
{
|
||||
ActionContainer *menu = ActionManager::createMenu("Squish.Menu");
|
||||
@@ -95,8 +88,7 @@ void SquishPluginPrivate::initializeMenuEntries()
|
||||
Command *command = ActionManager::registerAction(action, "Squish.ServerSettings");
|
||||
menu->addAction(command);
|
||||
connect(action, &QAction::triggered, this, [] {
|
||||
const SquishSettings *settings = SquishPlugin::squishSettings();
|
||||
if (!settings->squishPath().exists()) {
|
||||
if (!settings().squishPath().exists()) {
|
||||
SquishMessages::criticalMessage(Tr::tr("Invalid Squish settings. Configure Squish "
|
||||
"installation path inside "
|
||||
"Preferences... > Squish > General to use "
|
||||
@@ -117,8 +109,8 @@ bool SquishPluginPrivate::initializeGlobalScripts()
|
||||
QTC_ASSERT(dd->m_squishTools, return false);
|
||||
SquishFileHandler::instance()->setSharedFolders({});
|
||||
|
||||
const Utils::FilePath squishserver = dd->m_squishSettings.squishPath().pathAppended(
|
||||
Utils::HostOsInfo::withExecutableSuffix("bin/squishserver"));
|
||||
const FilePath squishserver = settings().squishPath().pathAppended(
|
||||
HostOsInfo::withExecutableSuffix("bin/squishserver"));
|
||||
if (!squishserver.isExecutableFile())
|
||||
return false;
|
||||
|
||||
@@ -142,7 +134,7 @@ void SquishPlugin::initialize()
|
||||
|
||||
bool SquishPlugin::delayedInitialize()
|
||||
{
|
||||
connect(&dd->m_squishSettings.squishPath, &Utils::BaseAspect::changed,
|
||||
connect(&settings().squishPath, &BaseAspect::changed,
|
||||
dd, &SquishPluginPrivate::initializeGlobalScripts);
|
||||
|
||||
return dd->initializeGlobalScripts();
|
||||
|
@@ -3,15 +3,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "squishplugin_global.h"
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
namespace Squish {
|
||||
namespace Internal {
|
||||
|
||||
class SquishSettings;
|
||||
|
||||
class SquishPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -20,8 +16,6 @@ public:
|
||||
SquishPlugin() = default;
|
||||
~SquishPlugin() override;
|
||||
|
||||
static SquishSettings *squishSettings();
|
||||
|
||||
void initialize() override;
|
||||
bool delayedInitialize() override;
|
||||
ShutdownFlag aboutToShutdown() override;
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include "squishtools.h"
|
||||
#include "squishtr.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/basetreeview.h>
|
||||
@@ -28,17 +29,16 @@
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Squish {
|
||||
namespace Internal {
|
||||
namespace Squish::Internal {
|
||||
|
||||
SquishSettings &settings()
|
||||
{
|
||||
static SquishSettings theSettings;
|
||||
return theSettings;
|
||||
}
|
||||
|
||||
SquishSettings::SquishSettings()
|
||||
{
|
||||
setId("A.Squish.General");
|
||||
setDisplayName(Tr::tr("General"));
|
||||
setCategory(Constants::SQUISH_SETTINGS_CATEGORY);
|
||||
setDisplayCategory("Squish");
|
||||
setCategoryIcon(Icon({{":/squish/images/settingscategory_squish.png",
|
||||
Theme::PanelTextColorDark}}, Icon::Tint));
|
||||
setSettingsGroup("Squish");
|
||||
setAutoApply(false);
|
||||
|
||||
@@ -113,9 +113,9 @@ SquishSettings::SquishSettings()
|
||||
readSettings();
|
||||
}
|
||||
|
||||
Utils::FilePath SquishSettings::scriptsPath(Language language) const
|
||||
FilePath SquishSettings::scriptsPath(Language language) const
|
||||
{
|
||||
Utils::FilePath scripts = squishPath().pathAppended("scriptmodules");
|
||||
FilePath scripts = squishPath().pathAppended("scriptmodules");
|
||||
switch (language) {
|
||||
case Language::Python: scripts = scripts.pathAppended("python"); break;
|
||||
case Language::Perl: scripts = scripts.pathAppended("perl"); break;
|
||||
@@ -124,9 +124,28 @@ Utils::FilePath SquishSettings::scriptsPath(Language language) const
|
||||
case Language::Tcl: scripts = scripts.pathAppended("tcl"); break;
|
||||
}
|
||||
|
||||
return scripts.isReadableDir() ? scripts : Utils::FilePath();
|
||||
return scripts.isReadableDir() ? scripts : FilePath();
|
||||
}
|
||||
|
||||
class SquishSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
SquishSettingsPage()
|
||||
{
|
||||
setId("A.Squish.General");
|
||||
setDisplayName(Tr::tr("General"));
|
||||
setCategory(Constants::SQUISH_SETTINGS_CATEGORY);
|
||||
setDisplayCategory("Squish");
|
||||
setCategoryIcon(Icon({{":/squish/images/settingscategory_squish.png",
|
||||
Theme::PanelTextColorDark}}, Icon::Tint));
|
||||
setSettingsProvider([] { return &settings(); });
|
||||
}
|
||||
};
|
||||
|
||||
const SquishSettingsPage settingsPage;
|
||||
|
||||
// SquishServerSettings
|
||||
|
||||
SquishServerSettings::SquishServerSettings()
|
||||
{
|
||||
autTimeout.setLabel(Tr::tr("Maximum startup time:"));
|
||||
@@ -681,5 +700,4 @@ void SquishServerSettingsDialog::configWriteFailed(QProcess::ProcessError error)
|
||||
SquishMessages::criticalMessage(detail);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Squish
|
||||
} // Squish::Internal
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <utils/aspects.h>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QProcess>
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
Utils::BoolAspect animatedCursor{this};
|
||||
};
|
||||
|
||||
class SquishSettings : public Core::PagedSettings
|
||||
class SquishSettings : public Utils::AspectContainer
|
||||
{
|
||||
public:
|
||||
SquishSettings();
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
Utils::BoolAspect minimizeIDE{this};
|
||||
};
|
||||
|
||||
SquishSettings &settings();
|
||||
|
||||
class SquishServerSettingsDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
|
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "squishconstants.h"
|
||||
#include "squishfilehandler.h"
|
||||
#include "squishplugin.h"
|
||||
#include "squishsettings.h"
|
||||
#include "squishtesttreemodel.h"
|
||||
#include "suiteconf.h"
|
||||
@@ -163,10 +162,6 @@ void SquishTestTreeItemDelegate::setEditorData(QWidget *editor, const QModelInde
|
||||
|
||||
static bool copyScriptTemplates(const SuiteConf &suiteConf, const Utils::FilePath &destination)
|
||||
{
|
||||
const SquishSettings *s = SquishPlugin::squishSettings();
|
||||
QTC_ASSERT(s, return false);
|
||||
// copy template files
|
||||
|
||||
Utils::expected_str<void> result = destination.ensureWritableDir();
|
||||
QTC_ASSERT_EXPECTED(result, return false);
|
||||
|
||||
@@ -174,7 +169,7 @@ static bool copyScriptTemplates(const SuiteConf &suiteConf, const Utils::FilePat
|
||||
const QString extension = suiteConf.scriptExtension();
|
||||
const QString testStr = scripted ? QString("script_som_template") : QString("script_template");
|
||||
|
||||
const Utils::FilePath scripts = s->scriptsPath(suiteConf.language());
|
||||
const Utils::FilePath scripts = settings().scriptsPath(suiteConf.language());
|
||||
const Utils::FilePath test = scripts.pathAppended(testStr + extension);
|
||||
const Utils::FilePath testFile = destination.pathAppended("test" + extension);
|
||||
QTC_ASSERT(!testFile.exists(), return false);
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "scripthelper.h"
|
||||
#include "squishmessages.h"
|
||||
#include "squishoutputpane.h"
|
||||
#include "squishplugin.h"
|
||||
#include "squishsettings.h"
|
||||
#include "squishtr.h"
|
||||
#include "squishxmloutputhandler.h"
|
||||
@@ -167,9 +166,7 @@ struct SquishToolsSettings
|
||||
// populate members using current settings
|
||||
void setup()
|
||||
{
|
||||
const SquishSettings *squishSettings = SquishPlugin::squishSettings();
|
||||
QTC_ASSERT(squishSettings, return);
|
||||
squishPath = squishSettings->squishPath();
|
||||
squishPath = settings().squishPath();
|
||||
|
||||
if (!squishPath.isEmpty()) {
|
||||
const FilePath squishBin(squishPath.pathAppended("bin"));
|
||||
@@ -181,12 +178,12 @@ struct SquishToolsSettings
|
||||
HostOsInfo::withExecutableSuffix("processcomm")).absoluteFilePath();
|
||||
}
|
||||
|
||||
isLocalServer = squishSettings->local();
|
||||
serverHost = squishSettings->serverHost();
|
||||
serverPort = squishSettings->serverPort();
|
||||
verboseLog = squishSettings->verbose();
|
||||
licenseKeyPath = squishSettings->licensePath();
|
||||
minimizeIDE = squishSettings->minimizeIDE();
|
||||
isLocalServer = settings().local();
|
||||
serverHost = settings().serverHost();
|
||||
serverPort = settings().serverPort();
|
||||
verboseLog = settings().verbose();
|
||||
licenseKeyPath = settings().licensePath();
|
||||
minimizeIDE = settings().minimizeIDE();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -4,7 +4,6 @@
|
||||
#include "squishwizardpages.h"
|
||||
|
||||
#include "squishfilehandler.h"
|
||||
#include "squishplugin.h"
|
||||
#include "squishsettings.h"
|
||||
#include "squishtools.h"
|
||||
#include "squishtr.h"
|
||||
@@ -111,8 +110,7 @@ bool SquishToolkitsPage::handleReject()
|
||||
|
||||
void SquishToolkitsPage::delayedInitialize()
|
||||
{
|
||||
const auto s = SquishPlugin::squishSettings();
|
||||
const Utils::FilePath server = s->squishPath().pathAppended(
|
||||
const Utils::FilePath server = settings().squishPath().pathAppended(
|
||||
Utils::HostOsInfo::withExecutableSuffix("bin/squishserver"));
|
||||
if (server.isExecutableFile())
|
||||
fetchServerSettings();
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "suiteconf.h"
|
||||
|
||||
#include "squishplugin.h"
|
||||
#include "squishsettings.h"
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
@@ -314,7 +313,7 @@ bool SuiteConf::ensureObjectMapExists() const
|
||||
return objectMap.parentDir().ensureWritableDir() && objectMap.ensureExistingFile();
|
||||
}
|
||||
|
||||
const Utils::FilePath scripts = SquishPlugin::squishSettings()->scriptsPath(language());
|
||||
const Utils::FilePath scripts = settings().scriptsPath(language());
|
||||
QTC_ASSERT(scripts.exists(), return false);
|
||||
|
||||
const QString extension = scriptExtension();
|
||||
|
Reference in New Issue
Block a user