forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -570,7 +570,6 @@ QmlJSEditorEditable::QmlJSEditorEditable(QmlJSTextEditor *editor)
|
|||||||
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
|
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
|
||||||
m_context << uidm->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
|
m_context << uidm->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
|
||||||
m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
|
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
|
// Use preferred mode from Bauhaus settings
|
||||||
|
@@ -20,8 +20,7 @@ HEADERS += \
|
|||||||
qmljshighlighter.h \
|
qmljshighlighter.h \
|
||||||
qmljshoverhandler.h \
|
qmljshoverhandler.h \
|
||||||
qmljsmodelmanager.h \
|
qmljsmodelmanager.h \
|
||||||
qmljsmodelmanagerinterface.h \
|
qmljsmodelmanagerinterface.h
|
||||||
qmljspreviewrunner.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
qmljscodecompletion.cpp \
|
qmljscodecompletion.cpp \
|
||||||
@@ -34,8 +33,7 @@ SOURCES += \
|
|||||||
qmljshighlighter.cpp \
|
qmljshighlighter.cpp \
|
||||||
qmljshoverhandler.cpp \
|
qmljshoverhandler.cpp \
|
||||||
qmljsmodelmanager.cpp \
|
qmljsmodelmanager.cpp \
|
||||||
qmljsmodelmanagerinterface.cpp \
|
qmljsmodelmanagerinterface.cpp
|
||||||
qmljspreviewrunner.cpp
|
|
||||||
|
|
||||||
RESOURCES += qmljseditor.qrc
|
RESOURCES += qmljseditor.qrc
|
||||||
OTHER_FILES += QmlJSEditor.pluginspec QmlJSEditor.mimetypes.xml
|
OTHER_FILES += QmlJSEditor.pluginspec QmlJSEditor.mimetypes.xml
|
||||||
|
@@ -36,7 +36,6 @@ namespace QmlJSEditor {
|
|||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
// menus
|
// menus
|
||||||
const char * const M_QTQUICK = "QtQuickDesigner.Menu";
|
|
||||||
const char * const M_CONTEXT = "QML JS Editor.ContextMenu";
|
const char * const M_CONTEXT = "QML JS Editor.ContextMenu";
|
||||||
|
|
||||||
const char * const RUN_SEP = "QmlJSEditor.Run.Separator";
|
const char * const RUN_SEP = "QmlJSEditor.Run.Separator";
|
||||||
|
@@ -36,7 +36,6 @@
|
|||||||
#include "qmljshoverhandler.h"
|
#include "qmljshoverhandler.h"
|
||||||
#include "qmljsmodelmanager.h"
|
#include "qmljsmodelmanager.h"
|
||||||
#include "qmlfilewizard.h"
|
#include "qmlfilewizard.h"
|
||||||
#include "qmljspreviewrunner.h"
|
|
||||||
|
|
||||||
#include <qmldesigner/qmldesignerconstants.h>
|
#include <qmldesigner/qmldesignerconstants.h>
|
||||||
|
|
||||||
@@ -99,8 +98,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
|
|||||||
addAutoReleasedObject(m_modelManager);
|
addAutoReleasedObject(m_modelManager);
|
||||||
|
|
||||||
QList<int> context;
|
QList<int> context;
|
||||||
context << core->uniqueIDManager()->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
|
context << core->uniqueIDManager()->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
|
||||||
<< core->uniqueIDManager()->uniqueIdentifier(QmlDesigner::Constants::C_QT_QUICK_TOOLS_MENU);
|
|
||||||
|
|
||||||
m_editor = new QmlJSEditorFactory(this);
|
m_editor = new QmlJSEditorFactory(this);
|
||||||
addObject(m_editor);
|
addObject(m_editor);
|
||||||
@@ -122,21 +120,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
|
|||||||
Core::ActionManager *am = core->actionManager();
|
Core::ActionManager *am = core->actionManager();
|
||||||
Core::ActionContainer *contextMenu = am->createMenu(QmlJSEditor::Constants::M_CONTEXT);
|
Core::ActionContainer *contextMenu = am->createMenu(QmlJSEditor::Constants::M_CONTEXT);
|
||||||
|
|
||||||
Core::ActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS);
|
Core::Command *cmd;
|
||||||
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<int> toolsMenuContext = QList<int>()
|
|
||||||
<< 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());
|
|
||||||
|
|
||||||
QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this);
|
QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this);
|
||||||
cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context);
|
cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
|
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)
|
void QmlJSEditorPlugin::initializeEditor(QmlJSEditor::Internal::QmlJSTextEditor *editor)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_instance, /**/);
|
QTC_ASSERT(m_instance, /**/);
|
||||||
|
@@ -53,7 +53,6 @@ namespace Internal {
|
|||||||
|
|
||||||
class QmlJSEditorFactory;
|
class QmlJSEditorFactory;
|
||||||
class QmlJSTextEditor;
|
class QmlJSTextEditor;
|
||||||
class QmlJSPreviewRunner;
|
|
||||||
|
|
||||||
class QmlJSEditorPlugin : public ExtensionSystem::IPlugin
|
class QmlJSEditorPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
@@ -75,18 +74,12 @@ public:
|
|||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void followSymbolUnderCursor();
|
void followSymbolUnderCursor();
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void openPreview();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::Command *addToolAction(QAction *a, Core::ActionManager *am, const QList<int> &context, const QString &name,
|
Core::Command *addToolAction(QAction *a, Core::ActionManager *am, const QList<int> &context, const QString &name,
|
||||||
Core::ActionContainer *c1, const QString &keySequence);
|
Core::ActionContainer *c1, const QString &keySequence);
|
||||||
|
|
||||||
static QmlJSEditorPlugin *m_instance;
|
static QmlJSEditorPlugin *m_instance;
|
||||||
|
|
||||||
QAction *m_actionPreview;
|
|
||||||
QmlJSPreviewRunner *m_previewRunner;
|
|
||||||
|
|
||||||
ModelManagerInterface *m_modelManager;
|
ModelManagerInterface *m_modelManager;
|
||||||
QmlFileWizard *m_wizard;
|
QmlFileWizard *m_wizard;
|
||||||
QmlJSEditorFactory *m_editor;
|
QmlJSEditorFactory *m_editor;
|
||||||
|
@@ -1,50 +0,0 @@
|
|||||||
#include "qmljspreviewrunner.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/environment.h>
|
|
||||||
#include <utils/synchronousprocess.h>
|
|
||||||
|
|
||||||
#include <QtGui/QMessageBox>
|
|
||||||
#include <QtGui/QApplication>
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
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
|
|
@@ -1,36 +0,0 @@
|
|||||||
#ifndef QMLJSPREVIEWRUNNER_H
|
|
||||||
#define QMLJSPREVIEWRUNNER_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <projectexplorer/applicationlauncher.h>
|
|
||||||
|
|
||||||
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
|
|
Reference in New Issue
Block a user