1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

[popupwindow] Show locationbar's icons also in popup windows.

This commit is contained in:
nowrep 2013-02-10 14:09:28 +01:00
parent 23690d4154
commit 06b582a37e
4 changed files with 63 additions and 14 deletions

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* QupZilla - WebKit based browser * QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,6 +20,10 @@
#include "toolbutton.h" #include "toolbutton.h"
#include "qztools.h" #include "qztools.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "bookmarkicon.h"
#include "autofillicon.h"
#include "rssicon.h"
#include "webpage.h"
#include <QMovie> #include <QMovie>
#include <QLabel> #include <QLabel>
@ -50,22 +54,43 @@ PopupLocationBar::PopupLocationBar(QWidget* parent)
m_siteIcon->setIcon(qIconProvider->emptyWebIcon()); m_siteIcon->setIcon(qIconProvider->emptyWebIcon());
m_siteIcon->setFixedSize(26, 26); m_siteIcon->setFixedSize(26, 26);
m_bookmarkIcon = new BookmarkIcon(this);
m_rssIcon = new RssIcon(this);
m_autofillIcon = new AutoFillIcon(this);
m_loadingAnimation = new QLabel(this); m_loadingAnimation = new QLabel(this);
QMovie* movie = new QMovie(":icons/other/progress.gif", QByteArray(), m_loadingAnimation); QMovie* movie = new QMovie(":icons/other/progress.gif", QByteArray(), m_loadingAnimation);
m_loadingAnimation->setMovie(movie); m_loadingAnimation->setMovie(movie);
m_loadingAnimation->setFixedSize(20, 26); m_loadingAnimation->setFixedSize(16, 26);
QWidget* rightSpacer = new QWidget(this);
rightSpacer->setFixedWidth(3);
addWidget(m_siteIcon, LineEdit::LeftSide); addWidget(m_siteIcon, LineEdit::LeftSide);
addWidget(m_autofillIcon, LineEdit::RightSide);
addWidget(m_bookmarkIcon, LineEdit::RightSide);
addWidget(m_rssIcon, LineEdit::RightSide);
addWidget(m_loadingAnimation, LineEdit::RightSide); addWidget(m_loadingAnimation, LineEdit::RightSide);
addWidget(rightSpacer, LineEdit::RightSide);
setLeftMargin(20); setLeftMargin(20);
setFixedHeight(26); setFixedHeight(26);
setReadOnly(true); setReadOnly(true);
// Hide icons by default
m_rssIcon->hide();
m_autofillIcon->hide();
} }
void PopupLocationBar::setView(PopupWebView* view) void PopupLocationBar::setView(PopupWebView* view)
{ {
m_view = view; m_view = view;
m_bookmarkIcon->setWebView(m_view);
m_rssIcon->setWebView(m_view);
m_autofillIcon->setWebView(m_view);
connect(m_view, SIGNAL(rssChanged(bool)), this, SLOT(showRSSIcon(bool)));
} }
void PopupLocationBar::startLoading() void PopupLocationBar::startLoading()
@ -73,6 +98,8 @@ void PopupLocationBar::startLoading()
m_loadingAnimation->show(); m_loadingAnimation->show();
m_loadingAnimation->movie()->start(); m_loadingAnimation->movie()->start();
m_autofillIcon->hide();
updateTextMargins(); updateTextMargins();
} }
@ -81,6 +108,15 @@ void PopupLocationBar::stopLoading()
m_loadingAnimation->hide(); m_loadingAnimation->hide();
m_loadingAnimation->movie()->stop(); m_loadingAnimation->movie()->stop();
m_bookmarkIcon->checkBookmark(m_view->url());
WebPage* page = qobject_cast<WebPage*>(m_view->page());
if (page && page->hasMultipleUsernames()) {
m_autofillIcon->setFormData(page->autoFillData());
m_autofillIcon->show();
}
updateTextMargins(); updateTextMargins();
} }
@ -90,7 +126,14 @@ void PopupLocationBar::showUrl(const QUrl &url)
setCursorPosition(0); setCursorPosition(0);
} }
void PopupLocationBar::showIcon() void PopupLocationBar::showSiteIcon()
{ {
m_siteIcon->setIcon(m_view->icon()); m_siteIcon->setIcon(m_view->icon());
} }
void PopupLocationBar::showRSSIcon(bool state)
{
m_rssIcon->setVisible(state);
updateTextMargins();
}

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* QupZilla - WebKit based browser * QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,6 +26,9 @@ class QLabel;
class PopupSiteIcon; class PopupSiteIcon;
class PopupWebView; class PopupWebView;
class AutoFillIcon;
class BookmarkIcon;
class RssIcon;
class QT_QUPZILLA_EXPORT PopupLocationBar : public LineEdit class QT_QUPZILLA_EXPORT PopupLocationBar : public LineEdit
{ {
@ -42,16 +45,19 @@ public:
void startLoading(); void startLoading();
void stopLoading(); void stopLoading();
signals:
public slots: public slots:
void showUrl(const QUrl &url); void showUrl(const QUrl &url);
void showIcon(); void showSiteIcon();
void showRSSIcon(bool state);
private: private:
PopupWebView* m_view; PopupWebView* m_view;
PopupSiteIcon* m_siteIcon;
QLabel* m_loadingAnimation; QLabel* m_loadingAnimation;
PopupSiteIcon* m_siteIcon;
AutoFillIcon* m_autofillIcon;
BookmarkIcon* m_bookmarkIcon;
RssIcon* m_rssIcon;
}; };
#endif // POPUPLOCATIONBAR_H #endif // POPUPLOCATIONBAR_H

View File

@ -114,7 +114,7 @@ PopupWindow::PopupWindow(PopupWebView* view)
connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*))); connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
connect(m_view, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged())); connect(m_view, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged()));
connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar, SLOT(showUrl(QUrl))); connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar, SLOT(showUrl(QUrl)));
connect(m_view, SIGNAL(iconChanged()), m_locationBar, SLOT(showIcon())); connect(m_view, SIGNAL(iconChanged()), m_locationBar, SLOT(showSiteIcon()));
connect(m_view, SIGNAL(statusBarMessage(QString)), this, SLOT(showStatusBarMessage(QString))); connect(m_view, SIGNAL(statusBarMessage(QString)), this, SLOT(showStatusBarMessage(QString)));
connect(m_view, SIGNAL(loadStarted()), this, SLOT(loadStarted())); connect(m_view, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int))); connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
@ -154,11 +154,11 @@ PopupWebView* PopupWindow::webView()
void PopupWindow::showNotification(QWidget* notif) void PopupWindow::showNotification(QWidget* notif)
{ {
if (m_layout->count() > 3) { if (m_layout->count() > 4) {
delete m_layout->itemAt(1)->widget(); delete m_layout->itemAt(2)->widget();
} }
m_layout->insertWidget(1, notif); m_layout->insertWidget(2, notif);
notif->show(); notif->show();
} }

View File

@ -36,8 +36,8 @@
- with menubar - with menubar
</p> </p>
<p> <p>
<a href="javascript:window.open('popup.html', '_blank', 'status=yes')">Popup 7</a> <a href="javascript:window.open('http://blog.qupzilla.com', '_blank', 'status=yes')">Popup 7</a>
- with statusbar - with statusbar (blog.qupzilla.com)
</p> </p>
<p> <p>
<p> <p>