diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-07-28 00:16:59 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-08-14 19:39:47 +0200 |
commit | 1ed00f9949c9507768db0973c61b9648a8a58575 (patch) | |
tree | d34878e8368219ff90e97a8a72b1c62a4789fab8 /src/urlbar/urlbar.cpp | |
parent | Fixed focus regression. (diff) | |
download | rekonq-1ed00f9949c9507768db0973c61b9648a8a58575.tar.xz |
Manually importing Yoann merge 2260
PLease, check if I did something wrong..
Diffstat (limited to 'src/urlbar/urlbar.cpp')
-rw-r--r-- | src/urlbar/urlbar.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index d924a30d..4936d18f 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -41,6 +41,8 @@ #include "webpage.h" #include "webview.h" #include "completionwidget.h" +#include "bookmarksmanager.h" +#include "bookmarkwidget.h" // KDE Includes #include <KCompletionBox> @@ -107,6 +109,8 @@ UrlBar::UrlBar(QWidget *parent) connect(_tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished())); connect(_tab->view(), SIGNAL(loadStarted()), this, SLOT(clearRightIcons())); + connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(const QString &, const QString &)), this, SLOT(onBookmarksChanged())); + // load typed urls connect(this, SIGNAL(returnPressed(const QString &)), this, SLOT(loadTyped(const QString &))); @@ -321,6 +325,10 @@ void UrlBar::loadFinished() connect(bt, SIGNAL(clicked(QPoint)), _tab->page(), SLOT(showSSLInfo(QPoint))); } + // show bookmark info + IconButton *bt = addRightIcon(UrlBar::BK); + connect(bt, SIGNAL(clicked(const QPoint &)), this, SLOT(showBookmarkInfo(const QPoint &))); + // we need to update urlbar after the right icon settings // removing this code (where setStyleSheet automatically calls update) needs adding again // an update call @@ -330,6 +338,34 @@ void UrlBar::loadFinished() } +void UrlBar::showBookmarkInfo(const QPoint &pos) +{ + KBookmark bookmark = Application::bookmarkProvider()->bookmarkForUrl(_tab->url()); + + IconButton *bt = qobject_cast<IconButton *>(this->sender()); + if (!bt) + return; + + if (bookmark.isNull()) + { + Application::bookmarkProvider()->rootGroup().addBookmark(_tab->view()->title(), _tab->url()); + Application::bookmarkProvider()->bookmarkManager()->emitChanged(); + } + else + { + BookmarkWidget *widget = new BookmarkWidget(bookmark, window()); + widget->showAt(pos); + } +} + + +void UrlBar::onBookmarksChanged() +{ + clearRightIcons(); + loadFinished(); +} + + void UrlBar::loadTyped(const QString &text) { activated( KUrl(text) ); @@ -383,6 +419,16 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic) rightIcon->setIcon(KIcon("object-locked")); rightIcon->setToolTip(i18n("Show SSL Info")); break; + case UrlBar::BK: + if (Application::bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull()) + { + rightIcon->setIcon(KIcon("bookmarks").pixmap(32,32, QIcon::Disabled)); + } + else + { + rightIcon->setIcon(KIcon("bookmarks")); + } + break; default: kDebug() << "ERROR.. default non extant case!!"; break; |