[vlc-commits] qml: use dynamic Columns on KeyNavigableTableView
Abel Tesfaye
git at videolan.org
Tue Aug 20 18:21:19 CEST 2019
vlc | branch: master | Abel Tesfaye <Abeltesfaye45 at gmail.com> | Fri Aug 9 17:26:54 2019 +0300| [8d0aba3063b0d5fd75ec467bf9e71d45b86362a7] | committer: Jean-Baptiste Kempf
qml: use dynamic Columns on KeyNavigableTableView
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8d0aba3063b0d5fd75ec467bf9e71d45b86362a7
---
modules/gui/qt/qml/utils/KeyNavigableTableView.qml | 58 ++++++++++++++--------
1 file changed, 38 insertions(+), 20 deletions(-)
diff --git a/modules/gui/qt/qml/utils/KeyNavigableTableView.qml b/modules/gui/qt/qml/utils/KeyNavigableTableView.qml
index e0521e183b..41b3e621eb 100644
--- a/modules/gui/qt/qml/utils/KeyNavigableTableView.qml
+++ b/modules/gui/qt/qml/utils/KeyNavigableTableView.qml
@@ -19,8 +19,7 @@ import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQml.Models 2.2
import QtQuick.Layouts 1.3
-
-import org.videolan.medialib 0.1
+import QtGraphicalEffects 1.0
import "qrc:///utils/" as Utils
import "qrc:///style/"
@@ -30,8 +29,11 @@ NavigableFocusScope {
//forwarded from subview
signal actionForSelection( var selection )
+ signal contextMenuButtonClicked(Item menuParent, var menuModel)
+ signal rightClick(Item menuParent, var menuModel)
property var sortModel: ListModel { }
+ property Component colDelegate: Item { }
property var model: []
property alias contentHeight: view.contentHeight
@@ -47,6 +49,8 @@ NavigableFocusScope {
property color headerColor
property alias delegateModel: delegateModel
+ property real rowHeight: VLCStyle.fontHeight_normal + VLCStyle.margin_large
+ property alias spacing: view.spacing
Utils.SelectableDelegateModel {
id: delegateModel
@@ -61,30 +65,49 @@ NavigableFocusScope {
Package.name: "list"
id: lineView
- width: view.width
- height: VLCStyle.fontHeight_normal + VLCStyle.margin_large
-
- color: VLCStyle.colors.getBgColor(element.DelegateModel.inSelected, hoverArea.containsMouse, this.activeFocus)
+ width: root.width
+ height: root.rowHeight
+ color: VLCStyle.colors.bg
MouseArea {
id: hoverArea
anchors.fill: parent
hoverEnabled: true
+ Keys.onMenuPressed: root.contextMenuButtonClicked(contextButton,rowModel)
+ acceptedButtons: Qt.RightButton | Qt.LeftButton
+
onClicked: {
delegateModel.updateSelection( mouse.modifiers , view.currentIndex, index)
view.currentIndex = rowModel.index
lineView.forceActiveFocus()
+
+ if (mouse.button === Qt.RightButton){
+ root.rightClick(lineView,rowModel)
+ }
}
onDoubleClicked: {
actionForSelection(delegateModel.selectedGroup)
}
+ RectangularGlow {
+ visible: element.DelegateModel.inSelected || hoverArea.containsMouse
+ anchors.fill: parent
+ glowRadius: VLCStyle.margin_xxsmall
+ color: VLCStyle.colors.getBgColor(element.DelegateModel.inSelected, hoverArea.containsMouse, lineView.activeFocus)
+ }
+
+ Rectangle{
+ anchors.fill: parent
+ anchors.topMargin: VLCStyle.margin_xxsmall
+ anchors.bottomMargin: VLCStyle.margin_xxsmall
+ anchors.leftMargin: VLCStyle.margin_xxxsmall
+ anchors.rightMargin: VLCStyle.margin_xxxsmall
+ color: VLCStyle.colors.bg
Row {
anchors {
fill: parent
}
-
Repeater {
model: sortModel
@@ -92,23 +115,18 @@ NavigableFocusScope {
height: parent.height
width: model.width * view.width
Layout.alignment: Qt.AlignVCenter
+ Loader{
+ anchors.fill: parent
+ sourceComponent: colDelegate
- Text {
- text: rowModel[model.criteria]
- elide: Text.ElideRight
- font.pixelSize: VLCStyle.fontSize_normal
- color: VLCStyle.colors.text
+ property var rowModel: element.rowModel
+ property var colModel: model
- anchors {
- fill: parent
- leftMargin: VLCStyle.margin_xsmall
- rightMargin: VLCStyle.margin_xsmall
}
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignLeft
- }
+
}
}
+ }
}
}
}
@@ -152,7 +170,7 @@ NavigableFocusScope {
//Layout.alignment: Qt.AlignVCenter
Text {
- text: model.text
+ text: model.text || ""
elide: Text.ElideRight
font {
pixelSize: VLCStyle.fontSize_normal
More information about the vlc-commits
mailing list