From b4543ce1708dc0e59cb1dd54e1c53648c5959b24 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sun, 7 Jan 2007 21:10:52 +0000 Subject: [PATCH] Remember the position and size of the docks by using QMainWindow::saveState() and QMainWindow::restoreState(). I assume that in KDE 4 there will be a generic mechanism to store the position and size of docks like done for toolbars -> this is only a temporary solution to have a usable version of Dolphin in the meantime. svn path=/trunk/playground/utils/dolphin/; revision=620954 --- src/dolphinmainwindow.cpp | 36 ++++++++++++++++++++++++++++-------- src/dolphinui.rc | 2 +- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 7d0e09926..081960df0 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -307,17 +307,23 @@ void DolphinMainWindow::linkDroppedItems() void DolphinMainWindow::closeEvent(QCloseEvent* event) { - // KDE4-TODO - //KConfig* config = KGlobal::config(); - //config->setGroup("General"); - //config->writeEntry("First Run", false); - DolphinSettings& settings = DolphinSettings::instance(); GeneralSettings* generalSettings = settings.generalSettings(); generalSettings->setFirstRun(false); settings.save(); + // TODO: I assume there will be a generic way in KDE 4 to store the docks + // of the main window. In the meantime they are stored manually: + QString filename = KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName()); + filename.append("/panels_layout"); + QFile file(filename); + if (file.open(QIODevice::WriteOnly)) { + QByteArray data = saveState(); + file.write(data); + file.close(); + } + KMainWindow::closeEvent(event); } @@ -1138,6 +1144,18 @@ void DolphinMainWindow::loadSettings() } updateViewActions(); + + // TODO: I assume there will be a generic way in KDE 4 to restore the docks + // of the main window. In the meantime they are restored manually (see also + // DolphinMainWindow::closeEvent() for more details): + QString filename = KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName()); + filename.append("/panels_layout"); + QFile file(filename); + if (file.open(QIODevice::ReadOnly)) { + QByteArray data = file.readAll(); + restoreState(data); + file.close(); + } } void DolphinMainWindow::setupActions() @@ -1306,17 +1324,19 @@ void DolphinMainWindow::setupActions() void DolphinMainWindow::setupDockWidgets() { - QDockWidget* shortcutsDock = new QDockWidget(i18n("Shortcuts")); + QDockWidget* shortcutsDock = new QDockWidget(i18n("Bookmarks")); + shortcutsDock->setObjectName("bookmarksDock"); shortcutsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); shortcutsDock->setWidget(new BookmarksSidebarPage(this)); - shortcutsDock->toggleViewAction()->setObjectName("show_shortcuts_panel"); - shortcutsDock->toggleViewAction()->setText(i18n("Show Shortcuts Panel")); + shortcutsDock->toggleViewAction()->setObjectName("show_bookmarks_panel"); + shortcutsDock->toggleViewAction()->setText(i18n("Show Bookmarks Panel")); actionCollection()->insert(shortcutsDock->toggleViewAction()); addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock); QDockWidget* infoDock = new QDockWidget(i18n("Information")); + infoDock->setObjectName("infoDock"); infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); infoDock->setWidget(new InfoSidebarPage(this)); diff --git a/src/dolphinui.rc b/src/dolphinui.rc index 22bfe909e..a090a1d2f 100644 --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -43,7 +43,7 @@ Panels - + -- 2.47.3