1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Get ride of the sidebar and use dockwidgets instead.

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
This commit is contained in:
Kevin Ottens 2006-11-29 18:09:26 +00:00
parent 91c5f52d87
commit b1d5b6b746
13 changed files with 22 additions and 300 deletions

View 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} )

View 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:

View 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;
}
QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts"));
shortcutsDock->setObjectName("shortcutsDock");
shortcutsDock->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
shortcutsDock->setWidget(new BookmarksSidebarPage(this));
addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
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);
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"

View 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;
/**

View 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;
}

View 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

View 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">

View 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:

View File

@ -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"

View File

@ -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_

View 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:

View File

@ -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>

View File

@ -1,4 +0,0 @@
File=sidebarsettings.kcfg
ClassName=SidebarSettings
Singleton=false
Mutators=true