summaryrefslogtreecommitdiff
path: root/src/urlbar/urlbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar/urlbar.cpp')
-rw-r--r--src/urlbar/urlbar.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index d924a30d..e2033120 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,11 @@ UrlBar::UrlBar(QWidget *parent)
connect(_tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
connect(_tab->view(), SIGNAL(loadStarted()), this, SLOT(clearRightIcons()));
+ // bookmark icon
+ _icon->setIcon(KIcon("bookmarks").pixmap(32,32, QIcon::Disabled));
+ connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(const QString &, const QString &)), this, SLOT(onBookmarksChanged()));
+ connect(_icon, SIGNAL(clicked(const QPoint &)), this, SLOT(showBookmarkInfo(const QPoint &)));
+
// load typed urls
connect(this, SIGNAL(returnPressed(const QString &)), this, SLOT(loadTyped(const QString &)));
@@ -138,7 +145,8 @@ void UrlBar::setQUrl(const QUrl& url)
clearFocus();
KLineEdit::setUrl(url);
setCursorPosition(0);
- _icon->setIcon(Application::icon(url));
+// _icon->setIcon(Application::icon(url));
+// updateIcon();
}
}
@@ -300,6 +308,16 @@ void UrlBar::loadFinished()
return;
}
+ // setting bookmark icon
+ if (Application::bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull())
+ {
+ _icon->setIcon(KIcon("bookmarks").pixmap(32,32, QIcon::Disabled));
+ }
+ else
+ {
+ _icon->setIcon(KIcon("bookmarks"));
+ }
+
// show KGet downloads??
if (ReKonfig::kgetList())
{
@@ -330,6 +348,35 @@ void UrlBar::loadFinished()
}
+void UrlBar::showBookmarkInfo(const QPoint &pos)
+{
+ if( _tab->url().scheme() == QL1S("about") )
+ return;
+
+ KBookmark bookmark = Application::bookmarkProvider()->bookmarkForUrl(_tab->url());
+
+ IconButton *bt = qobject_cast<IconButton *>(this->sender());
+ if (!bt)
+ return;
+
+ if (bookmark.isNull())
+ {
+ bookmark = Application::bookmarkProvider()->rootGroup().addBookmark(_tab->view()->title(), _tab->url());
+ Application::bookmarkProvider()->bookmarkManager()->emitChanged();
+ }
+
+ BookmarkWidget *widget = new BookmarkWidget(bookmark, window());
+ widget->showAt(pos);
+}
+
+
+void UrlBar::onBookmarksChanged()
+{
+ clearRightIcons();
+ loadFinished();
+}
+
+
void UrlBar::loadTyped(const QString &text)
{
activated( KUrl(text) );