154 lines
4.0 KiB
QML
154 lines
4.0 KiB
QML
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
|
//
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
import QtQuick 2.15
|
|
import QtQuick.Controls 2.15
|
|
import QtQuick.Layouts 1.15
|
|
import org.deepin.ds 1.0
|
|
|
|
ContainmentItem {
|
|
id: root
|
|
objectName: "graphics driver applet"
|
|
implicitWidth: 56
|
|
implicitHeight: 56
|
|
property int dockOrder: 20
|
|
|
|
property var applet: Applet
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
color: "#3498db"
|
|
radius: 8
|
|
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: "GPU"
|
|
font.pixelSize: 14
|
|
color: "white"
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: {
|
|
popup.visible = !popup.visible
|
|
}
|
|
}
|
|
}
|
|
|
|
Popup {
|
|
id: popup
|
|
x: 0
|
|
y: -popup.height - 10
|
|
width: 300
|
|
height: 400
|
|
closePolicy: Popup.CloseOnPressOutside
|
|
|
|
ColumnLayout {
|
|
anchors.fill: parent
|
|
anchors.margins: 16
|
|
spacing: 12
|
|
|
|
Text {
|
|
text: "Graphics Driver Manager"
|
|
font.pixelSize: 16
|
|
font.bold: true
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
Rectangle {
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: 1
|
|
color: "#ccc"
|
|
}
|
|
|
|
GroupBox {
|
|
Layout.fillWidth: true
|
|
title: "Device Information"
|
|
|
|
ColumnLayout {
|
|
anchors.fill: parent
|
|
spacing: 8
|
|
|
|
Text {
|
|
text: "Current Driver: " + (root.applet ? root.applet.currentDriver || "Unknown" : "Unknown")
|
|
font.pixelSize: 12
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
Text {
|
|
text: "Device Info: " + (root.applet ? root.applet.deviceInfo || "Unknown" : "Unknown")
|
|
font.pixelSize: 12
|
|
wrapMode: Text.WordWrap
|
|
Layout.fillWidth: true
|
|
}
|
|
}
|
|
}
|
|
|
|
Button {
|
|
text: "Refresh"
|
|
Layout.fillWidth: true
|
|
onClicked: {
|
|
if (root.applet) {
|
|
root.applet.refreshDeviceInfo()
|
|
}
|
|
}
|
|
}
|
|
|
|
Button {
|
|
text: "Test Install"
|
|
Layout.fillWidth: true
|
|
enabled: root.applet && !root.applet.isInstalling
|
|
onClicked: {
|
|
if (root.applet) {
|
|
root.applet.testInstall()
|
|
}
|
|
}
|
|
}
|
|
|
|
ColumnLayout {
|
|
visible: root.applet && root.applet.isInstalling
|
|
Layout.fillWidth: true
|
|
spacing: 8
|
|
|
|
Text {
|
|
text: "Installing... " + (root.applet ? root.applet.installProgress + "%" : "0%")
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
ProgressBar {
|
|
Layout.fillWidth: true
|
|
value: root.applet ? root.applet.installProgress / 100 : 0
|
|
}
|
|
|
|
Button {
|
|
text: "Cancel"
|
|
Layout.fillWidth: true
|
|
onClicked: {
|
|
if (root.applet) {
|
|
root.applet.cancelInstall()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Item {
|
|
Layout.fillHeight: true
|
|
}
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: root.applet
|
|
function onInstallSuccess() {
|
|
console.log("Install succeeded")
|
|
}
|
|
function onInstallFailed(error) {
|
|
console.log("Install failed:", error)
|
|
}
|
|
function onRequestReboot() {
|
|
console.log("Reboot requested")
|
|
}
|
|
}
|
|
}
|