Verified Commit df784d36 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applet: use less MouseArea in detail area

This slightly improves the efficiency.
parent debf4f53
Pipeline #209684 passed with stage
in 56 seconds
......@@ -6,7 +6,7 @@
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
import QtQuick 2.2
import QtQuick 2.15
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.3
......@@ -120,34 +120,44 @@ PlasmaExtras.ExpandableListItem {
}
// Details
GridLayout {
columns: 2
rowSpacing: PlasmaCore.Units.smallSpacing / 4
MouseArea {
Layout.fillWidth: true
Layout.preferredHeight: detailsGrid.implicitHeight
acceptedButtons: Qt.RightButton
onPressed: {
const item = detailsGrid.childAt(mouse.x, mouse.y);
if (!item || !item.isContent) {
return; // only let users copy the value on the right
}
contextMenu.show(this, item.text, mouse.x, mouse.y);
}
Repeater {
id: repeater
GridLayout {
id: detailsGrid
width: parent.width
columns: 2
rowSpacing: PlasmaCore.Units.smallSpacing / 4
model: currentDeviceDetails.length
Repeater {
id: repeater
PlasmaComponents3.Label {
id: detailLabel
model: currentDeviceDetails.length
Layout.fillWidth: true
PlasmaComponents3.Label {
id: detailLabel
readonly property bool isContent: index % 2
Layout.fillWidth: true
horizontalAlignment: isContent ? Text.AlignLeft : Text.AlignRight
elide: isContent ? Text.ElideRight : Text.ElideNone
font: PlasmaCore.Theme.smallestFont
opacity: isContent ? 1 : 0.6
text: isContent ? currentDeviceDetails[index] : `${currentDeviceDetails[index]}:`
textFormat: isContent ? Text.PlainText : Text.StyledText
readonly property bool isContent: index % 2
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onPressed: contextMenu.show(this, detailLabel.text, mouse.x, mouse.y)
enabled: parent.isContent // only let users copy the value on the right
horizontalAlignment: isContent ? Text.AlignLeft : Text.AlignRight
elide: isContent ? Text.ElideRight : Text.ElideNone
font: PlasmaCore.Theme.smallestFont
opacity: isContent ? 1 : 0.6
text: isContent ? currentDeviceDetails[index] : `${currentDeviceDetails[index]}:`
textFormat: isContent ? Text.PlainText : Text.StyledText
}
}
}
......
Supports Markdown
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