summaryrefslogtreecommitdiff
path: root/src/webwindow/webwindow.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-08-10 17:34:04 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:05 +0100
commit08ca2545eede86a0f6de42be596b063de1321ddb (patch)
tree9f1d9986b04d7db3ace13f9304eae704d9c189eb /src/webwindow/webwindow.cpp
parentFindBar. Rewamped and restored (diff)
downloadrekonq-08ca2545eede86a0f6de42be596b063de1321ddb.tar.xz
Manage Bookmarks Toolbar show/hide (&& create/delete)
Diffstat (limited to 'src/webwindow/webwindow.cpp')
-rw-r--r--src/webwindow/webwindow.cpp66
1 files changed, 58 insertions, 8 deletions
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);
+}