summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-04-22 01:18:22 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-04-22 01:18:22 +0200
commit182a330e250008177d05a5ef4ed0bd87226ee954 (patch)
tree27e54a567764689b75931d435085aa895dc948a4
parentpedantic (diff)
downloadrekonq-182a330e250008177d05a5ef4ed0bd87226ee954.tar.xz
Side Panel
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/application.cpp41
-rw-r--r--src/application.h20
-rw-r--r--src/bookmarks.cpp24
-rw-r--r--src/mainwindow.cpp42
-rw-r--r--src/mainwindow.h19
-rw-r--r--src/panelhistory.cpp94
-rw-r--r--src/panelhistory.h55
-rw-r--r--src/rekonq.kcfg3
-rw-r--r--src/rekonqui.rc6
-rw-r--r--src/settings_general.ui7
-rw-r--r--src/sidepanel.cpp54
-rw-r--r--src/sidepanel.h52
13 files changed, 371 insertions, 48 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9f67c749..486a3992 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,6 +18,8 @@ SET( rekonq_SRCS
settings.cpp
webview.cpp
main.cpp
+ sidepanel.cpp
+ panelhistory.cpp
)
KDE4_ADD_UI_FILES( rekonq_SRCS
diff --git a/src/application.cpp b/src/application.cpp
index 45641ea8..5b296333 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -48,28 +48,24 @@
#include <QtWebKit>
-HistoryManager *Application::s_historyManager = 0;
-NetworkAccessManager *Application::s_networkAccessManager = 0;
-DownloadManager *Application::s_downloadManager = 0;
-BookmarkProvider *Application::s_bookmarkProvider = 0;
+QPointer<HistoryManager> Application::s_historyManager;
+QPointer<NetworkAccessManager> Application::s_networkAccessManager;
+QPointer<DownloadManager> Application::s_downloadManager;
+QPointer<BookmarkProvider> Application::s_bookmarkProvider;
+
Application::Application()
- : KUniqueApplication()
+ : KUniqueApplication()
+ , m_mainWindow(0)
{
- m_mainWindow = new MainWindow();
- m_mainWindow->setObjectName("MainWindow");
- setWindowIcon(KIcon("rekonq"));
-
- m_mainWindow->show();
-
- QTimer::singleShot(0, this, SLOT(postLaunch()));
}
Application::~Application()
{
- delete s_downloadManager;
+ delete m_mainWindow;
+ delete s_bookmarkProvider;
delete s_networkAccessManager;
delete s_historyManager;
}
@@ -80,6 +76,18 @@ int Application::newInstance()
KCmdLineArgs::setCwd(QDir::currentPath().toUtf8());
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
+ if (!m_mainWindow)
+ {
+ m_mainWindow = new MainWindow();
+
+ m_mainWindow->setObjectName("MainWindow");
+ setWindowIcon(KIcon("rekonq"));
+
+ m_mainWindow->show();
+
+ QTimer::singleShot(0, this, SLOT(postLaunch()));
+ }
+
if (args->count() > 0)
{
for (int i = 0; i < args->count(); ++i)
@@ -120,6 +128,13 @@ void Application::postLaunch()
}
+
+void Application::slotSaveConfiguration() const
+{
+ ReKonfig::self()->writeConfig();
+}
+
+
void Application::openUrl(const KUrl &url)
{
mainWindow()->loadUrl(url);
diff --git a/src/application.h b/src/application.h
index ee3d3112..5c0ee3cb 100644
--- a/src/application.h
+++ b/src/application.h
@@ -22,6 +22,8 @@
#ifndef APPLICATION_H
#define APPLICATION_H
+// Qt Includes
+#include <QPointer>
// KDE Includes
#include <KUniqueApplication>
@@ -69,6 +71,14 @@ public:
static DownloadManager *downloadManager();
static BookmarkProvider *bookmarkProvider();
+public slots:
+ /**
+ * Save application's configuration
+ * @see ReKonfig::self()->writeConfig();
+ */
+ void slotSaveConfiguration() const;
+
+
private slots:
/**
@@ -78,12 +88,12 @@ private slots:
void openUrl(const KUrl &url);
private:
- static HistoryManager *s_historyManager;
- static NetworkAccessManager *s_networkAccessManager;
- static DownloadManager *s_downloadManager;
- static BookmarkProvider *s_bookmarkProvider;
+ static QPointer<HistoryManager> s_historyManager;
+ static QPointer<NetworkAccessManager> s_networkAccessManager;
+ static QPointer<DownloadManager> s_downloadManager;
+ static QPointer<BookmarkProvider> s_bookmarkProvider;
- MainWindow* m_mainWindow;
+ QPointer<MainWindow> m_mainWindow;
};
#endif // APPLICATION_H
diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp
index fc69b88f..e6dbf1df 100644
--- a/src/bookmarks.cpp
+++ b/src/bookmarks.cpp
@@ -87,20 +87,6 @@ QString BookmarkOwner::currentTitle() const
}
-// QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const
-// {
-// QList< QPair<QString, QString> > list;
-// QList<WebView *> tabs = Application::instance()->mainWindow()->mainView()->tabs();
-// foreach(WebView *tab, tabs)
-// {
-// QString url = tab->url().url();
-// QString title = tab->title();
-// list.append(QPair<QString, QString>(url, title));
-// }
-// return list;
-// }
-
-
// ------------------------------------------------------------------------------------------------------
@@ -149,12 +135,12 @@ void BookmarkMenu::slotAddBookmark()
BookmarkProvider::BookmarkProvider(QWidget *parent)
: QWidget(parent)
- , m_manager(NULL)
- , m_owner(NULL)
+ , m_manager(0)
+ , m_owner(0)
, m_menu(new KMenu(this))
, m_actionCollection(new KActionCollection(this))
- , m_bookmarkMenu(NULL)
- , m_bookmarkToolBar(NULL)
+ , m_bookmarkMenu(0)
+ , m_bookmarkToolBar(0)
{
KUrl bookfile = KUrl("~/.kde/share/apps/konqueror/bookmarks.xml"); // share konqueror bookmarks
@@ -184,9 +170,9 @@ BookmarkProvider::BookmarkProvider(QWidget *parent)
// setup toolbar
setupToolBar();
-
}
+
BookmarkProvider::~BookmarkProvider()
{
delete m_bookmarkToolBar;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7b9139cc..82b15ebf 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -37,6 +37,8 @@
#include "mainview.h"
#include "bookmarks.h"
#include "download.h"
+#include "findbar.h"
+#include "sidepanel.h"
// KDE Includes
#include <KUrl>
@@ -66,6 +68,7 @@ MainWindow::MainWindow()
, m_view(new MainView(this))
, m_findBar(new FindBar(this))
, m_searchBar(new SearchBar(this))
+ , m_sidePanel(0)
{
// accept dnd
setAcceptDrops(true);
@@ -73,19 +76,23 @@ MainWindow::MainWindow()
// updating rekonq configuration
slotUpdateConfiguration();
- // creating a centralWidget containing m_view and the hidden findbar
+ // creating a centralWidget containing panel, m_view and the hidden findbar
QWidget *centralWidget = new QWidget;
+ centralWidget->setContentsMargins(0, 0, 0, 0);
+
+ // setting layout
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_view);
-
- // Adding Find Bar
- connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &)));
layout->addWidget(m_findBar);
-
centralWidget->setLayout(layout);
+
+ // central widget
setCentralWidget(centralWidget);
+ // Adding Find Bar
+ connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &)));
+
// setting size policies
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -127,6 +134,7 @@ MainWindow::MainWindow()
KActionMenu *bmMenu = Application::bookmarkProvider()->bookmarkActionMenu();
actionCollection()->addAction(QLatin1String("bookmarks"), bmMenu);
+ setupSidePanel();
// a call to KXmlGuiWindow::setupGUI() populates the GUI
// with actions, using KXMLGUI.
// It also applies the saved mainwindow settings, if any, and ask the
@@ -143,6 +151,8 @@ MainWindow::MainWindow()
// setting up toolbars to NOT have context menu enabled
setContextMenuPolicy(Qt::DefaultContextMenu);
+
+
}
@@ -304,6 +314,28 @@ void MainWindow::setupActions()
}
+void MainWindow::setupSidePanel()
+{
+ // Setup history side panel
+ m_sidePanel = new SidePanel(i18n("History"), this);
+ connect(m_sidePanel, SIGNAL(openUrl(const KUrl&)), this, SLOT(loadUrl(const KUrl&)));
+ connect(m_sidePanel, SIGNAL(destroyed()), Application::instance(), SLOT(slotSaveConfiguration()));
+
+ addDockWidget(Qt::LeftDockWidgetArea, m_sidePanel);
+
+ // setup side panel actions
+ KAction* a = new KAction(this);
+ a->setText(i18n("History"));
+ a->setCheckable(true);
+ a->setChecked(ReKonfig::showSideBar());
+ a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_H));
+ actionCollection()->addAction(QLatin1String("show_history_panel"), a);
+
+ // connect to toogle action
+ connect(a, SIGNAL(triggered(bool)), m_sidePanel->toggleViewAction(), SLOT(trigger()));
+}
+
+
void MainWindow::setupHistoryMenu()
{
HistoryMenu *historyMenu = new HistoryMenu(this);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 76f5431b..74fee529 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -24,21 +24,27 @@
#define MAINWINDOW_H
// Local Includes
-#include "findbar.h"
#include "searchbar.h"
#include "bookmarks.h"
#include "mainview.h"
+#include "webview.h"
// KDE Includes
#include <KXmlGuiWindow>
-#include <KIcon>
-#include <KAction>
#include <KToolBar>
-#include <KMenu>
// Forward Declarations
-class KUrl;
class QWebFrame;
+
+class KUrl;
+class KAction;
+class KActionMenu;
+class KIcon;
+class KMenu;
+
+class FindBar;
+class HistoryMenu;
+class SidePanel;
class WebView;
@@ -65,6 +71,8 @@ private:
void setupActions();
void setupHistoryMenu();
void setupToolBars();
+ void setupSidePanel();
+ SidePanel *sidePanel() { return m_sidePanel; }
public slots:
void slotHome();
@@ -134,6 +142,7 @@ private:
MainView *m_view;
FindBar *m_findBar;
SearchBar *m_searchBar;
+ SidePanel *m_sidePanel;
};
#endif // MAINWINDOW_H
diff --git a/src/panelhistory.cpp b/src/panelhistory.cpp
new file mode 100644
index 00000000..4b71cefa
--- /dev/null
+++ b/src/panelhistory.cpp
@@ -0,0 +1,94 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Domrachev Alexandr <alexandr.domrachev@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, 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.
+*
+* ============================================================ */
+
+
+// Self Includes
+#include "panelhistory.h"
+
+// QT Includes
+#include <QLabel>
+
+// KDE Includes
+#include <KLocalizedString>
+#include <KLineEdit>
+#include <KUrl>
+
+// Local Includes
+#include "history.h"
+
+
+PanelHistory::PanelHistory(QWidget *parent)
+ : QWidget(parent)
+ , m_historyTreeView(new QTreeView)
+ , m_treeProxyModel(new TreeProxyModel(this))
+{
+ m_historyTreeView->setUniformRowHeights(true);
+ m_historyTreeView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ m_historyTreeView->setTextElideMode(Qt::ElideMiddle);
+ m_historyTreeView->setAlternatingRowColors(true);
+
+ // add search bar
+ QHBoxLayout *hBoxLayout = new QHBoxLayout;
+ hBoxLayout->setContentsMargins(5, 0, 0, 0);
+ QLabel *searchLabel = new QLabel(i18n("Search: "));
+ hBoxLayout->addWidget(searchLabel);
+ KLineEdit *search = new KLineEdit;
+ hBoxLayout->addWidget(search);
+ QWidget *searchBar = new QWidget;
+ searchBar->setLayout(hBoxLayout);
+
+ // setup view
+ QVBoxLayout *vBoxLayout = new QVBoxLayout;
+ vBoxLayout->setContentsMargins(0, 0, 0, 0);
+ vBoxLayout->addWidget(searchBar);
+ vBoxLayout->addWidget(m_historyTreeView);
+ setLayout(vBoxLayout);
+
+ //-
+ HistoryManager *historyManager = Application::historyManager();
+ QAbstractItemModel *model = historyManager->historyTreeModel();
+
+ m_treeProxyModel->setSourceModel(model);
+ m_historyTreeView->setModel(m_treeProxyModel);
+ m_historyTreeView->setExpanded(m_treeProxyModel->index(0, 0), true);
+ m_historyTreeView->header()->hideSection(1);
+ QFontMetrics fm(font());
+ int header = fm.width(QLatin1Char('m')) * 40;
+ m_historyTreeView->header()->resizeSection(0, header);
+
+ connect(search, SIGNAL(textChanged(QString)), m_treeProxyModel, SLOT(setFilterFixedString(QString)));
+ connect(m_historyTreeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(open()));
+}
+
+
+PanelHistory::~PanelHistory()
+{
+ delete m_treeProxyModel;
+ delete m_historyTreeView;
+}
+
+
+void PanelHistory::open()
+{
+ QModelIndex index = m_historyTreeView->currentIndex();
+ if (!index.parent().isValid())
+ return;
+ emit openUrl(index.data(HistoryModel::UrlRole).toUrl());
+}
+
diff --git a/src/panelhistory.h b/src/panelhistory.h
new file mode 100644
index 00000000..45847565
--- /dev/null
+++ b/src/panelhistory.h
@@ -0,0 +1,55 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Domrachev Alexandr <alexandr.domrachev@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, 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.
+*
+* ============================================================ */
+
+#ifndef PANELHISTORY_H
+#define PANELHISTORY_H
+
+// Qt Includes
+#include <QWidget>
+
+// Local Includes
+#include "application.h"
+
+class QTreeView;
+class KUrl;
+class TreeProxyModel;
+
+
+class PanelHistory : public QWidget
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(PanelHistory)
+
+public:
+ explicit PanelHistory(QWidget *parent = 0);
+ virtual ~PanelHistory();
+
+signals:
+ void openUrl(const KUrl&);
+
+private slots:
+ void open();
+
+private:
+ QTreeView *m_historyTreeView;
+ TreeProxyModel *m_treeProxyModel;
+
+};
+
+#endif // PANELHISTORY_H
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index a02f10ad..c6d5b0ff 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -23,6 +23,9 @@
<entry name="alwaysShowTabBar" type="Bool">
<default>true</default>
</entry>
+ <entry name="showSideBar" type="Bool">
+ <default>false</default>
+ </entry>
</group>
<!-- Fonts Settings -->
diff --git a/src/rekonqui.rc b/src/rekonqui.rc
index 6de55eb5..e7b8d292 100644
--- a/src/rekonqui.rc
+++ b/src/rekonqui.rc
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
-<gui name="rekonq" version="37">
+<gui name="rekonq" version="38">
<MenuBar>
@@ -63,6 +63,10 @@
<!-- ============ SETTINGS menu =========== -->
<Menu name="settings" noMerge="1"><text>&amp;Settings</text>
<Action name="options_show_menubar" />
+ <Merge/>
+ <Menu name="side_panels"><text>Side &amp;Panels</text>
+ <Action name="show_history_panel" />
+ </Menu>
<Action name="options_show_statusbar" />
<Merge name="StandardToolBarMenuHandler" />
<Separator/>
diff --git a/src/settings_general.ui b/src/settings_general.ui
index 3b117854..580c6bb2 100644
--- a/src/settings_general.ui
+++ b/src/settings_general.ui
@@ -100,6 +100,13 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="kcfg_showSideBar">
+ <property name="text">
+ <string>Show side panel</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/src/sidepanel.cpp b/src/sidepanel.cpp
new file mode 100644
index 00000000..2197a603
--- /dev/null
+++ b/src/sidepanel.cpp
@@ -0,0 +1,54 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot 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, 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.
+*
+* ============================================================ */
+
+// Self Includes
+#include "sidepanel.h"
+
+// Auto Includes
+#include "rekonq.h"
+
+// Local Includes
+#include "panelhistory.h"
+
+
+SidePanel::SidePanel(const QString &title, QWidget *parent, Qt::WindowFlags flags)
+ : QDockWidget(title, parent, flags)
+ , m_panelHistory(new PanelHistory(this))
+{
+ setObjectName("sidePanel");
+ setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+
+ setShown(ReKonfig::showSideBar());
+
+ connect(m_panelHistory, SIGNAL(openUrl(const KUrl&)), this, SIGNAL(openUrl(const KUrl&)));
+
+ setWidget(m_panelHistory);
+}
+
+
+SidePanel::~SidePanel()
+{
+ // Save side panel's state
+ ReKonfig::setShowSideBar(!isHidden());
+
+ delete m_panelHistory;
+}
+
+
+
diff --git a/src/sidepanel.h b/src/sidepanel.h
new file mode 100644
index 00000000..636eb363
--- /dev/null
+++ b/src/sidepanel.h
@@ -0,0 +1,52 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot 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, 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.
+*
+* ============================================================ */
+
+
+#ifndef SIDEPANEL_H
+#define SIDEPANEL_H
+
+
+// Qt Includes
+#include <QDockWidget>
+
+// Local Includes
+#include "application.h"
+
+class KUrl;
+class PanelHistory;
+
+
+class SidePanel : public QDockWidget
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(SidePanel)
+
+public:
+ explicit SidePanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~SidePanel();
+
+signals:
+ void openUrl(const KUrl&);
+
+private:
+ PanelHistory *m_panelHistory;
+
+};
+
+#endif // SIDEPANEL_H