mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
[StatusBarIcons] Added network icon.
Currenlty only shows status of connection and proxy.
This commit is contained in:
parent
0f695b0264
commit
c5b7dbb48c
@ -103,6 +103,11 @@ PacManager* NetworkProxyFactory::pacManager() const
|
||||
return m_pacManager;
|
||||
}
|
||||
|
||||
NetworkProxyFactory::ProxyPreference NetworkProxyFactory::proxyPreference() const
|
||||
{
|
||||
return m_proxyPreference;
|
||||
}
|
||||
|
||||
QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &query)
|
||||
{
|
||||
QList<QNetworkProxy> proxyList;
|
||||
|
@ -51,7 +51,9 @@ public:
|
||||
~NetworkProxyFactory();
|
||||
|
||||
void loadSettings();
|
||||
|
||||
PacManager* pacManager() const;
|
||||
ProxyPreference proxyPreference() const;
|
||||
|
||||
QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery());
|
||||
|
||||
|
@ -5,12 +5,16 @@ TARGET = $$qtLibraryTarget(StatusBarIcons)
|
||||
SOURCES += statusbariconsplugin.cpp \
|
||||
sbi_iconsmanager.cpp \
|
||||
sbi_imagesicon.cpp \
|
||||
sbi_javascripticon.cpp
|
||||
sbi_javascripticon.cpp \
|
||||
sbi_networkicon.cpp \
|
||||
sbi_networkproxy.cpp
|
||||
|
||||
HEADERS += statusbariconsplugin.h \
|
||||
sbi_iconsmanager.h \
|
||||
sbi_imagesicon.h \
|
||||
sbi_javascripticon.h
|
||||
sbi_javascripticon.h \
|
||||
sbi_networkicon.h \
|
||||
sbi_networkproxy.h
|
||||
|
||||
RESOURCES += statusbaricons.qrc
|
||||
|
||||
|
BIN
src/plugins/StatusBarIcons/data/network-offline.png
Normal file
BIN
src/plugins/StatusBarIcons/data/network-offline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 489 B |
BIN
src/plugins/StatusBarIcons/data/network-online.png
Normal file
BIN
src/plugins/StatusBarIcons/data/network-online.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 757 B |
BIN
src/plugins/StatusBarIcons/data/network-unknown.png
Normal file
BIN
src/plugins/StatusBarIcons/data/network-unknown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 941 B |
@ -18,6 +18,7 @@
|
||||
#include "sbi_iconsmanager.h"
|
||||
#include "sbi_imagesicon.h"
|
||||
#include "sbi_javascripticon.h"
|
||||
#include "sbi_networkicon.h"
|
||||
#include "qupzilla.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -67,8 +68,6 @@ void SBI_IconsManager::destroyIcons()
|
||||
|
||||
void SBI_IconsManager::mainWindowCreated(QupZilla* window)
|
||||
{
|
||||
typedef QWidget SBI_NetworkIcon;
|
||||
|
||||
if (m_showImagesIcon) {
|
||||
SBI_ImagesIcon* w = new SBI_ImagesIcon(window, m_settingsPath);
|
||||
window->statusBar()->addPermanentWidget(w);
|
||||
@ -82,7 +81,7 @@ void SBI_IconsManager::mainWindowCreated(QupZilla* window)
|
||||
}
|
||||
|
||||
if (m_showNetworkIcon) {
|
||||
SBI_NetworkIcon* w = new SBI_NetworkIcon;
|
||||
SBI_NetworkIcon* w = new SBI_NetworkIcon(window, m_settingsPath);
|
||||
window->statusBar()->addPermanentWidget(w);
|
||||
m_windows[window].append(w);
|
||||
}
|
||||
|
105
src/plugins/StatusBarIcons/sbi_networkicon.cpp
Normal file
105
src/plugins/StatusBarIcons/sbi_networkicon.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
/* ============================================================
|
||||
* StatusBarIcons - Extra icons in statusbar for QupZilla
|
||||
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "sbi_networkicon.h"
|
||||
#include "mainapplication.h"
|
||||
#include "networkmanager.h"
|
||||
#include "networkproxyfactory.h"
|
||||
#include "qupzilla.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
SBI_NetworkIcon::SBI_NetworkIcon(QupZilla* window, const QString &settingsPath)
|
||||
: ClickableLabel(window)
|
||||
, p_QupZilla(window)
|
||||
, m_settingsFile(settingsPath + "networkicon.ini")
|
||||
{
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
|
||||
connect(mApp->networkManager(), SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)), this, SLOT(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)));
|
||||
|
||||
networkAccessibleChanged(mApp->networkManager()->networkAccessible());
|
||||
}
|
||||
|
||||
void SBI_NetworkIcon::networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessibility)
|
||||
{
|
||||
switch (accessibility) {
|
||||
case QNetworkAccessManager::Accessible:
|
||||
setPixmap(QIcon(":sbi/data/network-online.png").pixmap(16));
|
||||
break;
|
||||
|
||||
case QNetworkAccessManager::NotAccessible:
|
||||
setPixmap(QIcon(":sbi/data/network-offline.png").pixmap(16));
|
||||
break;
|
||||
|
||||
default:
|
||||
setPixmap(QIcon(":sbi/data/network-unknown.png").pixmap(16));
|
||||
break;
|
||||
}
|
||||
|
||||
updateToolTip();
|
||||
}
|
||||
|
||||
void SBI_NetworkIcon::updateToolTip()
|
||||
{
|
||||
QString tooltip = tr("Shows network status and manages proxy<br/><br/><b>Network:</b><br/>%1<br/><br/><b>Proxy:</b><br/>%2");
|
||||
|
||||
switch (mApp->networkManager()->networkAccessible()) {
|
||||
case QNetworkAccessManager::Accessible:
|
||||
tooltip = tooltip.arg(tr("Connected"));
|
||||
break;
|
||||
|
||||
case QNetworkAccessManager::NotAccessible:
|
||||
tooltip = tooltip.arg(tr("Offline"));
|
||||
break;
|
||||
|
||||
default:
|
||||
tooltip = tooltip.arg(tr("Unknown"));
|
||||
break;
|
||||
}
|
||||
|
||||
switch (mApp->networkManager()->proxyFactory()->proxyPreference()) {
|
||||
case NetworkProxyFactory::SystemProxy:
|
||||
tooltip = tooltip.arg("System proxy");
|
||||
break;
|
||||
|
||||
case NetworkProxyFactory::NoProxy:
|
||||
tooltip = tooltip.arg("No proxy");
|
||||
break;
|
||||
|
||||
case NetworkProxyFactory::ProxyAutoConfig:
|
||||
tooltip = tooltip.arg("PAC (Proxy Auto-Config)");
|
||||
break;
|
||||
|
||||
case NetworkProxyFactory::DefinedProxy:
|
||||
tooltip = tooltip.arg("User defined");
|
||||
break;
|
||||
|
||||
default:
|
||||
qWarning() << "Unknown NetworkProxyFactory::ProxyPreference!";
|
||||
break;
|
||||
}
|
||||
|
||||
setToolTip(tooltip);
|
||||
}
|
||||
|
||||
void SBI_NetworkIcon::enterEvent(QEvent* event)
|
||||
{
|
||||
updateToolTip();
|
||||
|
||||
ClickableLabel::enterEvent(event);
|
||||
}
|
48
src/plugins/StatusBarIcons/sbi_networkicon.h
Normal file
48
src/plugins/StatusBarIcons/sbi_networkicon.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* ============================================================
|
||||
* StatusBarIcons - Extra icons in statusbar for QupZilla
|
||||
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#ifndef SBI_NETWORKICON_H
|
||||
#define SBI_NETWORKICON_H
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
#include "clickablelabel.h"
|
||||
|
||||
class QupZilla;
|
||||
|
||||
class SBI_NetworkIcon : public ClickableLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SBI_NetworkIcon(QupZilla* window, const QString &settingsPath);
|
||||
|
||||
private slots:
|
||||
void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessibility);
|
||||
|
||||
private:
|
||||
void updateToolTip();
|
||||
|
||||
void enterEvent(QEvent* event);
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
QString m_settingsFile;
|
||||
|
||||
QIcon m_icon;
|
||||
};
|
||||
|
||||
#endif // SBI_NETWORKICON_H
|
142
src/plugins/StatusBarIcons/sbi_networkproxy.cpp
Normal file
142
src/plugins/StatusBarIcons/sbi_networkproxy.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
/* ============================================================
|
||||
* StatusBarIcons - Extra icons in statusbar for QupZilla
|
||||
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "sbi_networkproxy.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
SBI_NetworkProxy::SBI_NetworkProxy()
|
||||
: m_port(0)
|
||||
, m_httpsPort(0)
|
||||
, m_useDifferentProxyForHttps(false)
|
||||
{
|
||||
}
|
||||
|
||||
quint16 SBI_NetworkProxy::port() const
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::setPort(quint16 port)
|
||||
{
|
||||
m_port = port;
|
||||
}
|
||||
|
||||
QString SBI_NetworkProxy::hostName() const
|
||||
{
|
||||
return m_hostname;
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::setHostName(const QString &hostName)
|
||||
{
|
||||
m_hostname = hostName;
|
||||
}
|
||||
|
||||
QString SBI_NetworkProxy::userName() const
|
||||
{
|
||||
return m_username;
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::setUserName(const QString &userName)
|
||||
{
|
||||
m_username = userName;
|
||||
}
|
||||
|
||||
QString SBI_NetworkProxy::password() const
|
||||
{
|
||||
return m_password;
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::setPassword(const QString &password)
|
||||
{
|
||||
m_password = password;
|
||||
}
|
||||
|
||||
bool SBI_NetworkProxy::useDifferentProxyForHttps() const
|
||||
{
|
||||
return m_useDifferentProxyForHttps;
|
||||
}
|
||||
|
||||
quint16 SBI_NetworkProxy::httpsPort() const
|
||||
{
|
||||
return m_httpsPort;
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::setHttpsPort(quint16 port)
|
||||
{
|
||||
m_httpsPort = port;
|
||||
}
|
||||
|
||||
QString SBI_NetworkProxy::httpsHostName() const
|
||||
{
|
||||
return m_httpsHostname;
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::setHttpsHostName(const QString &hostName)
|
||||
{
|
||||
m_httpsHostname = hostName;
|
||||
}
|
||||
|
||||
QString SBI_NetworkProxy::httpsUserName() const
|
||||
{
|
||||
return m_httpsUsername;
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::setHttpsUserName(const QString &userName)
|
||||
{
|
||||
m_httpsUsername = userName;
|
||||
}
|
||||
|
||||
QString SBI_NetworkProxy::httpsPassword() const
|
||||
{
|
||||
return m_httpsPassword;
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::setHttpsPassword(const QString &password)
|
||||
{
|
||||
m_httpsPassword = password;
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::loadFromSettings(QSettings* settings)
|
||||
{
|
||||
m_hostname = settings->value("HostName", QString()).toString();
|
||||
m_port = settings->value("Port", 0).toInt();
|
||||
m_username = settings->value("Username", QString()).toString();
|
||||
m_password = settings->value("Password", QString()).toString();
|
||||
|
||||
m_httpsHostname = settings->value("HttpsHostName", QString()).toString();
|
||||
m_httpsPort = settings->value("HttpsPort", 0).toInt();
|
||||
m_httpsUsername = settings->value("HttpsUsername", QString()).toString();
|
||||
m_httpsPassword = settings->value("HttpsPassword", QString()).toString();
|
||||
|
||||
m_useDifferentProxyForHttps = settings->value("UseDifferentProxyForHttps", false).toBool();
|
||||
}
|
||||
|
||||
void SBI_NetworkProxy::saveToSettings(QSettings* settings)
|
||||
{
|
||||
settings->setValue("HostName", m_hostname);
|
||||
settings->setValue("Port", m_port);
|
||||
settings->setValue("Username", m_username);
|
||||
settings->setValue("Password", m_password);
|
||||
|
||||
settings->setValue("HttpsHostName", m_httpsHostname);
|
||||
settings->setValue("HttpsPort", m_httpsPort);
|
||||
settings->setValue("HttpsUsername", m_httpsUsername);
|
||||
settings->setValue("HttpsPassword", m_httpsPassword);
|
||||
|
||||
settings->setValue("UseDifferentProxyForHttps", m_useDifferentProxyForHttps);
|
||||
}
|
73
src/plugins/StatusBarIcons/sbi_networkproxy.h
Normal file
73
src/plugins/StatusBarIcons/sbi_networkproxy.h
Normal file
@ -0,0 +1,73 @@
|
||||
/* ============================================================
|
||||
* StatusBarIcons - Extra icons in statusbar for QupZilla
|
||||
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#ifndef SBI_NETWORKPROXY_H
|
||||
#define SBI_NETWORKPROXY_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class QSettings;
|
||||
|
||||
class SBI_NetworkProxy
|
||||
{
|
||||
public:
|
||||
explicit SBI_NetworkProxy();
|
||||
|
||||
quint16 port() const;
|
||||
void setPort(quint16 port);
|
||||
|
||||
QString hostName() const;
|
||||
void setHostName(const QString &hostName);
|
||||
|
||||
QString userName() const;
|
||||
void setUserName(const QString &userName);
|
||||
|
||||
QString password() const;
|
||||
void setPassword(const QString &password);
|
||||
|
||||
bool useDifferentProxyForHttps() const;
|
||||
|
||||
quint16 httpsPort() const;
|
||||
void setHttpsPort(quint16 port);
|
||||
|
||||
QString httpsHostName() const;
|
||||
void setHttpsHostName(const QString &hostName);
|
||||
|
||||
QString httpsUserName() const;
|
||||
void setHttpsUserName(const QString &userName);
|
||||
|
||||
QString httpsPassword() const;
|
||||
void setHttpsPassword(const QString &password);
|
||||
|
||||
void loadFromSettings(QSettings* settings);
|
||||
void saveToSettings(QSettings* settings);
|
||||
|
||||
private:
|
||||
quint16 m_port;
|
||||
QString m_hostname;
|
||||
QString m_username;
|
||||
QString m_password;
|
||||
|
||||
quint16 m_httpsPort;
|
||||
QString m_httpsHostname;
|
||||
QString m_httpsUsername;
|
||||
QString m_httpsPassword;
|
||||
|
||||
bool m_useDifferentProxyForHttps;
|
||||
};
|
||||
|
||||
#endif // SBI_NETWORKPROXY_H
|
@ -3,5 +3,8 @@
|
||||
<file>data/icon.png</file>
|
||||
<file>data/images.png</file>
|
||||
<file>data/javascript.png</file>
|
||||
<file>data/network-offline.png</file>
|
||||
<file>data/network-online.png</file>
|
||||
<file>data/network-unknown.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -67,4 +67,27 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SBI_NetworkIcon</name>
|
||||
<message>
|
||||
<location filename="../sbi_networkicon.cpp" line="59"/>
|
||||
<source>Shows network status and manages proxy<br/><br/><b>Network:</b><br/>%1<br/><br/><b>Proxy:</b><br/>%2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_networkicon.cpp" line="63"/>
|
||||
<source>Connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_networkicon.cpp" line="67"/>
|
||||
<source>Offline</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_networkicon.cpp" line="71"/>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
Loading…
Reference in New Issue
Block a user