summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamarque V. Souza <lamarque@kde.org>2012-02-19 19:26:44 (GMT)
committerLamarque V. Souza <lamarque@kde.org>2012-02-19 19:26:44 (GMT)
commit1b297323168c693771d3cb2e05029ed768846a59 (patch)
tree641221d4ca03a5e56e86d9cad9062743ee578293
parent040324ee84fbb7e1dbaf9e018c979c9b259f7ce7 (diff)
Add USE_QML option to compile the (yet to implement) QML NMPopup. Also
re-organize the code to simplify switching between the current NMPopup and the future QML NMPopup.
-rw-r--r--applet/CMakeLists.txt1
-rw-r--r--applet/networkmanager.cpp65
-rw-r--r--applet/networkmanager.h3
-rw-r--r--applet/nmpopup.h1
4 files changed, 36 insertions, 34 deletions
diff --git a/applet/CMakeLists.txt b/applet/CMakeLists.txt
index b70b981..817a166 100644
--- a/applet/CMakeLists.txt
+++ b/applet/CMakeLists.txt
@@ -39,6 +39,7 @@ target_link_libraries(plasma_applet_networkmanagement ${KDE4_PLASMA_LIBS}
install(TARGETS plasma_applet_networkmanagement DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plasma-applet-networkmanagement.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+install(DIRECTORY qml/ DESTINATION ${DATA_INSTALL_DIR}/networkmanagement/qml)
add_subdirectory(icons)
diff --git a/applet/networkmanager.cpp b/applet/networkmanager.cpp
index b8778b0..5213224 100644
--- a/applet/networkmanager.cpp
+++ b/applet/networkmanager.cpp
@@ -21,6 +21,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "networkmanager.h"
+#include "nmpopup.h"
+#include "uiutils.h"
+#include "remoteactivatablelist.h"
+#include "paths.h"
+#include "knmserviceprefs.h"
#include <QAction>
#include <QPainter>
@@ -28,17 +33,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KCModuleInfo>
#include <KConfigDialog>
#include <KCModuleProxy>
+#include <KStandardDirs>
#include <Plasma/Containment>
+#include <Plasma/DeclarativeWidget>
#include <QtNetworkManager/manager.h>
#include <QtNetworkManager/wireddevice.h>
-#include "nmpopup.h"
-#include "uiutils.h"
-#include "remoteactivatablelist.h"
-#include "paths.h"
-#include "knmserviceprefs.h"
+//#define USE_QML
K_EXPORT_PLASMA_APPLET(networkmanagement, NetworkManagerApplet)
@@ -49,16 +52,19 @@ bool networkInterfaceSameConnectionStateLessThan(NetworkManager::Device * if1, N
class NetworkManagerApplet::Private
{
public:
- Private() { }
- ~Private() { }
+ Private(): m_popup(0) { }
+#ifdef USE_QML
+ Plasma::DeclarativeWidget * m_popup;
+#else
+ NMPopup * m_popup;
+#endif
QList<QAction*> actions;
};
NetworkManagerApplet::NetworkManagerApplet(QObject * parent, const QVariantList & args)
: Plasma::PopupApplet(parent, args),
m_activatables(0),
- m_popup(0),
m_panelContainment(true),
m_totalActiveVpnConnections(0),
m_activeInterface(0),
@@ -297,20 +303,26 @@ void NetworkManagerApplet::init()
setupInterfaceSignals();
- if (!m_popup) {
- m_popup = new NMPopup(m_activatables, this);
- connect(m_popup, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));
+#ifdef USE_QML
+ d->m_popup = new Plasma::DeclarativeWidget(this);
+ d->m_popup->setInitializationDelayed(true);
+ d->m_popup->setQmlPath(KStandardDirs::locate("data",
+ "networkmanagement/qml/NMPopup.qml"));
+#else
+ d->m_popup = new NMPopup(m_activatables, this);
+#endif
+ connect(d->m_popup, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));
- QAction* action = new QAction(i18nc("CheckBox to enable or disable networking completely", "Enable networking"), this);
- action->setToolTip(i18nc("@info:tooltip tooltip for the 'Enable networking' checkbox", "Enable or disable the networking system"));
- action->setCheckable(true);
- action->setChecked(NetworkManager::isNetworkingEnabled());
- connect(action, SIGNAL(triggered(bool)), m_popup, SLOT(networkingEnabledToggled(bool)));
- connect(NetworkManager::notifier(), SIGNAL(networkingEnabledChanged(bool)),
- action, SLOT(setChecked(bool)));
+ QAction* action = new QAction(i18nc("CheckBox to enable or disable networking completely", "Enable networking"), this);
+ action->setToolTip(i18nc("@info:tooltip tooltip for the 'Enable networking' checkbox", "Enable or disable the networking system"));
+ action->setCheckable(true);
+ action->setChecked(NetworkManager::isNetworkingEnabled());
+ connect(action, SIGNAL(triggered(bool)), d->m_popup, SLOT(networkingEnabledToggled(bool)));
+ connect(NetworkManager::notifier(), SIGNAL(networkingEnabledChanged(bool)),
+ action, SLOT(setChecked(bool)));
- d->actions.append(action);
- }
+ d->actions.append(action);
+ setGraphicsWidget(d->m_popup);
// m_activatables->init() must be called after SLOT(activatableAdded(RemoteActivatable*)) has been connected and
// NMPopup has been allocated.
@@ -342,15 +354,6 @@ void NetworkManagerApplet::finishInitialization()
networkmanagement.call(QLatin1String("FinishInitialization"));
}
-QGraphicsWidget* NetworkManagerApplet::graphicsWidget()
-{
- if (!m_popup) {
- m_popup = new NMPopup(m_activatables, this);
- }
-
- return m_popup;
-}
-
void NetworkManagerApplet::createConfigurationInterface(KConfigDialog *parent)
{
// Add the networkmanager KCM pages to the applet's configdialog
@@ -690,13 +693,13 @@ void NetworkManagerApplet::toolTipAboutToShow()
} else {
text = i18nc("tooltip, all interfaces are down", "Disconnected");
- if (m_popup->hasWireless() && !NetworkManager::isWirelessEnabled()) {
+ if (d->m_popup->property("hasWireless").toBool() && !NetworkManager::isWirelessEnabled()) {
subText = i18nc("tooltip, wireless is disabled in software", "Wireless disabled in software");
}
if (!NetworkManager::isNetworkingEnabled()) {
subText = i18nc("tooltip, all interfaces are down", "Networking disabled");
}
- if (m_popup->hasWireless() && !NetworkManager::isWirelessHardwareEnabled()) {
+ if (d->m_popup->property("hasWireless").toBool() && !NetworkManager::isWirelessHardwareEnabled()) {
subText = i18nc("tooltip, wireless is disabled by hardware", "Wireless disabled by hardware");
}
diff --git a/applet/networkmanager.h b/applet/networkmanager.h
index 4aaa78f..574fda2 100644
--- a/applet/networkmanager.h
+++ b/applet/networkmanager.h
@@ -45,7 +45,6 @@ namespace Plasma
class Applet;
} // namespace Plasma
-class NMPopup;
class RemoteActivatable;
class RemoteActivatableList;
class RemoteInterfaceConnection;
@@ -67,7 +66,6 @@ public:
//Qt::Orientations expandingDirections() const;
/* reimp Plasma::Applet */
void constraintsEvent(Plasma::Constraints constraints);
- QGraphicsWidget *graphicsWidget();
//virtual void initExtenderItem(Plasma::ExtenderItem *);
@@ -142,7 +140,6 @@ private:
Plasma::ToolTipContent m_toolTip;
RemoteActivatableList* m_activatables;
- NMPopup* m_popup;
bool m_panelContainment;
QPixmap m_pixmap;
diff --git a/applet/nmpopup.h b/applet/nmpopup.h
index e9e3d33..1124383 100644
--- a/applet/nmpopup.h
+++ b/applet/nmpopup.h
@@ -56,6 +56,7 @@ class VpnInterfaceItem;
class NMPopup: public QGraphicsWidget
{
Q_OBJECT
+Q_PROPERTY(bool hasWireless READ hasWireless)
public:
explicit NMPopup(RemoteActivatableList *, QGraphicsWidget* parent = 0);
virtual ~NMPopup();