diff --git a/src/plugins/StatusBarIcons/sbi_networkicon.cpp b/src/plugins/StatusBarIcons/sbi_networkicon.cpp index aa85b2c15..45b27696f 100644 --- a/src/plugins/StatusBarIcons/sbi_networkicon.cpp +++ b/src/plugins/StatusBarIcons/sbi_networkicon.cpp @@ -26,33 +26,28 @@ #include #include +#include SBI_NetworkIcon::SBI_NetworkIcon(QupZilla* window) : ClickableLabel(window) , p_QupZilla(window) + , m_networkConfiguration(new QNetworkConfigurationManager(this)) { setCursor(Qt::PointingHandCursor); - networkAccessibleChanged(mApp->networkManager()->networkAccessible()); + onlineStateChanged(m_networkConfiguration->isOnline()); - connect(mApp->networkManager(), SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)), this, SLOT(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility))); + connect(m_networkConfiguration, SIGNAL(onlineStateChanged(bool)), this, SLOT(onlineStateChanged(bool))); connect(this, SIGNAL(clicked(QPoint)), this, SLOT(showMenu(QPoint))); } -void SBI_NetworkIcon::networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessibility) +void SBI_NetworkIcon::onlineStateChanged(bool online) { - switch (accessibility) { - case QNetworkAccessManager::Accessible: + if (online) { setPixmap(QIcon(":sbi/data/network-online.png").pixmap(16)); - break; - - case QNetworkAccessManager::NotAccessible: + } + else { setPixmap(QIcon(":sbi/data/network-offline.png").pixmap(16)); - break; - - default: - setPixmap(QIcon(":sbi/data/network-unknown.png").pixmap(16)); - break; } updateToolTip(); @@ -105,18 +100,11 @@ void SBI_NetworkIcon::updateToolTip() { QString tooltip = tr("Shows network status and manages proxy

Network:
%1

Proxy:
%2"); - switch (mApp->networkManager()->networkAccessible()) { - case QNetworkAccessManager::Accessible: + if (m_networkConfiguration->isOnline()) { tooltip = tooltip.arg(tr("Connected")); - break; - - case QNetworkAccessManager::NotAccessible: + } + else { tooltip = tooltip.arg(tr("Offline")); - break; - - default: - tooltip = tooltip.arg(tr("Unknown")); - break; } switch (mApp->networkManager()->proxyFactory()->proxyPreference()) { diff --git a/src/plugins/StatusBarIcons/sbi_networkicon.h b/src/plugins/StatusBarIcons/sbi_networkicon.h index 82e0c7a0f..8ce65507b 100644 --- a/src/plugins/StatusBarIcons/sbi_networkicon.h +++ b/src/plugins/StatusBarIcons/sbi_networkicon.h @@ -22,6 +22,8 @@ #include "clickablelabel.h" +class QNetworkConfigurationManager; + class QupZilla; class SBI_NetworkIcon : public ClickableLabel @@ -32,7 +34,7 @@ public: explicit SBI_NetworkIcon(QupZilla* window); private slots: - void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessibility); + void onlineStateChanged(bool online); void showDialog(); void showMenu(const QPoint &pos); @@ -43,6 +45,7 @@ private: void enterEvent(QEvent* event); QupZilla* p_QupZilla; + QNetworkConfigurationManager* m_networkConfiguration; }; #endif // SBI_NETWORKICON_H diff --git a/src/plugins/StatusBarIcons/statusbariconsplugin.cpp b/src/plugins/StatusBarIcons/statusbariconsplugin.cpp index d671ec9ce..8924f71f0 100644 --- a/src/plugins/StatusBarIcons/statusbariconsplugin.cpp +++ b/src/plugins/StatusBarIcons/statusbariconsplugin.cpp @@ -35,7 +35,7 @@ PluginSpec StatusBarIconsPlugin::pluginSpec() spec.name = "StatusBar Icons"; spec.info = "Icons in statusbar providing various actions"; spec.description = "Adds additional icons to statusbar"; - spec.version = "0.1.5"; + spec.version = "0.1.6"; spec.author = "David Rosca "; spec.icon = QPixmap(":sbi/data/icon.png"); spec.hasSettings = true;