forked from qt-creator/qt-creator
Design mode integration
Moved Qt Designer to open from Design Mode. Also, Design mode is now global, and created in coreplugin. Other plugins can register themselves to it.
This commit is contained in:
@@ -63,8 +63,10 @@ const char * const IDE_REVISION_STR = "";
|
|||||||
//modes
|
//modes
|
||||||
const char * const MODE_WELCOME = "Welcome";
|
const char * const MODE_WELCOME = "Welcome";
|
||||||
const char * const MODE_EDIT = "Edit";
|
const char * const MODE_EDIT = "Edit";
|
||||||
|
const char * const MODE_DESIGN = "Design";
|
||||||
const int P_MODE_WELCOME = 100;
|
const int P_MODE_WELCOME = 100;
|
||||||
const int P_MODE_EDIT = 90;
|
const int P_MODE_EDIT = 90;
|
||||||
|
const int P_MODE_DESIGN = 89;
|
||||||
const int P_MODE_OUTPUT = 10;
|
const int P_MODE_OUTPUT = 10;
|
||||||
|
|
||||||
//menubar
|
//menubar
|
||||||
@@ -87,6 +89,7 @@ const char * const C_GLOBAL = "Global Context";
|
|||||||
const int C_GLOBAL_ID = 0;
|
const int C_GLOBAL_ID = 0;
|
||||||
const char * const C_WELCOME_MODE = "Core.WelcomeMode";
|
const char * const C_WELCOME_MODE = "Core.WelcomeMode";
|
||||||
const char * const C_EDIT_MODE = "Core.EditMode";
|
const char * const C_EDIT_MODE = "Core.EditMode";
|
||||||
|
const char * const C_DESIGN_MODE = "Core.DesignMode";
|
||||||
const char * const C_EDITORMANAGER = "Core.EditorManager";
|
const char * const C_EDITORMANAGER = "Core.EditorManager";
|
||||||
const char * const C_NAVIGATION_PANE = "Core.NavigationPane";
|
const char * const C_NAVIGATION_PANE = "Core.NavigationPane";
|
||||||
const char * const C_PROBLEM_PANE = "Core.ProblemPane";
|
const char * const C_PROBLEM_PANE = "Core.ProblemPane";
|
||||||
|
@@ -33,12 +33,14 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "modemanager.h"
|
#include "modemanager.h"
|
||||||
#include "fileiconprovider.h"
|
#include "fileiconprovider.h"
|
||||||
|
#include "designmode.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <QtCore/QtPlugin>
|
#include <QtCore/QtPlugin>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
|
||||||
CorePlugin::CorePlugin() :
|
CorePlugin::CorePlugin() :
|
||||||
@@ -53,6 +55,11 @@ CorePlugin::~CorePlugin()
|
|||||||
delete m_editMode;
|
delete m_editMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_designMode) {
|
||||||
|
removeObject(m_designMode);
|
||||||
|
delete m_designMode;
|
||||||
|
}
|
||||||
|
|
||||||
// delete FileIconProvider singleton
|
// delete FileIconProvider singleton
|
||||||
delete FileIconProvider::instance();
|
delete FileIconProvider::instance();
|
||||||
|
|
||||||
@@ -78,6 +85,9 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
EditorManager *editorManager = m_mainWindow->editorManager();
|
EditorManager *editorManager = m_mainWindow->editorManager();
|
||||||
m_editMode = new EditMode(editorManager);
|
m_editMode = new EditMode(editorManager);
|
||||||
addObject(m_editMode);
|
addObject(m_editMode);
|
||||||
|
|
||||||
|
m_designMode = new DesignMode(editorManager);
|
||||||
|
addObject(m_designMode);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
class DesignMode;
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class EditMode;
|
class EditMode;
|
||||||
@@ -59,6 +60,7 @@ private:
|
|||||||
|
|
||||||
MainWindow *m_mainWindow;
|
MainWindow *m_mainWindow;
|
||||||
EditMode *m_editMode;
|
EditMode *m_editMode;
|
||||||
|
DesignMode *m_designMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -80,7 +80,9 @@ SOURCES += mainwindow.cpp \
|
|||||||
settingsdatabase.cpp \
|
settingsdatabase.cpp \
|
||||||
eventfilteringmainwindow.cpp \
|
eventfilteringmainwindow.cpp \
|
||||||
imode.cpp \
|
imode.cpp \
|
||||||
editormanager/systemeditor.cpp
|
editormanager/systemeditor.cpp \
|
||||||
|
designmode.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
editmode.h \
|
editmode.h \
|
||||||
tabpositionindicator.h \
|
tabpositionindicator.h \
|
||||||
@@ -158,7 +160,9 @@ HEADERS += mainwindow.h \
|
|||||||
mimedatabase.h \
|
mimedatabase.h \
|
||||||
settingsdatabase.h \
|
settingsdatabase.h \
|
||||||
eventfilteringmainwindow.h \
|
eventfilteringmainwindow.h \
|
||||||
editormanager/systemeditor.h
|
editormanager/systemeditor.h \
|
||||||
|
designmode.h
|
||||||
|
|
||||||
FORMS += dialogs/newdialog.ui \
|
FORMS += dialogs/newdialog.ui \
|
||||||
dialogs/shortcutsettings.ui \
|
dialogs/shortcutsettings.ui \
|
||||||
dialogs/saveitemsdialog.ui \
|
dialogs/saveitemsdialog.ui \
|
||||||
|
215
src/plugins/coreplugin/designmode.cpp
Normal file
215
src/plugins/coreplugin/designmode.cpp
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "designmode.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/modemanager.h>
|
||||||
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/actionmanager/command.h>
|
||||||
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/mimedatabase.h>
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
#include <QtCore/QPair>
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
|
||||||
|
#include <QtGui/QPlainTextEdit>
|
||||||
|
#include <QtGui/QStackedWidget>
|
||||||
|
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
|
||||||
|
class EditorManager;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
debug = false
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
DesignModeCoreListener::DesignModeCoreListener(DesignMode *mode) :
|
||||||
|
m_mode(mode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DesignModeCoreListener::coreAboutToClose()
|
||||||
|
{
|
||||||
|
m_mode->currentEditorChanged(0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
|
DesignMode::DesignMode(EditorManager *editorManager) :
|
||||||
|
IMode(),
|
||||||
|
m_coreListener(new Internal::DesignModeCoreListener(this)),
|
||||||
|
m_isActive(false),
|
||||||
|
m_editorManager(editorManager),
|
||||||
|
m_stackWidget(new QStackedWidget)
|
||||||
|
{
|
||||||
|
setEnabled(false);
|
||||||
|
ExtensionSystem::PluginManager::instance()->addObject(m_coreListener);
|
||||||
|
|
||||||
|
connect(editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)),
|
||||||
|
this, SLOT(currentEditorChanged(Core::IEditor*)));
|
||||||
|
//updateActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
DesignMode::~DesignMode()
|
||||||
|
{
|
||||||
|
ExtensionSystem::PluginManager::instance()->removeObject(m_coreListener);
|
||||||
|
delete m_coreListener;
|
||||||
|
|
||||||
|
qDeleteAll(m_editors);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<int> DesignMode::context() const
|
||||||
|
{
|
||||||
|
static QList<int> contexts = QList<int>() <<
|
||||||
|
Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::C_DESIGN_MODE);
|
||||||
|
return contexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *DesignMode::widget()
|
||||||
|
{
|
||||||
|
return m_stackWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DesignMode::displayName() const
|
||||||
|
{
|
||||||
|
return tr(Constants::MODE_DESIGN);
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon DesignMode::icon() const
|
||||||
|
{
|
||||||
|
return QIcon(QLatin1String(":/qmldesigner/images/mode_Design.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
int DesignMode::priority() const
|
||||||
|
{
|
||||||
|
return Constants::P_MODE_DESIGN;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DesignMode::id() const
|
||||||
|
{
|
||||||
|
return QLatin1String(Constants::MODE_DESIGN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignMode::registerDesignWidget(QWidget *widget, const QStringList &mimeTypes, bool preferDesignMode)
|
||||||
|
{
|
||||||
|
int index = m_stackWidget->addWidget(widget);
|
||||||
|
|
||||||
|
DesignEditorInfo *info = new DesignEditorInfo;
|
||||||
|
info->preferredMode = preferDesignMode;
|
||||||
|
info->mimeTypes = mimeTypes;
|
||||||
|
info->widgetIndex = index;
|
||||||
|
info->widget = widget;
|
||||||
|
m_editors.append(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignMode::unregisterDesignWidget(QWidget *widget)
|
||||||
|
{
|
||||||
|
m_stackWidget->removeWidget(widget);
|
||||||
|
foreach(DesignEditorInfo *info, m_editors) {
|
||||||
|
if (info->widget == widget) {
|
||||||
|
m_editors.removeAll(info);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if editor changes, check if we have valid mimetype registered.
|
||||||
|
void DesignMode::currentEditorChanged(Core::IEditor *editor)
|
||||||
|
{
|
||||||
|
bool mimeEditorAvailable = false;
|
||||||
|
bool modeActivated = false;
|
||||||
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
|
||||||
|
if (editor && editor->file()) {
|
||||||
|
MimeType type = core->mimeDatabase()->findByFile(QFileInfo(editor->file()->fileName()));
|
||||||
|
QString mimeType = editor->file()->mimeType();
|
||||||
|
|
||||||
|
if (type && !type.type().isEmpty())
|
||||||
|
mimeType = type.type();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach(DesignEditorInfo *editorInfo, m_editors) {
|
||||||
|
foreach(QString mime, editorInfo->mimeTypes) {
|
||||||
|
if (mime == mimeType) {
|
||||||
|
m_stackWidget->setCurrentIndex(editorInfo->widgetIndex);
|
||||||
|
mimeEditorAvailable = true;
|
||||||
|
setEnabled(true);
|
||||||
|
if (editorInfo->preferredMode && core->modeManager()->currentMode() != this) {
|
||||||
|
core->modeManager()->activateMode(Constants::MODE_DESIGN);
|
||||||
|
modeActivated = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mimeEditorAvailable)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!mimeEditorAvailable)
|
||||||
|
setEnabled(false);
|
||||||
|
|
||||||
|
if ((!mimeEditorAvailable && core->modeManager()->currentMode() == this)
|
||||||
|
|| !modeActivated)
|
||||||
|
{
|
||||||
|
// switch back to edit mode
|
||||||
|
core->modeManager()->activateMode(Constants::MODE_EDIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_currentEditor.data() == editor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_currentEditor)
|
||||||
|
disconnect(m_currentEditor.data(), SIGNAL(changed()), this, SLOT(updateActions()));
|
||||||
|
|
||||||
|
m_currentEditor = QWeakPointer<Core::IEditor>(editor);
|
||||||
|
|
||||||
|
if (m_currentEditor)
|
||||||
|
connect(m_currentEditor.data(), SIGNAL(changed()), this, SLOT(updateActions()));
|
||||||
|
|
||||||
|
emit actionsUpdated(m_currentEditor.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignMode::updateActions()
|
||||||
|
{
|
||||||
|
emit actionsUpdated(m_currentEditor.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Core
|
@@ -2,7 +2,7 @@
|
|||||||
**
|
**
|
||||||
** This file is part of Qt Creator
|
** This file is part of Qt Creator
|
||||||
**
|
**
|
||||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
**
|
**
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
**
|
**
|
||||||
@@ -35,16 +35,19 @@
|
|||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
|
||||||
#include <QWeakPointer>
|
#include <QWeakPointer>
|
||||||
|
#include <QPair>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAction;
|
class QAction;
|
||||||
|
class QStackedWidget;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace Core {
|
||||||
namespace Internal {
|
class EditorManager;
|
||||||
|
|
||||||
class DesignMode;
|
class DesignMode;
|
||||||
class DesignModeWidget;
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
class DesignModeCoreListener : public Core::ICoreListener
|
class DesignModeCoreListener : public Core::ICoreListener
|
||||||
{
|
{
|
||||||
@@ -56,14 +59,25 @@ private:
|
|||||||
DesignMode *m_mode;
|
DesignMode *m_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DesignMode : public Core::IMode
|
} // namespace Internal
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A global mode for Design pane - used by Bauhaus (QML Designer) and
|
||||||
|
* Qt Designer. Other plugins can register themselves by registerDesignWidget()
|
||||||
|
* and giving a list of mimetypes that the editor understands, as well as an instance
|
||||||
|
* to the main editor widget itself.
|
||||||
|
*/
|
||||||
|
class CORE_EXPORT DesignMode : public Core::IMode
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DesignMode();
|
DesignMode(EditorManager *editorManager);
|
||||||
~DesignMode();
|
~DesignMode();
|
||||||
|
|
||||||
|
void registerDesignWidget(QWidget *widget, const QStringList &mimeTypes,
|
||||||
|
bool preferDesignMode = false);
|
||||||
|
void unregisterDesignWidget(QWidget *widget);
|
||||||
// IContext
|
// IContext
|
||||||
QList<int> context() const;
|
QList<int> context() const;
|
||||||
QWidget *widget();
|
QWidget *widget();
|
||||||
@@ -74,30 +88,34 @@ public:
|
|||||||
int priority() const;
|
int priority() const;
|
||||||
QString id() const;
|
QString id() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void actionsUpdated(Core::IEditor *editor);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void textEditorsClosed(QList<Core::IEditor *> editors);
|
|
||||||
void modeChanged(Core::IMode *mode);
|
|
||||||
void currentEditorChanged(Core::IEditor *editor);
|
void currentEditorChanged(Core::IEditor *editor);
|
||||||
void makeCurrentEditorWritable();
|
|
||||||
void updateActions();
|
void updateActions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DesignModeWidget *m_mainWidget;
|
Internal::DesignModeCoreListener *m_coreListener;
|
||||||
DesignModeCoreListener *m_coreListener;
|
|
||||||
QWeakPointer<Core::IEditor> m_currentEditor;
|
QWeakPointer<Core::IEditor> m_currentEditor;
|
||||||
bool m_isActive;
|
bool m_isActive;
|
||||||
|
|
||||||
QAction *m_revertToSavedAction;
|
struct DesignEditorInfo {
|
||||||
QAction *m_saveAction;
|
int widgetIndex;
|
||||||
QAction *m_saveAsAction;
|
QStringList mimeTypes;
|
||||||
QAction *m_closeCurrentEditorAction;
|
bool preferredMode;
|
||||||
QAction *m_closeAllEditorsAction;
|
QWidget *widget;
|
||||||
QAction *m_closeOtherEditorsAction;
|
};
|
||||||
|
|
||||||
friend class DesignModeCoreListener;
|
QList<DesignEditorInfo*> m_editors;
|
||||||
|
|
||||||
|
EditorManager *m_editorManager;
|
||||||
|
QStackedWidget *m_stackWidget;
|
||||||
|
|
||||||
|
friend class Internal::DesignModeCoreListener;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace QmlDesigner
|
} // namespace Core
|
||||||
|
|
||||||
#endif // DESIGNMODE_H
|
#endif // DESIGNMODE_H
|
@@ -230,6 +230,11 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
|||||||
const QList<int> editManagerContext =
|
const QList<int> editManagerContext =
|
||||||
QList<int>() << m_d->m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_EDITORMANAGER);
|
QList<int>() << m_d->m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_EDITORMANAGER);
|
||||||
|
|
||||||
|
// combined context for edit & design modes
|
||||||
|
const QList<int> editDesignContext =
|
||||||
|
QList<int>() << m_d->m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_EDITORMANAGER)
|
||||||
|
<< m_d->m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_DESIGN_MODE);
|
||||||
|
|
||||||
ActionManager *am = m_d->m_core->actionManager();
|
ActionManager *am = m_d->m_core->actionManager();
|
||||||
ActionContainer *mfile = am->actionContainer(Constants::M_FILE);
|
ActionContainer *mfile = am->actionContainer(Constants::M_FILE);
|
||||||
|
|
||||||
@@ -284,7 +289,7 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
|||||||
connect(m_d->m_closeOtherEditorsAction, SIGNAL(triggered()), this, SLOT(closeOtherEditors()));
|
connect(m_d->m_closeOtherEditorsAction, SIGNAL(triggered()), this, SLOT(closeOtherEditors()));
|
||||||
|
|
||||||
// Goto Previous In History Action
|
// Goto Previous In History Action
|
||||||
cmd = am->registerAction(m_d->m_gotoPreviousDocHistoryAction, Constants::GOTOPREVINHISTORY, editManagerContext);
|
cmd = am->registerAction(m_d->m_gotoPreviousDocHistoryAction, Constants::GOTOPREVINHISTORY, editDesignContext);
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Tab")));
|
cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Tab")));
|
||||||
#else
|
#else
|
||||||
@@ -294,7 +299,7 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
|||||||
connect(m_d->m_gotoPreviousDocHistoryAction, SIGNAL(triggered()), this, SLOT(gotoPreviousDocHistory()));
|
connect(m_d->m_gotoPreviousDocHistoryAction, SIGNAL(triggered()), this, SLOT(gotoPreviousDocHistory()));
|
||||||
|
|
||||||
// Goto Next In History Action
|
// Goto Next In History Action
|
||||||
cmd = am->registerAction(m_d->m_gotoNextDocHistoryAction, Constants::GOTONEXTINHISTORY, editManagerContext);
|
cmd = am->registerAction(m_d->m_gotoNextDocHistoryAction, Constants::GOTONEXTINHISTORY, editDesignContext);
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+Tab")));
|
cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+Tab")));
|
||||||
#else
|
#else
|
||||||
@@ -304,7 +309,7 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
|||||||
connect(m_d->m_gotoNextDocHistoryAction, SIGNAL(triggered()), this, SLOT(gotoNextDocHistory()));
|
connect(m_d->m_gotoNextDocHistoryAction, SIGNAL(triggered()), this, SLOT(gotoNextDocHistory()));
|
||||||
|
|
||||||
// Go back in navigation history
|
// Go back in navigation history
|
||||||
cmd = am->registerAction(m_d->m_goBackAction, Constants::GO_BACK, editManagerContext);
|
cmd = am->registerAction(m_d->m_goBackAction, Constants::GO_BACK, editDesignContext);
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Left")));
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Left")));
|
||||||
#else
|
#else
|
||||||
@@ -314,7 +319,7 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
|||||||
connect(m_d->m_goBackAction, SIGNAL(triggered()), this, SLOT(goBackInNavigationHistory()));
|
connect(m_d->m_goBackAction, SIGNAL(triggered()), this, SLOT(goBackInNavigationHistory()));
|
||||||
|
|
||||||
// Go forward in navigation history
|
// Go forward in navigation history
|
||||||
cmd = am->registerAction(m_d->m_goForwardAction, Constants::GO_FORWARD, editManagerContext);
|
cmd = am->registerAction(m_d->m_goForwardAction, Constants::GO_FORWARD, editDesignContext);
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Right")));
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Right")));
|
||||||
#else
|
#else
|
||||||
@@ -522,8 +527,6 @@ Core::Internal::EditorView *EditorManager::currentEditorView() const
|
|||||||
return currentSplitterOrView()->view();
|
return currentSplitterOrView()->view();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QList<IEditor *> EditorManager::editorsForFileName(const QString &filename) const
|
QList<IEditor *> EditorManager::editorsForFileName(const QString &filename) const
|
||||||
{
|
{
|
||||||
QList<IEditor *> found;
|
QList<IEditor *> found;
|
||||||
@@ -919,6 +922,7 @@ Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, C
|
|||||||
if (isVisible())
|
if (isVisible())
|
||||||
editor->widget()->setFocus();
|
editor->widget()->setFocus();
|
||||||
}
|
}
|
||||||
|
emit currentEditorChanged(editor);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1445,7 +1449,9 @@ void EditorManager::updateActions()
|
|||||||
QString fName;
|
QString fName;
|
||||||
IEditor *curEditor = currentEditor();
|
IEditor *curEditor = currentEditor();
|
||||||
int openedCount = openedEditors().count() + m_d->m_editorModel->restoredEditors().count();
|
int openedCount = openedEditors().count() + m_d->m_editorModel->restoredEditors().count();
|
||||||
|
|
||||||
if (curEditor) {
|
if (curEditor) {
|
||||||
|
|
||||||
if (!curEditor->file()->fileName().isEmpty()) {
|
if (!curEditor->file()->fileName().isEmpty()) {
|
||||||
QFileInfo fi(curEditor->file()->fileName());
|
QFileInfo fi(curEditor->file()->fileName());
|
||||||
fName = fi.fileName();
|
fName = fi.fileName();
|
||||||
@@ -1453,7 +1459,6 @@ void EditorManager::updateActions()
|
|||||||
fName = curEditor->displayName();
|
fName = curEditor->displayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (curEditor->file()->isModified() && curEditor->file()->isReadOnly()) {
|
if (curEditor->file()->isModified() && curEditor->file()->isReadOnly()) {
|
||||||
// we are about to change a read-only file, warn user
|
// we are about to change a read-only file, warn user
|
||||||
showEditorInfoBar(QLatin1String("Core.EditorManager.MakeWritable"),
|
showEditorInfoBar(QLatin1String("Core.EditorManager.MakeWritable"),
|
||||||
@@ -1472,11 +1477,11 @@ void EditorManager::updateActions()
|
|||||||
QString quotedName;
|
QString quotedName;
|
||||||
if (!fName.isEmpty())
|
if (!fName.isEmpty())
|
||||||
quotedName = '"' + fName + '"';
|
quotedName = '"' + fName + '"';
|
||||||
|
|
||||||
m_d->m_saveAsAction->setText(tr("Save %1 &As...").arg(quotedName));
|
m_d->m_saveAsAction->setText(tr("Save %1 &As...").arg(quotedName));
|
||||||
m_d->m_saveAction->setText(tr("&Save %1").arg(quotedName));
|
m_d->m_saveAction->setText(tr("&Save %1").arg(quotedName));
|
||||||
m_d->m_revertToSavedAction->setText(tr("Revert %1 to Saved").arg(quotedName));
|
m_d->m_revertToSavedAction->setText(tr("Revert %1 to Saved").arg(quotedName));
|
||||||
|
|
||||||
|
|
||||||
m_d->m_closeCurrentEditorAction->setEnabled(curEditor != 0);
|
m_d->m_closeCurrentEditorAction->setEnabled(curEditor != 0);
|
||||||
m_d->m_closeCurrentEditorAction->setText(tr("Close %1").arg(quotedName));
|
m_d->m_closeCurrentEditorAction->setText(tr("Close %1").arg(quotedName));
|
||||||
m_d->m_closeAllEditorsAction->setEnabled(openedCount > 0);
|
m_d->m_closeAllEditorsAction->setEnabled(openedCount > 0);
|
||||||
@@ -1700,7 +1705,6 @@ void EditorManager::showEditorInfoBar(const QString &id,
|
|||||||
const QString &buttonText,
|
const QString &buttonText,
|
||||||
QObject *object, const char *member)
|
QObject *object, const char *member)
|
||||||
{
|
{
|
||||||
|
|
||||||
currentEditorView()->showEditorInfoBar(id, infoText, buttonText, object, member);
|
currentEditorView()->showEditorInfoBar(id, infoText, buttonText, object, member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -788,7 +788,6 @@ static IFileFactory *findFileFactory(const QList<IFileFactory*> &fileFactories,
|
|||||||
// opens either an editor or loads a project
|
// opens either an editor or loads a project
|
||||||
void MainWindow::openFiles(const QStringList &fileNames)
|
void MainWindow::openFiles(const QStringList &fileNames)
|
||||||
{
|
{
|
||||||
bool needToSwitchToEditor = false;
|
|
||||||
QList<IFileFactory*> nonEditorFileFactories = getNonEditorFileFactories();
|
QList<IFileFactory*> nonEditorFileFactories = getNonEditorFileFactories();
|
||||||
|
|
||||||
foreach (const QString &fileName, fileNames) {
|
foreach (const QString &fileName, fileNames) {
|
||||||
@@ -797,13 +796,9 @@ void MainWindow::openFiles(const QStringList &fileNames)
|
|||||||
if (IFileFactory *fileFactory = findFileFactory(nonEditorFileFactories, mimeDatabase(), fi)) {
|
if (IFileFactory *fileFactory = findFileFactory(nonEditorFileFactories, mimeDatabase(), fi)) {
|
||||||
fileFactory->open(absoluteFilePath);
|
fileFactory->open(absoluteFilePath);
|
||||||
} else {
|
} else {
|
||||||
IEditor *editor = editorManager()->openEditor(absoluteFilePath);
|
editorManager()->openEditor(absoluteFilePath);
|
||||||
if (editor)
|
|
||||||
needToSwitchToEditor = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (needToSwitchToEditor)
|
|
||||||
editorManager()->ensureEditorManagerVisible();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setFocusToEditor()
|
void MainWindow::setFocusToEditor()
|
||||||
|
@@ -36,7 +36,11 @@ HEADERS += formeditorplugin.h \
|
|||||||
formtemplatewizardpage.h \
|
formtemplatewizardpage.h \
|
||||||
formwizarddialog.h \
|
formwizarddialog.h \
|
||||||
codemodelhelpers.h \
|
codemodelhelpers.h \
|
||||||
designer_export.h
|
designer_export.h \
|
||||||
|
designerxmleditor.h \
|
||||||
|
designercontext.h \
|
||||||
|
faketoolbar.h \
|
||||||
|
formeditorstack.h
|
||||||
|
|
||||||
SOURCES += formeditorplugin.cpp \
|
SOURCES += formeditorplugin.cpp \
|
||||||
formeditorfactory.cpp \
|
formeditorfactory.cpp \
|
||||||
@@ -51,8 +55,12 @@ SOURCES += formeditorplugin.cpp \
|
|||||||
settingsmanager.cpp \
|
settingsmanager.cpp \
|
||||||
formtemplatewizardpage.cpp \
|
formtemplatewizardpage.cpp \
|
||||||
formwizarddialog.cpp \
|
formwizarddialog.cpp \
|
||||||
codemodelhelpers.cpp
|
codemodelhelpers.cpp \
|
||||||
|
designerxmleditor.cpp \
|
||||||
|
designercontext.cpp \
|
||||||
|
faketoolbar.cpp \
|
||||||
|
formeditorstack.cpp
|
||||||
|
|
||||||
RESOURCES += designer.qrc
|
RESOURCES += designer.qrc
|
||||||
|
|
||||||
OTHER_FILES += Designer.pluginspec
|
OTHER_FILES += Designer.pluginspec Designer.mimetypes.xml
|
||||||
|
@@ -35,6 +35,12 @@
|
|||||||
namespace Designer {
|
namespace Designer {
|
||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
|
const char * const INFO_READ_ONLY = "DesignerXmlEditor.ReadOnly";
|
||||||
|
const char * const K_DESIGNER_XML_EDITOR_ID = "FormEditor.DesignerXmlEditor";
|
||||||
|
const char * const C_DESIGNER_XML_EDITOR = "Designer Xml Editor";
|
||||||
|
const char * const DESIGNER_XML_EDITOR_ID ="DesignerXmlEditor";
|
||||||
|
const char * const C_DESIGNER_XML_DISPLAY_NAME = QT_TRANSLATE_NOOP("Designer", "Xml Editor");
|
||||||
|
|
||||||
const char * const SETTINGS_CATEGORY = "P.Designer";
|
const char * const SETTINGS_CATEGORY = "P.Designer";
|
||||||
const char * const SETTINGS_TR_CATEGORY = QT_TRANSLATE_NOOP("Designer", "Designer");
|
const char * const SETTINGS_TR_CATEGORY = QT_TRANSLATE_NOOP("Designer", "Designer");
|
||||||
const char * const SETTINGS_CPP_SETTINGS_ID = "Class Generation";
|
const char * const SETTINGS_CPP_SETTINGS_ID = "Class Generation";
|
||||||
|
72
src/plugins/designer/designercontext.cpp
Normal file
72
src/plugins/designer/designercontext.cpp
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "designercontext.h"
|
||||||
|
#include "designerconstants.h"
|
||||||
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
|
#include <coreplugin/coreconstants.h>
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Designer {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
DesignerContext::DesignerContext(QWidget *widget) : Core::IContext(widget),
|
||||||
|
m_widget(widget)
|
||||||
|
{
|
||||||
|
Core::UniqueIDManager *idMan = Core::UniqueIDManager::instance();
|
||||||
|
m_context << idMan->uniqueIdentifier(Designer::Constants::C_FORMEDITOR)
|
||||||
|
<< idMan->uniqueIdentifier(Core::Constants::C_EDITORMANAGER)
|
||||||
|
<< idMan->uniqueIdentifier(Core::Constants::C_DESIGN_MODE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DesignerContext::~DesignerContext()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<int> DesignerContext::context() const
|
||||||
|
{
|
||||||
|
return m_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *DesignerContext::widget()
|
||||||
|
{
|
||||||
|
return m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignerContext::setWidget(QWidget *widget)
|
||||||
|
{
|
||||||
|
m_widget = widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
60
src/plugins/designer/designercontext.h
Normal file
60
src/plugins/designer/designercontext.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DESIGNERCONTEXT_H
|
||||||
|
#define DESIGNERCONTEXT_H
|
||||||
|
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QWidget;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Designer {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class DesignerContext : public Core::IContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DesignerContext(QWidget *widget = 0);
|
||||||
|
~DesignerContext();
|
||||||
|
QList<int> context() const;
|
||||||
|
QWidget *widget();
|
||||||
|
void setWidget(QWidget *widget);
|
||||||
|
private:
|
||||||
|
QList<int> m_context;
|
||||||
|
QWidget *m_widget;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DESIGNERCONTEXT_H
|
98
src/plugins/designer/designerxmleditor.cpp
Normal file
98
src/plugins/designer/designerxmleditor.cpp
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "designerxmleditor.h"
|
||||||
|
#include "designerconstants.h"
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/modemanager.h>
|
||||||
|
#include <coreplugin/imode.h>
|
||||||
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
using namespace Designer::Internal;
|
||||||
|
|
||||||
|
DesignerXmlEditor::DesignerXmlEditor(QWidget *parent) : TextEditor::PlainTextEditor(parent)
|
||||||
|
{
|
||||||
|
setReadOnly(true);
|
||||||
|
connect(Core::ICore::instance()->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
||||||
|
SLOT(updateEditorInfoBar(Core::IEditor*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
DesignerXmlEditor::~DesignerXmlEditor()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DesignerXmlEditor::open(const QString &fileName)
|
||||||
|
{
|
||||||
|
bool res = TextEditor::PlainTextEditor::open(fileName);
|
||||||
|
QPlainTextEdit::setReadOnly(true);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignerXmlEditor::updateEditorInfoBar(Core::IEditor *editor)
|
||||||
|
{
|
||||||
|
if (editor == editableInterface()) {
|
||||||
|
Core::EditorManager::instance()->showEditorInfoBar(Constants::INFO_READ_ONLY,
|
||||||
|
tr("This file can only be edited in Design Mode."),
|
||||||
|
"Open Designer", this, SLOT(designerOpened()));
|
||||||
|
}
|
||||||
|
if (!editor)
|
||||||
|
Core::EditorManager::instance()->hideEditorInfoBar(Constants::INFO_READ_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignerXmlEditor::designerOpened()
|
||||||
|
{
|
||||||
|
Core::ICore::instance()->modeManager()->activateMode(Core::Constants::MODE_DESIGN);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DesignerXmlEditorEditable::id() const
|
||||||
|
{
|
||||||
|
return QLatin1String(Designer::Constants::K_DESIGNER_XML_EDITOR_ID);
|
||||||
|
}
|
||||||
|
DesignerXmlEditorEditable::DesignerXmlEditorEditable(DesignerXmlEditor *editor)
|
||||||
|
: TextEditor::PlainTextEditorEditable(editor)
|
||||||
|
{
|
||||||
|
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
|
||||||
|
m_context << uidm->uniqueIdentifier(Designer::Constants::K_DESIGNER_XML_EDITOR_ID);
|
||||||
|
m_context << uidm->uniqueIdentifier(Designer::Constants::C_DESIGNER_XML_EDITOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<int> DesignerXmlEditorEditable::context() const
|
||||||
|
{
|
||||||
|
return m_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::IEditor *DesignerXmlEditorEditable::duplicate(QWidget *parent)
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
return 0;
|
||||||
|
}
|
89
src/plugins/designer/designerxmleditor.h
Normal file
89
src/plugins/designer/designerxmleditor.h
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DESIGNERXMLEDITOR_H
|
||||||
|
#define DESIGNERXMLEDITOR_H
|
||||||
|
|
||||||
|
#include <texteditor/plaintexteditor.h>
|
||||||
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class IEditor;
|
||||||
|
class IMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Designer {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class DesignerXmlEditor;
|
||||||
|
|
||||||
|
class TEXTEDITOR_EXPORT DesignerXmlEditorEditable : public TextEditor::PlainTextEditorEditable
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
DesignerXmlEditorEditable(DesignerXmlEditor *editor);
|
||||||
|
QList<int> context() const;
|
||||||
|
|
||||||
|
bool duplicateSupported() const { return false; }
|
||||||
|
Core::IEditor *duplicate(QWidget *parent);
|
||||||
|
virtual QString id() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<int> m_context;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A stub-like, read-only text editor which displays UI files as text. Could be used as a
|
||||||
|
* read/write editor too, but due to lack of XML editor, highlighting and other such
|
||||||
|
* functionality, editing is disabled.
|
||||||
|
*/
|
||||||
|
class DesignerXmlEditor : public TextEditor::PlainTextEditor
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
DesignerXmlEditor(QWidget *parent = 0);
|
||||||
|
virtual ~DesignerXmlEditor();
|
||||||
|
bool open(const QString &fileName = QString());
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void designerOpened();
|
||||||
|
void updateEditorInfoBar(Core::IEditor *editor);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual TextEditor::BaseTextEditorEditable *createEditableInterface() { return new DesignerXmlEditorEditable(this); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Internal
|
||||||
|
} // Designer
|
||||||
|
|
||||||
|
#endif // DESIGNERXMLEDITOR_H
|
@@ -97,6 +97,7 @@ EditorWidget::EditorWidget(QWidget *formWindow)
|
|||||||
// Get shared sub windows from Form Editor
|
// Get shared sub windows from Form Editor
|
||||||
FormEditorW *few = FormEditorW::instance();
|
FormEditorW *few = FormEditorW::instance();
|
||||||
QWidget * const*subs = few->designerSubWindows();
|
QWidget * const*subs = few->designerSubWindows();
|
||||||
|
|
||||||
// Create shared sub windows
|
// Create shared sub windows
|
||||||
for (int i=0; i < DesignerSubWindowCount; i++) {
|
for (int i=0; i < DesignerSubWindowCount; i++) {
|
||||||
m_designerSubWindows[i] = new SharedSubWindow(subs[i]);
|
m_designerSubWindows[i] = new SharedSubWindow(subs[i]);
|
||||||
@@ -132,6 +133,13 @@ void EditorWidget::resetToDefaultLayout()
|
|||||||
|
|
||||||
void EditorWidget::activate()
|
void EditorWidget::activate()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
|
||||||
|
- now, settings are only changed when form is hidden.
|
||||||
|
- they should be not restored when a new form is activated - the same settings should be kept.
|
||||||
|
- only on initial load, settings should be loaded.
|
||||||
|
|
||||||
|
*/
|
||||||
for (int i=0; i < DesignerSubWindowCount; i++)
|
for (int i=0; i < DesignerSubWindowCount; i++)
|
||||||
m_designerSubWindows[i]->activate();
|
m_designerSubWindows[i]->activate();
|
||||||
|
|
||||||
@@ -143,13 +151,12 @@ void EditorWidget::activate()
|
|||||||
// don't have their widgets yet there
|
// don't have their widgets yet there
|
||||||
resetToDefaultLayout();
|
resetToDefaultLayout();
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
|
if (!m_globalState.isEmpty())
|
||||||
|
m_mainWindow->restoreSettings(m_globalState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_globalState.isEmpty())
|
if (m_globalState.isEmpty())
|
||||||
m_mainWindow->restoreSettings(m_globalState);
|
|
||||||
else {
|
|
||||||
m_globalState = m_mainWindow->saveSettings();
|
m_globalState = m_mainWindow->saveSettings();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWidget::hideEvent(QHideEvent *)
|
void EditorWidget::hideEvent(QHideEvent *)
|
||||||
|
@@ -77,6 +77,7 @@ class EditorWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit EditorWidget(QWidget *formWindow);
|
explicit EditorWidget(QWidget *formWindow);
|
||||||
|
|
||||||
|
|
||||||
void resetToDefaultLayout();
|
void resetToDefaultLayout();
|
||||||
QDockWidget* const* dockWidgets() const { return m_designerDockWidgets; }
|
QDockWidget* const* dockWidgets() const { return m_designerDockWidgets; }
|
||||||
bool isLocked() const { return m_mainWindow->isLocked(); }
|
bool isLocked() const { return m_mainWindow->isLocked(); }
|
||||||
|
242
src/plugins/designer/faketoolbar.cpp
Normal file
242
src/plugins/designer/faketoolbar.cpp
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "faketoolbar.h"
|
||||||
|
|
||||||
|
#include <designerconstants.h>
|
||||||
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/minisplitter.h>
|
||||||
|
#include <coreplugin/sidebar.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||||
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/actionmanager/command.h>
|
||||||
|
#include <coreplugin/modemanager.h>
|
||||||
|
|
||||||
|
#include <utils/parameteraction.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtCore/QEvent>
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include <QtGui/QPlainTextEdit>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
#include <QtGui/QScrollArea>
|
||||||
|
#include <QtGui/QTabWidget>
|
||||||
|
#include <QtGui/QToolButton>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
#include <QtGui/QClipboard>
|
||||||
|
#include <QtGui/QLabel>
|
||||||
|
#include <QtGui/QToolBar>
|
||||||
|
|
||||||
|
using Core::MiniSplitter;
|
||||||
|
using Core::IEditor;
|
||||||
|
using Core::EditorManager;
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(Core::IEditor*)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
debug = false
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Designer {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Mimic the look of the text editor toolbar as defined in e.g. EditorView::EditorView
|
||||||
|
*/
|
||||||
|
FakeToolBar::FakeToolBar(Core::IEditor *editor, QWidget *toolbar, QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
m_editorList(new QComboBox),
|
||||||
|
m_closeButton(new QToolButton),
|
||||||
|
m_lockButton(new QToolButton),
|
||||||
|
m_goBackAction(new QAction(QIcon(QLatin1String(":/help/images/previous.png")), EditorManager::tr("Go Back"), parent)),
|
||||||
|
m_goForwardAction(new QAction(QIcon(QLatin1String(":/help/images/next.png")), EditorManager::tr("Go Forward"), parent)),
|
||||||
|
m_editor(editor)
|
||||||
|
{
|
||||||
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
|
||||||
|
//setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
m_editorsListModel = core->editorManager()->openedEditorsModel();
|
||||||
|
|
||||||
|
// copied from EditorView::EditorView
|
||||||
|
m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
m_editorList->setMinimumContentsLength(20);
|
||||||
|
m_editorList->setModel(m_editorsListModel);
|
||||||
|
m_editorList->setMaxVisibleItems(40);
|
||||||
|
m_editorList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
m_editorList->setCurrentIndex(m_editorsListModel->indexOf(m_editor).row());
|
||||||
|
|
||||||
|
QToolBar *editorListToolBar = new QToolBar;
|
||||||
|
editorListToolBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
|
||||||
|
editorListToolBar->addWidget(m_editorList);
|
||||||
|
|
||||||
|
m_lockButton->setAutoRaise(true);
|
||||||
|
m_lockButton->setProperty("type", QLatin1String("dockbutton"));
|
||||||
|
|
||||||
|
m_closeButton->setAutoRaise(true);
|
||||||
|
m_closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
|
||||||
|
m_closeButton->setProperty("type", QLatin1String("dockbutton"));
|
||||||
|
|
||||||
|
// Core::ActionManager *am = core->actionManager();
|
||||||
|
// Core::EditorManager *em = core->editorManager();
|
||||||
|
|
||||||
|
// TODO back/FW buttons disabled for the time being, as the implementation would require changing editormanager.
|
||||||
|
//
|
||||||
|
// QToolBar *backFwToolBar = new QToolBar;
|
||||||
|
// backFwToolBar->addAction(m_goBackAction);
|
||||||
|
// backFwToolBar->addAction(m_goForwardAction);
|
||||||
|
// Core::Command *cmd = am->registerAction(m_goBackAction, Core::Constants::GO_BACK, editor->context());
|
||||||
|
//#ifdef Q_WS_MAC
|
||||||
|
// cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Left")));
|
||||||
|
//#else
|
||||||
|
// cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Left")));
|
||||||
|
//#endif
|
||||||
|
// connect(m_goBackAction, SIGNAL(triggered()), em, SLOT(goBackInNavigationHistory()));
|
||||||
|
// cmd = am->registerAction(m_goForwardAction, Core::Constants::GO_FORWARD, editor->context());
|
||||||
|
//#ifdef Q_WS_MAC
|
||||||
|
// cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Right")));
|
||||||
|
//#else
|
||||||
|
// cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Right")));
|
||||||
|
//#endif
|
||||||
|
// connect(m_goForwardAction, SIGNAL(triggered()), em, SLOT(goForwardInNavigationHistory()));
|
||||||
|
|
||||||
|
QToolBar *rightToolBar = new QToolBar;
|
||||||
|
rightToolBar->setLayoutDirection(Qt::RightToLeft);
|
||||||
|
rightToolBar->addWidget(m_closeButton);
|
||||||
|
rightToolBar->addWidget(m_lockButton);
|
||||||
|
|
||||||
|
QHBoxLayout *toplayout = new QHBoxLayout(this);
|
||||||
|
toplayout->setSpacing(0);
|
||||||
|
toplayout->setMargin(0);
|
||||||
|
toplayout->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
// toplayout->addWidget(backFwToolBar);
|
||||||
|
toplayout->addWidget(editorListToolBar);
|
||||||
|
toplayout->addWidget(toolbar);
|
||||||
|
toplayout->addWidget(rightToolBar);
|
||||||
|
|
||||||
|
connect(m_editorList, SIGNAL(activated(int)), this, SLOT(listSelectionActivated(int)));
|
||||||
|
connect(m_editorList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(listContextMenu(QPoint)));
|
||||||
|
connect(m_lockButton, SIGNAL(clicked()), this, SLOT(makeEditorWritable()));
|
||||||
|
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||||
|
|
||||||
|
connect(m_editor, SIGNAL(changed()), this, SLOT(updateEditorStatus()));
|
||||||
|
connect(core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(updateEditorListSelection(Core::IEditor*)));
|
||||||
|
|
||||||
|
updateEditorStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeToolBar::updateEditorListSelection(Core::IEditor *newSelection)
|
||||||
|
{
|
||||||
|
if (newSelection) {
|
||||||
|
m_editorList->setCurrentIndex(m_editorsListModel->indexOf(newSelection).row());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeToolBar::close()
|
||||||
|
{
|
||||||
|
// instead of closing & deleting the visual editor, we want to go to edit mode and
|
||||||
|
// close the xml file instead.
|
||||||
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
|
||||||
|
Core::IEditor *editor = core->editorManager()->currentEditor();
|
||||||
|
if (editor && editor->id() == Designer::Constants::K_DESIGNER_XML_EDITOR_ID
|
||||||
|
&& editor->file() == m_editor->file())
|
||||||
|
{
|
||||||
|
core->editorManager()->closeEditors(QList<Core::IEditor*>() << editor);
|
||||||
|
}
|
||||||
|
core->modeManager()->activateMode(Core::Constants::MODE_EDIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeToolBar::listSelectionActivated(int row)
|
||||||
|
{
|
||||||
|
Core::EditorManager *em = Core::ICore::instance()->editorManager();
|
||||||
|
QAbstractItemModel *model = m_editorList->model();
|
||||||
|
|
||||||
|
const QModelIndex modelIndex = model->index(row, 0);
|
||||||
|
IEditor *editor = model->data(modelIndex, Qt::UserRole).value<IEditor*>();
|
||||||
|
if (editor) {
|
||||||
|
if (editor != em->currentEditor())
|
||||||
|
em->activateEditor(editor, EditorManager::NoModeSwitch);
|
||||||
|
} else {
|
||||||
|
QString fileName = model->data(modelIndex, Qt::UserRole + 1).toString();
|
||||||
|
QByteArray kind = model->data(modelIndex, Qt::UserRole + 2).toByteArray();
|
||||||
|
editor = em->openEditor(fileName, kind, EditorManager::NoModeSwitch);
|
||||||
|
}
|
||||||
|
if (editor) {
|
||||||
|
m_editorList->setCurrentIndex(m_editorsListModel->indexOf(editor).row());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeToolBar::listContextMenu(QPoint pos)
|
||||||
|
{
|
||||||
|
QModelIndex index = m_editorsListModel->index(m_editorList->currentIndex(), 0);
|
||||||
|
QString fileName = m_editorsListModel->data(index, Qt::UserRole + 1).toString();
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
return;
|
||||||
|
QMenu menu;
|
||||||
|
menu.addAction(tr("Copy full path to clipboard"));
|
||||||
|
if (menu.exec(m_editorList->mapToGlobal(pos))) {
|
||||||
|
QApplication::clipboard()->setText(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeToolBar::makeEditorWritable()
|
||||||
|
{
|
||||||
|
Core::ICore::instance()->editorManager()->makeEditorWritable(m_editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeToolBar::updateEditorStatus()
|
||||||
|
{
|
||||||
|
if (!m_editor->file())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_editor->file()->isReadOnly()) {
|
||||||
|
m_lockButton->setIcon(m_editorsListModel->lockedIcon());
|
||||||
|
m_lockButton->setEnabled(!m_editor->file()->fileName().isEmpty());
|
||||||
|
m_lockButton->setToolTip(tr("Make writable"));
|
||||||
|
} else {
|
||||||
|
m_lockButton->setIcon(m_editorsListModel->unlockedIcon());
|
||||||
|
m_lockButton->setEnabled(false);
|
||||||
|
m_lockButton->setToolTip(tr("File is writable"));
|
||||||
|
}
|
||||||
|
m_editorList->setToolTip(
|
||||||
|
m_editor->file()->fileName().isEmpty()
|
||||||
|
? m_editor->displayName()
|
||||||
|
: QDir::toNativeSeparators(m_editor->file()->fileName())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Internal
|
||||||
|
} // Designer
|
84
src/plugins/designer/faketoolbar.h
Normal file
84
src/plugins/designer/faketoolbar.h
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef FAKETOOLBAR_H
|
||||||
|
#define FAKETOOLBAR_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QtCore/QPointer>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class IEditor;
|
||||||
|
class OpenEditorsModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QComboBox;
|
||||||
|
class QToolButton;
|
||||||
|
class QToolBar;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Designer {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fakes an IEditor-like toolbar for design mode widgets such as Qt Designer and Bauhaus.
|
||||||
|
* Creates a combobox for open files and lock and close buttons on the right.
|
||||||
|
*/
|
||||||
|
class FakeToolBar : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(FakeToolBar)
|
||||||
|
public:
|
||||||
|
explicit FakeToolBar(Core::IEditor *editor, QWidget *toolbar, QWidget *parent = 0);
|
||||||
|
|
||||||
|
void updateActions();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateEditorListSelection(Core::IEditor *newSelection);
|
||||||
|
void close();
|
||||||
|
void listSelectionActivated(int row);
|
||||||
|
void listContextMenu(QPoint);
|
||||||
|
void makeEditorWritable();
|
||||||
|
void updateEditorStatus();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Core::OpenEditorsModel *m_editorsListModel;
|
||||||
|
QComboBox *m_editorList;
|
||||||
|
QToolButton *m_closeButton;
|
||||||
|
QToolButton *m_lockButton;
|
||||||
|
QAction *m_goBackAction;
|
||||||
|
QAction *m_goForwardAction;
|
||||||
|
QPointer<Core::IEditor> m_editor;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FAKETOOLBAR_H
|
@@ -31,10 +31,12 @@
|
|||||||
#include "formeditorw.h"
|
#include "formeditorw.h"
|
||||||
#include "formwindoweditor.h"
|
#include "formwindoweditor.h"
|
||||||
#include "designerconstants.h"
|
#include "designerconstants.h"
|
||||||
|
#include "designerxmleditor.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/fileiconprovider.h>
|
#include <coreplugin/fileiconprovider.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
@@ -53,12 +55,12 @@ FormEditorFactory::FormEditorFactory()
|
|||||||
|
|
||||||
QString FormEditorFactory::id() const
|
QString FormEditorFactory::id() const
|
||||||
{
|
{
|
||||||
return QLatin1String(FORMEDITOR_ID);
|
return QLatin1String(DESIGNER_XML_EDITOR_ID); //FORMEDITOR_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FormEditorFactory::displayName() const
|
QString FormEditorFactory::displayName() const
|
||||||
{
|
{
|
||||||
return tr(C_FORMEDITOR_DISPLAY_NAME);
|
return tr(C_DESIGNER_XML_DISPLAY_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IFile *FormEditorFactory::open(const QString &fileName)
|
Core::IFile *FormEditorFactory::open(const QString &fileName)
|
||||||
@@ -69,7 +71,9 @@ Core::IFile *FormEditorFactory::open(const QString &fileName)
|
|||||||
|
|
||||||
Core::IEditor *FormEditorFactory::createEditor(QWidget *parent)
|
Core::IEditor *FormEditorFactory::createEditor(QWidget *parent)
|
||||||
{
|
{
|
||||||
return FormEditorW::instance()->createFormWindowEditor(parent);
|
DesignerXmlEditor *xmlEditor = new DesignerXmlEditor(parent);
|
||||||
|
TextEditor::TextEditorSettings::instance()->initializeEditor(xmlEditor);
|
||||||
|
return xmlEditor->editableInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList FormEditorFactory::mimeTypes() const
|
QStringList FormEditorFactory::mimeTypes() const
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "formeditorfactory.h"
|
#include "formeditorfactory.h"
|
||||||
#include "formeditorw.h"
|
#include "formeditorw.h"
|
||||||
#include "formwizard.h"
|
#include "formwizard.h"
|
||||||
|
#include "formeditorstack.h"
|
||||||
|
|
||||||
#ifdef CPP_ENABLED
|
#ifdef CPP_ENABLED
|
||||||
# include "formclasswizard.h"
|
# include "formclasswizard.h"
|
||||||
@@ -39,12 +40,24 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "designerconstants.h"
|
#include "designerconstants.h"
|
||||||
|
#include "formwindoweditor.h"
|
||||||
|
#include "designerxmleditor.h"
|
||||||
|
#include "formwindowfile.h"
|
||||||
|
|
||||||
|
#include <QDesignerFormWindowInterface>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/modemanager.h>
|
||||||
|
#include <coreplugin/designmode.h>
|
||||||
|
#include <texteditor/basetextdocument.h>
|
||||||
|
|
||||||
|
#include <QtCore/QPointer>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QtPlugin>
|
#include <QtCore/QtPlugin>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
@@ -52,6 +65,8 @@
|
|||||||
#include <QtCore/QLibraryInfo>
|
#include <QtCore/QLibraryInfo>
|
||||||
#include <QtCore/QTranslator>
|
#include <QtCore/QTranslator>
|
||||||
|
|
||||||
|
#include <QtGui/QTextDocument>
|
||||||
|
|
||||||
#ifdef CPP_ENABLED
|
#ifdef CPP_ENABLED
|
||||||
# include <QtGui/QAction>
|
# include <QtGui/QAction>
|
||||||
# include <QtGui/QWizard>
|
# include <QtGui/QWizard>
|
||||||
@@ -86,9 +101,6 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
|
|
||||||
initializeTemplates();
|
initializeTemplates();
|
||||||
|
|
||||||
const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR));
|
|
||||||
const QList<int> context = QList<int>() << uid;
|
|
||||||
|
|
||||||
addAutoReleasedObject(new FormEditorFactory);
|
addAutoReleasedObject(new FormEditorFactory);
|
||||||
|
|
||||||
// Ensure that loading designer translations is done before FormEditorW is instantiated
|
// Ensure that loading designer translations is done before FormEditorW is instantiated
|
||||||
@@ -113,6 +125,8 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
const QByteArray output = proc.readAll();
|
const QByteArray output = proc.readAll();
|
||||||
if (output.contains("KDE: 4.2.0"))
|
if (output.contains("KDE: 4.2.0"))
|
||||||
FormEditorW::ensureInitStage(FormEditorW::FullyInitialized);
|
FormEditorW::ensureInitStage(FormEditorW::FullyInitialized);
|
||||||
|
else
|
||||||
|
FormEditorW::ensureInitStage(FormEditorW::RegisterPlugins);
|
||||||
} else {
|
} else {
|
||||||
FormEditorW::ensureInitStage(FormEditorW::RegisterPlugins);
|
FormEditorW::ensureInitStage(FormEditorW::RegisterPlugins);
|
||||||
}
|
}
|
||||||
@@ -123,6 +137,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
|
|
||||||
void FormEditorPlugin::extensionsInitialized()
|
void FormEditorPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
|
// 4) test and make sure everything works (undo, saving, editors, opening/closing multiple files, dirtiness etc)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
@@ -31,9 +31,19 @@
|
|||||||
#define FORMEDITORPLUGIN_H
|
#define FORMEDITORPLUGIN_H
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
#include <QtCore/QPointer>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class DesignMode;
|
||||||
|
class IMode;
|
||||||
|
class IEditor;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Designer {
|
namespace Designer {
|
||||||
|
class FormWindowEditor;
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
class FormEditorStack;
|
||||||
|
|
||||||
|
|
||||||
class FormEditorPlugin : public ExtensionSystem::IPlugin
|
class FormEditorPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
@@ -48,7 +58,10 @@ public:
|
|||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void initializeTemplates();
|
void initializeTemplates();
|
||||||
|
|
||||||
|
//Core::IMode *m_prevMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
142
src/plugins/designer/formeditorstack.cpp
Normal file
142
src/plugins/designer/formeditorstack.cpp
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "formeditorstack.h"
|
||||||
|
#include "designerxmleditor.h"
|
||||||
|
#include <QDesignerFormWindowInterface>
|
||||||
|
#include <texteditor/basetextdocument.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include "formwindoweditor.h"
|
||||||
|
#include "formeditorw.h"
|
||||||
|
#include "designerconstants.h"
|
||||||
|
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
|
namespace Designer {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
|
||||||
|
FormEditorStack::FormEditorStack() : activeEditor(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FormEditorStack::~FormEditorStack()
|
||||||
|
{
|
||||||
|
qDeleteAll(m_formEditors);
|
||||||
|
}
|
||||||
|
|
||||||
|
Designer::FormWindowEditor *FormEditorStack::createFormWindowEditor(DesignerXmlEditorEditable *xmlEditor)
|
||||||
|
{
|
||||||
|
FormXmlData *data = new FormXmlData;
|
||||||
|
data->formEditor = FormEditorW::instance()->createFormWindowEditor(this);
|
||||||
|
data->formEditor->setFile(xmlEditor->file());
|
||||||
|
data->xmlEditor = xmlEditor;
|
||||||
|
data->widgetIndex = addWidget(data->formEditor->widget());
|
||||||
|
m_formEditors.append(data);
|
||||||
|
|
||||||
|
setFormEditorData(data->formEditor, xmlEditor->contents());
|
||||||
|
|
||||||
|
TextEditor::BaseTextDocument *document = qobject_cast<TextEditor::BaseTextDocument*>(xmlEditor->file());
|
||||||
|
connect(document, SIGNAL(reloaded()), SLOT(reloadDocument()));
|
||||||
|
|
||||||
|
return data->formEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FormEditorStack::removeFormWindowEditor(Core::IEditor *xmlEditor)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < m_formEditors.length(); ++i) {
|
||||||
|
if (m_formEditors[i]->xmlEditor == xmlEditor) {
|
||||||
|
disconnect(m_formEditors[i]->formEditor->formWindow(), SIGNAL(changed()), this, SLOT(formChanged()));
|
||||||
|
removeWidget(m_formEditors[i]->formEditor->widget());
|
||||||
|
delete m_formEditors[i]->formEditor;
|
||||||
|
m_formEditors.removeAt(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FormEditorStack::setVisibleEditor(Core::IEditor *xmlEditor)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < m_formEditors.length(); ++i) {
|
||||||
|
if (m_formEditors[i]->xmlEditor == xmlEditor) {
|
||||||
|
setCurrentIndex(m_formEditors[i]->widgetIndex);
|
||||||
|
activeEditor = m_formEditors[i];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Designer::FormWindowEditor *FormEditorStack::formWindowEditorForXmlEditor(Core::IEditor *xmlEditor)
|
||||||
|
{
|
||||||
|
foreach(FormXmlData *data, m_formEditors) {
|
||||||
|
if (data->xmlEditor == xmlEditor)
|
||||||
|
return data->formEditor;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FormEditorStack::reloadDocument()
|
||||||
|
{
|
||||||
|
if (activeEditor) {
|
||||||
|
setFormEditorData(activeEditor->formEditor, activeEditor->xmlEditor->contents());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormEditorStack::setFormEditorData(Designer::FormWindowEditor *formEditor, const QString &contents)
|
||||||
|
{
|
||||||
|
disconnect(formEditor->formWindow(), SIGNAL(changed()), this, SLOT(formChanged()));
|
||||||
|
formEditor->createNew(contents);
|
||||||
|
connect(formEditor->formWindow(), SIGNAL(changed()), SLOT(formChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormEditorStack::formChanged()
|
||||||
|
{
|
||||||
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
|
||||||
|
if (core->editorManager()->currentEditor() && activeEditor
|
||||||
|
&& core->editorManager()->currentEditor() == activeEditor->xmlEditor)
|
||||||
|
{
|
||||||
|
TextEditor::BaseTextDocument *doc = qobject_cast<TextEditor::BaseTextDocument*>(activeEditor->xmlEditor->file());
|
||||||
|
Q_ASSERT(doc);
|
||||||
|
if (doc) {
|
||||||
|
doc->document()->setPlainText(activeEditor->formEditor->contents());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // Internal
|
||||||
|
} // Designer
|
87
src/plugins/designer/formeditorstack.h
Normal file
87
src/plugins/designer/formeditorstack.h
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef FORMEDITORSTACK_H
|
||||||
|
#define FORMEDITORSTACK_H
|
||||||
|
|
||||||
|
#include <QtGui/QStackedWidget>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class IEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Designer {
|
||||||
|
class FormWindowEditor;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
class DesignerXmlEditorEditable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A wrapper for Qt Designer form editors, so that they can be used in Design mode.
|
||||||
|
* FormEditorW owns an instance of this class, and creates new form editors when
|
||||||
|
* needed.
|
||||||
|
*/
|
||||||
|
class FormEditorStack : public QStackedWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(FormEditorStack);
|
||||||
|
public:
|
||||||
|
FormEditorStack();
|
||||||
|
~FormEditorStack();
|
||||||
|
Designer::FormWindowEditor *createFormWindowEditor(DesignerXmlEditorEditable *xmlEditor);
|
||||||
|
bool removeFormWindowEditor(Core::IEditor *xmlEditor);
|
||||||
|
bool setVisibleEditor(Core::IEditor *xmlEditor);
|
||||||
|
Designer::FormWindowEditor *formWindowEditorForXmlEditor(Core::IEditor *xmlEditor);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void formChanged();
|
||||||
|
void reloadDocument();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setFormEditorData(Designer::FormWindowEditor *formEditor, const QString &contents);
|
||||||
|
|
||||||
|
struct FormXmlData;
|
||||||
|
QList<FormXmlData*> m_formEditors;
|
||||||
|
|
||||||
|
FormXmlData *activeEditor;
|
||||||
|
|
||||||
|
struct FormXmlData {
|
||||||
|
DesignerXmlEditorEditable *xmlEditor;
|
||||||
|
Designer::FormWindowEditor *formEditor;
|
||||||
|
int widgetIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FORMEDITORSTACK_H
|
@@ -34,7 +34,13 @@
|
|||||||
#include "settingspage.h"
|
#include "settingspage.h"
|
||||||
#include "editorwidget.h"
|
#include "editorwidget.h"
|
||||||
#include "qtcreatorintegration.h"
|
#include "qtcreatorintegration.h"
|
||||||
|
#include "designerxmleditor.h"
|
||||||
|
#include "designercontext.h"
|
||||||
|
#include "formeditorstack.h"
|
||||||
|
|
||||||
|
#include <texteditor/basetextdocument.h>
|
||||||
|
#include <coreplugin/modemanager.h>
|
||||||
|
#include <coreplugin/designmode.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
@@ -198,7 +204,10 @@ FormEditorW::FormEditorW() :
|
|||||||
m_actionPreview(0),
|
m_actionPreview(0),
|
||||||
m_actionGroupPreviewInStyle(0),
|
m_actionGroupPreviewInStyle(0),
|
||||||
m_actionAboutPlugins(0),
|
m_actionAboutPlugins(0),
|
||||||
m_shortcutMapper(new QSignalMapper(this))
|
m_shortcutMapper(new QSignalMapper(this)),
|
||||||
|
m_context(0),
|
||||||
|
m_stack(new FormEditorStack),
|
||||||
|
m_designMode(0)
|
||||||
{
|
{
|
||||||
if (Designer::Constants::Internal::debug)
|
if (Designer::Constants::Internal::debug)
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
@@ -217,9 +226,7 @@ FormEditorW::FormEditorW() :
|
|||||||
m_fwm = qobject_cast<qdesigner_internal::QDesignerFormWindowManager*>(m_formeditor->formWindowManager());
|
m_fwm = qobject_cast<qdesigner_internal::QDesignerFormWindowManager*>(m_formeditor->formWindowManager());
|
||||||
QTC_ASSERT(m_fwm, return);
|
QTC_ASSERT(m_fwm, return);
|
||||||
|
|
||||||
const int uid = m_core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR));
|
m_context = new DesignerContext();
|
||||||
m_context << uid;
|
|
||||||
|
|
||||||
setupActions();
|
setupActions();
|
||||||
|
|
||||||
foreach (QDesignerOptionsPageInterface *designerPage, m_formeditor->optionsPages()) {
|
foreach (QDesignerOptionsPageInterface *designerPage, m_formeditor->optionsPages()) {
|
||||||
@@ -239,6 +246,12 @@ FormEditorW::~FormEditorW()
|
|||||||
{
|
{
|
||||||
saveSettings(m_core->settings());
|
saveSettings(m_core->settings());
|
||||||
|
|
||||||
|
if (m_initStage == FullyInitialized) {
|
||||||
|
m_designMode->unregisterDesignWidget(m_stack);
|
||||||
|
delete m_stack;
|
||||||
|
m_stack = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < Designer::Constants::DesignerSubWindowCount; ++i)
|
for (int i = 0; i < Designer::Constants::DesignerSubWindowCount; ++i)
|
||||||
delete m_designerSubWindows[i];
|
delete m_designerSubWindows[i];
|
||||||
|
|
||||||
@@ -247,7 +260,10 @@ FormEditorW::~FormEditorW()
|
|||||||
ExtensionSystem::PluginManager::instance()->removeObject(settingsPage);
|
ExtensionSystem::PluginManager::instance()->removeObject(settingsPage);
|
||||||
delete settingsPage;
|
delete settingsPage;
|
||||||
}
|
}
|
||||||
delete m_integration;
|
delete m_integration;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_self = 0;
|
m_self = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +303,18 @@ void FormEditorW::fullInit()
|
|||||||
delete initTime;
|
delete initTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(m_core->editorManager()->instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
||||||
|
SLOT(checkToActivateEditor(Core::IEditor*)));
|
||||||
|
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
|
||||||
|
SLOT(syncOnModeChange(Core::IMode*)));
|
||||||
|
connect(m_core->editorManager()->instance(), SIGNAL(editorsClosed(QList<Core::IEditor*>)),
|
||||||
|
SLOT(closeFormEditorsForXmlEditors(QList<Core::IEditor*>)));
|
||||||
|
|
||||||
|
m_designMode = ExtensionSystem::PluginManager::instance()->getObject<Core::DesignMode>();
|
||||||
|
QStringList mimeTypes;
|
||||||
|
mimeTypes << FORM_MIMETYPE;
|
||||||
|
m_designMode->registerDesignWidget(m_stack, mimeTypes);
|
||||||
|
|
||||||
m_initStage = FullyInitialized;
|
m_initStage = FullyInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,6 +371,24 @@ void FormEditorW::deleteInstance()
|
|||||||
delete m_self;
|
delete m_self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormEditorW::checkToActivateEditor(Core::IEditor *editor)
|
||||||
|
{
|
||||||
|
Core::ModeManager *mm = Core::ICore::instance()->modeManager();
|
||||||
|
if (editor && editor->id() == Constants::K_DESIGNER_XML_EDITOR_ID) {
|
||||||
|
mm->activateMode(Core::Constants::MODE_DESIGN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormEditorW::syncOnModeChange(Core::IMode *mode)
|
||||||
|
{
|
||||||
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
if (mode->id() == Core::Constants::MODE_DESIGN
|
||||||
|
&& core->editorManager()->currentEditor()->id() == Designer::Constants::K_DESIGNER_XML_EDITOR_ID )
|
||||||
|
{
|
||||||
|
m_stack->setVisibleEditor(core->editorManager()->currentEditor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FormEditorW::setupActions()
|
void FormEditorW::setupActions()
|
||||||
{
|
{
|
||||||
Core::ActionManager *am = m_core->actionManager();
|
Core::ActionManager *am = m_core->actionManager();
|
||||||
@@ -360,19 +406,19 @@ void FormEditorW::setupActions()
|
|||||||
mtools->addMenu(mformtools);
|
mtools->addMenu(mformtools);
|
||||||
|
|
||||||
//overridden actions
|
//overridden actions
|
||||||
bindShortcut(am->registerAction(m_fwm->actionUndo(), Core::Constants::UNDO, m_context), m_fwm->actionUndo());
|
bindShortcut(am->registerAction(m_fwm->actionUndo(), Core::Constants::UNDO, m_context->context()), m_fwm->actionUndo());
|
||||||
bindShortcut(am->registerAction(m_fwm->actionRedo(), Core::Constants::REDO, m_context), m_fwm->actionRedo());
|
bindShortcut(am->registerAction(m_fwm->actionRedo(), Core::Constants::REDO, m_context->context()), m_fwm->actionRedo());
|
||||||
bindShortcut(am->registerAction(m_fwm->actionCut(), Core::Constants::CUT, m_context), m_fwm->actionCut());
|
bindShortcut(am->registerAction(m_fwm->actionCut(), Core::Constants::CUT, m_context->context()), m_fwm->actionCut());
|
||||||
bindShortcut(am->registerAction(m_fwm->actionCopy(), Core::Constants::COPY, m_context), m_fwm->actionCopy());
|
bindShortcut(am->registerAction(m_fwm->actionCopy(), Core::Constants::COPY, m_context->context()), m_fwm->actionCopy());
|
||||||
bindShortcut(am->registerAction(m_fwm->actionPaste(), Core::Constants::PASTE, m_context), m_fwm->actionPaste());
|
bindShortcut(am->registerAction(m_fwm->actionPaste(), Core::Constants::PASTE, m_context->context()), m_fwm->actionPaste());
|
||||||
bindShortcut(am->registerAction(m_fwm->actionSelectAll(), Core::Constants::SELECTALL, m_context), m_fwm->actionSelectAll());
|
bindShortcut(am->registerAction(m_fwm->actionSelectAll(), Core::Constants::SELECTALL, m_context->context()), m_fwm->actionSelectAll());
|
||||||
|
|
||||||
m_actionPrint = new QAction(this);
|
m_actionPrint = new QAction(this);
|
||||||
bindShortcut(am->registerAction(m_actionPrint, Core::Constants::PRINT, m_context), m_actionPrint);
|
bindShortcut(am->registerAction(m_actionPrint, Core::Constants::PRINT, m_context->context()), m_actionPrint);
|
||||||
connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(print()));
|
connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(print()));
|
||||||
|
|
||||||
//'delete' action
|
//'delete' action
|
||||||
command = am->registerAction(m_fwm->actionDelete(), QLatin1String("FormEditor.Edit.Delete"), m_context);
|
command = am->registerAction(m_fwm->actionDelete(), QLatin1String("FormEditor.Edit.Delete"), m_context->context());
|
||||||
command->setDefaultKeySequence(QKeySequence::Delete);
|
command->setDefaultKeySequence(QKeySequence::Delete);
|
||||||
bindShortcut(command, m_fwm->actionDelete());
|
bindShortcut(command, m_fwm->actionDelete());
|
||||||
command->setAttribute(Core::Command::CA_Hide);
|
command->setAttribute(Core::Command::CA_Hide);
|
||||||
@@ -451,7 +497,7 @@ void FormEditorW::setupActions()
|
|||||||
addToolAction(m_fwm->actionSimplifyLayout(), am, globalcontext,
|
addToolAction(m_fwm->actionSimplifyLayout(), am, globalcontext,
|
||||||
m_toolActionIds.back(), mformtools);
|
m_toolActionIds.back(), mformtools);
|
||||||
|
|
||||||
createSeparator(this, am, m_context, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator1"));
|
createSeparator(this, am, m_context->context(), mformtools, QLatin1String("FormEditor.Menu.Tools.Separator1"));
|
||||||
|
|
||||||
addToolAction(m_fwm->actionLower(), am, globalcontext,
|
addToolAction(m_fwm->actionLower(), am, globalcontext,
|
||||||
QLatin1String("FormEditor.Lower"), mformtools);
|
QLatin1String("FormEditor.Lower"), mformtools);
|
||||||
@@ -512,7 +558,7 @@ void FormEditorW::setupActions()
|
|||||||
mformtools->addMenu(createPreviewStyleMenu(am, m_actionGroupPreviewInStyle));
|
mformtools->addMenu(createPreviewStyleMenu(am, m_actionGroupPreviewInStyle));
|
||||||
|
|
||||||
// Form settings
|
// Form settings
|
||||||
createSeparator(this, am, m_context, medit, QLatin1String("FormEditor.Edit.Separator2"), Core::Constants::G_EDIT_OTHER);
|
createSeparator(this, am, m_context->context(), medit, QLatin1String("FormEditor.Edit.Separator2"), Core::Constants::G_EDIT_OTHER);
|
||||||
|
|
||||||
createSeparator(this, am, globalcontext, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator3"));
|
createSeparator(this, am, globalcontext, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator3"));
|
||||||
QAction *actionFormSettings = m_fwm->actionShowFormWindowSettingsDialog();
|
QAction *actionFormSettings = m_fwm->actionShowFormWindowSettingsDialog();
|
||||||
@@ -576,7 +622,7 @@ Core::ActionContainer *FormEditorW::createPreviewStyleMenu(Core::ActionManager *
|
|||||||
name += dot;
|
name += dot;
|
||||||
}
|
}
|
||||||
name += data.toString();
|
name += data.toString();
|
||||||
Core::Command *command = am->registerAction(a, name, m_context);
|
Core::Command *command = am->registerAction(a, name, m_context->context());
|
||||||
bindShortcut(command, a);
|
bindShortcut(command, a);
|
||||||
if (isDeviceProfile) {
|
if (isDeviceProfile) {
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
@@ -661,12 +707,17 @@ FormWindowEditor *FormEditorW::createFormWindowEditor(QWidget* parentWidget)
|
|||||||
{
|
{
|
||||||
m_fwm->closeAllPreviews();
|
m_fwm->closeAllPreviews();
|
||||||
QDesignerFormWindowInterface *form = m_fwm->createFormWindow(0);
|
QDesignerFormWindowInterface *form = m_fwm->createFormWindow(0);
|
||||||
|
|
||||||
connect(form, SIGNAL(toolChanged(int)), this, SLOT(toolChanged(int)));
|
connect(form, SIGNAL(toolChanged(int)), this, SLOT(toolChanged(int)));
|
||||||
qdesigner_internal::FormWindowBase::setupDefaultAction(form);
|
qdesigner_internal::FormWindowBase::setupDefaultAction(form);
|
||||||
FormWindowEditor *fww = new FormWindowEditor(m_context, form, parentWidget);
|
|
||||||
|
FormWindowEditor *fww = new FormWindowEditor(form, parentWidget);
|
||||||
// Store a pointer to all form windows so we can unselect
|
// Store a pointer to all form windows so we can unselect
|
||||||
// all other formwindows except the active one.
|
// all other formwindows except the active one.
|
||||||
m_formWindows.append(fww);
|
m_formWindows.append(fww);
|
||||||
|
|
||||||
|
fww->setContext(m_context->context());
|
||||||
|
|
||||||
connect(fww, SIGNAL(destroyed()), this, SLOT(editorDestroyed()));
|
connect(fww, SIGNAL(destroyed()), this, SLOT(editorDestroyed()));
|
||||||
return fww;
|
return fww;
|
||||||
}
|
}
|
||||||
@@ -705,10 +756,20 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor)
|
|||||||
qDebug() << Q_FUNC_INFO << editor << " of " << m_fwm->formWindowCount();
|
qDebug() << Q_FUNC_INFO << editor << " of " << m_fwm->formWindowCount();
|
||||||
|
|
||||||
// Deactivate Designer if a non-form is being edited
|
// Deactivate Designer if a non-form is being edited
|
||||||
if (editor && editor->id() == QLatin1String(Constants::FORMEDITOR_ID)) {
|
if (editor && editor->id() == QLatin1String(Constants::K_DESIGNER_XML_EDITOR_ID)) {
|
||||||
FormWindowEditor *fw = qobject_cast<FormWindowEditor *>(editor);
|
DesignerXmlEditorEditable *xmlEditor = qobject_cast<DesignerXmlEditorEditable *>(editor);
|
||||||
QTC_ASSERT(fw, return);
|
FormWindowEditor *fw = m_stack->formWindowEditorForXmlEditor(xmlEditor);
|
||||||
|
QTC_ASSERT(xmlEditor, return);
|
||||||
|
if (!fw)
|
||||||
|
fw = m_stack->createFormWindowEditor(xmlEditor);
|
||||||
|
|
||||||
|
// change context when activating another editor
|
||||||
|
m_core->removeContextObject(m_context);
|
||||||
|
m_context->setWidget(fw->widget());
|
||||||
|
m_core->addContextObject(m_context);
|
||||||
|
|
||||||
fw->activate();
|
fw->activate();
|
||||||
|
|
||||||
m_fwm->setActiveFormWindow(fw->formWindow());
|
m_fwm->setActiveFormWindow(fw->formWindow());
|
||||||
m_actionGroupEditMode->setVisible(true);
|
m_actionGroupEditMode->setVisible(true);
|
||||||
m_modeActionSeparator->setVisible(true);
|
m_modeActionSeparator->setVisible(true);
|
||||||
@@ -810,6 +871,13 @@ void FormEditorW::resetToDefaultLayout()
|
|||||||
fwe->resetToDefaultLayout();
|
fwe->resetToDefaultLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormEditorW::closeFormEditorsForXmlEditors(QList<Core::IEditor*> editors)
|
||||||
|
{
|
||||||
|
foreach(Core::IEditor *editor, editors) {
|
||||||
|
m_stack->removeFormWindowEditor(editor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FormEditorW::print()
|
void FormEditorW::print()
|
||||||
{
|
{
|
||||||
// Printing code courtesy of designer_actions.cpp
|
// Printing code courtesy of designer_actions.cpp
|
||||||
@@ -864,3 +932,4 @@ void FormEditorW::print()
|
|||||||
m_core->printer()->setFullPage(oldFullPage);
|
m_core->printer()->setFullPage(oldFullPage);
|
||||||
m_core->printer()->setOrientation(oldOrientation);
|
m_core->printer()->setOrientation(oldOrientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,6 +67,8 @@ class ActionContainer;
|
|||||||
class ICore;
|
class ICore;
|
||||||
class IEditor;
|
class IEditor;
|
||||||
class Command;
|
class Command;
|
||||||
|
class IMode;
|
||||||
|
class DesignMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Designer {
|
namespace Designer {
|
||||||
@@ -74,7 +76,9 @@ class FormWindowEditor;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class FormEditorStack;
|
||||||
class SettingsPage;
|
class SettingsPage;
|
||||||
|
class DesignerContext;
|
||||||
|
|
||||||
class ProxyAction : public QAction
|
class ProxyAction : public QAction
|
||||||
{
|
{
|
||||||
@@ -144,6 +148,9 @@ private slots:
|
|||||||
|
|
||||||
void editorDestroyed();
|
void editorDestroyed();
|
||||||
void updateShortcut(QObject *command);
|
void updateShortcut(QObject *command);
|
||||||
|
void syncOnModeChange(Core::IMode *mode);
|
||||||
|
void checkToActivateEditor(Core::IEditor *editor);
|
||||||
|
void closeFormEditorsForXmlEditors(QList<Core::IEditor*> editors);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FormEditorW();
|
FormEditorW();
|
||||||
@@ -199,12 +206,15 @@ private:
|
|||||||
QActionGroup *m_actionGroupPreviewInStyle;
|
QActionGroup *m_actionGroupPreviewInStyle;
|
||||||
QAction *m_actionAboutPlugins;
|
QAction *m_actionAboutPlugins;
|
||||||
QAction *m_modeActionSeparator;
|
QAction *m_modeActionSeparator;
|
||||||
|
|
||||||
QList<int> m_context;
|
|
||||||
|
|
||||||
EditorList m_formWindows;
|
|
||||||
QStringList m_toolActionIds;
|
|
||||||
QSignalMapper *m_shortcutMapper;
|
QSignalMapper *m_shortcutMapper;
|
||||||
|
|
||||||
|
DesignerContext *m_context;
|
||||||
|
EditorList m_formWindows;
|
||||||
|
|
||||||
|
QStringList m_toolActionIds;
|
||||||
|
QPointer<FormEditorStack> m_stack;
|
||||||
|
Core::DesignMode *m_designMode;
|
||||||
|
|
||||||
QMap<Core::Command *, QAction *> m_commandToDesignerAction;
|
QMap<Core::Command *, QAction *> m_commandToDesignerAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "formwindoweditor.h"
|
#include "formwindoweditor.h"
|
||||||
#include "formwindowfile.h"
|
#include "formwindowfile.h"
|
||||||
#include "formwindowhost.h"
|
#include "formwindowhost.h"
|
||||||
|
#include "faketoolbar.h"
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
@@ -41,6 +42,8 @@
|
|||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
#include <QtDesigner/QDesignerFormWindowInterface>
|
#include <QtDesigner/QDesignerFormWindowInterface>
|
||||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||||
@@ -99,38 +102,60 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FormWindowEditor::FormWindowEditor(const QList<int> &context,
|
FormWindowEditor::FormWindowEditor(QDesignerFormWindowInterface *form,
|
||||||
QDesignerFormWindowInterface *form,
|
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: Core::IEditor(parent),
|
: Core::IEditor(parent),
|
||||||
m_context(context),
|
|
||||||
m_formWindow(form),
|
m_formWindow(form),
|
||||||
m_file(new FormWindowFile(form, this)),
|
m_file(0),
|
||||||
m_host(new FormWindowHost(form)),
|
m_host(new FormWindowHost(form)),
|
||||||
m_editorWidget(new EditorWidget(m_host)),
|
m_editorWidget(new EditorWidget(m_host)),
|
||||||
m_toolBar(0),
|
m_toolBar(0),
|
||||||
m_sessionNode(0),
|
m_sessionNode(0),
|
||||||
m_sessionWatcher(0)
|
m_sessionWatcher(0),
|
||||||
|
m_fakeToolBar(new FakeToolBar(this, toolBar()))
|
||||||
{
|
{
|
||||||
|
m_containerWidget = new QWidget;
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(m_containerWidget);
|
||||||
|
m_containerWidget->setLayout(layout);
|
||||||
|
|
||||||
|
layout->addWidget(m_fakeToolBar);
|
||||||
|
layout->addWidget(m_editorWidget);
|
||||||
|
layout->setStretch(0,0);
|
||||||
|
layout->setStretch(1,1);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
layout->setMargin(0);
|
||||||
|
layout->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
if (Designer::Constants::Internal::debug)
|
if (Designer::Constants::Internal::debug)
|
||||||
qDebug() << Q_FUNC_INFO << form << parent;
|
qDebug() << Q_FUNC_INFO << form << parent;
|
||||||
|
|
||||||
connect(m_file, SIGNAL(reload(QString)), this, SLOT(slotOpen(QString)));
|
|
||||||
connect(m_file, SIGNAL(setDisplayName(QString)), this, SLOT(slotSetDisplayName(QString)));
|
|
||||||
connect(m_file, SIGNAL(changed()), this, SIGNAL(changed()));
|
|
||||||
connect(m_file, SIGNAL(changed()), this, SLOT(updateResources()));
|
|
||||||
connect(this, SIGNAL(opened(QString)), m_file, SLOT(setFileName(QString)));
|
|
||||||
|
|
||||||
connect(m_host, SIGNAL(changed()), this, SIGNAL(changed()));
|
connect(m_host, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||||
|
|
||||||
connect(form, SIGNAL(toolChanged(int)), m_editorWidget, SLOT(toolChanged(int)));
|
connect(form, SIGNAL(toolChanged(int)), m_editorWidget, SLOT(toolChanged(int)));
|
||||||
|
|
||||||
m_editorWidget->activate();
|
m_editorWidget->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormWindowEditor::setFile(Core::IFile *file)
|
||||||
|
{
|
||||||
|
if (m_file) {
|
||||||
|
disconnect(m_file, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||||
|
disconnect(m_file, SIGNAL(changed()), this, SLOT(updateResources()));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_file = file;
|
||||||
|
|
||||||
|
if (m_file) {
|
||||||
|
connect(m_file, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||||
|
connect(m_file, SIGNAL(changed()), this, SLOT(updateResources()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FormWindowEditor::~FormWindowEditor()
|
FormWindowEditor::~FormWindowEditor()
|
||||||
{
|
{
|
||||||
// Close: Delete the Designer form window via embedding widget
|
// Close: Delete the Designer form window via embedding widget
|
||||||
delete m_toolBar;
|
delete m_toolBar;
|
||||||
|
delete m_fakeToolBar;
|
||||||
delete m_host;
|
delete m_host;
|
||||||
delete m_editorWidget;
|
delete m_editorWidget;
|
||||||
if (Designer::Constants::Internal::debug)
|
if (Designer::Constants::Internal::debug)
|
||||||
@@ -141,6 +166,11 @@ FormWindowEditor::~FormWindowEditor()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormWindowEditor::setContext(QList<int> context)
|
||||||
|
{
|
||||||
|
m_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
bool FormWindowEditor::createNew(const QString &contents)
|
bool FormWindowEditor::createNew(const QString &contents)
|
||||||
{
|
{
|
||||||
if (Designer::Constants::Internal::debug)
|
if (Designer::Constants::Internal::debug)
|
||||||
@@ -302,7 +332,7 @@ QList<int> FormWindowEditor::context() const
|
|||||||
|
|
||||||
QWidget *FormWindowEditor::widget()
|
QWidget *FormWindowEditor::widget()
|
||||||
{
|
{
|
||||||
return m_editorWidget;
|
return m_containerWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -321,11 +351,6 @@ void FormWindowEditor::updateFormWindowSelectionHandles(bool state)
|
|||||||
m_host->updateFormWindowSelectionHandles(state);
|
m_host->updateFormWindowSelectionHandles(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormWindowEditor::setSuggestedFileName(const QString &fileName)
|
|
||||||
{
|
|
||||||
m_file->setSuggestedFileName(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FormWindowEditor::activate()
|
void FormWindowEditor::activate()
|
||||||
{
|
{
|
||||||
m_editorWidget->activate();
|
m_editorWidget->activate();
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QPointer>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QDesignerFormWindowInterface;
|
class QDesignerFormWindowInterface;
|
||||||
@@ -54,6 +55,7 @@ namespace Internal {
|
|||||||
class FormWindowFile;
|
class FormWindowFile;
|
||||||
class FormWindowHost;
|
class FormWindowHost;
|
||||||
class EditorWidget;
|
class EditorWidget;
|
||||||
|
class FakeToolBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Master class maintaining a form window editor,
|
// Master class maintaining a form window editor,
|
||||||
@@ -63,8 +65,7 @@ class DESIGNER_EXPORT FormWindowEditor : public Core::IEditor
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FormWindowEditor(const QList<int> &context,
|
FormWindowEditor(QDesignerFormWindowInterface *form,
|
||||||
QDesignerFormWindowInterface *form,
|
|
||||||
QObject *parent = 0);
|
QObject *parent = 0);
|
||||||
~FormWindowEditor();
|
~FormWindowEditor();
|
||||||
|
|
||||||
@@ -82,6 +83,7 @@ public:
|
|||||||
bool restoreState(const QByteArray &state);
|
bool restoreState(const QByteArray &state);
|
||||||
virtual bool isTemporary() const { return false; }
|
virtual bool isTemporary() const { return false; }
|
||||||
|
|
||||||
|
void setContext(QList<int> ctx);
|
||||||
// ContextInterface
|
// ContextInterface
|
||||||
virtual QList<int> context() const;
|
virtual QList<int> context() const;
|
||||||
virtual QWidget *widget();
|
virtual QWidget *widget();
|
||||||
@@ -90,12 +92,12 @@ public:
|
|||||||
QDesignerFormWindowInterface *formWindow() const;
|
QDesignerFormWindowInterface *formWindow() const;
|
||||||
QWidget *integrationContainer();
|
QWidget *integrationContainer();
|
||||||
void updateFormWindowSelectionHandles(bool state);
|
void updateFormWindowSelectionHandles(bool state);
|
||||||
void setSuggestedFileName(const QString &fileName);
|
|
||||||
QDockWidget* const* dockWidgets() const;
|
QDockWidget* const* dockWidgets() const;
|
||||||
bool isLocked() const;
|
bool isLocked() const;
|
||||||
void setLocked(bool locked);
|
void setLocked(bool locked);
|
||||||
|
|
||||||
QString contents() const;
|
QString contents() const;\
|
||||||
|
void setFile(Core::IFile *file);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Internal
|
// Internal
|
||||||
@@ -111,18 +113,20 @@ private slots:
|
|||||||
void updateResources();
|
void updateResources();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QWidget *m_containerWidget;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
const QList<int> m_context;
|
QList<int> m_context;
|
||||||
QDesignerFormWindowInterface *m_formWindow;
|
QDesignerFormWindowInterface *m_formWindow;
|
||||||
Internal::FormWindowFile *m_file;
|
QPointer<Core::IFile> m_file;
|
||||||
Internal::FormWindowHost *m_host;
|
Internal::FormWindowHost *m_host;
|
||||||
Internal::EditorWidget *m_editorWidget;
|
Internal::EditorWidget *m_editorWidget;
|
||||||
QToolBar *m_toolBar;
|
QToolBar *m_toolBar;
|
||||||
QStringList m_originalUiQrcPaths;
|
QStringList m_originalUiQrcPaths;
|
||||||
ProjectExplorer::SessionNode *m_sessionNode;
|
ProjectExplorer::SessionNode *m_sessionNode;
|
||||||
ProjectExplorer::NodesWatcher *m_sessionWatcher;
|
ProjectExplorer::NodesWatcher *m_sessionWatcher;
|
||||||
|
Internal::FakeToolBar *m_fakeToolBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Designer
|
||||||
|
|
||||||
#endif // FORMWINDOWEDITOR_H
|
#endif // FORMWINDOWEDITOR_H
|
||||||
|
@@ -95,7 +95,6 @@ void BaseFileFilter::accept(Locator::FilterEntry selection) const
|
|||||||
{
|
{
|
||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
Core::EditorManager *em = Core::EditorManager::instance();
|
||||||
em->openEditor(selection.internalData.toString());
|
em->openEditor(selection.internalData.toString());
|
||||||
em->ensureEditorManagerVisible();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseFileFilter::generateFileNames()
|
void BaseFileFilter::generateFileNames()
|
||||||
|
@@ -266,7 +266,6 @@ void FolderNavigationWidget::openItem(const QModelIndex &srcIndex)
|
|||||||
// Open file.
|
// Open file.
|
||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
editorManager->openEditor(m_fileSystemModel->filePath(srcIndex));
|
editorManager->openEditor(m_fileSystemModel->filePath(srcIndex));
|
||||||
editorManager->ensureEditorManagerVisible();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderNavigationWidget::setCurrentTitle(const QString &dirName, const QString &fullPath)
|
void FolderNavigationWidget::setCurrentTitle(const QString &dirName, const QString &fullPath)
|
||||||
|
@@ -337,7 +337,6 @@ void ProjectTreeWidget::openItem(const QModelIndex &mainIndex)
|
|||||||
if (node->nodeType() == FileNodeType) {
|
if (node->nodeType() == FileNodeType) {
|
||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
editorManager->openEditor(node->path());
|
editorManager->openEditor(node->path());
|
||||||
editorManager->ensureEditorManagerVisible();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,292 +0,0 @@
|
|||||||
/**************************************************************************
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator
|
|
||||||
**
|
|
||||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
**
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** Commercial Usage
|
|
||||||
**
|
|
||||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
||||||
** accordance with the Qt Commercial License Agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Nokia.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
**
|
|
||||||
** Alternatively, 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.
|
|
||||||
**
|
|
||||||
** If you are unsure which license is appropriate for your use, please
|
|
||||||
** contact the sales department at http://qt.nokia.com/contact.
|
|
||||||
**
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include "designmode.h"
|
|
||||||
#include "qmldesignerconstants.h"
|
|
||||||
#include "designmodewidget.h"
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/modemanager.h>
|
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
|
||||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
|
||||||
#include <coreplugin/actionmanager/command.h>
|
|
||||||
#include <coreplugin/coreconstants.h>
|
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
|
|
||||||
#include <QAction>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QFileInfo>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
enum {
|
|
||||||
debug = false
|
|
||||||
};
|
|
||||||
|
|
||||||
DesignModeCoreListener::DesignModeCoreListener(DesignMode *mode) :
|
|
||||||
m_mode(mode)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DesignModeCoreListener::coreAboutToClose()
|
|
||||||
{
|
|
||||||
// make sure settings are stored before actual program exit
|
|
||||||
m_mode->currentEditorChanged(0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
DesignMode::DesignMode() :
|
|
||||||
IMode(),
|
|
||||||
m_mainWidget(new DesignModeWidget(this)),
|
|
||||||
m_coreListener(new DesignModeCoreListener(this)),
|
|
||||||
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))
|
|
||||||
{
|
|
||||||
Core::ICore *creatorCore = Core::ICore::instance();
|
|
||||||
Core::ModeManager *modeManager = creatorCore->modeManager();
|
|
||||||
|
|
||||||
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)),
|
|
||||||
this, SLOT(modeChanged(Core::IMode*)));
|
|
||||||
|
|
||||||
ExtensionSystem::PluginManager::instance()->addObject(m_coreListener);
|
|
||||||
|
|
||||||
Core::ActionManager *actionManager = creatorCore->actionManager();
|
|
||||||
Core::EditorManager *editorManager = creatorCore->editorManager();
|
|
||||||
|
|
||||||
// Undo / Redo
|
|
||||||
actionManager->registerAction(m_mainWidget->undoAction(), Core::Constants::UNDO, context());
|
|
||||||
actionManager->registerAction(m_mainWidget->redoAction(), Core::Constants::REDO, context());
|
|
||||||
|
|
||||||
// Revert to saved
|
|
||||||
actionManager->registerAction(m_revertToSavedAction,
|
|
||||||
Core::Constants::REVERTTOSAVED, context());
|
|
||||||
connect(m_revertToSavedAction, SIGNAL(triggered()), editorManager, SLOT(revertToSaved()));
|
|
||||||
|
|
||||||
//Save
|
|
||||||
actionManager->registerAction(m_saveAction, Core::Constants::SAVE, context());
|
|
||||||
connect(m_saveAction, SIGNAL(triggered()), editorManager, SLOT(saveFile()));
|
|
||||||
|
|
||||||
//Save As
|
|
||||||
actionManager->registerAction(m_saveAsAction, Core::Constants::SAVEAS, context());
|
|
||||||
connect(m_saveAsAction, SIGNAL(triggered()), editorManager, SLOT(saveFileAs()));
|
|
||||||
|
|
||||||
//Close Editor
|
|
||||||
actionManager->registerAction(m_closeCurrentEditorAction, Core::Constants::CLOSE, context());
|
|
||||||
connect(m_closeCurrentEditorAction, SIGNAL(triggered()), editorManager, SLOT(closeEditor()));
|
|
||||||
|
|
||||||
//Close All
|
|
||||||
actionManager->registerAction(m_closeAllEditorsAction, Core::Constants::CLOSEALL, context());
|
|
||||||
connect(m_closeAllEditorsAction, SIGNAL(triggered()), editorManager, SLOT(closeAllEditors()));
|
|
||||||
|
|
||||||
//Close All Others Action
|
|
||||||
actionManager->registerAction(m_closeOtherEditorsAction, Core::Constants::CLOSEOTHERS, context());
|
|
||||||
connect(m_closeOtherEditorsAction, SIGNAL(triggered()), editorManager, SLOT(closeOtherEditors()));
|
|
||||||
|
|
||||||
connect(editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)),
|
|
||||||
this, SLOT(currentEditorChanged(Core::IEditor*)));
|
|
||||||
connect(editorManager, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
|
|
||||||
this, SLOT(textEditorsClosed(QList<Core::IEditor*>)));
|
|
||||||
|
|
||||||
Core::ActionContainer *editMenu = actionManager->actionContainer(Core::Constants::M_EDIT);
|
|
||||||
|
|
||||||
Core::Command *command;
|
|
||||||
command = actionManager->registerAction(m_mainWidget->deleteAction(),
|
|
||||||
QmlDesigner::Constants::DELETE, context());
|
|
||||||
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(),
|
|
||||||
Core::Constants::CUT, context());
|
|
||||||
command->setDefaultKeySequence(QKeySequence::Cut);
|
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
|
||||||
|
|
||||||
command = actionManager->registerAction(m_mainWidget->copyAction(),
|
|
||||||
Core::Constants::COPY, context());
|
|
||||||
command->setDefaultKeySequence(QKeySequence::Copy);
|
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
|
||||||
|
|
||||||
command = actionManager->registerAction(m_mainWidget->pasteAction(),
|
|
||||||
Core::Constants::PASTE, context());
|
|
||||||
command->setDefaultKeySequence(QKeySequence::Paste);
|
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
|
||||||
|
|
||||||
command = actionManager->registerAction(m_mainWidget->selectAllAction(),
|
|
||||||
Core::Constants::SELECTALL, context());
|
|
||||||
command->setDefaultKeySequence(QKeySequence::SelectAll);
|
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_SELECTALL);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
updateActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
DesignMode::~DesignMode()
|
|
||||||
{
|
|
||||||
delete m_mainWidget;
|
|
||||||
ExtensionSystem::PluginManager::instance()->removeObject(m_coreListener);
|
|
||||||
delete m_coreListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<int> DesignMode::context() const
|
|
||||||
{
|
|
||||||
static QList<int> contexts = QList<int>() <<
|
|
||||||
Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::C_DESIGN_MODE);
|
|
||||||
return contexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *DesignMode::widget()
|
|
||||||
{
|
|
||||||
return m_mainWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DesignMode::displayName() const
|
|
||||||
{
|
|
||||||
return tr(Constants::DESIGN_MODE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon DesignMode::icon() const
|
|
||||||
{
|
|
||||||
return QIcon(QLatin1String(":/qmldesigner/images/mode_Design.png"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int DesignMode::priority() const
|
|
||||||
{
|
|
||||||
return Constants::DESIGN_MODE_PRIORITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DesignMode::id() const
|
|
||||||
{
|
|
||||||
return QLatin1String(Constants::DESIGN_MODE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DesignMode::textEditorsClosed(QList<Core::IEditor*> editors)
|
|
||||||
{
|
|
||||||
m_mainWidget->closeEditors(editors);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DesignMode::modeChanged(Core::IMode *mode)
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
qDebug() << Q_FUNC_INFO << ((mode == this) ? "Design mode" : "other mode");
|
|
||||||
if (mode == this) {
|
|
||||||
m_isActive = true;
|
|
||||||
m_mainWidget->showEditor(m_currentEditor.data());
|
|
||||||
} else {
|
|
||||||
if (m_isActive) {
|
|
||||||
m_isActive = false;
|
|
||||||
m_mainWidget->showEditor(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DesignMode::currentEditorChanged(Core::IEditor *editor)
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
qDebug() << Q_FUNC_INFO << editor;
|
|
||||||
|
|
||||||
if (m_currentEditor.data() == editor)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_currentEditor)
|
|
||||||
disconnect(m_currentEditor.data(), SIGNAL(changed()), this, SLOT(updateActions()));
|
|
||||||
|
|
||||||
m_currentEditor = QWeakPointer<Core::IEditor>(editor);
|
|
||||||
|
|
||||||
if (m_currentEditor)
|
|
||||||
connect(m_currentEditor.data(), SIGNAL(changed()), this, SLOT(updateActions()));
|
|
||||||
|
|
||||||
updateActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DesignMode::makeCurrentEditorWritable()
|
|
||||||
{
|
|
||||||
Core::ICore *creatorCore = Core::ICore::instance();
|
|
||||||
if (m_currentEditor)
|
|
||||||
creatorCore->editorManager()->makeEditorWritable(m_currentEditor.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
// copied from EditorManager::updateActions
|
|
||||||
void DesignMode::updateActions()
|
|
||||||
{
|
|
||||||
Core::ICore *creatorCore = Core::ICore::instance();
|
|
||||||
Core::EditorManager *editorManager = creatorCore->editorManager();
|
|
||||||
|
|
||||||
Core::IEditor *curEditor = m_currentEditor.data();
|
|
||||||
int openedCount = editorManager->openedEditors().count()
|
|
||||||
+ 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")));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace QmlDesigner
|
|
61
src/plugins/qmldesigner/designmodecontext.cpp
Normal file
61
src/plugins/qmldesigner/designmodecontext.cpp
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "designmodecontext.h"
|
||||||
|
#include "qmldesignerconstants.h"
|
||||||
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace QmlDesigner {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
DesignModeContext::DesignModeContext(QWidget *widget) : IContext(widget),
|
||||||
|
m_widget(widget)
|
||||||
|
{
|
||||||
|
m_context << Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::C_FORMEDITOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
DesignModeContext::~DesignModeContext()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<int> DesignModeContext::context() const
|
||||||
|
{
|
||||||
|
return m_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *DesignModeContext::widget()
|
||||||
|
{
|
||||||
|
return m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
62
src/plugins/qmldesigner/designmodecontext.h
Normal file
62
src/plugins/qmldesigner/designmodecontext.h
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DESIGNMODECONTEXT_H
|
||||||
|
#define DESIGNMODECONTEXT_H
|
||||||
|
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QWidget;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace QmlDesigner {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bauhaus Design mode context object
|
||||||
|
*/
|
||||||
|
class DesignModeContext : public Core::IContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DesignModeContext(QWidget *widget);
|
||||||
|
~DesignModeContext();
|
||||||
|
|
||||||
|
QList<int> context() const;
|
||||||
|
QWidget *widget();
|
||||||
|
private:
|
||||||
|
QList<int> m_context;
|
||||||
|
QWidget *m_widget;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // DESIGNMODECONTEXT_H
|
@@ -28,7 +28,6 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "designmodewidget.h"
|
#include "designmodewidget.h"
|
||||||
#include "designmode.h"
|
|
||||||
#include "qmldesignerconstants.h"
|
#include "qmldesignerconstants.h"
|
||||||
|
|
||||||
#include <model.h>
|
#include <model.h>
|
||||||
@@ -471,9 +470,8 @@ ModelNode DocumentWidget::nodeForPosition(int cursorPos) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------- DesignModeWidget
|
// ---------- DesignModeWidget
|
||||||
DesignModeWidget::DesignModeWidget(DesignMode *designMode, QWidget *parent) :
|
DesignModeWidget::DesignModeWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
m_designMode(designMode),
|
|
||||||
m_documentWidgetStack(new QStackedWidget),
|
m_documentWidgetStack(new QStackedWidget),
|
||||||
m_currentDocumentWidget(0),
|
m_currentDocumentWidget(0),
|
||||||
m_currentTextEdit(0),
|
m_currentTextEdit(0),
|
||||||
@@ -603,11 +601,6 @@ QAction *DesignModeWidget::selectAllAction() const
|
|||||||
return m_selectAllAction;
|
return m_selectAllAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
DesignMode *DesignModeWidget::designMode() const
|
|
||||||
{
|
|
||||||
return m_designMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DesignModeWidget::undo()
|
void DesignModeWidget::undo()
|
||||||
{
|
{
|
||||||
if (m_currentDocumentWidget)
|
if (m_currentDocumentWidget)
|
||||||
|
@@ -161,7 +161,7 @@ class DesignModeWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(DesignModeWidget)
|
Q_DISABLE_COPY(DesignModeWidget)
|
||||||
public:
|
public:
|
||||||
explicit DesignModeWidget(DesignMode *designMode, QWidget *parent = 0);
|
explicit DesignModeWidget(QWidget *parent = 0);
|
||||||
~DesignModeWidget();
|
~DesignModeWidget();
|
||||||
|
|
||||||
// void syncWithTextEdit(bool sync);
|
// void syncWithTextEdit(bool sync);
|
||||||
@@ -176,8 +176,6 @@ public:
|
|||||||
QAction *pasteAction() const;
|
QAction *pasteAction() const;
|
||||||
QAction *selectAllAction() const;
|
QAction *selectAllAction() const;
|
||||||
|
|
||||||
DesignMode *designMode() const;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
@@ -193,8 +191,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void setCurrentDocumentWidget(DocumentWidget *newDocumentWidget);
|
void setCurrentDocumentWidget(DocumentWidget *newDocumentWidget);
|
||||||
|
|
||||||
DesignMode *m_designMode;
|
|
||||||
|
|
||||||
QStackedWidget *m_documentWidgetStack;
|
QStackedWidget *m_documentWidgetStack;
|
||||||
QHash<QPlainTextEdit*,DocumentWidget*> m_documentHash;
|
QHash<QPlainTextEdit*,DocumentWidget*> m_documentHash;
|
||||||
DocumentWidget *m_currentDocumentWidget;
|
DocumentWidget *m_currentDocumentWidget;
|
||||||
|
@@ -39,7 +39,7 @@ const char * const DELETE = "QmlDesigner.Delete";
|
|||||||
|
|
||||||
// context
|
// context
|
||||||
const char * const C_DESIGN_MODE = "QmlDesigner::DesignMode";
|
const char * const C_DESIGN_MODE = "QmlDesigner::DesignMode";
|
||||||
const char * const C_FORMEDITOR = "QmlDesigner::FormEditor";
|
const char * const C_FORMEDITOR = "QmlDesigner::QmlFormEditor";
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
const char * const SWITCH_TEXT_DESIGN = "QmlDesigner.SwitchTextDesign";
|
const char * const SWITCH_TEXT_DESIGN = "QmlDesigner.SwitchTextDesign";
|
||||||
|
@@ -29,11 +29,13 @@
|
|||||||
|
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "qmldesignerplugin.h"
|
#include "qmldesignerplugin.h"
|
||||||
#include "designmode.h"
|
|
||||||
#include "qmldesignerconstants.h"
|
#include "qmldesignerconstants.h"
|
||||||
#include "pluginmanager.h"
|
#include "pluginmanager.h"
|
||||||
|
#include "designmodewidget.h"
|
||||||
#include "settingspage.h"
|
#include "settingspage.h"
|
||||||
|
#include "designmodecontext.h"
|
||||||
|
|
||||||
|
#include <coreplugin/designmode.h>
|
||||||
#include <qmljseditor/qmljseditorconstants.h>
|
#include <qmljseditor/qmljseditorconstants.h>
|
||||||
|
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
@@ -46,13 +48,21 @@
|
|||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
|
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/modemanager.h>
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <integrationcore.h>
|
#include <integrationcore.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtGui/QAction>
|
||||||
|
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/qplugin.h>
|
#include <QtCore/qplugin.h>
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -60,7 +70,15 @@ namespace Internal {
|
|||||||
BauhausPlugin *BauhausPlugin::m_pluginInstance = 0;
|
BauhausPlugin *BauhausPlugin::m_pluginInstance = 0;
|
||||||
|
|
||||||
BauhausPlugin::BauhausPlugin() :
|
BauhausPlugin::BauhausPlugin() :
|
||||||
m_designerCore(0)
|
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))
|
||||||
{
|
{
|
||||||
// Exceptions should never ever assert: they are handled in a number of
|
// Exceptions should never ever assert: they are handled in a number of
|
||||||
// places where it is actually VALID AND EXPECTED BEHAVIOUR to get an
|
// places where it is actually VALID AND EXPECTED BEHAVIOUR to get an
|
||||||
@@ -77,6 +95,7 @@ BauhausPlugin::BauhausPlugin() :
|
|||||||
BauhausPlugin::~BauhausPlugin()
|
BauhausPlugin::~BauhausPlugin()
|
||||||
{
|
{
|
||||||
delete m_designerCore;
|
delete m_designerCore;
|
||||||
|
Core::ICore::instance()->removeContextObject(m_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
@@ -91,7 +110,7 @@ bool BauhausPlugin::initialize(const QStringList & /*arguments*/, QString *error
|
|||||||
const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(QmlDesigner::Constants::C_FORMEDITOR));
|
const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(QmlDesigner::Constants::C_FORMEDITOR));
|
||||||
const QList<int> context = QList<int>() << uid;
|
const QList<int> context = QList<int>() << uid;
|
||||||
|
|
||||||
const QList<int> switchContext = QList<int() << uid
|
const QList<int> switchContext = QList<int>() << uid
|
||||||
<< core->uniqueIDManager()->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
|
<< core->uniqueIDManager()->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
|
||||||
|
|
||||||
Core::ActionManager *am = core->actionManager();
|
Core::ActionManager *am = core->actionManager();
|
||||||
@@ -103,7 +122,6 @@ bool BauhausPlugin::initialize(const QStringList & /*arguments*/, QString *error
|
|||||||
connect(switchAction, SIGNAL(triggered()), this, SLOT(switchTextDesign()));
|
connect(switchAction, SIGNAL(triggered()), this, SLOT(switchTextDesign()));
|
||||||
|
|
||||||
m_designerCore = new QmlDesigner::IntegrationCore;
|
m_designerCore = new QmlDesigner::IntegrationCore;
|
||||||
|
|
||||||
m_pluginInstance = this;
|
m_pluginInstance = this;
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
@@ -115,7 +133,8 @@ bool BauhausPlugin::initialize(const QStringList & /*arguments*/, QString *error
|
|||||||
|
|
||||||
m_designerCore->pluginManager()->setPluginPaths(QStringList() << pluginPath);
|
m_designerCore->pluginManager()->setPluginPaths(QStringList() << pluginPath);
|
||||||
|
|
||||||
addAutoReleasedObject(new DesignMode);
|
createDesignModeWidget();
|
||||||
|
|
||||||
addAutoReleasedObject(new SettingsPage);
|
addAutoReleasedObject(new SettingsPage);
|
||||||
|
|
||||||
error_message->clear();
|
error_message->clear();
|
||||||
@@ -123,8 +142,157 @@ bool BauhausPlugin::initialize(const QStringList & /*arguments*/, QString *error
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Revert to saved
|
||||||
|
actionManager->registerAction(m_revertToSavedAction,
|
||||||
|
Core::Constants::REVERTTOSAVED, m_context->context());
|
||||||
|
connect(m_revertToSavedAction, SIGNAL(triggered()), m_editorManager, SLOT(revertToSaved()));
|
||||||
|
|
||||||
|
//Save
|
||||||
|
actionManager->registerAction(m_saveAction, Core::Constants::SAVE, m_context->context());
|
||||||
|
connect(m_saveAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFile()));
|
||||||
|
|
||||||
|
//Save As
|
||||||
|
actionManager->registerAction(m_saveAsAction, Core::Constants::SAVEAS, m_context->context());
|
||||||
|
connect(m_saveAsAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFileAs()));
|
||||||
|
|
||||||
|
//Close Editor
|
||||||
|
actionManager->registerAction(m_closeCurrentEditorAction, Core::Constants::CLOSE, m_context->context());
|
||||||
|
connect(m_closeCurrentEditorAction, SIGNAL(triggered()), m_editorManager, SLOT(closeEditor()));
|
||||||
|
|
||||||
|
//Close All
|
||||||
|
actionManager->registerAction(m_closeAllEditorsAction, Core::Constants::CLOSEALL, m_context->context());
|
||||||
|
connect(m_closeAllEditorsAction, SIGNAL(triggered()), m_editorManager, SLOT(closeAllEditors()));
|
||||||
|
|
||||||
|
//Close All Others Action
|
||||||
|
actionManager->registerAction(m_closeOtherEditorsAction, Core::Constants::CLOSEOTHERS, m_context->context());
|
||||||
|
connect(m_closeOtherEditorsAction, SIGNAL(triggered()), m_editorManager, SLOT(closeOtherEditors()));
|
||||||
|
|
||||||
|
// Undo / Redo
|
||||||
|
actionManager->registerAction(m_mainWidget->undoAction(), Core::Constants::UNDO, m_context->context());
|
||||||
|
actionManager->registerAction(m_mainWidget->redoAction(), Core::Constants::REDO, m_context->context());
|
||||||
|
|
||||||
|
Core::Command *command;
|
||||||
|
command = actionManager->registerAction(m_mainWidget->deleteAction(),
|
||||||
|
QmlDesigner::Constants::DELETE, m_context->context());
|
||||||
|
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(),
|
||||||
|
Core::Constants::CUT, m_context->context());
|
||||||
|
command->setDefaultKeySequence(QKeySequence::Cut);
|
||||||
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
|
|
||||||
|
command = actionManager->registerAction(m_mainWidget->copyAction(),
|
||||||
|
Core::Constants::COPY, m_context->context());
|
||||||
|
command->setDefaultKeySequence(QKeySequence::Copy);
|
||||||
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
|
|
||||||
|
command = actionManager->registerAction(m_mainWidget->pasteAction(),
|
||||||
|
Core::Constants::PASTE, m_context->context());
|
||||||
|
command->setDefaultKeySequence(QKeySequence::Paste);
|
||||||
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
|
|
||||||
|
command = actionManager->registerAction(m_mainWidget->selectAllAction(),
|
||||||
|
Core::Constants::SELECTALL, m_context->context());
|
||||||
|
command->setDefaultKeySequence(QKeySequence::SelectAll);
|
||||||
|
editMenu->addAction(command, Core::Constants::G_EDIT_SELECTALL);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
Core::ModeManager *modeManager = creatorCore->modeManager();
|
||||||
|
|
||||||
|
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)),
|
||||||
|
this, SLOT(modeChanged(Core::IMode*)));
|
||||||
|
|
||||||
|
connect(m_editorManager, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
|
||||||
|
this, SLOT(textEditorsClosed(QList<Core::IEditor*>)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BauhausPlugin::modeChanged(Core::IMode *mode)
|
||||||
|
{
|
||||||
|
if (mode == m_designMode) {
|
||||||
|
m_isActive = true;
|
||||||
|
m_mainWidget->showEditor(m_editorManager->currentEditor());
|
||||||
|
} else {
|
||||||
|
if (m_isActive) {
|
||||||
|
m_isActive = false;
|
||||||
|
|
||||||
|
m_mainWidget->showEditor(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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")));
|
||||||
|
}
|
||||||
|
|
||||||
void BauhausPlugin::extensionsInitialized()
|
void BauhausPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
|
m_designMode = ExtensionSystem::PluginManager::instance()->getObject<Core::DesignMode>();
|
||||||
|
|
||||||
|
m_mimeTypes << "application/x-qml" << "application/javascript"
|
||||||
|
<< "application/x-javascript" << "text/javascript";
|
||||||
|
|
||||||
|
m_designMode->registerDesignWidget(m_mainWidget, m_mimeTypes);
|
||||||
|
connect(m_designMode, SIGNAL(actionsUpdated(Core::IEditor*)), SLOT(updateActions(Core::IEditor*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
BauhausPlugin *BauhausPlugin::pluginInstance()
|
BauhausPlugin *BauhausPlugin::pluginInstance()
|
||||||
@@ -135,18 +303,15 @@ BauhausPlugin *BauhausPlugin::pluginInstance()
|
|||||||
void BauhausPlugin::switchTextDesign()
|
void BauhausPlugin::switchTextDesign()
|
||||||
{
|
{
|
||||||
Core::ModeManager *modeManager = Core::ModeManager::instance();
|
Core::ModeManager *modeManager = Core::ModeManager::instance();
|
||||||
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
if (modeManager->currentMode() == Core::Constants::MODE_EDIT) {
|
|
||||||
|
|
||||||
} else if (modeManager->currentMode() == Core::Constants::MODE_DESIGN) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::IEditor *editor = editorManager->currentEditor();
|
Core::IEditor *editor = editorManager->currentEditor();
|
||||||
QString otherFile = correspondingHeaderOrSource(editor->file()->fileName());
|
|
||||||
if (!otherFile.isEmpty()) {
|
|
||||||
editorManager->openEditor(otherFile);
|
if (modeManager->currentMode()->id() == Core::Constants::MODE_EDIT) {
|
||||||
editorManager->ensureEditorManagerVisible();
|
if (editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
|
||||||
|
modeManager->activateMode(Core::Constants::MODE_DESIGN);
|
||||||
|
} else if (modeManager->currentMode()->id() == Core::Constants::MODE_DESIGN) {
|
||||||
|
modeManager->activateMode(Core::Constants::MODE_EDIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,11 +34,21 @@
|
|||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
|
#include <QWeakPointer>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QAction;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IWizard;
|
class IWizard;
|
||||||
class ICore;
|
class ICore;
|
||||||
class IEditorFactory;
|
class IEditorFactory;
|
||||||
class IEditor;
|
class IEditor;
|
||||||
|
class IMode;
|
||||||
|
class DesignMode;
|
||||||
|
class EditorManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -48,6 +58,9 @@ namespace QmlDesigner {
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class DesignModeWidget;
|
||||||
|
class DesignModeContext;
|
||||||
|
|
||||||
class BauhausPlugin : public ExtensionSystem::IPlugin
|
class BauhausPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -66,12 +79,32 @@ public:
|
|||||||
void setSettings(const DesignerSettings &s);
|
void setSettings(const DesignerSettings &s);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void switchTextDesign();
|
void switchTextDesign();
|
||||||
|
void modeChanged(Core::IMode *mode);
|
||||||
|
void textEditorsClosed(QList<Core::IEditor *> editors);
|
||||||
|
void updateActions(Core::IEditor* editor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void createDesignModeWidget();
|
||||||
|
|
||||||
|
QStringList m_mimeTypes;
|
||||||
|
DesignModeWidget *m_mainWidget;
|
||||||
|
|
||||||
QmlDesigner::IntegrationCore *m_designerCore;
|
QmlDesigner::IntegrationCore *m_designerCore;
|
||||||
static BauhausPlugin *m_pluginInstance;
|
static BauhausPlugin *m_pluginInstance;
|
||||||
DesignerSettings m_settings;
|
DesignerSettings m_settings;
|
||||||
|
DesignModeContext *m_context;
|
||||||
|
Core::DesignMode *m_designMode;
|
||||||
|
Core::EditorManager *m_editorManager;
|
||||||
|
bool m_isActive;
|
||||||
|
|
||||||
|
QAction *m_revertToSavedAction;
|
||||||
|
QAction *m_saveAction;
|
||||||
|
QAction *m_saveAsAction;
|
||||||
|
QAction *m_closeCurrentEditorAction;
|
||||||
|
QAction *m_closeAllEditorsAction;
|
||||||
|
QAction *m_closeOtherEditorsAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -17,17 +17,17 @@ include(components/resources/resources.pri)
|
|||||||
|
|
||||||
HEADERS += qmldesignerconstants.h \
|
HEADERS += qmldesignerconstants.h \
|
||||||
qmldesignerplugin.h \
|
qmldesignerplugin.h \
|
||||||
designmode.h \
|
|
||||||
designmodewidget.h \
|
designmodewidget.h \
|
||||||
application.h \
|
application.h \
|
||||||
designersettings.h \
|
designersettings.h \
|
||||||
settingspage.h
|
settingspage.h \
|
||||||
|
designmodecontext.h
|
||||||
SOURCES += qmldesignerplugin.cpp \
|
SOURCES += qmldesignerplugin.cpp \
|
||||||
designmode.cpp \
|
|
||||||
designmodewidget.cpp \
|
designmodewidget.cpp \
|
||||||
application.cpp \
|
application.cpp \
|
||||||
designersettings.cpp \
|
designersettings.cpp \
|
||||||
settingspage.cpp
|
settingspage.cpp \
|
||||||
|
designmodecontext.cpp
|
||||||
FORMS += settingspage.ui
|
FORMS += settingspage.ui
|
||||||
|
|
||||||
OTHER_FILES += QmlDesigner.pluginspec
|
OTHER_FILES += QmlDesigner.pluginspec
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/applicationlauncher.h>
|
#include <projectexplorer/applicationlauncher.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <debugger/debuggerconstants.h>
|
||||||
|
|
||||||
#include <debugger/debuggerconstants.h>
|
#include <debugger/debuggerconstants.h>
|
||||||
#include <debugger/debuggeruiswitcher.h>
|
#include <debugger/debuggeruiswitcher.h>
|
||||||
|
@@ -299,7 +299,7 @@ public:
|
|||||||
// EditorInterface
|
// EditorInterface
|
||||||
Core::IFile * file();
|
Core::IFile * file();
|
||||||
bool createNew(const QString &contents);
|
bool createNew(const QString &contents);
|
||||||
bool open(const QString &fileName = QString());
|
virtual bool open(const QString &fileName = QString());
|
||||||
QByteArray saveState() const;
|
QByteArray saveState() const;
|
||||||
bool restoreState(const QByteArray &state);
|
bool restoreState(const QByteArray &state);
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
|
@@ -46,8 +46,9 @@ public:
|
|||||||
|
|
||||||
bool duplicateSupported() const { return true; }
|
bool duplicateSupported() const { return true; }
|
||||||
Core::IEditor *duplicate(QWidget *parent);
|
Core::IEditor *duplicate(QWidget *parent);
|
||||||
QString id() const;
|
|
||||||
bool isTemporary() const { return false; }
|
bool isTemporary() const { return false; }
|
||||||
|
virtual QString id() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<int> m_context;
|
QList<int> m_context;
|
||||||
};
|
};
|
||||||
@@ -60,7 +61,7 @@ public:
|
|||||||
PlainTextEditor(QWidget *parent);
|
PlainTextEditor(QWidget *parent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseTextEditorEditable *createEditableInterface() { return new PlainTextEditorEditable(this); }
|
virtual BaseTextEditorEditable *createEditableInterface() { return new PlainTextEditorEditable(this); }
|
||||||
// Indent a text block based on previous line.
|
// Indent a text block based on previous line.
|
||||||
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user