Commit 3be86bb8 authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

Added Window->Views menu entry for restoring Qt Quick Designer layout

parent fe48286e
......@@ -201,12 +201,17 @@ void SideBar::saveSettings(QSettings *settings, const QString &name)
settings->setValue(prefix + "Width", width());
}
void SideBar::closeAllWidgets()
{
foreach (SideBarWidget *widget, m_widgets)
removeSideBarWidget(widget);
}
void SideBar::readSettings(QSettings *settings, const QString &name)
{
const QString prefix = name.isEmpty() ? name : (name + QLatin1Char('/'));
foreach (SideBarWidget *widget, m_widgets)
removeSideBarWidget(widget);
closeAllWidgets();
if (settings->contains(prefix + "Views")) {
QStringList views = settings->value(prefix + "Views").toStringList();
......
......@@ -109,7 +109,7 @@ public:
void saveSettings(QSettings *settings, const QString &name);
void readSettings(QSettings *settings, const QString &name);
void closeAllWidgets();
void activateItem(SideBarItem *item);
void setShortcutMap(const QMap<QString, Core::Command*> &shortcutMap);
......
......@@ -154,6 +154,9 @@ DesignModeWidget::DesignModeWidget(QWidget *parent) :
connect(m_selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll()));
m_hideSidebarsAction = new QAction(tr("Toggle Full Screen"), this);
connect(m_hideSidebarsAction, SIGNAL(triggered()), this, SLOT(toggleSidebars()));
m_restoreDefaultViewAction = new QAction(tr("&Restore Default View"), this);
connect(m_restoreDefaultViewAction, SIGNAL(triggered()), SLOT(restoreDefaultView()));
Core::ModeManager *modeManager = Core::ModeManager::instance();
Core::IMode *designmode = modeManager->mode(Core::Constants::MODE_DESIGN);
......@@ -165,6 +168,17 @@ DesignModeWidget::~DesignModeWidget()
{
}
void DesignModeWidget::restoreDefaultView()
{
QSettings *settings = Core::ICore::instance()->settings();
m_leftSideBar->closeAllWidgets();
m_rightSideBar->closeAllWidgets();
m_leftSideBar->readSettings(settings, "none.LeftSideBar");
m_rightSideBar->readSettings(settings, "none.RightSideBar");
m_leftSideBar->show();
m_rightSideBar->show();
}
void DesignModeWidget::toggleSidebars()
{
if (m_initStatus == Initializing)
......@@ -298,6 +312,11 @@ QAction *DesignModeWidget::hideSidebarsAction() const
return m_hideSidebarsAction;
}
QAction *DesignModeWidget::restoreDefaultViewAction() const
{
return m_restoreDefaultViewAction;
}
void DesignModeWidget::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
......@@ -591,28 +610,26 @@ void DesignModeWidget::setup()
Core::SideBarItem *libraryItem = new Core::SideBarItem(m_itemLibrary.data());
Core::SideBarItem *propertiesItem = new Core::SideBarItem(m_allPropertiesBox.data());
QList<Core::SideBarItem*> sideBarItems;
// default items
sideBarItems << navigatorItem << libraryItem << propertiesItem;
m_sideBarItems << navigatorItem << libraryItem << propertiesItem;
if (projectsExplorer) {
Core::SideBarItem *projectExplorerItem = new Core::SideBarItem(projectsExplorer);
sideBarItems << projectExplorerItem;
m_sideBarItems << projectExplorerItem;
}
if (fileSystemExplorer) {
Core::SideBarItem *fileSystemExplorerItem = new Core::SideBarItem(fileSystemExplorer);
sideBarItems << fileSystemExplorerItem;
m_sideBarItems << fileSystemExplorerItem;
}
if (openDocumentsWidget) {
Core::SideBarItem *openDocumentsItem = new Core::SideBarItem(openDocumentsWidget);
sideBarItems << openDocumentsItem;
m_sideBarItems << openDocumentsItem;
}
m_leftSideBar = new Core::SideBar(sideBarItems, QList<Core::SideBarItem*>() << navigatorItem << libraryItem);
m_rightSideBar = new Core::SideBar(sideBarItems, QList<Core::SideBarItem*>() << propertiesItem);
m_leftSideBar = new Core::SideBar(m_sideBarItems, QList<Core::SideBarItem*>() << navigatorItem << libraryItem);
m_rightSideBar = new Core::SideBar(m_sideBarItems, QList<Core::SideBarItem*>() << propertiesItem);
connect(m_leftSideBar, SIGNAL(availableItemsChanged()), SLOT(updateAvailableSidebarItemsRight()));
connect(m_rightSideBar, SIGNAL(availableItemsChanged()), SLOT(updateAvailableSidebarItemsLeft()));
......
......@@ -63,6 +63,7 @@ QT_END_NAMESPACE
namespace Core {
class SideBar;
class SideBarItem;
class OpenEditorsModel;
class EditorToolBar;
class OutputPanePlaceHolder;
......@@ -115,6 +116,7 @@ public:
QAction *pasteAction() const;
QAction *selectAllAction() const;
QAction *hideSidebarsAction() const;
QAction *restoreDefaultViewAction() const;
void readSettings();
void saveSettings();
......@@ -132,6 +134,7 @@ private slots:
void selectAll();
void closeCurrentEditor();
void toggleSidebars();
void restoreDefaultView();
void undoAvailable(bool isAvailable);
void redoAvailable(bool isAvailable);
......@@ -161,6 +164,7 @@ private:
QAction *m_pasteAction;
QAction *m_selectAllAction;
QAction *m_hideSidebarsAction;
QAction *m_restoreDefaultViewAction;
QWeakPointer<ItemLibrary> m_itemLibrary;
QWeakPointer<NavigatorView> m_navigator;
......@@ -182,7 +186,7 @@ private:
Core::EditorToolBar *m_fakeToolBar;
Core::OutputPanePlaceHolder *m_outputPanePlaceholder;
Core::MiniSplitter *m_outputPlaceholderSplitter;
QList<Core::SideBarItem*> m_sideBarItems;
bool m_isDisabled;
bool m_showSidebars;
......
......@@ -44,6 +44,7 @@ const char * const C_QT_QUICK_TOOLS_MENU = "QmlDesigner::ToolsMenu";
// actions
const char * const SWITCH_TEXT_DESIGN = "QmlDesigner.SwitchTextDesign";
const char * const RESTORE_DEFAULT_VIEW = "QmlDesigner.RestoreDefaultView";
// mode
const char * const DESIGN_MODE_NAME = "Design";
......@@ -51,6 +52,7 @@ const char * const DESIGN_MODE_NAME = "Design";
// Wizard type
const char * const FORM_MIMETYPE = "application/x-qmldesigner";
// This setting is also accessed by the QMlJsEditor.
const char * const QML_SETTINGS_GROUP = "QML";
const char * const QML_DESIGNER_SETTINGS_GROUP = "Designer";
......
......@@ -224,11 +224,17 @@ void BauhausPlugin::createDesignModeWidget()
editMenu->addAction(command, Core::Constants::G_EDIT_SELECTALL);
Core::UniqueIDManager *uuidManager = Core::UniqueIDManager::instance();
actionManager->command(Core::Constants::TOGGLE_SIDEBAR);
command = actionManager->registerAction(m_mainWidget->hideSidebarsAction(),
Core::Constants::TOGGLE_SIDEBAR,
QList<int> () << uuidManager->uniqueIdentifier(Constants::C_FORMEDITOR));
Core::ActionContainer *viewsMenu = actionManager->actionContainer(Core::Constants::M_WINDOW_VIEWS);
command = actionManager->registerAction(m_mainWidget->restoreDefaultViewAction(),
Constants::RESTORE_DEFAULT_VIEW,
QList<int> () << uuidManager->uniqueIdentifier(Constants::C_FORMEDITOR));
command->setAttribute(Core::Command::CA_Hide);
viewsMenu->addAction(command);
#ifdef Q_OS_MACX
// add second shortcut to trigger delete
QAction *deleteAction = new QAction(m_mainWidget);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment