Commit 8a73ce12 authored by Martin Kacej's avatar Martin Kacej

mobile utils moved to Config module

parent 8e648a44
......@@ -14,7 +14,6 @@ set(plasmanm_internal_SRCS
debug.cpp
handler.cpp
uiutils.cpp
mobileutils.cpp
)
add_library(plasmanm_internal SHARED ${plasmanm_internal_SRCS})
......
......@@ -34,7 +34,6 @@
#include "kcmidentitymodel.h"
#include "networkmodel.h"
#include "mobileproxymodel.h"
#include "mobileutils.h"
#include "handler.h"
#include "enums.h"
......@@ -67,5 +66,4 @@ void QmlPlugins::registerTypes(const char* uri)
qmlRegisterType<CreatableConnectionsModel>(uri, 0, 2, "CreatableConnectionsModel");
// @uri org.kde.plasma.networkmanagement.MobileProxyModel
qmlRegisterType<MobileProxyModel>(uri, 0, 2, "MobileProxyModel");
qmlRegisterType<MobileUtils>(uri, 0, 2, "MobileUtils");
}
This diff is collapsed.
/*
* Copyright 2018 Martin Kacej <m.kacej@atlas.sk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef MOBILEUTILS_H
#define MOBILEUTILS_H
#include <QObject>
class Q_DECL_EXPORT MobileUtils : public QObject
{
Q_OBJECT
public:
explicit MobileUtils(QObject *parent = nullptr);
Q_INVOKABLE QVariantMap getConnectionSettings(const QString &connection, const QString &type);
Q_INVOKABLE QVariantMap getActiveConnectionInfo(const QString &connection);
Q_INVOKABLE void addConnectionFromQML(const QVariantMap &QMLmap);
Q_INVOKABLE void updateConnectionFromQML(const QString &path, const QVariantMap &map);
Q_INVOKABLE QString getAccessPointDevice();
Q_INVOKABLE QString getAccessPointConnection();
};
#endif // MOBILEUTILS_H
......@@ -13,7 +13,7 @@ target_link_libraries(kcm_mobile_broadband
KF5::I18n
KF5::QuickAddons
KF5::NetworkManagerQt
KF5::ModemManagerQt
KF5::ModemManagerQt
)
kcoreaddons_desktop_to_json(kcm_mobile_broadband "mobilebroadbandsettings.desktop")
......
......@@ -37,7 +37,7 @@ Kirigami.Page {
}
Controls.CheckBox {
id: mobileDataCheckbox
// enabled: enabledConnections.wwanHwEnabled && availableDevices.modemDeviceAvailable
enabled: enabledConnections.wwanHwEnabled && availableDevices.modemDeviceAvailable
anchors.rightMargin: Kirigami.Units.gridUnit
}
}
......
......@@ -44,11 +44,11 @@ Kirigami.ApplicationItem {
id: enabledConnections
onWwanEnabledChanged: {
//mobileDataCheckbox.checked = mobileDataCheckbox.enabled && enabled
mobileDataCheckbox.checked = mobileDataCheckbox.enabled && enabled
}
onWwanHwEnabledChanged: {
//mobileDataCheckbox.enabled = enabled && availableDevices.modemDeviceAvailable
mobileDataCheckbox.enabled = enabled && availableDevices.modemDeviceAvailable
}
}
}
......@@ -12,6 +12,8 @@ target_link_libraries(kcm_mobile_wifi
KF5::Plasma
KF5::I18n
KF5::QuickAddons
KF5::NetworkManagerQt
KF5::ModemManagerQt
)
kcoreaddons_desktop_to_json(kcm_mobile_wifi "wifisettings.desktop")
......
......@@ -109,7 +109,7 @@ Kirigami.ScrollablePage {
connection["mode"] = "infrastructure"
connection["802-11-wireless-security"] = editorSecuritySection.securityMap
console.info(connection)
utils.addConnectionFromQML(connection)
kcm.addConnectionFromQML(connection)
console.info('Connection saved '+ connection["id"])
}
}
......@@ -106,10 +106,10 @@ Kirigami.ScrollablePage{
function loadNetworkSettings() {
console.info(path);
settings = utils.getConnectionSettings(path,"connection");
settings = kcm.getConnectionSettings(path,"connection");
detailsName.text = settings["id"]
detailsSecuritySection.securityMap = utils.getConnectionSettings(path,"802-11-wireless-security");
detailsIP.ipmap = utils.getConnectionSettings(path,"ipv4");
detailsSecuritySection.securityMap = kcm.getConnectionSettings(path,"802-11-wireless-security");
detailsIP.ipmap = kcm.getConnectionSettings(path,"ipv4");
detailsSecuritySection.setStateFromMap();
detailsIP.setStateFromMap();
}
......@@ -119,6 +119,6 @@ Kirigami.ScrollablePage{
if (detailsSecuritySection.password !== "") { //otherwise password is unchanged
settings["802-11-wireless-security"] = detailsSecuritySection.securityMap;
}
utils.updateConnectionFromQML(path,settings);
kcm.updateConnectionFromQML(path,settings);
}
}
......@@ -163,15 +163,15 @@ Kirigami.ScrollablePage {
}
function checkTethering() {
devicePath = utils.getAccessPointDevice();
devicePath = kcm.getAccessPointDevice();
if (devicePath === "") {
hotSpotStatus.text = i18n('Not possible to start Acces point.')
hotSpotStatusIcon.source = "dialog-close"
hotSpotSwitch.enabled = false
return
}
connectPath = utils.getAccessPointConnection()
var map = utils.getActiveConnectionInfo(connectPath);
connectPath = kcm.getAccessPointConnection()
var map = kcm.getActiveConnectionInfo(connectPath);
if (map["address"]) { // means AP connection is active
hotSpotSwitch.checked = true
hotSpotStatus.text = i18n('Access point running: ') + name
......@@ -179,7 +179,7 @@ Kirigami.ScrollablePage {
}
function initTethering() {
connectPath = utils.getAccessPointConnection()
connectPath = kcm.getAccessPointConnection()
if (connectPath === "") {
hotSpotStatus.text = i18n('No suitable configuration found.')
hotSpotStatusIcon.source = "error"
......@@ -213,19 +213,19 @@ Kirigami.ScrollablePage {
map["802-11-wireless-security"] = securityMap
}
if (connectPath === "") {
utils.addConnectionFromQML(map)
kcm.addConnectionFromQML(map)
} else {
utils.updateConnectionFromQML(connectPath,map)
kcm.updateConnectionFromQML(connectPath,map)
}
}
function loadSettings() {
var map = utils.getConnectionSettings(connectPath,"connection");
var map = kcm.getConnectionSettings(connectPath,"connection");
name = map["id"]
map = utils.getConnectionSettings(connectPath,"802-11-wireless");
map = kcm.getConnectionSettings(connectPath,"802-11-wireless");
if (map["hidden"])
hotSpotConfigHidden.checked = map["hidden"]
map = utils.getConnectionSettings(connectPath,"802-11-wireless-security")
map = kcm.getConnectionSettings(connectPath,"802-11-wireless-security")
if (map["key-mgmt"]) {
hotSpotConfigSecurity.checked = true
}
......
......@@ -53,10 +53,6 @@ Kirigami.ApplicationItem {
id: connectionModel
}
PlasmaNM.MobileUtils{
id: utils
}
PlasmaNM.MobileProxyModel {
id: mobileProxyModel
sourceModel: connectionModel
......
This diff is collapsed.
......@@ -24,8 +24,15 @@
class WifiSettings : public KQuickAddons::ConfigModule
{
Q_OBJECT
public:
WifiSettings(QObject *parent, const QVariantList &args);
Q_INVOKABLE QVariantMap getConnectionSettings(const QString &connection, const QString &type);
Q_INVOKABLE QVariantMap getActiveConnectionInfo(const QString &connection);
Q_INVOKABLE void addConnectionFromQML(const QVariantMap &QMLmap);
Q_INVOKABLE void updateConnectionFromQML(const QString &path, const QVariantMap &map);
Q_INVOKABLE QString getAccessPointDevice();
Q_INVOKABLE QString getAccessPointConnection();
virtual ~WifiSettings();
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment