From 420a2b4e6efdae067728d8a552016ed614f1d541 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 19 Aug 2010 15:53:29 +0200 Subject: QmlEditor: Remove QtQuick->Preview from tools menu This only works when a qmlviewer is in the PATH, which is non obvious. Removing the feature therefore completely. --- src/plugins/qmljseditor/qmljseditor.cpp | 1 - src/plugins/qmljseditor/qmljseditor.pro | 6 ++-- src/plugins/qmljseditor/qmljseditorconstants.h | 1 - src/plugins/qmljseditor/qmljseditorplugin.cpp | 29 ++------------- src/plugins/qmljseditor/qmljseditorplugin.h | 7 ---- src/plugins/qmljseditor/qmljspreviewrunner.cpp | 50 -------------------------- src/plugins/qmljseditor/qmljspreviewrunner.h | 36 ------------------- 7 files changed, 4 insertions(+), 126 deletions(-) delete mode 100644 src/plugins/qmljseditor/qmljspreviewrunner.cpp delete mode 100644 src/plugins/qmljseditor/qmljspreviewrunner.h diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 7f0a4e2477..24f9d7e541 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -570,7 +570,6 @@ QmlJSEditorEditable::QmlJSEditorEditable(QmlJSTextEditor *editor) Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); m_context << uidm->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID); m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); - m_context << uidm->uniqueIdentifier(QmlDesigner::Constants::C_QT_QUICK_TOOLS_MENU); } // Use preferred mode from Bauhaus settings diff --git a/src/plugins/qmljseditor/qmljseditor.pro b/src/plugins/qmljseditor/qmljseditor.pro index d7f95441dd..27130d97cd 100644 --- a/src/plugins/qmljseditor/qmljseditor.pro +++ b/src/plugins/qmljseditor/qmljseditor.pro @@ -20,8 +20,7 @@ HEADERS += \ qmljshighlighter.h \ qmljshoverhandler.h \ qmljsmodelmanager.h \ - qmljsmodelmanagerinterface.h \ - qmljspreviewrunner.h + qmljsmodelmanagerinterface.h SOURCES += \ qmljscodecompletion.cpp \ @@ -34,8 +33,7 @@ SOURCES += \ qmljshighlighter.cpp \ qmljshoverhandler.cpp \ qmljsmodelmanager.cpp \ - qmljsmodelmanagerinterface.cpp \ - qmljspreviewrunner.cpp + qmljsmodelmanagerinterface.cpp RESOURCES += qmljseditor.qrc OTHER_FILES += QmlJSEditor.pluginspec QmlJSEditor.mimetypes.xml diff --git a/src/plugins/qmljseditor/qmljseditorconstants.h b/src/plugins/qmljseditor/qmljseditorconstants.h index 0db49ad417..eb6989fdd3 100644 --- a/src/plugins/qmljseditor/qmljseditorconstants.h +++ b/src/plugins/qmljseditor/qmljseditorconstants.h @@ -36,7 +36,6 @@ namespace QmlJSEditor { namespace Constants { // menus -const char * const M_QTQUICK = "QtQuickDesigner.Menu"; const char * const M_CONTEXT = "QML JS Editor.ContextMenu"; const char * const RUN_SEP = "QmlJSEditor.Run.Separator"; diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 4afe4310e1..6166cb11b4 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -36,7 +36,6 @@ #include "qmljshoverhandler.h" #include "qmljsmodelmanager.h" #include "qmlfilewizard.h" -#include "qmljspreviewrunner.h" #include @@ -99,8 +98,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e addAutoReleasedObject(m_modelManager); QList context; - context << core->uniqueIDManager()->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID) - << core->uniqueIDManager()->uniqueIdentifier(QmlDesigner::Constants::C_QT_QUICK_TOOLS_MENU); + context << core->uniqueIDManager()->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID); m_editor = new QmlJSEditorFactory(this); addObject(m_editor); @@ -122,21 +120,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e Core::ActionManager *am = core->actionManager(); Core::ActionContainer *contextMenu = am->createMenu(QmlJSEditor::Constants::M_CONTEXT); - Core::ActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS); - Core::ActionContainer *menuQtQuick = am->createMenu(Constants::M_QTQUICK); - menuQtQuick->menu()->setTitle(tr("Qt Quick")); - mtools->addMenu(menuQtQuick); - m_actionPreview = new QAction(tr("&Preview"), this); - - QList toolsMenuContext = QList() - << core->uniqueIDManager()->uniqueIdentifier(QmlDesigner::Constants::C_QT_QUICK_TOOLS_MENU); - Core::Command *cmd = addToolAction(m_actionPreview, am, toolsMenuContext, - QLatin1String("QtQuick.Preview"), menuQtQuick, tr("Ctrl+Alt+R")); - connect(cmd->action(), SIGNAL(triggered()), SLOT(openPreview())); - - m_previewRunner = new QmlJSPreviewRunner(this); - m_actionPreview->setEnabled(m_previewRunner->isReady()); - + Core::Command *cmd; QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this); cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context); cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2)); @@ -172,15 +156,6 @@ void QmlJSEditorPlugin::extensionsInitialized() { } -void QmlJSEditorPlugin::openPreview() -{ - Core::EditorManager *em = Core::EditorManager::instance(); - - if (em->currentEditor() && em->currentEditor()->id() == Constants::C_QMLJSEDITOR_ID) - m_previewRunner->run(em->currentEditor()->file()->fileName()); - -} - void QmlJSEditorPlugin::initializeEditor(QmlJSEditor::Internal::QmlJSTextEditor *editor) { QTC_ASSERT(m_instance, /**/); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h index db534f0f29..d8cc225a0d 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.h +++ b/src/plugins/qmljseditor/qmljseditorplugin.h @@ -53,7 +53,6 @@ namespace Internal { class QmlJSEditorFactory; class QmlJSTextEditor; -class QmlJSPreviewRunner; class QmlJSEditorPlugin : public ExtensionSystem::IPlugin { @@ -75,18 +74,12 @@ public: public Q_SLOTS: void followSymbolUnderCursor(); -private Q_SLOTS: - void openPreview(); - private: Core::Command *addToolAction(QAction *a, Core::ActionManager *am, const QList &context, const QString &name, Core::ActionContainer *c1, const QString &keySequence); static QmlJSEditorPlugin *m_instance; - QAction *m_actionPreview; - QmlJSPreviewRunner *m_previewRunner; - ModelManagerInterface *m_modelManager; QmlFileWizard *m_wizard; QmlJSEditorFactory *m_editor; diff --git a/src/plugins/qmljseditor/qmljspreviewrunner.cpp b/src/plugins/qmljseditor/qmljspreviewrunner.cpp deleted file mode 100644 index 7611cecc2b..0000000000 --- a/src/plugins/qmljseditor/qmljspreviewrunner.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "qmljspreviewrunner.h" - -#include -#include - -#include -#include - -#include - -namespace QmlJSEditor { -namespace Internal { - -QmlJSPreviewRunner::QmlJSPreviewRunner(QObject *parent) : - QObject(parent) -{ - // prepend creator/bin dir to search path (only useful for special creator-qml package) - const QString searchPath = QCoreApplication::applicationDirPath() - + Utils::SynchronousProcess::pathSeparator() - + QString(qgetenv("PATH")); - m_qmlViewerDefaultPath = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer")); - - ProjectExplorer::Environment environment = ProjectExplorer::Environment::systemEnvironment(); - m_applicationLauncher.setEnvironment(environment.toStringList()); -} - -bool QmlJSPreviewRunner::isReady() const -{ - return !m_qmlViewerDefaultPath.isEmpty(); -} - -void QmlJSPreviewRunner::run(const QString &filename) -{ - QString errorMessage; - if (!filename.isEmpty()) { - m_applicationLauncher.start(ProjectExplorer::ApplicationLauncher::Gui, m_qmlViewerDefaultPath, - QStringList() << filename); - - } else { - errorMessage = "No file specified."; - } - - if (!errorMessage.isEmpty()) - QMessageBox::warning(0, tr("Failed to preview Qt Quick file"), - tr("Could not preview Qt Quick (QML) file. Reason: \n%1").arg(errorMessage)); -} - - -} // namespace Internal -} // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljspreviewrunner.h b/src/plugins/qmljseditor/qmljspreviewrunner.h deleted file mode 100644 index 1a3c26370f..0000000000 --- a/src/plugins/qmljseditor/qmljspreviewrunner.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef QMLJSPREVIEWRUNNER_H -#define QMLJSPREVIEWRUNNER_H - -#include - -#include - -namespace QmlJSEditor { -namespace Internal { - -class QmlJSPreviewRunner : public QObject -{ - Q_OBJECT -public: - explicit QmlJSPreviewRunner(QObject *parent = 0); - - bool isReady() const; - void run(const QString &filename); - -signals: - -public slots: - -private: - QString m_qmlViewerDefaultPath; - - ProjectExplorer::ApplicationLauncher m_applicationLauncher; - -}; - - -} // namespace Internal -} // namespace QmlJSEditor - - -#endif // QMLJSPREVIEWRUNNER_H -- cgit v1.2.1