2010-01-07 12:14:35 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-01-07 15:13:01 +01:00
|
|
|
#include "exception.h"
|
2010-01-07 12:14:35 +01:00
|
|
|
#include "qmldesignerplugin.h"
|
|
|
|
|
#include "qmldesignerconstants.h"
|
|
|
|
|
#include "pluginmanager.h"
|
2010-02-26 11:08:17 +01:00
|
|
|
#include "designmodewidget.h"
|
2010-02-09 16:01:47 +01:00
|
|
|
#include "settingspage.h"
|
2010-02-26 11:08:17 +01:00
|
|
|
#include "designmodecontext.h"
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2010-02-25 16:54:42 +01:00
|
|
|
#include <qmljseditor/qmljseditorconstants.h>
|
|
|
|
|
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2010-06-25 17:37:59 +02:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2010-02-25 16:54:42 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2010-11-02 16:53:56 +01:00
|
|
|
#include <coreplugin/uniqueidmanager.h>
|
2010-06-25 17:37:59 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/designmode.h>
|
2010-01-07 12:14:35 +01:00
|
|
|
#include <coreplugin/dialogs/iwizard.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2010-06-25 17:37:59 +02:00
|
|
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
2010-02-26 11:08:17 +01:00
|
|
|
#include <coreplugin/editormanager/openeditorsmodel.h>
|
2010-06-25 17:37:59 +02:00
|
|
|
#include <coreplugin/icontext.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/mimedatabase.h>
|
2010-02-26 11:08:17 +01:00
|
|
|
#include <coreplugin/modemanager.h>
|
2010-06-25 17:37:59 +02:00
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
#include <integrationcore.h>
|
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QFileInfo>
|
2010-01-07 12:14:35 +01:00
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
|
#include <QtCore/qplugin.h>
|
2010-02-26 11:08:17 +01:00
|
|
|
#include <QtCore/QDebug>
|
2010-03-24 12:55:10 +01:00
|
|
|
#include <QtCore/QProcessEnvironment>
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
namespace QmlDesigner {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
BauhausPlugin *BauhausPlugin::m_pluginInstance = 0;
|
|
|
|
|
|
2010-03-24 12:55:10 +01:00
|
|
|
bool shouldAssertInException()
|
|
|
|
|
{
|
|
|
|
|
QProcessEnvironment processEnvironment = QProcessEnvironment::systemEnvironment();
|
|
|
|
|
return !processEnvironment.value("QMLDESIGNER_ASSERT_ON_EXCEPTION").isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
BauhausPlugin::BauhausPlugin() :
|
2010-02-26 11:08:17 +01:00
|
|
|
m_designerCore(0),
|
|
|
|
|
m_designMode(0),
|
|
|
|
|
m_isActive(false),
|
|
|
|
|
m_revertToSavedAction(new QAction(this)),
|
|
|
|
|
m_saveAction(new QAction(this)),
|
|
|
|
|
m_saveAsAction(new QAction(this)),
|
|
|
|
|
m_closeCurrentEditorAction(new QAction(this)),
|
|
|
|
|
m_closeAllEditorsAction(new QAction(this)),
|
|
|
|
|
m_closeOtherEditorsAction(new QAction(this))
|
2010-01-07 12:14:35 +01:00
|
|
|
{
|
2010-03-12 16:02:23 +01:00
|
|
|
|
2010-01-07 15:13:01 +01:00
|
|
|
// Exceptions should never ever assert: they are handled in a number of
|
|
|
|
|
// places where it is actually VALID AND EXPECTED BEHAVIOUR to get an
|
|
|
|
|
// exception.
|
|
|
|
|
// If you still want to see exactly where the exception originally
|
|
|
|
|
// occurred, then you have various ways to do this:
|
|
|
|
|
// 1. set a breakpoint on the constructor of the exception
|
|
|
|
|
// 2. in gdb: "catch throw" or "catch throw Exception"
|
|
|
|
|
// 3. set a breakpoint on __raise_exception()
|
|
|
|
|
// And with gdb, you can even do this from your ~/.gdbinit file.
|
2010-03-24 12:55:10 +01:00
|
|
|
// DnD is not working with gdb so this is still needed to get a good stacktrace
|
|
|
|
|
|
|
|
|
|
Exception::setShouldAssert(shouldAssertInException());
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BauhausPlugin::~BauhausPlugin()
|
|
|
|
|
{
|
|
|
|
|
delete m_designerCore;
|
2010-02-26 11:08:17 +01:00
|
|
|
Core::ICore::instance()->removeContextObject(m_context);
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// INHERITED FROM ExtensionSystem::Plugin
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
bool BauhausPlugin::initialize(const QStringList & /*arguments*/, QString *error_message/* = 0*/) // =0;
|
|
|
|
|
{
|
|
|
|
|
Core::ICore *core = Core::ICore::instance();
|
|
|
|
|
|
2010-11-17 12:59:08 +01:00
|
|
|
const Core::Context switchContext(QmlDesigner::Constants::C_QMLDESIGNER,
|
2010-06-28 10:07:05 +02:00
|
|
|
QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
|
2010-02-25 16:54:42 +01:00
|
|
|
|
|
|
|
|
Core::ActionManager *am = core->actionManager();
|
|
|
|
|
|
|
|
|
|
QAction *switchAction = new QAction(tr("Switch Text/Design"), this);
|
|
|
|
|
Core::Command *command = am->registerAction(switchAction, QmlDesigner::Constants::SWITCH_TEXT_DESIGN, switchContext);
|
|
|
|
|
command->setDefaultKeySequence(QKeySequence(Qt::Key_F4));
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
m_designerCore = new QmlDesigner::IntegrationCore;
|
2010-02-09 11:09:11 +01:00
|
|
|
m_pluginInstance = this;
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
const QString pluginPath = QCoreApplication::applicationDirPath() + "/../PlugIns/QmlDesigner";
|
|
|
|
|
#else
|
|
|
|
|
const QString pluginPath = QCoreApplication::applicationDirPath() + "/../"
|
|
|
|
|
+ QLatin1String(IDE_LIBRARY_BASENAME) + "/qmldesigner";
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
m_designerCore->pluginManager()->setPluginPaths(QStringList() << pluginPath);
|
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
createDesignModeWidget();
|
2010-03-08 14:54:24 +01:00
|
|
|
connect(switchAction, SIGNAL(triggered()), this, SLOT(switchTextDesign()));
|
2010-02-26 11:08:17 +01:00
|
|
|
|
2010-02-09 16:01:47 +01:00
|
|
|
addAutoReleasedObject(new SettingsPage);
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2010-03-17 14:14:00 +01:00
|
|
|
|
2010-08-12 15:46:56 +02:00
|
|
|
m_settings.fromSettings(core->settings());
|
2010-07-06 11:11:27 +02:00
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
error_message->clear();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
void BauhausPlugin::createDesignModeWidget()
|
|
|
|
|
{
|
|
|
|
|
Core::ICore *creatorCore = Core::ICore::instance();
|
|
|
|
|
Core::ActionManager *actionManager = creatorCore->actionManager();
|
|
|
|
|
m_editorManager = creatorCore->editorManager();
|
|
|
|
|
Core::ActionContainer *editMenu = actionManager->actionContainer(Core::Constants::M_EDIT);
|
|
|
|
|
|
|
|
|
|
m_mainWidget = new DesignModeWidget;
|
|
|
|
|
|
|
|
|
|
m_context = new DesignModeContext(m_mainWidget);
|
|
|
|
|
creatorCore->addContextObject(m_context);
|
2010-11-17 12:59:08 +01:00
|
|
|
Core::Context qmlDesignerMainContext(Constants::C_QMLDESIGNER);
|
|
|
|
|
Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR);
|
2010-02-26 11:08:17 +01:00
|
|
|
|
|
|
|
|
// Revert to saved
|
|
|
|
|
actionManager->registerAction(m_revertToSavedAction,
|
2010-11-17 12:59:08 +01:00
|
|
|
Core::Constants::REVERTTOSAVED, qmlDesignerMainContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
connect(m_revertToSavedAction, SIGNAL(triggered()), m_editorManager, SLOT(revertToSaved()));
|
|
|
|
|
|
|
|
|
|
//Save
|
2010-11-17 12:59:08 +01:00
|
|
|
actionManager->registerAction(m_saveAction, Core::Constants::SAVE, qmlDesignerMainContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
connect(m_saveAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFile()));
|
|
|
|
|
|
|
|
|
|
//Save As
|
2010-11-17 12:59:08 +01:00
|
|
|
actionManager->registerAction(m_saveAsAction, Core::Constants::SAVEAS, qmlDesignerMainContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
connect(m_saveAsAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFileAs()));
|
|
|
|
|
|
|
|
|
|
//Close Editor
|
2010-11-17 12:59:08 +01:00
|
|
|
actionManager->registerAction(m_closeCurrentEditorAction, Core::Constants::CLOSE, qmlDesignerMainContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
connect(m_closeCurrentEditorAction, SIGNAL(triggered()), m_editorManager, SLOT(closeEditor()));
|
|
|
|
|
|
|
|
|
|
//Close All
|
2010-11-17 12:59:08 +01:00
|
|
|
actionManager->registerAction(m_closeAllEditorsAction, Core::Constants::CLOSEALL, qmlDesignerMainContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
connect(m_closeAllEditorsAction, SIGNAL(triggered()), m_editorManager, SLOT(closeAllEditors()));
|
|
|
|
|
|
|
|
|
|
//Close All Others Action
|
2010-11-17 12:59:08 +01:00
|
|
|
actionManager->registerAction(m_closeOtherEditorsAction, Core::Constants::CLOSEOTHERS, qmlDesignerMainContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
connect(m_closeOtherEditorsAction, SIGNAL(triggered()), m_editorManager, SLOT(closeOtherEditors()));
|
|
|
|
|
|
|
|
|
|
// Undo / Redo
|
2010-11-17 12:59:08 +01:00
|
|
|
actionManager->registerAction(m_mainWidget->undoAction(), Core::Constants::UNDO, qmlDesignerMainContext);
|
|
|
|
|
actionManager->registerAction(m_mainWidget->redoAction(), Core::Constants::REDO, qmlDesignerMainContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
|
|
|
|
|
Core::Command *command;
|
|
|
|
|
command = actionManager->registerAction(m_mainWidget->deleteAction(),
|
2010-11-17 12:59:08 +01:00
|
|
|
QmlDesigner::Constants::DELETE, qmlDesignerFormEditorContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence::Delete);
|
|
|
|
|
command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes
|
|
|
|
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
|
|
|
|
|
|
|
|
|
command = actionManager->registerAction(m_mainWidget->cutAction(),
|
2010-11-17 12:59:08 +01:00
|
|
|
Core::Constants::CUT, qmlDesignerFormEditorContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence::Cut);
|
|
|
|
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
|
|
|
|
|
|
|
|
|
command = actionManager->registerAction(m_mainWidget->copyAction(),
|
2010-11-17 12:59:08 +01:00
|
|
|
Core::Constants::COPY, qmlDesignerFormEditorContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence::Copy);
|
|
|
|
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
|
|
|
|
|
|
|
|
|
command = actionManager->registerAction(m_mainWidget->pasteAction(),
|
2010-11-17 12:59:08 +01:00
|
|
|
Core::Constants::PASTE, qmlDesignerFormEditorContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence::Paste);
|
|
|
|
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
|
|
|
|
|
|
|
|
|
command = actionManager->registerAction(m_mainWidget->selectAllAction(),
|
2010-11-17 12:59:08 +01:00
|
|
|
Core::Constants::SELECTALL, qmlDesignerFormEditorContext);
|
2010-02-26 11:08:17 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence::SelectAll);
|
|
|
|
|
editMenu->addAction(command, Core::Constants::G_EDIT_SELECTALL);
|
|
|
|
|
|
2010-04-26 13:53:26 +02:00
|
|
|
Core::ActionContainer *viewsMenu = actionManager->actionContainer(Core::Constants::M_WINDOW_VIEWS);
|
|
|
|
|
|
|
|
|
|
command = actionManager->registerAction(m_mainWidget->toggleLeftSidebarAction(),
|
2010-11-17 12:59:08 +01:00
|
|
|
Constants::TOGGLE_LEFT_SIDEBAR, qmlDesignerMainContext);
|
2010-04-26 13:53:26 +02:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
command->setDefaultKeySequence(QKeySequence("Ctrl+Alt+0"));
|
|
|
|
|
viewsMenu->addAction(command);
|
|
|
|
|
|
|
|
|
|
command = actionManager->registerAction(m_mainWidget->toggleRightSidebarAction(),
|
2010-11-17 12:59:08 +01:00
|
|
|
Constants::TOGGLE_RIGHT_SIDEBAR, qmlDesignerMainContext);
|
2010-04-26 11:30:14 +02:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
2010-04-26 13:53:26 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence("Ctrl+Alt+Shift+0"));
|
2010-04-26 11:30:14 +02:00
|
|
|
viewsMenu->addAction(command);
|
|
|
|
|
|
2010-04-26 14:40:40 +02:00
|
|
|
command = actionManager->registerAction(m_mainWidget->restoreDefaultViewAction(),
|
2010-11-17 12:59:08 +01:00
|
|
|
Constants::RESTORE_DEFAULT_VIEW, qmlDesignerMainContext);
|
2010-04-26 14:40:40 +02:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
viewsMenu->addAction(command);
|
|
|
|
|
|
|
|
|
|
command = actionManager->registerAction(m_mainWidget->hideSidebarsAction(),
|
2010-11-17 12:59:08 +01:00
|
|
|
Core::Constants::TOGGLE_SIDEBAR, qmlDesignerMainContext);
|
2010-04-26 14:40:40 +02:00
|
|
|
|
2010-04-09 17:09:03 +02:00
|
|
|
#ifdef Q_OS_MACX
|
2010-02-26 11:08:17 +01:00
|
|
|
// add second shortcut to trigger delete
|
|
|
|
|
QAction *deleteAction = new QAction(m_mainWidget);
|
|
|
|
|
deleteAction->setShortcut(QKeySequence(QLatin1String("Backspace")));
|
|
|
|
|
connect(deleteAction, SIGNAL(triggered()), m_mainWidget->deleteAction(),
|
|
|
|
|
SIGNAL(triggered()));
|
|
|
|
|
|
|
|
|
|
m_mainWidget->addAction(deleteAction);
|
2010-04-09 17:09:03 +02:00
|
|
|
#endif // Q_OS_MACX
|
2010-02-26 11:08:17 +01:00
|
|
|
|
2010-02-26 14:28:26 +01:00
|
|
|
connect(m_editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)),
|
|
|
|
|
this, SLOT(updateEditor(Core::IEditor*)));
|
2010-02-26 11:08:17 +01:00
|
|
|
|
|
|
|
|
connect(m_editorManager, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
|
|
|
|
|
this, SLOT(textEditorsClosed(QList<Core::IEditor*>)));
|
|
|
|
|
|
2010-06-25 12:56:16 +02:00
|
|
|
connect(creatorCore, SIGNAL(contextChanged(Core::IContext*,Core::Context)),
|
|
|
|
|
this, SLOT(contextChanged(Core::IContext*,Core::Context)));
|
2010-03-26 12:39:26 +01:00
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-26 14:28:26 +01:00
|
|
|
void BauhausPlugin::updateEditor(Core::IEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
Core::ICore *creatorCore = Core::ICore::instance();
|
2010-02-26 14:44:37 +01:00
|
|
|
if (editor && editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID
|
2010-02-26 14:28:26 +01:00
|
|
|
&& creatorCore->modeManager()->currentMode() == m_designMode)
|
|
|
|
|
{
|
|
|
|
|
m_mainWidget->showEditor(editor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-25 12:56:16 +02:00
|
|
|
void BauhausPlugin::contextChanged(Core::IContext *context, const Core::Context &additionalContexts)
|
2010-03-16 17:17:09 +01:00
|
|
|
{
|
2010-03-26 12:39:26 +01:00
|
|
|
Q_UNUSED(context)
|
|
|
|
|
|
2010-06-25 18:05:09 +02:00
|
|
|
foreach (int additionalContext, additionalContexts) {
|
|
|
|
|
if (m_context->context().contains(additionalContext)) {
|
2010-03-26 12:39:26 +01:00
|
|
|
m_isActive = true;
|
|
|
|
|
m_mainWidget->showEditor(m_editorManager->currentEditor());
|
|
|
|
|
return;
|
2010-03-16 17:17:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
2010-03-26 12:39:26 +01:00
|
|
|
|
|
|
|
|
if (m_isActive) {
|
|
|
|
|
m_isActive = false;
|
|
|
|
|
m_mainWidget->showEditor(0);
|
|
|
|
|
}
|
2010-03-16 17:17:09 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
void BauhausPlugin::textEditorsClosed(QList<Core::IEditor*> editors)
|
|
|
|
|
{
|
|
|
|
|
m_mainWidget->closeEditors(editors);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// copied from EditorManager::updateActions
|
|
|
|
|
void BauhausPlugin::updateActions(Core::IEditor* editor)
|
|
|
|
|
{
|
|
|
|
|
Core::IEditor *curEditor = editor;
|
|
|
|
|
int openedCount = m_editorManager->openedEditors().count()
|
|
|
|
|
+ m_editorManager->openedEditorsModel()->restoredEditors().count();
|
|
|
|
|
|
|
|
|
|
QString fName;
|
|
|
|
|
if (curEditor) {
|
|
|
|
|
if (!curEditor->file()->fileName().isEmpty()) {
|
|
|
|
|
QFileInfo fi(curEditor->file()->fileName());
|
|
|
|
|
fName = fi.fileName();
|
|
|
|
|
} else {
|
|
|
|
|
fName = curEditor->displayName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_saveAction->setEnabled(curEditor != 0 && curEditor->file()->isModified());
|
|
|
|
|
m_saveAsAction->setEnabled(curEditor != 0 && curEditor->file()->isSaveAsAllowed());
|
|
|
|
|
m_revertToSavedAction->setEnabled(curEditor != 0
|
|
|
|
|
&& !curEditor->file()->fileName().isEmpty()
|
|
|
|
|
&& curEditor->file()->isModified());
|
|
|
|
|
|
|
|
|
|
QString quotedName;
|
|
|
|
|
if (!fName.isEmpty())
|
|
|
|
|
quotedName = '"' + fName + '"';
|
|
|
|
|
m_saveAsAction->setText(tr("Save %1 As...").arg(quotedName));
|
|
|
|
|
m_saveAction->setText(tr("&Save %1").arg(quotedName));
|
|
|
|
|
m_revertToSavedAction->setText(tr("Revert %1 to Saved").arg(quotedName));
|
|
|
|
|
|
|
|
|
|
m_closeCurrentEditorAction->setEnabled(curEditor != 0);
|
|
|
|
|
m_closeCurrentEditorAction->setText(tr("Close %1").arg(quotedName));
|
|
|
|
|
m_closeAllEditorsAction->setEnabled(openedCount > 0);
|
|
|
|
|
m_closeOtherEditorsAction->setEnabled(openedCount > 1);
|
|
|
|
|
m_closeOtherEditorsAction->setText((openedCount > 1 ? tr("Close All Except %1").arg(quotedName) : tr("Close Others")));
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
void BauhausPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2010-02-26 11:08:17 +01:00
|
|
|
m_designMode = ExtensionSystem::PluginManager::instance()->getObject<Core::DesignMode>();
|
|
|
|
|
|
2011-03-22 12:54:06 +01:00
|
|
|
m_mimeTypes << "application/x-qml";
|
2010-02-26 11:08:17 +01:00
|
|
|
|
2010-03-19 16:07:04 +01:00
|
|
|
m_designMode->registerDesignWidget(m_mainWidget, m_mimeTypes, m_context->context());
|
2010-02-26 11:08:17 +01:00
|
|
|
connect(m_designMode, SIGNAL(actionsUpdated(Core::IEditor*)), SLOT(updateActions(Core::IEditor*)));
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
BauhausPlugin *BauhausPlugin::pluginInstance()
|
|
|
|
|
{
|
|
|
|
|
return m_pluginInstance;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-25 16:54:42 +01:00
|
|
|
void BauhausPlugin::switchTextDesign()
|
|
|
|
|
{
|
|
|
|
|
Core::ModeManager *modeManager = Core::ModeManager::instance();
|
2010-02-26 11:08:17 +01:00
|
|
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
|
|
|
|
Core::IEditor *editor = editorManager->currentEditor();
|
2010-02-25 16:54:42 +01:00
|
|
|
|
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
if (modeManager->currentMode()->id() == Core::Constants::MODE_EDIT) {
|
2010-03-08 14:54:24 +01:00
|
|
|
if (editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
2010-02-26 11:08:17 +01:00
|
|
|
modeManager->activateMode(Core::Constants::MODE_DESIGN);
|
2010-03-08 14:54:24 +01:00
|
|
|
m_mainWidget->setFocus();
|
|
|
|
|
}
|
2010-02-26 11:08:17 +01:00
|
|
|
} else if (modeManager->currentMode()->id() == Core::Constants::MODE_DESIGN) {
|
|
|
|
|
modeManager->activateMode(Core::Constants::MODE_EDIT);
|
2010-02-25 16:54:42 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
DesignerSettings BauhausPlugin::settings() const
|
|
|
|
|
{
|
|
|
|
|
return m_settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BauhausPlugin::setSettings(const DesignerSettings &s)
|
|
|
|
|
{
|
|
|
|
|
if (s != m_settings) {
|
|
|
|
|
m_settings = s;
|
|
|
|
|
if (QSettings *settings = Core::ICore::instance()->settings())
|
|
|
|
|
m_settings.toSettings(settings);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_EXPORT_PLUGIN(QmlDesigner::Internal::BauhausPlugin)
|