diff options
Diffstat (limited to 'src/settingsui/settingsuiplugin/pluginMain.qml')
-rw-r--r-- | src/settingsui/settingsuiplugin/pluginMain.qml | 358 |
1 files changed, 260 insertions, 98 deletions
diff --git a/src/settingsui/settingsuiplugin/pluginMain.qml b/src/settingsui/settingsuiplugin/pluginMain.qml index 3f15c57..e8df0de 100644 --- a/src/settingsui/settingsuiplugin/pluginMain.qml +++ b/src/settingsui/settingsuiplugin/pluginMain.qml @@ -32,134 +32,296 @@ import QtQuick.Controls 2.0 import Qt.labs.settings 1.0 import QtQuick.XmlListModel 2.0 import QtDeviceUtilities.LocalDeviceSettings 1.0 +import QtDeviceUtilities.NetworkSettings 1.0 +import QtGraphicalEffects 1.0 +import QtDemoLauncher.QtButtonImageProvider 1.0 -Rectangle { +Item { id: root anchors.fill: parent - color: "white" visible: true property var service + property int margin: (root.width / 3 * 2) * 0.05 + property alias model: xmlModel.source + property alias backgroundColor: background.color + signal closed() - ToolBar { - id: titlebar - property string title: "" - width: parent.width - height: 40 - z: 2 + Rectangle { + id: background + anchors.fill:parent + color: "#09102b" + } - ToolButton { - height: parent.height + Item { + id: header + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + height: parent.height * 0.125 + + Image { + id: backButton + sourceSize.width: parent.width + sourceSize.height: parent.height + height: parent.height * 0.5 width: height - contentItem: Image { - fillMode: Image.PreserveAspectFit - source: "../icons/Chevron-left_black_6x.png" + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + anchors.margins: parent.height * .25 + fillMode: Image.PreserveAspectFit + source: "../newIcons/back_icon.svg" + MouseArea { anchors.fill: parent - anchors.margins: parent.height * .2 + onClicked: { + root.closed() + } } - - visible: stackView.depth > 1 - onClicked: stackView.pop(); } - Label { - id: titleText - font.pixelSize: 20 - text: stackView.currentItem.title - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - anchors.centerIn: parent + + Text { + id: settingsText + anchors.left: backButton.right + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: parent.height * 0.45 + text: qsTr("Settings") + color: "white" + font.family: appFont + font.styleName: "SemiBold" } - ToolButton { + + Item { + id: ipItem + width: parent.width * 0.25 height: parent.height - width: height - contentItem: Image { - fillMode: Image.PreserveAspectFit - source: "../icons/Power_black_6x.png" + anchors.right: parent.right + anchors.rightMargin: root.margin + property alias ipAddressText: ipText.text + property var lastService + property var currentService: NetworkSettingsManager.services.itemFromRow(0) + Text { + id: ipText anchors.fill: parent - anchors.margins: parent.height * .2 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + font.pixelSize: parent.height * 0.25 + color: "white" + text: qsTr("Device IP: ") + font.family: appFont + font.styleName: "SemiBold" } - anchors.right: parent.right - visible: stackView.depth === 1 - onClicked: menu.open(); + MouseArea { + anchors.fill: parent + onClicked: { + parent.refreshIP() + } + } - Menu { - id: menu - x: parent.width - width + function refreshIP() { + var networkCount = NetworkSettingsManager.services.sourceModel.rowCount(); + var ipAddress = "Not Found"; + for (var i = 0; i < networkCount; ++i) { + var networkService = NetworkSettingsManager.services.itemFromRow(i); + var tmp = NetworkSettingsManager.services.itemFromRow(i).ipv4.address; + if (tmp !== "" && ipAddress === "Not Found") + ipAddress = tmp; - MenuItem { - text: qsTr("Reboot") - onTriggered: LocalDevice.reboot() + if (networkService.type === NetworkSettingsType.Wired && + (networkService.status === NetworkSettingsState.Ready || + networkService.status === NetworkSettingsState.Online)) { + break; + } } - MenuItem { - text: qsTr("Shutdown") - onTriggered: LocalDevice.powerOff() + ipText.text = qsTr("Device IP: ") + ipAddress; + } + + Component.onCompleted: { + var networkCount = NetworkSettingsManager.services.sourceModel.rowCount(); + for (var i = 0; i < networkCount; ++i) { + NetworkSettingsManager.services.itemFromRow(i).ipv4Changed.connect(refreshIP); } + refreshIP() } } } - - StackView { - id: stackView - initialItem: mainView - anchors.top: titlebar.bottom - anchors.bottom: parent.bottom + Item { + id: listHolder + anchors.top: header.bottom anchors.left: parent.left - anchors.right: parent.right + anchors.bottom: parent.bottom + width: parent.width / 3 + + XmlListModel { + id: xmlModel + source: "settingsview.xml" + query: "/xml/settings/item" + XmlRole { name: "title"; query: "title/string()"} + XmlRole { name: "icon"; query: "icon/string()"} + XmlRole { name: "view"; query: "view/string()"} + XmlRole { name: "path"; query: "path/string()"} + } + + ListView { + id: settingsList + anchors.fill: parent - Component { - id: mainView + model: xmlModel + delegate: Item { + id: delegateItem + width: settingsList.width + height: settingsList.height * 0.08 - Item { - property string title: qsTr("Device Settings") + property bool isSelected: settingsList.currentIndex == index - XmlListModel { - id: xmlModel - source: "settingsview.xml" - query: "/xml/settings/item" - XmlRole { name: "title"; query: "title/string()"} - XmlRole { name: "icon"; query: "icon/string()"} - XmlRole { name: "view"; query: "view/string()"} - XmlRole { name: "path"; query: "path/string()"} + Image { + id: img + sourceSize.width: parent.width + sourceSize.height: parent.height + source: icon + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: parent.width * 0.075 + height: Math.min(parent.width * 0.5, parent.height * 0.6) + width: height + fillMode: Image.PreserveAspectFit + visible: parent.isSelected ? false : true + } + ColorOverlay { + source: img + anchors.fill: img + visible: parent.isSelected ? true : false + color: "#41cd52" } - GridView { - id: grid + Label { + text: title + height: parent.height * 0.75 + anchors.right: parent.right + anchors.left: img.right + anchors.leftMargin: parent.width * 0.025 + anchors.verticalCenter: parent.verticalCenter + fontSizeMode: Text.Fit + minimumPixelSize: 1 + font.pixelSize: Math.min(parent.width * 0.25, parent.height) + color: parent.isSelected ? "#41cd52" : "white" + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + font.family: appFont + font.styleName: parent.isSelected ? "Bold" : "Regular" + } + MouseArea { + id: mouseArea anchors.fill: parent - anchors.margins: 40 - cellHeight: 133 + spacing - cellWidth: 117 + spacing - model: xmlModel - property int spacing: 20 - delegate: MouseArea { - width: grid.cellWidth - grid.spacing - height: grid.cellHeight - grid.spacing - - Rectangle { - anchors.fill: parent - color: "#d6d6d6" - radius: 5 - visible: pressed - } - Column { - anchors.fill: parent - anchors.topMargin: 10 - Image { - id: image - source: icon - anchors.horizontalCenter: parent.horizontalCenter - width: grid.cellWidth - fillMode: Image.PreserveAspectFit - } - Label { - text: title - anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: grid.cellHeight * .1 - } - } - onClicked: { - var component = Qt.createComponent(path+'/'+view+'.qml'); - stackView.push(component.createObject(stackView)); - } + onClicked: { + settingsList.currentIndex = index + settingsLoader.source = path + '/' + view + '.qml' + } + } + Component.onCompleted: { + if (xmlModel.count == 0) { + console.error("Empty xmlModel") + return } + settingsLoader.source = xmlModel.get(0).path + '/' + xmlModel.get(0).view + '.qml' + } + } + } + } + + Rectangle { + id: rightLine + width: parent.width * 0.002 + height: parent.height * 0.8 + anchors.horizontalCenter: listHolder.right + anchors.top: header.bottom + color: "#9d9faa" + } + + Item { + id: loaderItem + anchors.top: header.bottom + anchors.left: listHolder.right + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.bottomMargin: root.margin + anchors.leftMargin: root.margin + anchors.rightMargin: root.margin + + Loader { + id: settingsLoader + anchors.fill: parent + } + } + + Popup { + id: shutdownPopup + width: parent.width + height: parent.height + leftPadding: width * 0.3 + rightPadding: leftPadding + topPadding: height * 0.275 + bottomPadding: topPadding + + property alias powerOffText: poweroffConfirmText.text + property alias buttonText: shutdownConfirm.text + + background: Rectangle { + color: "#09102b" + opacity: 0.9 + } + contentItem: Rectangle { + color: "#09102b" + border.color: "#9d9faa" + border.width: 3 + Text { + id: poweroffConfirmText + width: parent.width * 0.75 + height: parent.height * 0.1 + anchors.top: parent.top + anchors.topMargin: parent.height * 0.175 + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + fontSizeMode: Text.Fit + minimumPixelSize: 1 + font.pixelSize: height * 0.9 + color: "white" + font.family: appFont + font.styleName: "Light" + } + QtButton { + id: shutdownConfirm + width: parent.width * 0.5 + height: parent.height * 0.15 + anchors.top: poweroffConfirmText.bottom + anchors.topMargin: parent.height * 0.15 + anchors.horizontalCenter: parent.horizontalCenter + fillColor: "#41cd52" + borderColor: "transparent" + + onClicked: { + if (shutdownConfirm.text === qsTr("SHUT DOWN")) { + console.log("Powering off!") + LocalDevice.powerOff() + } + else if (shutdownConfirm.text === qsTr("REBOOT")) { + console.log("Rebooting!") + LocalDevice.reboot() + } + } + } + QtButton { + id: shutdownCancel + width: parent.width * 0.5 + height: parent.height * 0.15 + anchors.top: shutdownConfirm.bottom + anchors.topMargin: parent.height * 0.1 + anchors.horizontalCenter: parent.horizontalCenter + fillColor: "#9d9faa" + borderColor: "transparent" + text: qsTr("CANCEL") + + onClicked: { + shutdownPopup.close() } } } |