update
This commit is contained in:
+60
-30
@@ -4,46 +4,54 @@
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import org.deepin.ds 1.0
|
||||
import org.deepin.ds.dock 1.0
|
||||
|
||||
AppletItem {
|
||||
id: root
|
||||
objectName: "graphics driver applet"
|
||||
implicitWidth: Panel.rootObject.dockItemMaxSize
|
||||
implicitHeight: Panel.rootObject.dockItemMaxSize
|
||||
|
||||
property bool useColumnLayout: Panel.position % 2
|
||||
property int dockOrder: 20
|
||||
property int dockSize: Panel.rootObject.dockSize || 48
|
||||
|
||||
implicitWidth: useColumnLayout ? dockSize : 80
|
||||
implicitHeight: dockSize
|
||||
|
||||
property var applet: Applet
|
||||
|
||||
AppletItemButton {
|
||||
anchors.fill: parent
|
||||
PanelToolTip {
|
||||
id: toolTip
|
||||
text: qsTr("Graphics Driver Manager")
|
||||
toolTipX: DockPanelPositioner.x
|
||||
toolTipY: DockPanelPositioner.y
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#3498db"
|
||||
radius: 8
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "GPU"
|
||||
font.pixelSize: 12
|
||||
color: "white"
|
||||
HoverHandler {
|
||||
onHoveredChanged: {
|
||||
if (hovered && !driverPopup.popupVisible) {
|
||||
const point = root.mapToItem(null, root.width / 2, root.height / 2)
|
||||
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
|
||||
toolTip.open()
|
||||
} else {
|
||||
toolTip.close()
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
popup.visible = !popup.visible
|
||||
}
|
||||
}
|
||||
|
||||
Popup {
|
||||
id: popup
|
||||
x: 0
|
||||
y: -popup.height - 10
|
||||
PanelPopup {
|
||||
id: driverPopup
|
||||
width: 300
|
||||
height: 400
|
||||
closePolicy: Popup.CloseOnPressOutside
|
||||
height: 360
|
||||
popupX: DockPanelPositioner.x
|
||||
popupY: DockPanelPositioner.y
|
||||
|
||||
onPopupVisibleChanged: {
|
||||
if (popupVisible) {
|
||||
toolTip.close()
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
@@ -51,7 +59,7 @@ AppletItem {
|
||||
spacing: 12
|
||||
|
||||
Text {
|
||||
text: "Graphics Driver Manager"
|
||||
text: qsTr("Graphics Driver Manager")
|
||||
font.pixelSize: 16
|
||||
font.bold: true
|
||||
Layout.fillWidth: true
|
||||
@@ -65,7 +73,7 @@ AppletItem {
|
||||
|
||||
GroupBox {
|
||||
Layout.fillWidth: true
|
||||
title: "Device Information"
|
||||
title: qsTr("Device Information")
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
@@ -87,7 +95,7 @@ AppletItem {
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Refresh"
|
||||
text: qsTr("Refresh")
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
if (root.applet) {
|
||||
@@ -97,7 +105,7 @@ AppletItem {
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Test Install"
|
||||
text: qsTr("Test Install")
|
||||
Layout.fillWidth: true
|
||||
enabled: root.applet && !root.applet.isInstalling
|
||||
onClicked: {
|
||||
@@ -113,7 +121,7 @@ AppletItem {
|
||||
spacing: 8
|
||||
|
||||
Text {
|
||||
text: "Installing... " + (root.applet ? root.applet.installProgress + "%" : "0%")
|
||||
text: qsTr("Installing... ") + (root.applet ? root.applet.installProgress + "%" : "0%")
|
||||
font.pixelSize: 12
|
||||
}
|
||||
|
||||
@@ -123,7 +131,7 @@ AppletItem {
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Cancel"
|
||||
text: qsTr("Cancel")
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
if (root.applet) {
|
||||
@@ -137,6 +145,28 @@ AppletItem {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
DockPanelPositioner.bounding = Qt.binding(function () {
|
||||
const point = root.mapToItem(null, root.width / 2, root.height / 2)
|
||||
return Qt.rect(point.x, point.y, driverPopup.width, driverPopup.height)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||
|
||||
onTapped: {
|
||||
if (driverPopup.popupVisible) {
|
||||
driverPopup.close()
|
||||
} else {
|
||||
Panel.requestClosePopup()
|
||||
driverPopup.open()
|
||||
}
|
||||
toolTip.close()
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
||||
Reference in New Issue
Block a user