]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Get ride of the sidebar and use dockwidgets instead.
authorKevin Ottens <ervin@kde.org>
Wed, 29 Nov 2006 18:09:26 +0000 (18:09 +0000)
committerKevin Ottens <ervin@kde.org>
Wed, 29 Nov 2006 18:09:26 +0000 (18:09 +0000)
Default is now three panes, but the dockwidgets can be stacked, etc. to
the user convenience.

There's a slight loss in feature since I disabled dockwidgets hiding,
it's simply because some rework is still needed in kdelibs and Qt to
make them work correctly.

svn path=/trunk/playground/utils/dolphin/; revision=609186

13 files changed:
src/CMakeLists.txt
src/bookmarkssidebarpage.h
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinsettings.cpp
src/dolphinsettings.h
src/dolphinui.rc
src/infosidebarpage.h
src/sidebar.cpp [deleted file]
src/sidebar.h [deleted file]
src/sidebarpage.h
src/sidebarsettings.kcfg [deleted file]
src/sidebarsettings.kcfgc [deleted file]

index 7ea5426bb907cb0a76db4c3e1b652b82e297a0e2..2ee66d31a9363804c4d18ca8ecda155d27b4fded 100644 (file)
@@ -36,7 +36,6 @@ set(dolphin_SRCS
    bookmarkssettingspage.cpp
    editbookmarkdialog.cpp
    settingspagebase.cpp
-   sidebar.cpp
    sidebarpage.cpp
    bookmarkssidebarpage.cpp
    infosidebarpage.cpp
@@ -52,8 +51,7 @@ kde4_add_kcfg_files(dolphin_SRCS
    generalsettings.kcfgc
    iconsmodesettings.kcfgc
    detailsmodesettings.kcfgc
-   previewsmodesettings.kcfgc
-   sidebarsettings.kcfgc )
+   previewsmodesettings.kcfgc )
 
 kde4_add_executable(dolphin ${dolphin_SRCS})
 
@@ -65,7 +63,7 @@ install(TARGETS dolphin DESTINATION ${BIN_INSTALL_DIR})
 ########### install files ###############
 
 install( FILES  dolphin.desktop DESTINATION ${XDG_APPS_DIR} )
-install( FILES  directoryviewpropertysettings.kcfg generalsettings.kcfg                                iconsmodesettings.kcfg detailsmodesettings.kcfg previewsmodesettings.kcfg                               sidebarsettings.kcfg DESTINATION ${KCFG_INSTALL_DIR} )
+install( FILES  directoryviewpropertysettings.kcfg generalsettings.kcfg                                iconsmodesettings.kcfg detailsmodesettings.kcfg previewsmodesettings.kcfg                               DESTINATION ${KCFG_INSTALL_DIR} )
 install( FILES  dolphinui.rc DESTINATION ${DATA_INSTALL_DIR}/dolphin )
 
 kde4_install_icons( ${ICON_INSTALL_DIR} )
index 95375539974886675f1b09b363046b9b0393345a..601a4d836f3bf66193b9c0a571add6430f171b56 100644 (file)
@@ -41,7 +41,7 @@ class BookmarksSidebarPage : public SidebarPage
         Q_OBJECT
 
 public:
-    BookmarksSidebarPage(DolphinMainWindow *mainWindow, QWidget* parent);
+    BookmarksSidebarPage(DolphinMainWindow *mainWindow, QWidget* parent=0);
     virtual ~BookmarksSidebarPage();
 
 protected:
index 9748c6e24d34faa6e675fdcbc67fc50edba2bb90..938d41cbc5248c365d15038d754747b5655026e5 100644 (file)
@@ -58,6 +58,7 @@
 #include <Q3ValueList>
 #include <QCloseEvent>
 #include <QSplitter>
+#include <QDockWidget>
 
 #include "urlnavigator.h"
 #include "viewpropertiesdialog.h"
@@ -69,8 +70,8 @@
 #include "undomanager.h"
 #include "progressindicator.h"
 #include "dolphinsettings.h"
-#include "sidebar.h"
-#include "sidebarsettings.h"
+#include "bookmarkssidebarpage.h"
+#include "infosidebarpage.h"
 #include "generalsettings.h"
 #include "dolphinapplication.h"
 
@@ -78,7 +79,6 @@
 DolphinMainWindow::DolphinMainWindow() :
     KMainWindow(0, "Dolphin"),
     m_splitter(0),
-    m_sidebar(0),
     m_activeView(0),
     m_clipboardContainsCutData(false)
 {
@@ -339,13 +339,6 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
     GeneralSettings* generalSettings = settings.generalSettings();
     generalSettings->setFirstRun(false);
 
-    SidebarSettings* sidebarSettings = settings.sidebarSettings();
-    const bool isSidebarVisible = (m_sidebar != 0);
-    sidebarSettings->setVisible(isSidebarVisible);
-    if (isSidebarVisible) {
-        sidebarSettings->setWidth(m_sidebar->width());
-    }
-
     settings.save();
 
     KMainWindow::closeEvent(event);
@@ -1107,36 +1100,6 @@ void DolphinMainWindow::addUndoOperation(KJob* job)
     }
 }
 
-void DolphinMainWindow::toggleSidebar()
-{
-    if (m_sidebar == 0) {
-        openSidebar();
-    }
-    else {
-        closeSidebar();
-    }
-
-    KToggleAction* sidebarAction = static_cast<KToggleAction*>(actionCollection()->action("sidebar"));
-    sidebarAction->setChecked(m_sidebar != 0);
-}
-
-void DolphinMainWindow::closeSidebar()
-{
-    if (m_sidebar == 0) {
-        // the sidebar has already been closed
-        return;
-    }
-
-    // store width of sidebar and remember that the sidebar has been closed
-    SidebarSettings* settings = DolphinSettings::instance().sidebarSettings();
-    settings->setVisible(false);
-    settings->setWidth(m_sidebar->width());
-
-    m_sidebar->deleteLater();
-    m_sidebar = 0;
-}
-
-
 void DolphinMainWindow::init()
 {
     // Check whether Dolphin runs the first time. If yes then
@@ -1162,7 +1125,6 @@ void DolphinMainWindow::init()
     }
 
     setupActions();
-    setupGUI(Keys|Save|Create|ToolBar);
 
     const KUrl& homeUrl = root.first().url();
     setCaption(homeUrl.fileName());
@@ -1176,14 +1138,9 @@ void DolphinMainWindow::init()
     m_activeView = m_view[PrimaryIdx];
 
     setCentralWidget(m_splitter);
+    setupDockWidgets();
 
-    // open sidebar
-    SidebarSettings* sidebarSettings = settings.sidebarSettings();
-    assert(sidebarSettings != 0);
-    if (sidebarSettings->visible()) {
-        openSidebar();
-    }
-
+    setupGUI(Keys|Save|Create|ToolBar);
     createGUI();
 
     stateChanged("new_file");
@@ -1351,10 +1308,6 @@ void DolphinMainWindow::setupActions()
     editLocation->setShortcut(Qt::Key_F6);
     connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));
 
-    KToggleAction* sidebar = new KToggleAction(i18n("Sidebar"), actionCollection(), "sidebar");
-    sidebar->setShortcut(Qt::Key_F9);
-    connect(sidebar, SIGNAL(triggered()), this, SLOT(toggleSidebar()));
-
     KAction* adjustViewProps = new KAction(i18n("Adjust View Properties..."), actionCollection(), "view_properties");
     connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
 
@@ -1585,9 +1538,6 @@ void DolphinMainWindow::updateViewActions()
 
     KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
     splitAction->setChecked(m_view[SecondaryIdx] != 0);
-
-    KToggleAction* sidebarAction = static_cast<KToggleAction*>(actionCollection()->action("sidebar"));
-    sidebarAction->setChecked(m_sidebar != 0);
 }
 
 void DolphinMainWindow::updateGoActions()
@@ -1652,24 +1602,19 @@ void DolphinMainWindow::clearStatusBar()
     m_activeView->statusBar()->clear();
 }
 
-void DolphinMainWindow::openSidebar()
+void DolphinMainWindow::setupDockWidgets()
 {
-    if (m_sidebar != 0) {
-        // the sidebar is already open
-        return;
-    }
-
-    m_sidebar = new Sidebar(this, m_splitter);
-    m_sidebar->show();
-
-    connect(m_sidebar, SIGNAL(urlChanged(const KUrl&)),
-            this, SLOT(slotUrlChangeRequest(const KUrl&)));
-    m_splitter->setCollapsible(m_sidebar, false);
-    m_splitter->setResizeMode(m_sidebar, QSplitter::KeepSize);
-    m_splitter->moveToFirst(m_sidebar);
+    QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts"));
+    shortcutsDock->setObjectName("shortcutsDock");
+    shortcutsDock->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
+    shortcutsDock->setWidget(new BookmarksSidebarPage(this));
+    addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
 
-    SidebarSettings* settings = DolphinSettings::instance().sidebarSettings();
-    settings->setVisible(true);
+    QDockWidget *infoDock = new QDockWidget(i18n("Information"));
+    infoDock->setObjectName("infoDock");
+    infoDock->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
+    infoDock->setWidget(new InfoSidebarPage(this));
+    addDockWidget(Qt::RightDockWidgetArea, infoDock);
 }
 
 #include "dolphinmainwindow.moc"
index d736c82627fb5a460fd792dc0d88d8c07779b83d..8b5694619d0a8709df75c16fe97943bcdefcb017 100644 (file)
@@ -48,7 +48,6 @@ class Q3IconViewItem;
 class QSplitter;
 class KAction;
 class UrlNavigator;
-class Sidebar;
 class DolphinApplication;
 
 /**
@@ -373,14 +372,6 @@ private slots:
     void addUndoOperation(KJob* job);
 
 
-    void toggleSidebar();
-
-    /**
-     * Stores the current sidebar width and closes
-     * the sidebar.
-     */
-    void closeSidebar();
-
 private:
     DolphinMainWindow();
     void init();
@@ -388,6 +379,7 @@ private:
 
     void setupAccel();
     void setupActions();
+    void setupDockWidgets();
     void setupCreateNewMenuActions();
     void updateHistory();
     void updateEditActions();
@@ -401,10 +393,8 @@ private:
                            const KUrl::List& source,
                            const KUrl& dest);
     void clearStatusBar();
-    void openSidebar();
 
     QSplitter* m_splitter;
-    Sidebar* m_sidebar;
     DolphinView* m_activeView;
 
     /**
index f197d36f030c6d1b2caa3c8759ffbf83a5ebf5cd..11c18914ff24a71d8cf1eb6ea855f8de9a78c7fe 100644 (file)
@@ -34,7 +34,6 @@
 #include "iconsmodesettings.h"
 #include "previewsmodesettings.h"
 #include "detailsmodesettings.h"
-#include "sidebarsettings.h"
 
 #include <Q3IconView>
 
@@ -78,7 +77,6 @@ void DolphinSettings::save()
     m_iconsModeSettings->writeConfig();
     m_previewsModeSettings->writeConfig();
     m_detailsModeSettings->writeConfig();
-    m_sidebarSettings->writeConfig();
 
     QString basePath = KGlobal::instance()->instanceName();
     basePath.append("/bookmarks.xml");
@@ -163,7 +161,6 @@ DolphinSettings::DolphinSettings()
     m_iconsModeSettings = new IconsModeSettings();
     m_previewsModeSettings = new PreviewsModeSettings();
     m_detailsModeSettings = new DetailsModeSettings();
-    m_sidebarSettings = new SidebarSettings();
 }
 
 DolphinSettings::~DolphinSettings()
@@ -179,7 +176,4 @@ DolphinSettings::~DolphinSettings()
 
     delete m_detailsModeSettings;
     m_detailsModeSettings = 0;
-
-    delete m_sidebarSettings;
-    m_sidebarSettings = 0;
 }
index 981e7d51e6af28a57875a1a4baf448eda249dca5..2b97356a5ce66b181f64a9012e68b5282e512627 100644 (file)
@@ -27,7 +27,6 @@ class GeneralSettings;
 class IconsModeSettings;
 class PreviewsModeSettings;
 class DetailsModeSettings;
-class SidebarSettings;
 
 /**
  * @brief Manages and stores all settings from Dolphin.
@@ -48,7 +47,6 @@ public:
     IconsModeSettings* iconsModeSettings() const { return m_iconsModeSettings; }
     PreviewsModeSettings* previewsModeSettings() const { return m_previewsModeSettings; }
     DetailsModeSettings* detailsModeSettings() const { return m_detailsModeSettings; }
-    SidebarSettings* sidebarSettings() const { return m_sidebarSettings; }
 
     KBookmarkManager* bookmarkManager() const;
 
@@ -97,7 +95,6 @@ private:
     IconsModeSettings* m_iconsModeSettings;
     PreviewsModeSettings* m_previewsModeSettings;
     DetailsModeSettings* m_detailsModeSettings;
-    SidebarSettings* m_sidebarSettings;
 };
 
 #endif
index 49eb67dafca6df054a4fca0466b6bddca9e1b231..5db6ff9a9d7914624a7a3f9175519cb6e5b964c7 100644 (file)
@@ -46,7 +46,6 @@
     <Action name="editable_location" />
     <Action name="edit_location" />
    </Menu>
-   <Action name="sidebar" />
    <Action name="view_properties" />
   </Menu>
   <Menu name="tools">
index edd43229e12d3300f8d58cb5a89796d35a880093..e7d527126e6de605ee8657bdc41d7aa6ea9099d3 100644 (file)
@@ -59,7 +59,7 @@ class InfoSidebarPage : public SidebarPage
        Q_OBJECT
 
 public:
-    InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent);
+    InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent=0);
     virtual ~InfoSidebarPage();
 
 protected:
diff --git a/src/sidebar.cpp b/src/sidebar.cpp
deleted file mode 100644 (file)
index 26cfa0c..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com>       *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "sidebar.h"
-
-#include <QVBoxLayout>
-#include <QComboBox>
-
-#include <kiconloader.h>
-#include <klocale.h>
-
-#include "dolphinsettings.h"
-#include "sidebarsettings.h"
-#include "bookmarkssidebarpage.h"
-#include "infosidebarpage.h"
-
-Sidebar::Sidebar(DolphinMainWindow* mainWindow, QWidget* parent) :
-    QWidget(parent),
-    m_mainWindow(mainWindow),
-    m_pagesSelector(0),
-    m_page(0),
-    m_layout(0)
-{
-    m_layout = new QVBoxLayout(this);
-    m_layout->setMargin(0);
-    m_layout->setSpacing(0);
-
-    m_pagesSelector = new QComboBox(this);
-    m_pagesSelector->insertItem(i18n("Information"));
-    m_pagesSelector->insertItem(i18n("Bookmarks"));
-
-    // Assure that the combo box has the same height as the Url navigator for
-    // a clean layout.
-    // TODO: the following 2 lines have been copied from the UrlNavigator
-    // constructor (-> provide a shared height setting?)
-    QFontMetrics fontMetrics(font());
-    m_pagesSelector->setMinimumHeight(fontMetrics.height() + 8);
-
-    SidebarSettings* settings = DolphinSettings::instance().sidebarSettings();
-    const int selectedIndex = indexForName(settings->selectedPage());
-    m_pagesSelector->setCurrentItem(selectedIndex);
-    m_layout->addWidget(m_pagesSelector);
-
-    createPage(selectedIndex);
-
-    connect(m_pagesSelector, SIGNAL(activated(int)),
-            this, SLOT(createPage(int)));
-}
-
-Sidebar::~Sidebar()
-{
-}
-
-QSize Sidebar::sizeHint() const
-{
-    QSize size(QWidget::sizeHint());
-
-    SidebarSettings* settings = DolphinSettings::instance().sidebarSettings();
-    size.setWidth(settings->width());
-    return size;
-}
-
-void Sidebar::createPage(int index)
-{
-    if (m_page != 0) {
-        m_page->deleteLater();
-        m_page = 0;
-    }
-
-    switch (index) {
-        case 0: m_page = new InfoSidebarPage(m_mainWindow, this); break;
-        case 1: m_page = new BookmarksSidebarPage(m_mainWindow, this); break;
-        default: break;
-    }
-
-    m_layout->addWidget(m_page);
-    m_page->show();
-
-    SidebarSettings* settings = DolphinSettings::instance().sidebarSettings();
-    settings->setSelectedPage(m_pagesSelector->text(index));
-}
-
-int Sidebar::indexForName(const QString& name) const
-{
-    const int count = m_pagesSelector->count();
-    for (int i = 0; i < count; ++i) {
-        if (m_pagesSelector->text(i) == name) {
-            return i;
-        }
-    }
-
-    return 0;
-}
-
-#include "sidebar.moc"
diff --git a/src/sidebar.h b/src/sidebar.h
deleted file mode 100644 (file)
index 6c7abab..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com>       *
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _SIDEBAR_H_
-#define _SIDEBAR_H_
-
-#include <QWidget>
-#include <QVBoxLayout>
-
-class KUrl;
-class QComboBox;
-class Q3VBoxLayout;
-class SidebarPage;
-class DolphinMainWindow;
-
-/**
- * @brief The sidebar allows to access bookmarks, history items and TODO...
- *
- * TODO
- */
-class Sidebar : public QWidget
-{
-       Q_OBJECT
-
-public:
-    Sidebar(DolphinMainWindow* mainwindow, QWidget* parent);
-    virtual ~Sidebar();
-
-    virtual QSize sizeHint() const;
-
-signals:
-    /**
-     * The user selected an item on sidebar widget and item has
-     * Url property, so inform the parent togo to this Url;
-     */
-    void urlChanged(const KUrl& url);
-
-private slots:
-    void createPage(int index);
-
-private:
-    int indexForName(const QString& name) const;
-
-    DolphinMainWindow *m_mainWindow;
-    QComboBox* m_pagesSelector;
-    SidebarPage* m_page;
-    QVBoxLayout* m_layout;
-};
-
-#endif // _SIDEBAR_H_
index e97b0c9cf25f74f20eb5e59dbc834c1c9b558943..d83ef5e9a008b5430abeb4825c42a36aa98269c2 100644 (file)
@@ -36,7 +36,7 @@ class SidebarPage : public QWidget
        Q_OBJECT
 
 public:
-    SidebarPage(DolphinMainWindow* mainwindow, QWidget* parent);
+    SidebarPage(DolphinMainWindow* mainwindow, QWidget* parent=0);
     virtual ~SidebarPage();
 
 protected slots:
diff --git a/src/sidebarsettings.kcfg b/src/sidebarsettings.kcfg
deleted file mode 100644 (file)
index e3f7211..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
-<kcfg> 
-    <kcfgfile name="dolphinrc"/>
-    <group name="Sidebar">
-        <entry name="SelectedPage" type="String">
-            <label>Selected page</label>
-            <default>Information</default>
-        </entry>
-        <entry name="Visible" type="Bool">
-            <label>Is the sidebar visible</label>
-            <default>true</default>
-        </entry>
-        <entry name="Width" type="Int">
-            <label>Sidebar with</label>
-            <default>150</default>
-        </entry>
-    </group>
-</kcfg>
\ No newline at end of file
diff --git a/src/sidebarsettings.kcfgc b/src/sidebarsettings.kcfgc
deleted file mode 100644 (file)
index 2b6e078..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-File=sidebarsettings.kcfg
-ClassName=SidebarSettings
-Singleton=false 
-Mutators=true
\ No newline at end of file