Rewrite HTile and adapt components using it
Rewrite HTile in a more standard way, hopefully fixing the mysterious segfault on some systems
This commit is contained in:
@@ -1,141 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
HButton {
|
||||
id: tile
|
||||
|
||||
|
||||
signal leftClicked()
|
||||
signal rightClicked()
|
||||
signal longPressed()
|
||||
|
||||
default property alias additionalData: contentItem.data
|
||||
|
||||
property bool compact: window.settings.compactMode
|
||||
property real contentOpacity: 1
|
||||
|
||||
readonly property alias title: title
|
||||
readonly property alias additionalInfo: additionalInfo
|
||||
readonly property alias rightInfo: rightInfo
|
||||
readonly property alias subtitle: subtitle
|
||||
readonly property Item loadedImage: imageLoader.item
|
||||
|
||||
property alias contextMenu: contextMenuLoader.sourceComponent
|
||||
|
||||
property Component image
|
||||
|
||||
|
||||
contentItem: HRowLayout {
|
||||
id: contentItem
|
||||
spacing: tile.spacing
|
||||
opacity: tile.contentOpacity
|
||||
|
||||
HLoader {
|
||||
id: imageLoader
|
||||
sourceComponent: image
|
||||
}
|
||||
|
||||
HColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
HRowLayout {
|
||||
spacing: tile.spacing
|
||||
|
||||
HLabel {
|
||||
id: title
|
||||
text: "Missing title"
|
||||
elide: Text.ElideRight
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
HLabel {
|
||||
id: rightInfo
|
||||
font.pixelSize: theme.fontSize.small
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
color: theme.colors.halfDimText
|
||||
visible: Layout.maximumWidth > 0
|
||||
|
||||
Layout.fillHeight: true
|
||||
Layout.maximumWidth:
|
||||
text && tile.width >= 200 * theme.uiScale ?
|
||||
implicitWidth : 0
|
||||
|
||||
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
||||
}
|
||||
|
||||
HRowLayout {
|
||||
id: additionalInfo
|
||||
visible: visibleChildren.length > 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HRichLabel {
|
||||
id: subtitle
|
||||
textFormat: Text.StyledText
|
||||
font.pixelSize: theme.fontSize.small
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
color: theme.colors.dimText
|
||||
visible: Layout.maximumHeight > 0
|
||||
|
||||
Layout.maximumHeight: ! compact && text ? implicitHeight : 0
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
Behavior on Layout.maximumHeight { HNumberAnimation {} }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binding on topPadding {
|
||||
value: spacing / 4
|
||||
when: compact
|
||||
}
|
||||
|
||||
Binding on bottomPadding {
|
||||
value: spacing / 4
|
||||
when: compact
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onTapped: leftClicked()
|
||||
onLongPressed: tile.longPressed()
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
acceptedPointerTypes: PointerDevice.GenericPointer | PointerDevice.Pen
|
||||
onTapped: {
|
||||
rightClicked()
|
||||
if (contextMenu) contextMenuLoader.active = true
|
||||
}
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedPointerTypes: PointerDevice.Finger | PointerDevice.Pen
|
||||
onLongPressed: {
|
||||
rightClicked()
|
||||
if (contextMenu) contextMenuLoader.active = true
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
enabled: contextMenuLoader.status === Loader.Ready
|
||||
target: contextMenuLoader.item
|
||||
onClosed: contextMenuLoader.active = false
|
||||
}
|
||||
|
||||
HLoader {
|
||||
id: contextMenuLoader
|
||||
active: false
|
||||
onLoaded: item.popup()
|
||||
}
|
||||
}
|
12
src/gui/Base/HTile/ContentRow.qml
Normal file
12
src/gui/Base/HTile/ContentRow.qml
Normal file
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import ".."
|
||||
|
||||
HRowLayout {
|
||||
spacing: tile.spacing
|
||||
opacity: tile.contentOpacity
|
||||
|
||||
|
||||
property HTile tile
|
||||
}
|
65
src/gui/Base/HTile/HTile.qml
Normal file
65
src/gui/Base/HTile/HTile.qml
Normal file
@@ -0,0 +1,65 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import ".."
|
||||
|
||||
HButton {
|
||||
id: tile
|
||||
|
||||
|
||||
signal leftClicked()
|
||||
signal rightClicked()
|
||||
signal longPressed()
|
||||
|
||||
|
||||
property bool compact: window.settings.compactMode
|
||||
property real contentOpacity: 1
|
||||
|
||||
property alias contextMenu: contextMenuLoader.sourceComponent
|
||||
|
||||
|
||||
Binding on topPadding {
|
||||
value: spacing / 4
|
||||
when: compact
|
||||
}
|
||||
|
||||
Binding on bottomPadding {
|
||||
value: spacing / 4
|
||||
when: compact
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onTapped: leftClicked()
|
||||
onLongPressed: tile.longPressed()
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
acceptedPointerTypes: PointerDevice.GenericPointer | PointerDevice.Pen
|
||||
onTapped: {
|
||||
rightClicked()
|
||||
if (contextMenu) contextMenuLoader.active = true
|
||||
}
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedPointerTypes: PointerDevice.Finger | PointerDevice.Pen
|
||||
onLongPressed: {
|
||||
rightClicked()
|
||||
if (contextMenu) contextMenuLoader.active = true
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
enabled: contextMenuLoader.status === Loader.Ready
|
||||
target: contextMenuLoader.item
|
||||
onClosed: contextMenuLoader.active = false
|
||||
}
|
||||
|
||||
HLoader {
|
||||
id: contextMenuLoader
|
||||
active: false
|
||||
onLoaded: item.popup()
|
||||
}
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import ".."
|
||||
|
||||
HTile {
|
||||
id: tile
|
24
src/gui/Base/HTile/SubtitleLabel.qml
Normal file
24
src/gui/Base/HTile/SubtitleLabel.qml
Normal file
@@ -0,0 +1,24 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import ".."
|
||||
|
||||
HRichLabel {
|
||||
textFormat: Text.StyledText
|
||||
font.pixelSize: theme.fontSize.small
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
color: theme.colors.dimText
|
||||
visible: Layout.maximumHeight > 0
|
||||
|
||||
Layout.maximumHeight: ! tile.compact && text ? implicitHeight : 0
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
|
||||
property HTile tile
|
||||
|
||||
|
||||
Behavior on Layout.maximumHeight { HNumberAnimation {} }
|
||||
}
|
13
src/gui/Base/HTile/TitleLabel.qml
Normal file
13
src/gui/Base/HTile/TitleLabel.qml
Normal file
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import ".."
|
||||
|
||||
HLabel {
|
||||
elide: Text.ElideRight
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
23
src/gui/Base/HTile/TitleRightInfoLabel.qml
Normal file
23
src/gui/Base/HTile/TitleRightInfoLabel.qml
Normal file
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import ".."
|
||||
|
||||
HLabel {
|
||||
font.pixelSize: theme.fontSize.small
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
color: theme.colors.halfDimText
|
||||
visible: Layout.maximumWidth > 0
|
||||
|
||||
Layout.fillHeight: true
|
||||
Layout.maximumWidth:
|
||||
text && tile.width >= 200 * theme.uiScale ?
|
||||
implicitWidth : 0
|
||||
|
||||
|
||||
property HTile tile
|
||||
|
||||
|
||||
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
||||
}
|
Reference in New Issue
Block a user