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.cpp69
1 files changed, 66 insertions, 3 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 5c3cba28..0d130b94 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();
}
}
@@ -185,9 +193,23 @@ void UrlBar::paintEvent(QPaintEvent *event)
}
else
{
- QColor loadingColor = Application::palette().color(QPalette::ToolTipBase);
+ QColor highlight = Application::palette().color(QPalette::Highlight);
+
+ int r = (highlight.red()+2*backgroundColor.red())/3;
+ int g = (highlight.green()+2*backgroundColor.green())/3;
+ int b = (highlight.blue()+2*backgroundColor.blue())/3;
+
+ QColor loadingColor(r, g, b);
- QLinearGradient gradient( QPoint(0, 0), QPoint(width(), height()) );
+ if (abs(loadingColor.lightness() - backgroundColor.lightness()) < 20) //eg. Gaia color scheme
+ {
+ r = (2*highlight.red()+backgroundColor.red())/3;
+ g = (2*highlight.green()+backgroundColor.green())/3;
+ b = (2*highlight.blue()+backgroundColor.blue())/3;
+ loadingColor = QColor(r, g, b);
+ }
+
+ QLinearGradient gradient( QPoint(0, 0), QPoint(width(), 0) );
gradient.setColorAt(0, loadingColor);
gradient.setColorAt(((double)progr) / 100 - .000001, loadingColor);
gradient.setColorAt(((double)progr) / 100, backgroundColor);
@@ -286,6 +308,18 @@ void UrlBar::loadFinished()
return;
}
+ // setting bookmark icon
+ if (Application::bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull())
+ {
+ _icon->setIcon(KIcon("bookmarks").pixmap(32,32, QIcon::Disabled));
+ _icon->setToolTip(i18n("Bookmark this page"));
+ }
+ else
+ {
+ _icon->setIcon(KIcon("bookmarks"));
+ _icon->setToolTip(i18n("Edit this bookmark"));
+ }
+
// show KGet downloads??
if (ReKonfig::kgetList())
{
@@ -316,6 +350,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) );