forked from qt-creator/qt-creator
Add views menu for form editor.
This commit is contained in:
@@ -359,7 +359,6 @@ Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const
|
||||
baseAction->setSeparator(action->isSeparator());
|
||||
baseAction->setShortcutContext(Qt::ApplicationShortcut);
|
||||
baseAction->setEnabled(false);
|
||||
baseAction->setObjectName(id);
|
||||
baseAction->setParent(m_mainWnd);
|
||||
#ifdef Q_WS_MAC
|
||||
baseAction->setIconVisibleInMenu(false);
|
||||
|
@@ -495,6 +495,7 @@ void OverrideableAction::actionChanged()
|
||||
m_action->setWhatsThis(m_currentAction->whatsThis());
|
||||
}
|
||||
|
||||
m_action->setCheckable(m_currentAction->isCheckable());
|
||||
bool block = m_action->blockSignals(true);
|
||||
m_action->setChecked(m_currentAction->isChecked());
|
||||
m_action->blockSignals(block);
|
||||
|
@@ -42,6 +42,7 @@ const char * const SETTINGS_CPP_SETTINGS = QT_TRANSLATE_NOOP("Designer", "Class
|
||||
const char * const C_FORMEDITOR = "FormEditor";
|
||||
const char * const T_FORMEDITOR = "FormEditor.Toolbar";
|
||||
const char * const M_FORMEDITOR = "FormEditor.Menu";
|
||||
const char * const M_FORMEDITOR_VIEWS = "FormEditor.Menu.Views";
|
||||
const char * const M_FORMEDITOR_PREVIEW = "FormEditor.Menu.Preview";
|
||||
|
||||
// Wizard type
|
||||
|
@@ -78,6 +78,7 @@ public:
|
||||
explicit EditorWidget(QWidget *formWindow);
|
||||
|
||||
void setDefaultLayout();
|
||||
QDockWidget* const* dockWidgets() const { return m_designerDockWidgets; }
|
||||
|
||||
static void saveState(QSettings *settings);
|
||||
static void restoreState(QSettings *settings);
|
||||
|
@@ -66,6 +66,7 @@
|
||||
#include <QtGui/QActionGroup>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QCursor>
|
||||
#include <QtGui/QDockWidget>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QMessageBox>
|
||||
@@ -158,11 +159,71 @@ static inline void addToolAction(QAction *a,
|
||||
c1->addAction(command);
|
||||
}
|
||||
|
||||
// --------- FormEditorW
|
||||
|
||||
using namespace Designer::Internal;
|
||||
using namespace Designer::Constants;
|
||||
|
||||
// --------- Proxy Action
|
||||
|
||||
ProxyAction::ProxyAction(const QString &defaultText, QObject *parent)
|
||||
: QAction(defaultText, parent),
|
||||
m_defaultText(defaultText),
|
||||
m_action(0)
|
||||
{
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
void ProxyAction::setAction(QAction *action)
|
||||
{
|
||||
if (m_action) {
|
||||
disconnect(m_action, SIGNAL(changed()), this, SLOT(update()));
|
||||
disconnect(this, SIGNAL(triggered(bool)), m_action, SIGNAL(triggered(bool)));
|
||||
disconnect(this, SIGNAL(toggled(bool)), m_action, SLOT(setChecked(bool)));
|
||||
}
|
||||
m_action = action;
|
||||
if (!m_action) {
|
||||
setEnabled(false);
|
||||
// if (hasAttribute(CA_Hide))
|
||||
// m_action->setVisible(false);
|
||||
// if (hasAttribute(CA_UpdateText)) {
|
||||
setText(m_defaultText);
|
||||
// }
|
||||
} else {
|
||||
setCheckable(m_action->isCheckable());
|
||||
setSeparator(m_action->isSeparator());
|
||||
connect(m_action, SIGNAL(changed()), this, SLOT(update()));
|
||||
// we want to avoid the toggling semantic on slot trigger(), so we just connect the signals
|
||||
connect(this, SIGNAL(triggered(bool)), m_action, SIGNAL(triggered(bool)));
|
||||
// we need to update the checked state, so we connect to setChecked slot, which also fires a toggled signal
|
||||
connect(this, SIGNAL(toggled(bool)), m_action, SLOT(setChecked(bool)));
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void ProxyAction::update()
|
||||
{
|
||||
QTC_ASSERT(m_action, return)
|
||||
bool block = blockSignals(true);
|
||||
// if (hasAttribute(CA_UpdateIcon)) {
|
||||
setIcon(m_action->icon());
|
||||
setIconText(m_action->iconText());
|
||||
// }
|
||||
// if (hasAttribute(CA_UpdateText)) {
|
||||
setText(m_action->text());
|
||||
setToolTip(m_action->toolTip());
|
||||
setStatusTip(m_action->statusTip());
|
||||
setWhatsThis(m_action->whatsThis());
|
||||
// }
|
||||
|
||||
setChecked(m_action->isChecked());
|
||||
|
||||
setEnabled(m_action->isEnabled());
|
||||
setVisible(m_action->isVisible());
|
||||
blockSignals(block);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
// --------- FormEditorW
|
||||
|
||||
FormEditorW *FormEditorW::m_self = 0;
|
||||
|
||||
FormEditorW::FormEditorW() :
|
||||
@@ -185,6 +246,8 @@ FormEditorW::FormEditorW() :
|
||||
|
||||
qFill(m_designerSubWindows, m_designerSubWindows + Designer::Constants::DesignerSubWindowCount,
|
||||
static_cast<QWidget *>(0));
|
||||
qFill(m_designerSubWindowActions, m_designerSubWindowActions + Designer::Constants::DesignerSubWindowCount,
|
||||
static_cast<ProxyAction *>(0));
|
||||
|
||||
m_formeditor->setTopLevel(qobject_cast<QWidget *>(m_core->editorManager()));
|
||||
m_formeditor->setSettingsManager(new SettingsManager());
|
||||
@@ -268,26 +331,26 @@ void FormEditorW::initDesignerSubWindows()
|
||||
qFill(m_designerSubWindows, m_designerSubWindows + Designer::Constants::DesignerSubWindowCount, static_cast<QWidget*>(0));
|
||||
|
||||
QDesignerWidgetBoxInterface *wb = QDesignerComponents::createWidgetBox(m_formeditor, 0);
|
||||
wb->setWindowTitle(tr("Designer widgetbox"));
|
||||
wb->setWindowTitle(tr("Widget Box"));
|
||||
m_formeditor->setWidgetBox(wb);
|
||||
m_designerSubWindows[WidgetBoxSubWindow] = wb;
|
||||
|
||||
QDesignerObjectInspectorInterface *oi = QDesignerComponents::createObjectInspector(m_formeditor, 0);
|
||||
oi->setWindowTitle(tr("Object inspector"));
|
||||
oi->setWindowTitle(tr("Object Inspector"));
|
||||
m_formeditor->setObjectInspector(oi);
|
||||
m_designerSubWindows[ObjectInspectorSubWindow] = oi;
|
||||
|
||||
QDesignerPropertyEditorInterface *pe = QDesignerComponents::createPropertyEditor(m_formeditor, 0);
|
||||
pe->setWindowTitle(tr("Property editor"));
|
||||
pe->setWindowTitle(tr("Property Editor"));
|
||||
m_formeditor->setPropertyEditor(pe);
|
||||
m_designerSubWindows[PropertyEditorSubWindow] = pe;
|
||||
|
||||
QWidget *se = QDesignerComponents::createSignalSlotEditor(m_formeditor, 0);
|
||||
se->setWindowTitle(tr("Signals and slots editor"));
|
||||
se->setWindowTitle(tr("Signals & Slots Editor"));
|
||||
m_designerSubWindows[SignalSlotEditorSubWindow] = se;
|
||||
|
||||
QDesignerActionEditorInterface *ae = QDesignerComponents::createActionEditor(m_formeditor, 0);
|
||||
ae->setWindowTitle(tr("Action editor"));
|
||||
ae->setWindowTitle(tr("Action Editor"));
|
||||
m_formeditor->setActionEditor(ae);
|
||||
m_designerSubWindows[ActionEditorSubWindow] = ae;
|
||||
}
|
||||
@@ -431,6 +494,33 @@ void FormEditorW::setupActions()
|
||||
addToolAction(m_fwm->actionRaise(), am, globalcontext,
|
||||
QLatin1String("FormEditor.Raise"), mformtools);
|
||||
|
||||
// Views
|
||||
createSeparator(this, am, globalcontext, mformtools, QLatin1String("FormEditor.Menu.Tools.SeparatorViews"));
|
||||
|
||||
Core::ActionContainer *mviews = am->createMenu(M_FORMEDITOR_VIEWS);
|
||||
mviews->menu()->setTitle(tr("Views..."));
|
||||
mformtools->addMenu(mviews);
|
||||
|
||||
m_designerSubWindowActions[WidgetBoxSubWindow] = new ProxyAction(tr("Widget Box"), this);
|
||||
addToolAction(m_designerSubWindowActions[WidgetBoxSubWindow], am, globalcontext,
|
||||
QLatin1String("FormEditor.WidgetBox"), mviews, "");
|
||||
|
||||
m_designerSubWindowActions[ObjectInspectorSubWindow] = new ProxyAction(tr("Object Inspector"), this);
|
||||
addToolAction(m_designerSubWindowActions[ObjectInspectorSubWindow], am, globalcontext,
|
||||
QLatin1String("FormEditor.ObjectInspector"), mviews, "");
|
||||
|
||||
m_designerSubWindowActions[PropertyEditorSubWindow] = new ProxyAction(tr("Property Editor"), this);
|
||||
addToolAction(m_designerSubWindowActions[PropertyEditorSubWindow], am, globalcontext,
|
||||
QLatin1String("FormEditor.PropertyEditor"), mviews, "");
|
||||
|
||||
m_designerSubWindowActions[SignalSlotEditorSubWindow] = new ProxyAction(tr("Signals & Slots Editor"), this);
|
||||
addToolAction(m_designerSubWindowActions[SignalSlotEditorSubWindow], am, globalcontext,
|
||||
QLatin1String("FormEditor.SignalsAndSlotsEditor"), mviews, "");
|
||||
|
||||
m_designerSubWindowActions[ActionEditorSubWindow] = new ProxyAction(tr("Action Editor"), this);
|
||||
addToolAction(m_designerSubWindowActions[ActionEditorSubWindow], am, globalcontext,
|
||||
QLatin1String("FormEditor.ActionEditor"), mviews, "");
|
||||
|
||||
// Commands that do not go into the editor toolbar
|
||||
createSeparator(this, am, globalcontext, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator2"));
|
||||
|
||||
@@ -582,10 +672,19 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor)
|
||||
m_fwm->setActiveFormWindow(fw->formWindow());
|
||||
m_actionGroupEditMode->setVisible(true);
|
||||
m_modeActionSeparator->setVisible(true);
|
||||
QDockWidget * const*dockWidgets = fw->dockWidgets();
|
||||
for (int i = 0; i < Designer::Constants::DesignerSubWindowCount; ++i) {
|
||||
if (m_designerSubWindowActions[i] != 0 && dockWidgets[i] != 0)
|
||||
m_designerSubWindowActions[i]->setAction(dockWidgets[i]->toggleViewAction());
|
||||
}
|
||||
} else {
|
||||
m_actionGroupEditMode->setVisible(false);
|
||||
m_modeActionSeparator->setVisible(false);
|
||||
m_fwm->setActiveFormWindow(0);
|
||||
for (int i = 0; i < Designer::Constants::DesignerSubWindowCount; ++i) {
|
||||
if (m_designerSubWindowActions[i] != 0)
|
||||
m_designerSubWindowActions[i]->setAction(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtGui/QAction>
|
||||
|
||||
#include "designerconstants.h"
|
||||
|
||||
@@ -45,7 +46,6 @@ class QDesignerIntegrationInterface;
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerFormWindowInterface;
|
||||
|
||||
class QAction;
|
||||
class QActionGroup;
|
||||
class QFocusEvent;
|
||||
|
||||
@@ -73,6 +73,20 @@ namespace Internal {
|
||||
class FormWindowEditor;
|
||||
class SettingsPage;
|
||||
|
||||
class ProxyAction : public QAction
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProxyAction(const QString &defaultText, QObject *parent = 0);
|
||||
void setAction(QAction *action);
|
||||
|
||||
private slots:
|
||||
void update();
|
||||
|
||||
private:
|
||||
QString m_defaultText;
|
||||
QPointer<QAction> m_action;
|
||||
};
|
||||
|
||||
/** FormEditorW is a singleton that stores the Designer CoreInterface and
|
||||
* performs centralized operations. The instance() method will return an
|
||||
@@ -151,6 +165,7 @@ private:
|
||||
InitializationStage m_initStage;
|
||||
|
||||
QWidget *m_designerSubWindows[Designer::Constants::DesignerSubWindowCount];
|
||||
ProxyAction *m_designerSubWindowActions[Designer::Constants::DesignerSubWindowCount];
|
||||
|
||||
QList<SettingsPage *> m_settingsPages;
|
||||
QActionGroup *m_actionGroupEditMode;
|
||||
|
@@ -30,10 +30,13 @@
|
||||
#ifndef FORMWINDOWEDITOR_H
|
||||
#define FORMWINDOWEDITOR_H
|
||||
|
||||
#include "editorwidget.h"
|
||||
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtGui/QDockWidget>
|
||||
|
||||
#include "designer_export.h"
|
||||
|
||||
@@ -54,7 +57,6 @@ namespace Internal {
|
||||
|
||||
class FormWindowFile;
|
||||
class FormWindowHost;
|
||||
class EditorWidget;
|
||||
|
||||
// Master class maintaining a form window editor,
|
||||
// containing file and widget host
|
||||
@@ -91,6 +93,7 @@ public:
|
||||
QWidget *integrationContainer();
|
||||
void updateFormWindowSelectionHandles(bool state);
|
||||
void setSuggestedFileName(const QString &fileName);
|
||||
QDockWidget* const* dockWidgets() const { return m_editorWidget->dockWidgets(); }
|
||||
|
||||
QString contents() const;
|
||||
|
||||
|
Reference in New Issue
Block a user