[vlc-devel] [PATCH 06/21] qml: add TransparentSpinbox widget
Prince Gupta
guptaprince8832 at gmail.com
Fri Oct 23 15:21:00 CEST 2020
---
modules/gui/qt/Makefile.am | 1 +
modules/gui/qt/vlc.qrc | 1 +
.../gui/qt/widgets/qml/TransparentSpinBox.qml | 115 ++++++++++++++++++
3 files changed, 117 insertions(+)
create mode 100644 modules/gui/qt/widgets/qml/TransparentSpinBox.qml
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 68ca5682d9..b3d7f4c94f 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -717,6 +717,7 @@ libqt_plugin_la_QML = \
gui/qt/widgets/qml/PageLoader.qml \
gui/qt/widgets/qml/TabButtonExt.qml \
gui/qt/widgets/qml/TableColumns.qml \
+ gui/qt/widgets/qml/TransparentSpinBox.qml \
gui/qt/widgets/qml/TextToolButton.qml \
gui/qt/widgets/qml/ToolTipArea.qml \
gui/qt/widgets/qml/VideoProgressBar.qml \
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 5fc3971b45..37a424c4de 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -196,6 +196,7 @@
<file alias="DNDLabel.qml">widgets/qml/DNDLabel.qml</file>
<file alias="KeyNavigableTableView.qml">widgets/qml/KeyNavigableTableView.qml</file>
<file alias="TableColumns.qml">widgets/qml/TableColumns.qml</file>
+ <file alias="TransparentSpinBox.qml">widgets/qml/TransparentSpinBox.qml</file>
<file alias="NavigableFocusScope.qml">widgets/qml/NavigableFocusScope.qml</file>
<file alias="FocusBackground.qml">widgets/qml/FocusBackground.qml</file>
<file alias="ImageToolButton.qml">widgets/qml/ImageToolButton.qml</file>
diff --git a/modules/gui/qt/widgets/qml/TransparentSpinBox.qml b/modules/gui/qt/widgets/qml/TransparentSpinBox.qml
new file mode 100644
index 0000000000..45476e31ec
--- /dev/null
+++ b/modules/gui/qt/widgets/qml/TransparentSpinBox.qml
@@ -0,0 +1,115 @@
+
+/*****************************************************************************
+ * Copyright (C) 2020 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+import QtQuick.Templates 2.4 as T
+
+import "qrc:///widgets/" as Widgets
+import "qrc:///style/"
+
+T.SpinBox {
+ id: control
+
+ property color color: "white"
+ property int borderWidth: VLCStyle.dp(1, VLCStyle.scale)
+ property color borderColor: control.activeFocus
+ || control.hovered ? VLCStyle.colors.accent : Qt.rgba(
+ 1, 1, 1, .2)
+ value: 50
+ editable: true
+ from: 0
+ to: 99999
+ font.pixelSize: VLCStyle.fontSize_normal
+
+ contentItem: TextField {
+ z: 2
+ text: control.textFromValue(control.value, control.locale)
+ color: control.color
+ font: control.font
+ horizontalAlignment: Qt.AlignHCenter
+ verticalAlignment: Qt.AlignVCenter
+ readOnly: !control.editable
+ validator: control.validator
+ inputMethodHints: Qt.ImhFormattedNumbersOnly
+
+ background: Item {}
+ }
+
+ background: Rectangle {
+ implicitHeight: VLCStyle.dp(28, VLCStyle.scale)
+ implicitWidth: VLCStyle.dp(128, VLCStyle.scale)
+ color: "transparent"
+ border.width: control.borderWidth
+ border.color: control.borderColor
+ }
+
+ up.indicator: Label {
+ x: control.mirrored ? 0 : parent.width - width
+ z: 4
+ height: parent.height
+ width: implicitWidth
+ text: "\uff0b" // Full-width Plus
+ font.pixelSize: control.font.pixelSize
+ color: !control.up.pressed ? control.color : VLCStyle.colors.accent
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ padding: VLCStyle.margin_xsmall
+
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton
+ onPressed: {
+ control.up.pressed = true
+ control.increase()
+ mouse.accepted = true
+ }
+ onReleased: {
+ control.up.pressed = false
+ mouse.accepted = true
+ }
+ }
+ }
+
+ down.indicator: Label {
+ x: control.mirrored ? parent.width - width : 0
+ z: 4
+ height: parent.height
+ width: implicitWidth
+ text: "\uff0d" // Full-width Hyphen-minus
+ font.pixelSize: control.font.pixelSize
+ color: !control.down.pressed ? control.color : VLCStyle.colors.accent
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ padding: VLCStyle.margin_xsmall
+
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton
+ onPressed: {
+ control.down.pressed = true
+ control.decrease()
+ mouse.accepted = true
+ }
+ onReleased: {
+ control.down.pressed = false
+ mouse.accepted = true
+ }
+ }
+ }
+}
--
2.25.1
More information about the vlc-devel
mailing list