summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/application.cpp6
-rw-r--r--src/application.h5
-rw-r--r--src/bookmarks/bookmarkmanager.cpp4
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp6
-rw-r--r--src/bookmarks/bookmarkstoolbar.h1
-rw-r--r--src/history/historymanager.cpp1
-rw-r--r--src/rekonq.kcfg5
-rw-r--r--src/tabwindow/tabwindow.cpp7
-rw-r--r--src/webwindow/rekonqfactory.cpp36
-rw-r--r--src/webwindow/webwindow.cpp66
-rw-r--r--src/webwindow/webwindow.h5
11 files changed, 115 insertions, 27 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 7004a901..efad91c3 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -713,3 +713,9 @@ void Application::createWebAppShortcut()
dialog->deleteLater();
}
+
+
+void Application::bookmarksToolbarToggled(bool b)
+{
+ emit toggleBookmarksToolbar(b);
+}
diff --git a/src/application.h b/src/application.h
index c9ad7376..66780c5b 100644
--- a/src/application.h
+++ b/src/application.h
@@ -68,6 +68,8 @@ public:
TabWindow *tabWindow();
TabWindowList tabWindowList();
+ void bookmarksToolbarToggled(bool);
+
public Q_SLOTS:
/**
* Save application's configuration
@@ -92,6 +94,9 @@ protected:
// This is used to track which window was activated most recently
bool eventFilter(QObject *watched, QEvent *event);
+Q_SIGNALS:
+ void toggleBookmarksToolbar(bool);
+
private Q_SLOTS:
void updateConfiguration();
diff --git a/src/bookmarks/bookmarkmanager.cpp b/src/bookmarks/bookmarkmanager.cpp
index 7e1b5d90..57464846 100644
--- a/src/bookmarks/bookmarkmanager.cpp
+++ b/src/bookmarks/bookmarkmanager.cpp
@@ -181,7 +181,7 @@ void BookmarkManager::fillBookmarkBar(BookmarkToolBar *toolBar)
{
if (bookmark.isGroup())
{
- KBookmarkActionMenu *menuAction = new KBookmarkActionMenu(bookmark.toGroup(), this);
+ KBookmarkActionMenu *menuAction = new KBookmarkActionMenu(bookmark.toGroup(), toolBar);
menuAction->setDelayed(false);
BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menuAction->menu(), bookmark.address());
bMenu->setParent(menuAction->menu());
@@ -198,7 +198,7 @@ void BookmarkManager::fillBookmarkBar(BookmarkToolBar *toolBar)
}
else
{
- KBookmarkAction *action = new KBookmarkAction(bookmark, m_owner, this);
+ KBookmarkAction *action = new KBookmarkAction(bookmark, m_owner, toolBar);
action->setIcon(IconManager::self()->iconForUrl(KUrl(bookmark.url())));
toolBar->addAction(action);
toolBar->widgetForAction(action)->installEventFilter(toolBar);
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp
index 2ecb0e35..7a904ef5 100644
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ b/src/bookmarks/bookmarkstoolbar.cpp
@@ -170,6 +170,12 @@ BookmarkToolBar::BookmarkToolBar(QWidget *parent)
}
+BookmarkToolBar::~BookmarkToolBar()
+{
+ clear();
+}
+
+
void BookmarkToolBar::contextMenu(const QPoint &point)
{
KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface*>(actionAt(point));
diff --git a/src/bookmarks/bookmarkstoolbar.h b/src/bookmarks/bookmarkstoolbar.h
index 97fd7a8f..4098f2a3 100644
--- a/src/bookmarks/bookmarkstoolbar.h
+++ b/src/bookmarks/bookmarkstoolbar.h
@@ -83,6 +83,7 @@ class BookmarkToolBar : public KToolBar
public:
BookmarkToolBar(QWidget *parent);
+ ~BookmarkToolBar();
protected:
bool eventFilter(QObject *watched, QEvent *event);
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index 6fe13b73..30184cef 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -85,7 +85,6 @@ HistoryManager::HistoryManager(QObject *parent)
, m_historyLimit(0)
, m_historyTreeModel(0)
{
- kDebug() << "loading history";
connect(this, SIGNAL(entryAdded(HistoryItem)), m_saveTimer, SLOT(changeOccurred()));
connect(this, SIGNAL(entryRemoved(HistoryItem)), m_saveTimer, SLOT(changeOccurred()));
connect(m_saveTimer, SIGNAL(saveNeeded()), this, SLOT(save()));
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index 29bef9f1..908df083 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -18,10 +18,7 @@
<entry name="FirstExecution" type="Bool">
<default>true</default>
</entry>
- <entry name="showHistoryPanel" type="Bool">
- <default>false</default>
- </entry>
- <entry name="showBookmarksPanel" type="Bool">
+ <entry name="showBookmarksToolbar" type="Bool">
<default>false</default>
</entry>
<entry name="walletBlackList" type="StringList">
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index 765d0774..89ee76b9 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -94,7 +94,8 @@ TabWindow::TabWindow(bool withTab, QWidget *parent)
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
- // NOTE: NEVER create a tabwindow without AT LEAST one tab...
+ // NOTE: we usually create TabWindow with AT LEAST one tab, but
+ // in one important case...
if (withTab)
{
WebWindow *tab = prepareNewTab();
@@ -465,8 +466,6 @@ void TabWindow::detachTab(int index, TabWindow *toWindow)
w->addTab(tab, tab->title());
w->setCurrentWidget(tab);
- w->show();
-
// disconnect signals from old tabwindow
// WARNING: Code copied from prepareNewTab method.
// Any new changes there should be applied here...
@@ -482,6 +481,8 @@ void TabWindow::detachTab(int index, TabWindow *toWindow)
connect(tab, SIGNAL(loadStarted()), w, SLOT(tabLoadStarted()));
connect(tab, SIGNAL(loadFinished(bool)), w, SLOT(tabLoadFinished(bool)));
connect(tab, SIGNAL(pageCreated(WebPage *)), w, SLOT(pageCreated(WebPage *)));
+
+ w->show();
}
diff --git a/src/webwindow/rekonqfactory.cpp b/src/webwindow/rekonqfactory.cpp
index 78cd0367..8b09c0bd 100644
--- a/src/webwindow/rekonqfactory.cpp
+++ b/src/webwindow/rekonqfactory.cpp
@@ -44,20 +44,40 @@
#include <QDomElement>
-QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent, KActionCollection *ac)
+// Only used internally
+bool readDocument(QDomDocument & document, const QString & filePath)
{
- QString xmlFilePath;
- xmlFilePath = KStandardDirs::locateLocal( "data", "rekonq/rekonqui.rc");
- if (!QFile::exists(xmlFilePath))
+ QFile sessionFile(filePath);
+
+ if (!sessionFile.exists())
+ return false;
+
+ if (!sessionFile.open(QFile::ReadOnly))
{
- xmlFilePath = KStandardDirs::locate( "data", "rekonq/rekonqui.rc");
- kDebug() << "general xmlfile: " << xmlFilePath;
+ kDebug() << "Unable to open xml file" << sessionFile.fileName();
+ return false;
}
- QFile xmlFile(xmlFilePath);
+ if (!document.setContent(&sessionFile, false))
+ {
+ kDebug() << "Unable to parse xml file" << sessionFile.fileName();
+ return false;
+ }
+
+ return true;
+}
+
+
+// ---------------------------------------------------------------------------------------------------------
+
+QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent, KActionCollection *ac)
+{
QDomDocument document("rekonqui.rc");
- document.setContent(&xmlFile, false);
+ QString xmlFilePath = KStandardDirs::locate( "data", "rekonq/rekonqui.rc");
+
+ if (!readDocument(document, xmlFilePath))
+ return 0;
// Toolbars ----------------------------------------------------------------------
QDomNodeList elementToolbarList = document.elementsByTagName(QL1S("ToolBar"));
diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp
index 0af79cb6..83c49859 100644
--- a/src/webwindow/webwindow.cpp
+++ b/src/webwindow/webwindow.cpp
@@ -27,6 +27,9 @@
#include "webwindow.h"
#include "webwindow.moc"
+// Auto Includes
+#include "rekonq.h"
+
#include "application.h"
#include "adblockmanager.h"
@@ -72,7 +75,6 @@ WebWindow::WebWindow(QWidget *parent, WebPage *pg)
, _tab(new WebTab(this))
, _bar(new UrlBar(_tab))
, _mainToolBar(0)
- , _bookmarksBar(0)
, m_findBar(new FindBar(this))
, m_loadStopReloadAction(0)
, m_rekonqMenu(0)
@@ -92,22 +94,30 @@ WebWindow::WebWindow(QWidget *parent, WebPage *pg)
// setting up rekonq tools
setupTools();
+ // layout
+ QVBoxLayout *l = new QVBoxLayout(this);
+
// main toolbar
_mainToolBar = qobject_cast<KToolBar *>(RekonqFactory::createWidget(QL1S("mainToolBar"), this, actionCollection()));
+ l->addWidget(_mainToolBar);
- _bookmarksBar = qobject_cast<BookmarkToolBar *>(RekonqFactory::createWidget(QL1S("bookmarkToolBar"), this, actionCollection()));
- BookmarkManager::self()->registerBookmarkBar(_bookmarksBar);
+ if (ReKonfig::showBookmarksToolbar())
+ {
+ _bookmarksBar = qobject_cast<BookmarkToolBar *>(RekonqFactory::createWidget(QL1S("bookmarkToolBar"), this, actionCollection()));
+ BookmarkManager::self()->registerBookmarkBar(_bookmarksBar.data());
- // layout
- QVBoxLayout *l = new QVBoxLayout(this);
- l->addWidget(_mainToolBar);
- l->addWidget(_bookmarksBar);
+ l->addWidget(_bookmarksBar.data());
+ }
+
l->addWidget(_tab);
l->addWidget(m_findBar);
l->setContentsMargins(0, 0, 0, 0);
setContentsMargins(0, 0, 0, 0);
+ // bookmarks toolbar
+ connect(rApp, SIGNAL(toggleBookmarksToolbar(bool)), this, SLOT(toggleBookmarksToolbar(bool)));
+
// things changed signals
connect(_tab->view(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
@@ -135,7 +145,11 @@ WebWindow::~WebWindow()
{
m_hidePopupTimer->stop();
- BookmarkManager::self()->removeBookmarkBar(_bookmarksBar);
+ if (!_bookmarksBar.isNull())
+ {
+ BookmarkManager::self()->removeBookmarkBar(_bookmarksBar.data());
+ _bookmarksBar.clear();
+ }
}
@@ -189,6 +203,13 @@ void WebWindow::setupActions()
KStandardAction::preferences(this, SLOT(preferences()), actionCollection());
KStandardAction::quit(rApp, SLOT(queryQuit()), actionCollection());
+ // Bookmark Toolbar
+ a = new KAction(KIcon("bookmarks-bar"), i18n("Bookmarks Toolbar"), this);
+ a->setCheckable(true);
+ a->setChecked(ReKonfig::showBookmarksToolbar());
+ actionCollection()->addAction(QL1S("show_bookmarks_toolbar"), a);
+ connect(a, SIGNAL(toggled(bool)), this, SLOT(toggleBookmarksToolbar(bool)));
+
// find action
a = KStandardAction::find(m_findBar, SLOT(show()), actionCollection());
KShortcut findShortcut = KStandardShortcut::find();
@@ -816,3 +837,32 @@ void WebWindow::preferences()
s->show();
}
+
+
+void WebWindow::toggleBookmarksToolbar(bool b)
+{
+ bool actual = !_bookmarksBar.isNull();
+ if (actual == b)
+ return;
+
+ if (b)
+ {
+ _bookmarksBar = qobject_cast<BookmarkToolBar *>(RekonqFactory::createWidget(QL1S("bookmarkToolBar"), this, actionCollection()));
+ BookmarkManager::self()->registerBookmarkBar(_bookmarksBar.data());
+
+ qobject_cast<QVBoxLayout *>(layout())->insertWidget(1, _bookmarksBar.data());
+ }
+ else
+ {
+ qobject_cast<QVBoxLayout *>(layout())->removeWidget(_bookmarksBar.data());
+
+ BookmarkManager::self()->removeBookmarkBar(_bookmarksBar.data());
+ delete _bookmarksBar.data();
+ _bookmarksBar.clear();
+ }
+
+ ReKonfig::setShowBookmarksToolbar(b);
+ QAction *a = actionByName(QL1S("show_bookmarks_toolbar"));
+ a->setChecked(b);
+ rApp->bookmarksToolbarToggled(b);
+}
diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h
index 697d74e3..37f9c3c0 100644
--- a/src/webwindow/webwindow.h
+++ b/src/webwindow/webwindow.h
@@ -110,6 +110,9 @@ private Q_SLOTS:
void fileOpen();
void fileSaveAs();
+ // bookmarks bar
+ void toggleBookmarksToolbar(bool);
+
// Tools Menu slots
void viewPageSource();
void viewFullScreen(bool enable);
@@ -136,7 +139,7 @@ private:
UrlBar *_bar;
KToolBar *_mainToolBar;
- BookmarkToolBar *_bookmarksBar;
+ QWeakPointer<BookmarkToolBar> _bookmarksBar;
FindBar *m_findBar;