From 156fe5646cab841e274f97e17c5a335e952fca9a Mon Sep 17 00:00:00 2001 From: mhduiy Date: Sun, 22 Dec 2024 17:19:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AFui?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MFloat/Controls/MLoadIndicator.qml | 3 +- src/main.qrc | 1 + src/qml/components/BatteryRect.qml | 59 ++- src/qml/components/MonitorItem.qml | 18 + src/qml/pages/DeviceInfoPage.qml | 595 +++++++++++++------------ src/qml/pages/SettingPage.qml | 8 + 6 files changed, 379 insertions(+), 305 deletions(-) create mode 100644 src/qml/components/MonitorItem.qml diff --git a/src/MFloat/Controls/MLoadIndicator.qml b/src/MFloat/Controls/MLoadIndicator.qml index a5255c0..54723d1 100644 --- a/src/MFloat/Controls/MLoadIndicator.qml +++ b/src/MFloat/Controls/MLoadIndicator.qml @@ -49,8 +49,7 @@ Item { property: "rotation" from: 0 to: 360 - duration: 1500 + duration: 1000 loops: Animation.Infinite - easing.type: Easing.OutBack } } diff --git a/src/main.qrc b/src/main.qrc index 43da7ee..2412efe 100644 --- a/src/main.qrc +++ b/src/main.qrc @@ -7,6 +7,7 @@ qml/components/BatteryRect.qml qml/components/SettingItem.qml qml/components/TitleBar.qml + qml/components/MonitorItem.qml qml/pages/DeviceInfoPage.qml qml/pages/DeviceControlPage.qml qml/pages/DeviceAppPage.qml diff --git a/src/qml/components/BatteryRect.qml b/src/qml/components/BatteryRect.qml index b81baa4..5a1afe2 100644 --- a/src/qml/components/BatteryRect.qml +++ b/src/qml/components/BatteryRect.qml @@ -1,12 +1,13 @@ import QtQuick Item { + id: root property bool charging: false property int level: 80 - id: root // 背景 Rectangle { + clip: true id: backRect anchors.fill: parent radius: 10 @@ -19,22 +20,23 @@ Item { Rectangle { id: indi - height: parent.height + anchors.bottom: parent.bottom + width: parent.width radius: parent.radius - width: parent.width * root.level / 100.0 + height: parent.height * root.level / 100.0 color: { if (root.level < 10) { - return backRect.warningColor + return backRect.warningColor; } else if (root.level < 30) { - return backRect.lowColor + return backRect.lowColor; } else if (root.level < 50) { - return backRect.midColor + return backRect.midColor; } else { - return backRect.goodColor + return backRect.goodColor; } } - Behavior on width { + Behavior on height { PropertyAnimation { duration: 300 easing.type: Easing.OutExpo @@ -46,18 +48,49 @@ Item { duration: 300 } } + + Rectangle { + x: 0 + y: root.height + width: root.width + height: 100 + + // 使用一个线性渐变 + gradient: Gradient { + GradientStop { + position: 0.0 + color: Qt.rgba(255, 255, 255, 0.4) + } + GradientStop { + position: 1.0 + color: "transparent" + } + } + + NumberAnimation on y { + from: root.height + to: 0 + duration: 5000 + loops: Animation.Infinite + easing.type: Easing.OutQuad + } + + NumberAnimation on opacity { + from: 1 + to: 0 + duration: 5000 + loops: Animation.Infinite + } + } } Text { - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.bottomMargin: 10 - anchors.leftMargin: 10 + anchors.centerIn: parent color: "white" font.family: "黑体" font.pixelSize: 16 font.bold: true - text: (charging ? "充电中 " : "剩余电量 ") + root.level + "%" + text: root.level + "%" } } } diff --git a/src/qml/components/MonitorItem.qml b/src/qml/components/MonitorItem.qml new file mode 100644 index 0000000..d2a9a0c --- /dev/null +++ b/src/qml/components/MonitorItem.qml @@ -0,0 +1,18 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import MFloat + +MWrapper { + Layout.preferredHeight: 200 + Layout.fillWidth: true + title: "电池电量" + titleRightContent: MSwitchButton { + } + Rectangle { + radius: 12 + border.width: 1 + border.color: "gray" + color: "transparent" + } +} \ No newline at end of file diff --git a/src/qml/pages/DeviceInfoPage.qml b/src/qml/pages/DeviceInfoPage.qml index 7d81799..1ff32c9 100644 --- a/src/qml/pages/DeviceInfoPage.qml +++ b/src/qml/pages/DeviceInfoPage.qml @@ -16,14 +16,30 @@ ItemPage { id: root state: "pageShow" property var monitorMap: [ - {"name": "CPU占用"}, - {"name": "CPU温度"}, - {"name": "GPU占用"}, - {"name": "电池温度"}, - {"name": "电池电压"}, - {"name": "电池电流"}, - {"name": "电池功率"}, - {"name": "FPS"}, + { + "name": "CPU占用" + }, + { + "name": "CPU温度" + }, + { + "name": "GPU占用" + }, + { + "name": "电池温度" + }, + { + "name": "电池电压" + }, + { + "name": "电池电流" + }, + { + "name": "电池功率" + }, + { + "name": "FPS" + }, ] ColorConstants { @@ -31,7 +47,7 @@ ItemPage { } function gInfo(key) { - return DetailInfoControl.info[key] + return DetailInfoControl.info[key]; } property var monitorItems: [0, 1] @@ -42,322 +58,321 @@ ItemPage { Layout.preferredWidth: parent.width * 0.48 Layout.fillHeight: true Layout.alignment: Qt.AlignLeft - ScrollView { - id: scrollView - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - ScrollBar.vertical.policy: ScrollBar.AlwaysOff - ColumnLayout { - width: scrollView.availableWidth - // 设备Title + ColumnLayout { + RowLayout { + Layout.fillWidth: true + Layout.preferredHeight: 200 spacing: 10 - Text { - text: { - let title = DetailInfoControl.info[DetailInfoControl.DETA_MANUFACTURER]; - if (title === "" || title === undefined) { - title = "请连接设备" + Rectangle { + Layout.preferredHeight: 200 + Layout.preferredWidth: 130 + radius: 12 + color: "transparent" + + BatteryRect { + anchors.fill: parent + level: BatteryControl.level + } + } + + ColumnLayout { + spacing: 5 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignLeft + Text { + text: { + let title = DetailInfoControl.info[DetailInfoControl.DETA_MANUFACTURER]; + if (title === "" || title === undefined) { + title = "请连接设备"; + return title; + } + title = title + " " + (DetailInfoControl.info[DetailInfoControl.DETA_DEVICENAME] === "" ? DetailInfoControl.info[DetailInfoControl.DETA_MODEL] : DetailInfoControl.info[DetailInfoControl.DETA_DEVICENAME]); return title; } - title = title + " " - + (DetailInfoControl.info[DetailInfoControl.DETA_DEVICENAME] === "" ? - DetailInfoControl.info[DetailInfoControl.DETA_MODEL] - : DetailInfoControl.info[DetailInfoControl.DETA_DEVICENAME]) - return title; + font.pixelSize: 22 + font.bold: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter } - font.pixelSize: 22 - font.bold: true - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - Text { - text: { - let str = DetailInfoControl.info[DetailInfoControl.DETA_SERIALNUMBER] - if (str === "" || str === undefined) { - str = "请连接设备" + Item { + Layout.preferredHeight: 10 + Layout.fillWidth: true + } + + Repeater { + model: [ + { + key: "设备序列号:", + value: DetailInfoControl.info[DetailInfoControl.DETA_SERIALNUMBER] + }, + { + key: "CPU:", + value: DetailInfoControl.info[DetailInfoControl.DETA_CPUINFO] + }, + { + key: "安卓版本:", + value: DetailInfoControl.info[DetailInfoControl.DETA_ANDROIDVERSION] + }, + { + key: "分辨率:", + value: DetailInfoControl.info[DetailInfoControl.DETA_RESOLVING] + }, + ] + RowLayout { + Text { + text: modelData.key + color: "#008c8c" + } + Text { + text: modelData.value + color: "gray" + } } - return "设备序列号:" + str; } - opacity: 0.8 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - Item { - Layout.preferredHeight: 10 + GridLayout { + columns: 2 + uniformCellHeights: true + uniformCellWidths: true + Layout.topMargin: 2 + columnSpacing: 10 + rowSpacing: 3 + MButton { + text: "关机" + Layout.fillWidth: true + btnType: MButton.FBtnType.Warning + } + MButton { + text: "重启" + Layout.fillWidth: true + btnType: MButton.FBtnType.Suggest + } + MButton { + text: "Recovery" + Layout.fillWidth: true + btnType: MButton.FBtnType.Ordinary + } + MButton { + text: "FastBoot" + Layout.fillWidth: true + btnType: MButton.FBtnType.Ordinary + } + } } + } + + Item { + Layout.fillWidth: true + Layout.fillHeight: true - Repeater { - id: deviceDetailInfoRep - property var texts: [ - ["厂商", "品牌", "型号", "设备名", "设备代号"], - ["CPU信息", "最大频率", "核心数"], - ["系统", "安卓版本", "sdk版本"], - ["尺寸", "分辨率", "DPI"], - ["MAC地址", "IP地址", "内存容量"] - ] - property var values: [ - [ DetailInfoControl.info[DetailInfoControl.DETA_MANUFACTURER], DetailInfoControl.info[DetailInfoControl.DETA_BRAND], DetailInfoControl.info[DetailInfoControl.DETA_MODEL], DetailInfoControl.info[DetailInfoControl.DETA_DEVICENAME], DetailInfoControl.info[DetailInfoControl.DETA_DEVICECODE]], - [ DetailInfoControl.info[DetailInfoControl.DETA_CPUINFO], DetailInfoControl.info[DetailInfoControl.DATE_MAXFREP], DetailInfoControl.info[DetailInfoControl.DATE_MAXCORENUM]], - ["未知", DetailInfoControl.info[DetailInfoControl.DETA_ANDROIDVERSION], DetailInfoControl.info[DetailInfoControl.DETA_SDKVERSION]], - ["未知", DetailInfoControl.info[DetailInfoControl.DETA_RESOLVING], DetailInfoControl.info[DetailInfoControl.DETA_DPI]], - [ DetailInfoControl.info[DetailInfoControl.DETA_MACADDR], DetailInfoControl.info[DetailInfoControl.DETA_IPADDR], DetailInfoControl.info[DetailInfoControl.DETA_MEMORY]] - ] - property var titles: ["设备信息", "处理器", "系统信息", "屏幕", "其他信息"] - model: texts.length + ScrollView { + id: scrollView + anchors.fill: parent + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ScrollBar.vertical.policy: ScrollBar.AlwaysOff ColumnLayout { - Text { - text: deviceDetailInfoRep.titles[index] - font.bold: true - font.pixelSize: 18 - color: colorConstants.ordinaryClickedColor - } + width: scrollView.availableWidth + // 设备Title + spacing: 10 + Repeater { - id: rep - model: deviceDetailInfoRep.texts[index].length - property int repIndex: index - delegate: RowLayout { - Layout.leftMargin: 20 - Rectangle { - width: 10 - height: 10 - radius: width / 2 - color: "#008c8c" - opacity: 0.6 + id: deviceDetailInfoRep + property var texts: [["厂商", "品牌", "型号", "设备名", "设备代号"], ["CPU信息", "最大频率", "核心数"], ["系统", "安卓版本", "sdk版本"], ["尺寸", "分辨率", "DPI"], ["MAC地址", "IP地址", "内存容量"]] + property var values: [[DetailInfoControl.info[DetailInfoControl.DETA_MANUFACTURER], DetailInfoControl.info[DetailInfoControl.DETA_BRAND], DetailInfoControl.info[DetailInfoControl.DETA_MODEL], DetailInfoControl.info[DetailInfoControl.DETA_DEVICENAME], DetailInfoControl.info[DetailInfoControl.DETA_DEVICECODE]], [DetailInfoControl.info[DetailInfoControl.DETA_CPUINFO], DetailInfoControl.info[DetailInfoControl.DATE_MAXFREP], DetailInfoControl.info[DetailInfoControl.DATE_MAXCORENUM]], ["未知", DetailInfoControl.info[DetailInfoControl.DETA_ANDROIDVERSION], DetailInfoControl.info[DetailInfoControl.DETA_SDKVERSION]], ["未知", DetailInfoControl.info[DetailInfoControl.DETA_RESOLVING], DetailInfoControl.info[DetailInfoControl.DETA_DPI]], [DetailInfoControl.info[DetailInfoControl.DETA_MACADDR], DetailInfoControl.info[DetailInfoControl.DETA_IPADDR], DetailInfoControl.info[DetailInfoControl.DETA_MEMORY]]] + property var titles: ["设备信息", "处理器", "系统信息", "屏幕", "其他信息"] + model: texts.length + ColumnLayout { + Text { + text: deviceDetailInfoRep.titles[index] + font.bold: true + font.pixelSize: 18 + color: colorConstants.ordinaryClickedColor } + Repeater { + id: rep + model: deviceDetailInfoRep.texts[index].length + property int repIndex: index + delegate: RowLayout { + Layout.leftMargin: 20 + Rectangle { + width: 10 + height: 10 + radius: width / 2 + color: "#008c8c" + opacity: 0.6 + } - Item { - Layout.preferredWidth: 5 - } + Item { + Layout.preferredWidth: 5 + } - Text { - text: deviceDetailInfoRep.texts[rep.repIndex][index] - opacity: 0.4 - font.pixelSize: 14 - } + Text { + text: deviceDetailInfoRep.texts[rep.repIndex][index] + opacity: 0.4 + font.pixelSize: 14 + } - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: 1 - color: Qt.rgba(255, 255, 255, 0.7) - } + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: 1 + color: Qt.rgba(255, 255, 255, 0.7) + } - Text { - visible: deviceDetailInfoRep.values[rep.repIndex][index] !== undefined - text: deviceDetailInfoRep.values[rep.repIndex][index] - } + Text { + visible: deviceDetailInfoRep.values[rep.repIndex][index] !== undefined + text: deviceDetailInfoRep.values[rep.repIndex][index] + } - MLoadIndicator { - scale: 0.8 - visible: deviceDetailInfoRep.values[rep.repIndex][index] === undefined - Component.onCompleted: { - start() + MLoadIndicator { + scale: 0.8 + visible: deviceDetailInfoRep.values[rep.repIndex][index] === undefined + Component.onCompleted: { + start(); + } + } } } } } - } - - } - Item { - Layout.fillHeight: true + Item { + Layout.fillHeight: true + } + } } } } - - } ColumnLayout { Layout.fillWidth: true Layout.fillHeight: true Layout.alignment: Qt.AlignTop - MWrapper { - Layout.fillWidth: true - Layout.preferredHeight: 120 - title: "快速控制" - titleRightContent: MButton { - text: "重启ADB" - btnType: MButton.FBtnType.Warning - Layout.alignment: Qt.AlignRight - onClicked: { - ADBControl.restartADB(); - } - } - GridLayout { - anchors.fill: parent - columns: 2 - MButton { - text: "重启手机" - btnType: MButton.FBtnType.Warning - Layout.fillWidth: true - onClicked: { - DeviceControl.control(DeviceControl.CTRL_Key, DeviceControl.Reboot) - } - } - MButton { - text: "关闭手机" - btnType: MButton.FBtnType.Warning - Layout.fillWidth: true - onClicked: { - DeviceControl.control(DeviceControl.CTRL_Key, DeviceControl.Poweroff) - } - } - MButton { - text: "重启到RECOVERY" - btnType: MButton.FBtnType.Warning - Layout.fillWidth: true - onClicked: { - DeviceControl.control(DeviceControl.CTRL_Key, DeviceControl.RebootToRec) - } - } - MButton { - text: "重启到FASTBOOT" - btnType: MButton.FBtnType.Warning - Layout.fillWidth: true - onClicked: { - DeviceControl.control(DeviceControl.CTRL_Key, DeviceControl.RebootToFB) - } - } - } - } - - MWrapper { + ScrollView { + id: scrollViewRight Layout.fillWidth: true - Layout.preferredHeight: 160 - title: "电池信息" + Layout.fillHeight: true + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ScrollBar.vertical.policy: ScrollBar.AlwaysOff ColumnLayout { - BatteryRect { + width: parent.parent.width + MWrapper { + // 当前活动信息 Layout.fillWidth: true - Layout.preferredHeight: 40 - level: BatteryControl.level - } + Layout.fillHeight: true + ColumnLayout { + anchors.fill: parent + RowLayout { + Layout.fillWidth: true + Layout.preferredHeight: 30 + Text { + font.bold: true + font.pixelSize: 20 + text: "前台应用" + } + Item { + Layout.fillWidth: true + } - GridLayout { - Layout.fillWidth: true - columns: 4 - Repeater { - model: batteryModel - MLabel { - rectColor: colorConstants.suggestClickedColor - text: model.name - Layout.row: index / 2 - Layout.column: index % 2 == 1 ? 2 : 0 + MButton { + Layout.preferredWidth: 80 + text: "强行停止" + btnType: MButton.FBtnType.Warning + onClicked: { + CutActivityControl.killCutActivity(); + NotificationController.send("命令已发送", "当前应用已停止", 1, 3000); + } + } } - } - Repeater { - model: batteryModel - Label { - text: model.info - Layout.row: index / 2 - Layout.column: index % 2 == 1 ? 3 : 1 + GridLayout { + columns: 2 + Layout.fillHeight: true Layout.fillWidth: true + MLabel { + Layout.preferredWidth: 100 + rectColor: colorConstants.suggestClickedColor + text: "窗口标识符" + } + Text { + Layout.fillWidth: true + text: CutActivityControl.identifier + } + MLabel { + Layout.preferredWidth: 100 + rectColor: colorConstants.suggestClickedColor + text: "前台包名" + } + Text { + Layout.fillWidth: true + text: CutActivityControl.cutPackageName + } + MLabel { + Layout.preferredWidth: 100 + rectColor: colorConstants.suggestClickedColor + text: "前台活动" + } + Text { + Layout.fillWidth: true + text: CutActivityControl.cutActivity + } } } } - } - } - - MWrapper { - Layout.fillWidth: true - Layout.preferredHeight: 140 - ColumnLayout { - anchors.fill: parent - Layout.alignment: Qt.AlignTop - MonitorBarItem { - title: "CPU温度" - valueStr: "46" - value: 20 - } - MonitorBarItem { - title: "CPU占用" - valueStr: "46" - value: 40 + MonitorItem { + title: "电池电量" } - MonitorBarItem { - title: "内存占用" - valueStr: RealTimeInfoHelper.memUse - value: RealTimeInfoHelper.memUse + MonitorItem { + title: "电池温度" } - MonitorBarItem { - title: "磁盘占用" - valueStr: "46" - value: 80 + MonitorItem { + title: "电池电压" } - MonitorBarItem { - title: "电池温度" - valueStr: "46" - value: 60 + MonitorItem { + title: "内存占用" } } } - MWrapper { // 当前活动信息 - Layout.fillWidth: true - Layout.fillHeight: true - ColumnLayout { - anchors.fill: parent - RowLayout { - Layout.fillWidth: true - Layout.preferredHeight: 30 - Text { - font.bold: true - font.family: "黑体" - font.pixelSize: 20 - text: "当前前台应用" - } - Item { - Layout.fillWidth: true - } + // MWrapper { + // Layout.fillWidth: true + // Layout.preferredHeight: 160 + // title: "电池信息" + // ColumnLayout { + // BatteryRect { + // Layout.fillWidth: true + // Layout.preferredHeight: 40 + // level: BatteryControl.level + // } - MButton { - Layout.preferredWidth: 80 - text: "停止当前应用" - btnType: MButton.FBtnType.Warning - onClicked: { - CutActivityControl.killCutActivity() - NotificationController.send("命令已发送", "当前应用已停止", 1, 3000); - } - } - } - GridLayout { - columns: 2 - Layout.fillHeight: true - Layout.fillWidth: true - MLabel { - Layout.preferredWidth: 100 - rectColor: colorConstants.suggestClickedColor - text: "窗口标识符" - } - Text { - Layout.fillWidth: true - text: CutActivityControl.identifier - } - MLabel { - Layout.preferredWidth: 100 - rectColor: colorConstants.suggestClickedColor - text: "前台包名" - } - Text { - Layout.fillWidth: true - text: CutActivityControl.cutPackageName - } - MLabel { - Layout.preferredWidth: 100 - rectColor: colorConstants.suggestClickedColor - text: "前台活动" - } - Text { - Layout.fillWidth: true - text: CutActivityControl.cutActivity - } - } - } - } + // GridLayout { + // Layout.fillWidth: true + // columns: 4 + // Repeater { + // model: batteryModel + // MLabel { + // rectColor: colorConstants.suggestClickedColor + // text: model.name + // Layout.row: index / 2 + // Layout.column: index % 2 == 1 ? 2 : 0 + // } + // } + // Repeater { + // model: batteryModel + // Label { + // text: model.info + // Layout.row: index / 2 + // Layout.column: index % 2 == 1 ? 3 : 1 + // Layout.fillWidth: true + // } + // } + // } + // } + // } } } - ListModel { id: batteryModel @@ -387,33 +402,33 @@ ItemPage { } Component.onCompleted: { - BatteryControl.chargeModeChanged.connect(function(mode) { - var str = "正在放电" + BatteryControl.chargeModeChanged.connect(function (mode) { + var str = "正在放电"; if (mode === 0) { - str = "常规充电" + str = "常规充电"; } else if (mode === 1) { - str = "USB充电" + str = "USB充电"; } else if (mode === 2) { - str = "无线充电" + str = "无线充电"; } else if (mode === 3) { - str = "Dock充电" + str = "Dock充电"; } - batteryModel.get(0).info = str + batteryModel.get(0).info = str; }); - BatteryControl.healthChanged.connect(function(health) { - batteryModel.get(1).info = health + "%" + BatteryControl.healthChanged.connect(function (health) { + batteryModel.get(1).info = health + "%"; }); - BatteryControl.voltageChanged.connect(function(voltage) { - batteryModel.get(2).info = voltage + "mV" + BatteryControl.voltageChanged.connect(function (voltage) { + batteryModel.get(2).info = voltage + "mV"; }); - BatteryControl.currentChanged.connect(function(current) { - batteryModel.get(3).info = current + "mA" + BatteryControl.currentChanged.connect(function (current) { + batteryModel.get(3).info = current + "mA"; }); - BatteryControl.powerChanged.connect(function(power) { - batteryModel.get(4).info = power + "w" + BatteryControl.powerChanged.connect(function (power) { + batteryModel.get(4).info = power + "w"; }); - BatteryControl.temperatureChanged.connect(function(temperature) { - batteryModel.get(5).info = parseFloat(temperature).toFixed(1) + BatteryControl.temperatureChanged.connect(function (temperature) { + batteryModel.get(5).info = parseFloat(temperature).toFixed(1); }); } } diff --git a/src/qml/pages/SettingPage.qml b/src/qml/pages/SettingPage.qml index 37cdbd4..ebd0903 100644 --- a/src/qml/pages/SettingPage.qml +++ b/src/qml/pages/SettingPage.qml @@ -198,6 +198,14 @@ ItemPage { } } + SettingItem { + title: "重启adb服务" + description: "若设备连接后程序无任何响应,可尝试重启adb服务解决" + controlItem: MButton { + text: "重启" + } + } + SettingItem { title: "夜间模式" description: "将所有控件设置为深色主题, 此功能开发中..."