forked from qt-creator/qt-creator
Squish: Dissolve plugin pimpl
Change-Id: I8e291e91c5d8c94274f39db40a625a796d8ad9b7 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -32,67 +32,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace Squish::Internal {
|
namespace Squish::Internal {
|
||||||
|
|
||||||
class SquishPluginPrivate final : public QObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SquishPluginPrivate();
|
|
||||||
|
|
||||||
bool initializeGlobalScripts();
|
|
||||||
};
|
|
||||||
|
|
||||||
SquishPluginPrivate::SquishPluginPrivate()
|
|
||||||
{
|
|
||||||
qRegisterMetaType<SquishResultItem*>("SquishResultItem*");
|
|
||||||
|
|
||||||
const Id menuId = "Squish.Menu";
|
|
||||||
ActionContainer *menu = ActionManager::createMenu(menuId);
|
|
||||||
menu->menu()->setTitle(Tr::tr("&Squish"));
|
|
||||||
menu->setOnAllDisabledBehavior(ActionContainer::Show);
|
|
||||||
|
|
||||||
ActionBuilder serverSettings(this, "Squish.ServerSettings");
|
|
||||||
serverSettings.setText(Tr::tr("&Server Settings..."));
|
|
||||||
serverSettings.addToContainer(menuId);
|
|
||||||
serverSettings.addOnTriggered(this, [] {
|
|
||||||
if (!settings().squishPath().exists()) {
|
|
||||||
SquishMessages::criticalMessage(Tr::tr("Invalid Squish settings. Configure Squish "
|
|
||||||
"installation path inside "
|
|
||||||
"Preferences... > Squish > General to use "
|
|
||||||
"this wizard."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SquishServerSettingsDialog dialog;
|
|
||||||
dialog.exec();
|
|
||||||
});
|
|
||||||
|
|
||||||
ActionContainer *toolsMenu = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
|
||||||
toolsMenu->addMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SquishPluginPrivate::initializeGlobalScripts()
|
|
||||||
{
|
|
||||||
// The code expects squishTestTreeModel to exist, so force creation now.
|
|
||||||
(void) SquishTestTreeModel::instance();
|
|
||||||
|
|
||||||
SquishFileHandler::instance()->setSharedFolders({});
|
|
||||||
|
|
||||||
const FilePath squishserver = settings().squishPath().pathAppended("bin/squishserver")
|
|
||||||
.withExecutableSuffix();
|
|
||||||
if (!squishserver.isExecutableFile())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SquishTools::instance()->queryGlobalScripts([](const QString &output, const QString &error) {
|
|
||||||
if (output.isEmpty() || !error.isEmpty())
|
|
||||||
return; // ignore (for now?)
|
|
||||||
|
|
||||||
// FIXME? comma, special characters in paths
|
|
||||||
const Utils::FilePaths globalDirs = Utils::transform(
|
|
||||||
output.trimmed().split(',', Qt::SkipEmptyParts), &Utils::FilePath::fromUserInput);
|
|
||||||
SquishFileHandler::instance()->setSharedFolders(globalDirs);
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
class SquishPlugin final : public ExtensionSystem::IPlugin
|
class SquishPlugin final : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -106,20 +45,67 @@ private:
|
|||||||
setupSquishOutputPane(this);
|
setupSquishOutputPane(this);
|
||||||
setupSquishTools(this);
|
setupSquishTools(this);
|
||||||
|
|
||||||
d.reset(new SquishPluginPrivate);
|
|
||||||
|
|
||||||
setupSquishWizardPages();
|
setupSquishWizardPages();
|
||||||
setupSquishNavigationWidgetFactory();
|
setupSquishNavigationWidgetFactory();
|
||||||
|
|
||||||
|
qRegisterMetaType<SquishResultItem*>("SquishResultItem*");
|
||||||
|
|
||||||
|
const Id menuId = "Squish.Menu";
|
||||||
|
ActionContainer *menu = ActionManager::createMenu(menuId);
|
||||||
|
menu->menu()->setTitle(Tr::tr("&Squish"));
|
||||||
|
menu->setOnAllDisabledBehavior(ActionContainer::Show);
|
||||||
|
|
||||||
|
ActionBuilder serverSettings(this, "Squish.ServerSettings");
|
||||||
|
serverSettings.setText(Tr::tr("&Server Settings..."));
|
||||||
|
serverSettings.addToContainer(menuId);
|
||||||
|
serverSettings.addOnTriggered(this, [] {
|
||||||
|
if (!settings().squishPath().exists()) {
|
||||||
|
SquishMessages::criticalMessage(Tr::tr("Invalid Squish settings. Configure Squish "
|
||||||
|
"installation path inside "
|
||||||
|
"Preferences... > Squish > General to use "
|
||||||
|
"this wizard."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SquishServerSettingsDialog dialog;
|
||||||
|
dialog.exec();
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionContainer *toolsMenu = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
||||||
|
toolsMenu->addMenu(menu);
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/squish/wizard/");
|
ProjectExplorer::JsonWizardFactory::addWizardPath(":/squish/wizard/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool initializeGlobalScripts()
|
||||||
|
{
|
||||||
|
// The code expects squishTestTreeModel to exist, so force creation now.
|
||||||
|
(void) SquishTestTreeModel::instance();
|
||||||
|
|
||||||
|
SquishFileHandler::instance()->setSharedFolders({});
|
||||||
|
|
||||||
|
const FilePath squishserver = settings().squishPath().pathAppended("bin/squishserver")
|
||||||
|
.withExecutableSuffix();
|
||||||
|
if (!squishserver.isExecutableFile())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SquishTools::instance()->queryGlobalScripts([](const QString &output, const QString &error) {
|
||||||
|
if (output.isEmpty() || !error.isEmpty())
|
||||||
|
return; // ignore (for now?)
|
||||||
|
|
||||||
|
// FIXME? comma, special characters in paths
|
||||||
|
const Utils::FilePaths globalDirs = Utils::transform(
|
||||||
|
output.trimmed().split(',', Qt::SkipEmptyParts), &Utils::FilePath::fromUserInput);
|
||||||
|
SquishFileHandler::instance()->setSharedFolders(globalDirs);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool delayedInitialize() final
|
bool delayedInitialize() final
|
||||||
{
|
{
|
||||||
connect(&settings().squishPath, &BaseAspect::changed,
|
connect(&settings().squishPath, &BaseAspect::changed,
|
||||||
d.get(), &SquishPluginPrivate::initializeGlobalScripts);
|
this, &SquishPlugin::initializeGlobalScripts);
|
||||||
|
|
||||||
return d->initializeGlobalScripts();
|
return initializeGlobalScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
ShutdownFlag aboutToShutdown() final
|
ShutdownFlag aboutToShutdown() final
|
||||||
@@ -130,8 +116,6 @@ private:
|
|||||||
this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished);
|
this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished);
|
||||||
return AsynchronousShutdown;
|
return AsynchronousShutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<SquishPluginPrivate> d;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Squish::Internal
|
} // Squish::Internal
|
||||||
|
Reference in New Issue
Block a user