forked from qt-creator/qt-creator
qmlpreview: prepare plugin to have an external client
- export the plugin andd add client creator API to be able to implement external debugtranslationclients - use the private/qqmldebugtranslationprotocol_p.h from Qt5::QmlDebugPrivate - have a basic client implementation which cares about changing language - remove out of date elide warning implementation - remove old ui - remove the menu entry The old client implementation is incompatible with the will be introduced service and there was never an officially released compatible service. Therefore we can remove the old client implementation without causing any harm. Change-Id: I26b5e8a99ba30ae6377443b3fffb05901b1cac28 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -26,8 +26,6 @@
|
||||
#include "qmlpreviewplugin.h"
|
||||
#include "qmlpreviewruncontrol.h"
|
||||
|
||||
#include "qmldebugtranslationwidget.h"
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
#include "tests/qmlpreviewclient_test.h"
|
||||
#include "tests/qmlpreviewplugin_test.h"
|
||||
@@ -67,7 +65,6 @@
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace QmlPreview {
|
||||
namespace Internal {
|
||||
|
||||
class QmlPreviewParser : public QObject
|
||||
{
|
||||
@@ -151,8 +148,7 @@ public:
|
||||
float m_zoomFactor = -1.0;
|
||||
QmlPreview::QmlPreviewFpsHandler m_fpsHandler = nullptr;
|
||||
QString m_localeIsoCode;
|
||||
bool m_translationElideWarning = false;
|
||||
QPointer<QmlDebugTranslationWidget> m_qmlDebugTranslationWidget;
|
||||
QmlDebugTranslationClientCreator m_createDebugTranslationClientMethod;
|
||||
|
||||
RunWorkerFactory localRunWorkerFactory{
|
||||
RunWorkerFactory::make<LocalQmlPreviewSupport>(),
|
||||
@@ -170,7 +166,7 @@ public:
|
||||
m_fpsHandler,
|
||||
m_zoomFactor,
|
||||
m_localeIsoCode,
|
||||
m_translationElideWarning
|
||||
m_createDebugTranslationClientMethod
|
||||
});
|
||||
connect(q, &QmlPreviewPlugin::updatePreviews,
|
||||
runner, &QmlPreviewRunner::loadFile);
|
||||
@@ -182,8 +178,6 @@ public:
|
||||
runner, &QmlPreviewRunner::zoom);
|
||||
connect(q, &QmlPreviewPlugin::localeIsoCodeChanged,
|
||||
runner, &QmlPreviewRunner::language);
|
||||
connect(q, &QmlPreviewPlugin::elideWarningChanged,
|
||||
runner, &QmlPreviewRunner::changeElideWarning);
|
||||
|
||||
connect(runner, &RunWorker::started, this, [this, runControl] {
|
||||
addPreview(runControl);
|
||||
@@ -222,50 +216,6 @@ QmlPreviewPluginPrivate::QmlPreviewPluginPrivate(QmlPreviewPlugin *parent)
|
||||
Core::ActionManager::registerAction(action, "QmlPreview.RunPreview"),
|
||||
Constants::G_BUILD_RUN);
|
||||
|
||||
action = new QAction(QmlPreviewPlugin::tr("Test Translations"), this);
|
||||
action->setToolTip(QLatin1String("Runs the preview with all available translations and collects all issues."));
|
||||
action->setEnabled(SessionManager::startupProject() != nullptr);
|
||||
connect(SessionManager::instance(), &SessionManager::startupProjectChanged, action,
|
||||
&QAction::setEnabled);
|
||||
connect(action, &QAction::triggered, this, [this]() {
|
||||
if (SessionManager::startupProject()) {
|
||||
// Deletion for this widget is taken care of in aboutToShutdown() and registerWindow()
|
||||
m_qmlDebugTranslationWidget = new QmlDebugTranslationWidget();
|
||||
Core::ICore::registerWindow(m_qmlDebugTranslationWidget, Core::Context("Core.DebugTranslation"));
|
||||
m_qmlDebugTranslationWidget->show();
|
||||
}
|
||||
});
|
||||
menu->addAction(
|
||||
Core::ActionManager::registerAction(action, "QmlPreview.TestTranslations"),
|
||||
Constants::G_BUILD_RUN);
|
||||
auto updateTestTranslationAction = [action]() {
|
||||
bool showTestTranslationAction = false;
|
||||
bool enableTestTranslationAction = false;
|
||||
QtSupport::BaseQtVersion *activeQt{};
|
||||
if (auto project = SessionManager::startupProject()) {
|
||||
if (auto target = project->activeTarget()) {
|
||||
if (auto activeKit = target->kit())
|
||||
activeQt = QtSupport::QtKitAspect::qtVersion(activeKit);
|
||||
}
|
||||
}
|
||||
for (auto qtVersion : QtSupport::QtVersionManager::versions()) {
|
||||
if (qtVersion->features().contains("QtStudio")) {
|
||||
showTestTranslationAction = true;
|
||||
if (qtVersion == activeQt)
|
||||
enableTestTranslationAction = true;
|
||||
}
|
||||
}
|
||||
action->setVisible(showTestTranslationAction);
|
||||
action->setEnabled(enableTestTranslationAction);
|
||||
};
|
||||
connect(ProjectExplorer::SessionManager::instance(),
|
||||
&ProjectExplorer::SessionManager::startupProjectChanged,
|
||||
updateTestTranslationAction);
|
||||
|
||||
connect(QtSupport::QtVersionManager::instance(),
|
||||
&QtSupport::QtVersionManager::qtVersionsChanged,
|
||||
updateTestTranslationAction);
|
||||
|
||||
menu = Core::ActionManager::actionContainer(Constants::M_FILECONTEXT);
|
||||
action = new QAction(QmlPreviewPlugin::tr("Preview File"), this);
|
||||
action->setEnabled(false);
|
||||
@@ -314,7 +264,6 @@ ExtensionSystem::IPlugin::ShutdownFlag QmlPreviewPlugin::aboutToShutdown()
|
||||
{
|
||||
d->m_parseThread.quit();
|
||||
d->m_parseThread.wait();
|
||||
delete d->m_qmlDebugTranslationWidget;
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
@@ -410,15 +359,9 @@ void QmlPreviewPlugin::setLocaleIsoCode(const QString &localeIsoCode)
|
||||
emit localeIsoCodeChanged(d->m_localeIsoCode);
|
||||
}
|
||||
|
||||
bool QmlPreviewPlugin::elideWarning() const
|
||||
void QmlPreviewPlugin::setQmlDebugTranslationClientCreator(QmlDebugTranslationClientCreator creator)
|
||||
{
|
||||
return d->m_translationElideWarning;
|
||||
}
|
||||
|
||||
void QmlPreviewPlugin::changeElideWarning(bool elideWarning)
|
||||
{
|
||||
d->m_translationElideWarning = elideWarning;
|
||||
emit elideWarningChanged(elideWarning);
|
||||
d->m_createDebugTranslationClientMethod = creator;
|
||||
}
|
||||
|
||||
void QmlPreviewPlugin::setFileLoader(QmlPreviewFileLoader fileLoader)
|
||||
@@ -588,7 +531,6 @@ void QmlPreviewParser::parse(const QString &name, const QByteArray &contents,
|
||||
emit failure();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlPreview
|
||||
|
||||
#include <qmlpreviewplugin.moc>
|
||||
|
||||
Reference in New Issue
Block a user