forked from qt-creator/qt-creator
Implement floating form editor tool support.
This commit is contained in:
@@ -105,12 +105,14 @@ EditorWidget::EditorWidget(QWidget *formWindow)
|
||||
}
|
||||
}
|
||||
|
||||
void EditorWidget::setDefaultLayout()
|
||||
void EditorWidget::resetToDefaultLayout()
|
||||
{
|
||||
m_mainWindow->setTrackingEnabled(false);
|
||||
QList<QDockWidget *> dockWidgets = m_mainWindow->dockWidgets();
|
||||
foreach (QDockWidget *dockWidget, dockWidgets)
|
||||
foreach (QDockWidget *dockWidget, dockWidgets) {
|
||||
dockWidget->setFloating(false);
|
||||
m_mainWindow->removeDockWidget(dockWidget);
|
||||
}
|
||||
|
||||
m_mainWindow->addDockWidget(Qt::LeftDockWidgetArea, m_designerDockWidgets[WidgetBoxSubWindow]);
|
||||
m_mainWindow->addDockWidget(Qt::RightDockWidgetArea, m_designerDockWidgets[ObjectInspectorSubWindow]);
|
||||
@@ -139,7 +141,7 @@ void EditorWidget::activate()
|
||||
// (otherwise we end up with a broken mainwindow layout)
|
||||
// we can't do it in the constructor, because the sub windows
|
||||
// don't have their widgets yet there
|
||||
setDefaultLayout();
|
||||
resetToDefaultLayout();
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
|
@@ -77,8 +77,10 @@ class EditorWidget : public QWidget
|
||||
public:
|
||||
explicit EditorWidget(QWidget *formWindow);
|
||||
|
||||
void setDefaultLayout();
|
||||
void resetToDefaultLayout();
|
||||
QDockWidget* const* dockWidgets() const { return m_designerDockWidgets; }
|
||||
bool isLocked() const { return m_mainWindow->isLocked(); }
|
||||
void setLocked(bool locked) { m_mainWindow->setLocked(locked); }
|
||||
|
||||
static void saveState(QSettings *settings);
|
||||
static void restoreState(QSettings *settings);
|
||||
|
@@ -498,7 +498,7 @@ void FormEditorW::setupActions()
|
||||
createSeparator(this, am, globalcontext, mformtools, QLatin1String("FormEditor.Menu.Tools.SeparatorViews"));
|
||||
|
||||
Core::ActionContainer *mviews = am->createMenu(M_FORMEDITOR_VIEWS);
|
||||
mviews->menu()->setTitle(tr("Views..."));
|
||||
mviews->menu()->setTitle(tr("Views"));
|
||||
mformtools->addMenu(mviews);
|
||||
|
||||
m_designerSubWindowActions[WidgetBoxSubWindow] = new ProxyAction(tr("Widget Box"), this);
|
||||
@@ -521,6 +521,19 @@ void FormEditorW::setupActions()
|
||||
addToolAction(m_designerSubWindowActions[ActionEditorSubWindow], am, globalcontext,
|
||||
QLatin1String("FormEditor.ActionEditor"), mviews, "");
|
||||
|
||||
createSeparator(this, am, globalcontext, mviews, QLatin1String("FormEditor.Menu.Tools.Views.SeparatorLock"));
|
||||
|
||||
m_lockAction = new QAction(tr("Locked"), this);
|
||||
m_lockAction->setCheckable(true);
|
||||
addToolAction(m_lockAction, am, globalcontext, QLatin1String("FormEditor.Locked"), mviews, "");
|
||||
connect(m_lockAction, SIGNAL(toggled(bool)), this, SLOT(setFormWindowLayoutLocked(bool)));
|
||||
|
||||
createSeparator(this, am, globalcontext, mviews, QLatin1String("FormEditor.Menu.Tools.Views.SeparatorReset"));
|
||||
|
||||
m_resetLayoutAction = new QAction(tr("Reset to Default Layout"), this);
|
||||
addToolAction(m_resetLayoutAction, am, globalcontext, QLatin1String("FormEditor.ResetToDefaultLayout"), mviews, "");
|
||||
connect(m_resetLayoutAction, SIGNAL(triggered()), this, SLOT(resetToDefaultLayout()));
|
||||
|
||||
// Commands that do not go into the editor toolbar
|
||||
createSeparator(this, am, globalcontext, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator2"));
|
||||
|
||||
@@ -677,6 +690,9 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor)
|
||||
if (m_designerSubWindowActions[i] != 0 && dockWidgets[i] != 0)
|
||||
m_designerSubWindowActions[i]->setAction(dockWidgets[i]->toggleViewAction());
|
||||
}
|
||||
m_lockAction->setEnabled(true);
|
||||
m_lockAction->setChecked(fw->isLocked());
|
||||
m_resetLayoutAction->setEnabled(true);
|
||||
} else {
|
||||
m_actionGroupEditMode->setVisible(false);
|
||||
m_modeActionSeparator->setVisible(false);
|
||||
@@ -685,6 +701,8 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor)
|
||||
if (m_designerSubWindowActions[i] != 0)
|
||||
m_designerSubWindowActions[i]->setAction(0);
|
||||
}
|
||||
m_lockAction->setEnabled(false);
|
||||
m_resetLayoutAction->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,6 +769,20 @@ void FormEditorW::toolChanged(int t)
|
||||
}
|
||||
}
|
||||
|
||||
void FormEditorW::setFormWindowLayoutLocked(bool locked)
|
||||
{
|
||||
FormWindowEditor *fwe = activeFormWindow();
|
||||
if (fwe)
|
||||
fwe->setLocked(locked);
|
||||
}
|
||||
|
||||
void FormEditorW::resetToDefaultLayout()
|
||||
{
|
||||
FormWindowEditor *fwe = activeFormWindow();
|
||||
if (fwe)
|
||||
fwe->resetToDefaultLayout();
|
||||
}
|
||||
|
||||
void FormEditorW::print()
|
||||
{
|
||||
// Printing code courtesy of designer_actions.cpp
|
||||
|
@@ -136,6 +136,8 @@ private slots:
|
||||
void currentEditorChanged(Core::IEditor *editor);
|
||||
void toolChanged(int);
|
||||
void print();
|
||||
void setFormWindowLayoutLocked(bool locked);
|
||||
void resetToDefaultLayout();
|
||||
|
||||
void editorDestroyed();
|
||||
|
||||
@@ -166,6 +168,8 @@ private:
|
||||
|
||||
QWidget *m_designerSubWindows[Designer::Constants::DesignerSubWindowCount];
|
||||
ProxyAction *m_designerSubWindowActions[Designer::Constants::DesignerSubWindowCount];
|
||||
QAction *m_lockAction;
|
||||
QAction *m_resetLayoutAction;
|
||||
|
||||
QList<SettingsPage *> m_settingsPages;
|
||||
QActionGroup *m_actionGroupEditMode;
|
||||
|
@@ -327,6 +327,11 @@ void FormWindowEditor::activate()
|
||||
m_editorWidget->activate();
|
||||
}
|
||||
|
||||
void FormWindowEditor::resetToDefaultLayout()
|
||||
{
|
||||
m_editorWidget->resetToDefaultLayout();
|
||||
}
|
||||
|
||||
QString FormWindowEditor::contextHelpId() const
|
||||
{
|
||||
const QDesignerFormEditorInterface *core = FormEditorW::instance()->designerEditor();
|
||||
|
@@ -94,6 +94,8 @@ public:
|
||||
void updateFormWindowSelectionHandles(bool state);
|
||||
void setSuggestedFileName(const QString &fileName);
|
||||
QDockWidget* const* dockWidgets() const { return m_editorWidget->dockWidgets(); }
|
||||
bool isLocked() const { return m_editorWidget->isLocked(); }
|
||||
void setLocked(bool locked) { m_editorWidget->setLocked(locked); }
|
||||
|
||||
QString contents() const;
|
||||
|
||||
@@ -103,6 +105,7 @@ signals:
|
||||
|
||||
public slots:
|
||||
void activate();
|
||||
void resetToDefaultLayout();
|
||||
|
||||
private slots:
|
||||
void slotOpen(const QString &fileName);
|
||||
|
Reference in New Issue
Block a user