1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Added StatusBarMessage class which handles and shows those messages on a

tooltip in left bottom corner of webview if statusbar is hidden
This commit is contained in:
nowrep 2011-05-09 17:58:19 +02:00
parent 8b9bfd7c0d
commit 85daf062d4
8 changed files with 119 additions and 14 deletions

View File

@ -117,7 +117,8 @@ SOURCES += main.cpp\
tools/progressbar.cpp \ tools/progressbar.cpp \
tools/iconprovider.cpp \ tools/iconprovider.cpp \
network/networkproxyfactory.cpp \ network/networkproxyfactory.cpp \
tools/closedtabsmanager.cpp tools/closedtabsmanager.cpp \
other/statusbarmessage.cpp
HEADERS += 3rdparty/squeezelabel.h \ HEADERS += 3rdparty/squeezelabel.h \
3rdparty/qtwin.h \ 3rdparty/qtwin.h \
@ -194,7 +195,8 @@ HEADERS += 3rdparty/squeezelabel.h \
tools/progressbar.h \ tools/progressbar.h \
tools/iconprovider.h \ tools/iconprovider.h \
network/networkproxyfactory.h \ network/networkproxyfactory.h \
tools/closedtabsmanager.h tools/closedtabsmanager.h \
other/statusbarmessage.h
FORMS += \ FORMS += \
preferences/autofillmanager.ui \ preferences/autofillmanager.ui \

View File

@ -52,6 +52,7 @@
#include "progressbar.h" #include "progressbar.h"
#include "adblockicon.h" #include "adblockicon.h"
#include "closedtabsmanager.h" #include "closedtabsmanager.h"
#include "statusbarmessage.h"
const QString QupZilla::VERSION = "1.0.0-b2"; const QString QupZilla::VERSION = "1.0.0-b2";
//const QString QupZilla::BUILDTIME = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM d yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss"); //const QString QupZilla::BUILDTIME = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM d yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss");
@ -69,6 +70,7 @@ QupZilla::QupZilla(bool tryRestore, QUrl startUrl) :
,m_webInspectorDock(0) ,m_webInspectorDock(0)
,m_webSearchToolbar(0) ,m_webSearchToolbar(0)
,m_sideBar(0) ,m_sideBar(0)
,m_statusBarMessage(new StatusBarMessage(this))
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
this->resize(640,480); this->resize(640,480);

View File

@ -72,6 +72,7 @@ class WebTab;
class AdBlockIcon; class AdBlockIcon;
class SideBar; class SideBar;
class ProgressBar; class ProgressBar;
class StatusBarMessage;
class QupZilla : public QMainWindow class QupZilla : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -97,9 +98,10 @@ public:
inline WebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); } inline WebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); }
inline WebView* weView(int index) const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); if (!webTab) return 0; return webTab->view(); } inline WebView* weView(int index) const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); if (!webTab) return 0; return webTab->view(); }
inline LocationBar* locationBar(){ return m_locationBar; } inline LocationBar* locationBar() { return m_locationBar; }
inline TabWidget* tabWidget(){ return m_tabWidget; } inline TabWidget* tabWidget() { return m_tabWidget; }
inline BookmarksToolbar* bookmarksToolbar(){ return m_bookmarksToolbar; } inline BookmarksToolbar* bookmarksToolbar() { return m_bookmarksToolbar; }
inline StatusBarMessage* statusBarMessage() { return m_statusBarMessage; }
inline QAction* buttonStop(){ return m_buttonStop; } inline QAction* buttonStop(){ return m_buttonStop; }
inline QAction* buttonReload(){ return m_buttonReload; } inline QAction* buttonReload(){ return m_buttonReload; }
@ -237,6 +239,7 @@ private:
LocationBar* m_locationBar; LocationBar* m_locationBar;
TabWidget* m_tabWidget; TabWidget* m_tabWidget;
QPointer<SideBar> m_sideBar; QPointer<SideBar> m_sideBar;
StatusBarMessage* m_statusBarMessage;
QSplitter* m_navigationSplitter; QSplitter* m_navigationSplitter;
QAction* m_buttonBack; QAction* m_buttonBack;

View File

@ -27,6 +27,7 @@
#include "webpage.h" #include "webpage.h"
#include "bookmarkicon.h" #include "bookmarkicon.h"
#include "progressbar.h" #include "progressbar.h"
#include "statusbarmessage.h"
LocationBar::LocationBar(QupZilla* mainClass, QWidget* parent) LocationBar::LocationBar(QupZilla* mainClass, QWidget* parent)
: LineEdit(parent) : LineEdit(parent)
@ -154,7 +155,7 @@ void LocationBar::rssIconClicked()
void LocationBar::showUrl(const QUrl &url, bool empty) void LocationBar::showUrl(const QUrl &url, bool empty)
{ {
if (hasFocus() || (url.isEmpty() && empty)) if (/*hasFocus() || (*/url.isEmpty() && empty/*)*/)
return; return;
if (url.toEncoded()!=text()) { if (url.toEncoded()!=text()) {
@ -171,15 +172,15 @@ void LocationBar::showUrl(const QUrl &url, bool empty)
p_QupZilla->progressBar()->setValue(view->getLoading()); p_QupZilla->progressBar()->setValue(view->getLoading());
p_QupZilla->buttonStop()->setVisible(true); p_QupZilla->buttonStop()->setVisible(true);
p_QupZilla->buttonReload()->setVisible(false); p_QupZilla->buttonReload()->setVisible(false);
p_QupZilla->statusBar()->showMessage(tr("Loading...")); } else {
}else{
p_QupZilla->progressBar()->setVisible(false); p_QupZilla->progressBar()->setVisible(false);
p_QupZilla->buttonStop()->setVisible(false); p_QupZilla->buttonStop()->setVisible(false);
p_QupZilla->buttonReload()->setVisible(true); p_QupZilla->buttonReload()->setVisible(true);
p_QupZilla->statusBar()->showMessage(tr("Done"));
p_QupZilla->ipLabel()->show(); p_QupZilla->ipLabel()->show();
} }
p_QupZilla->statusBarMessage()->clearMessage();
hideGoButton(); hideGoButton();
m_bookmarkIcon->checkBookmark(url); m_bookmarkIcon->checkBookmark(url);

View File

@ -0,0 +1,65 @@
#include "statusbarmessage.h"
#include "qupzilla.h"
#include "squeezelabel.h"
class TipLabel : public SqueezeLabel {
public:
TipLabel()
{
setWindowFlags(Qt::ToolTip);
setForegroundRole(QPalette::ToolTipText);
setBackgroundRole(QPalette::ToolTipBase);
setPalette(QToolTip::palette());
ensurePolished();
setFrameStyle(QFrame::NoFrame);
setMargin(2);
}
void paintEvent(QPaintEvent *ev)
{
QStylePainter p(this);
QStyleOptionFrame opt;
opt.init(this);
p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
p.end();
SqueezeLabel::paintEvent(ev);
}
};
StatusBarMessage::StatusBarMessage(QupZilla* mainClass)
: QObject()
, p_QupZilla(mainClass)
{
m_statusBarText = new TipLabel();
}
#define STATUS_Y_OFFSET -35
#define STATUS_X_OFFSET +3
#define STATUS_TOOLTIP_WIDTH_OFFSET -20
void StatusBarMessage::showMessage(const QString &message)
{
if (p_QupZilla->statusBar()->isVisible()) {
p_QupZilla->statusBar()->showMessage(message);
} else {
QPoint position = p_QupZilla->weView()->mapToGlobal(p_QupZilla->weView()->pos());
position.setY( p_QupZilla->weView()->size().height() + position.y() STATUS_Y_OFFSET);
position.setX(position.x() STATUS_X_OFFSET);
m_statusBarText->move(position);
m_statusBarText->setMaximumWidth(p_QupZilla->size().width() STATUS_TOOLTIP_WIDTH_OFFSET);
m_statusBarText->setText(message);
m_statusBarText->resize(m_statusBarText->sizeHint());
m_statusBarText->show();
}
}
void StatusBarMessage::clearMessage()
{
if (p_QupZilla->statusBar()->isVisible())
p_QupZilla->statusBar()->showMessage("");
else
m_statusBarText->hide();
}

View File

@ -0,0 +1,27 @@
#ifndef STATUSBARMESSAGE_H
#define STATUSBARMESSAGE_H
#include <QObject>
#include <QToolTip>
class QupZilla;
class TipLabel;
class StatusBarMessage : public QObject
{
Q_OBJECT
public:
explicit StatusBarMessage(QupZilla* mainClass);
void showMessage(const QString &message);
void clearMessage();
signals:
public slots:
private:
QupZilla* p_QupZilla;
TipLabel* m_statusBarText;
};
#endif // STATUSBARMESSAGE_H

View File

@ -593,8 +593,13 @@ void Preferences::saveSettings()
settings.setValue("defaultDownloadPath",""); settings.setValue("defaultDownloadPath","");
else{ else{
QString text = ui->downLoc->text(); QString text = ui->downLoc->text();
#ifdef Q_WS_WIN
if (!text.endsWith("\\"))
text+="\\";
#else
if (!text.endsWith("/")) if (!text.endsWith("/"))
text+="/"; text+="/";
#endif
settings.setValue("defaultDownloadPath",text); settings.setValue("defaultDownloadPath",text);
} }
settings.endGroup(); settings.endGroup();

View File

@ -31,6 +31,7 @@
#include "pluginproxy.h" #include "pluginproxy.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "webtab.h" #include "webtab.h"
#include "statusbarmessage.h"
WebView::WebView(QupZilla* mainClass, QWidget* parent) WebView::WebView(QupZilla* mainClass, QWidget* parent)
: QWebView(parent) : QWebView(parent)
@ -266,11 +267,10 @@ void WebView::linkHovered(const QString &link, const QString &title, const QStri
Q_UNUSED(title); Q_UNUSED(title);
Q_UNUSED(content); Q_UNUSED(content);
if (isCurrent()) { if (isCurrent()) {
if (link!="") { if (link!="")
p_QupZilla->statusBar()->showMessage(link); p_QupZilla->statusBarMessage()->showMessage(link);
}else{ else
isLoading() ? p_QupZilla->statusBar()->showMessage(tr("Loading...")) : p_QupZilla->statusBar()->showMessage(tr("Done")); p_QupZilla->statusBarMessage()->clearMessage();
}
} }
m_hoveredLink = link; m_hoveredLink = link;
} }