forked from qt-creator/qt-creator
Squish: Streamline plugin setup
Change-Id: I661587f26e1f90ddd55ea109be53194831745659 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -18,7 +18,7 @@ add_qtc_plugin(Squish
|
|||||||
squishnavigationwidget.cpp squishnavigationwidget.h
|
squishnavigationwidget.cpp squishnavigationwidget.h
|
||||||
squishoutputpane.cpp squishoutputpane.h
|
squishoutputpane.cpp squishoutputpane.h
|
||||||
squishperspective.cpp squishperspective.h
|
squishperspective.cpp squishperspective.h
|
||||||
squishplugin.cpp squishplugin.h
|
squishplugin.cpp
|
||||||
squishprocessbase.cpp squishprocessbase.h
|
squishprocessbase.cpp squishprocessbase.h
|
||||||
squishresultmodel.cpp squishresultmodel.h
|
squishresultmodel.cpp squishresultmodel.h
|
||||||
squishrunnerprocess.cpp squishrunnerprocess.h
|
squishrunnerprocess.cpp squishrunnerprocess.h
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ QtcPlugin {
|
|||||||
"squishperspective.cpp",
|
"squishperspective.cpp",
|
||||||
"squishperspective.h",
|
"squishperspective.h",
|
||||||
"squishplugin.cpp",
|
"squishplugin.cpp",
|
||||||
"squishplugin.h",
|
|
||||||
"squishplugin_global.h",
|
"squishplugin_global.h",
|
||||||
"squishprocessbase.cpp",
|
"squishprocessbase.cpp",
|
||||||
"squishprocessbase.h",
|
"squishprocessbase.h",
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
// Copyright (C) 2022 The Qt Company Ltd
|
// Copyright (C) 2022 The Qt Company Ltd
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "squishplugin.h"
|
|
||||||
|
|
||||||
#include "objectsmapeditor.h"
|
#include "objectsmapeditor.h"
|
||||||
#include "squishfilehandler.h"
|
#include "squishfilehandler.h"
|
||||||
#include "squishmessages.h"
|
#include "squishmessages.h"
|
||||||
@@ -20,6 +18,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
||||||
|
|
||||||
@@ -31,10 +30,9 @@
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Squish {
|
namespace Squish::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class SquishPluginPrivate : public QObject
|
class SquishPluginPrivate final : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SquishPluginPrivate();
|
SquishPluginPrivate();
|
||||||
@@ -47,7 +45,7 @@ public:
|
|||||||
SquishNavigationWidgetFactory m_navigationWidgetFactory;
|
SquishNavigationWidgetFactory m_navigationWidgetFactory;
|
||||||
ObjectsMapEditorFactory m_objectsMapEditorFactory;
|
ObjectsMapEditorFactory m_objectsMapEditorFactory;
|
||||||
SquishOutputPane *m_outputPane = nullptr;
|
SquishOutputPane *m_outputPane = nullptr;
|
||||||
SquishTools * m_squishTools = nullptr;
|
SquishTools m_squishTools;
|
||||||
|
|
||||||
SquishToolkitsPageFactory m_squishToolkitsPageFactory;
|
SquishToolkitsPageFactory m_squishToolkitsPageFactory;
|
||||||
SquishScriptLanguagePageFactory m_squishScriptLanguagePageFactory;
|
SquishScriptLanguagePageFactory m_squishScriptLanguagePageFactory;
|
||||||
@@ -55,27 +53,17 @@ public:
|
|||||||
SquishGeneratorFactory m_squishGeneratorFactory;
|
SquishGeneratorFactory m_squishGeneratorFactory;
|
||||||
};
|
};
|
||||||
|
|
||||||
static SquishPluginPrivate *dd = nullptr;
|
|
||||||
|
|
||||||
SquishPluginPrivate::SquishPluginPrivate()
|
SquishPluginPrivate::SquishPluginPrivate()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<SquishResultItem*>("SquishResultItem*");
|
qRegisterMetaType<SquishResultItem*>("SquishResultItem*");
|
||||||
|
|
||||||
m_outputPane = SquishOutputPane::instance();
|
m_outputPane = SquishOutputPane::instance();
|
||||||
m_squishTools = new SquishTools;
|
|
||||||
initializeMenuEntries();
|
initializeMenuEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
SquishPluginPrivate::~SquishPluginPrivate()
|
SquishPluginPrivate::~SquishPluginPrivate()
|
||||||
{
|
{
|
||||||
delete m_outputPane;
|
delete m_outputPane;
|
||||||
delete m_squishTools;
|
|
||||||
}
|
|
||||||
|
|
||||||
SquishPlugin::~SquishPlugin()
|
|
||||||
{
|
|
||||||
delete dd;
|
|
||||||
dd = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishPluginPrivate::initializeMenuEntries()
|
void SquishPluginPrivate::initializeMenuEntries()
|
||||||
@@ -106,7 +94,6 @@ void SquishPluginPrivate::initializeMenuEntries()
|
|||||||
|
|
||||||
bool SquishPluginPrivate::initializeGlobalScripts()
|
bool SquishPluginPrivate::initializeGlobalScripts()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dd->m_squishTools, return false);
|
|
||||||
SquishFileHandler::instance()->setSharedFolders({});
|
SquishFileHandler::instance()->setSharedFolders({});
|
||||||
|
|
||||||
const FilePath squishserver = settings().squishPath().pathAppended(
|
const FilePath squishserver = settings().squishPath().pathAppended(
|
||||||
@@ -114,7 +101,7 @@ bool SquishPluginPrivate::initializeGlobalScripts()
|
|||||||
if (!squishserver.isExecutableFile())
|
if (!squishserver.isExecutableFile())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dd->m_squishTools->queryGlobalScripts([](const QString &output, const QString &error) {
|
m_squishTools.queryGlobalScripts([](const QString &output, const QString &error) {
|
||||||
if (output.isEmpty() || !error.isEmpty())
|
if (output.isEmpty() || !error.isEmpty())
|
||||||
return; // ignore (for now?)
|
return; // ignore (for now?)
|
||||||
|
|
||||||
@@ -126,31 +113,38 @@ bool SquishPluginPrivate::initializeGlobalScripts()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishPlugin::initialize()
|
class SquishPlugin final : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
dd = new SquishPluginPrivate;
|
Q_OBJECT
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/squish/wizard/");
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Squish.json")
|
||||||
}
|
|
||||||
|
|
||||||
bool SquishPlugin::delayedInitialize()
|
private:
|
||||||
{
|
void initialize() final
|
||||||
connect(&settings().squishPath, &BaseAspect::changed,
|
{
|
||||||
dd, &SquishPluginPrivate::initializeGlobalScripts);
|
d.reset(new SquishPluginPrivate);
|
||||||
|
ProjectExplorer::JsonWizardFactory::addWizardPath(":/squish/wizard/");
|
||||||
|
}
|
||||||
|
|
||||||
return dd->initializeGlobalScripts();
|
bool delayedInitialize() final
|
||||||
}
|
{
|
||||||
|
connect(&settings().squishPath, &BaseAspect::changed,
|
||||||
|
d.get(), &SquishPluginPrivate::initializeGlobalScripts);
|
||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag SquishPlugin::aboutToShutdown()
|
return d->initializeGlobalScripts();
|
||||||
{
|
}
|
||||||
if (dd->m_squishTools) {
|
|
||||||
if (dd->m_squishTools->shutdown())
|
ShutdownFlag aboutToShutdown() final
|
||||||
|
{
|
||||||
|
if (d->m_squishTools.shutdown())
|
||||||
return SynchronousShutdown;
|
return SynchronousShutdown;
|
||||||
connect(dd->m_squishTools, &SquishTools::shutdownFinished,
|
connect(&d->m_squishTools, &SquishTools::shutdownFinished,
|
||||||
this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished);
|
this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished);
|
||||||
return AsynchronousShutdown;
|
return AsynchronousShutdown;
|
||||||
}
|
}
|
||||||
return SynchronousShutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
std::unique_ptr<SquishPluginPrivate> d;
|
||||||
} // namespace Squish
|
};
|
||||||
|
|
||||||
|
} // Squish::Internal
|
||||||
|
|
||||||
|
#include "squishplugin.moc"
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 The Qt Company Ltd
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
|
||||||
|
|
||||||
namespace Squish {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class SquishPlugin : public ExtensionSystem::IPlugin
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Squish.json")
|
|
||||||
public:
|
|
||||||
SquishPlugin() = default;
|
|
||||||
~SquishPlugin() override;
|
|
||||||
|
|
||||||
void initialize() override;
|
|
||||||
bool delayedInitialize() override;
|
|
||||||
ShutdownFlag aboutToShutdown() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Squish
|
|
||||||
Reference in New Issue
Block a user