[vlc-commits] qml: Add a spinbox

Rohan Rajpal git at videolan.org
Tue Jul 16 10:43:35 CEST 2019


vlc | branch: master | Rohan Rajpal <rohan17089 at iiitd.ac.in> | Fri Jun 28 15:34:06 2019 +0530| [86bf4f02d3af8fccf2cd4927d3bd7d719746e1af] | committer: Jean-Baptiste Kempf

qml: Add a spinbox

Add a generic spinbox

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=86bf4f02d3af8fccf2cd4927d3bd7d719746e1af
---

 modules/gui/qt/Makefile.am              |  1 +
 modules/gui/qt/qml/utils/SpinBoxExt.qml | 86 +++++++++++++++++++++++++++++++++
 modules/gui/qt/vlc.qrc                  |  1 +
 3 files changed, 88 insertions(+)

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 17e4708fb0..d4e5193af0 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -562,6 +562,7 @@ libqt_plugin_la_QML = \
 	gui/qt/qml/utils/KeyNavigableTableView.qml \
 	gui/qt/qml/utils/SelectableDelegateModel.qml \
 	gui/qt/qml/utils/ComboBoxExt.qml \
+	gui/qt/qml/utils/SpinBoxExt.qml \
 	gui/qt/qml/utils/StackViewExt.qml \
 	gui/qt/qml/utils/ScanProgressBar.qml \
         gui/qt/qml/utils/SearchBox.qml \
diff --git a/modules/gui/qt/qml/utils/SpinBoxExt.qml b/modules/gui/qt/qml/utils/SpinBoxExt.qml
new file mode 100644
index 0000000000..a63cff23ce
--- /dev/null
+++ b/modules/gui/qt/qml/utils/SpinBoxExt.qml
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * Copyright (C) 2019 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 "qrc:///style/"
+
+SpinBox{
+    id: control
+    font.pixelSize: VLCStyle.fontSize_large
+
+    background: Rectangle {
+        implicitWidth: 4 * scale
+        implicitHeight: 32 * scale
+        border.color: VLCStyle.colors.buttonBorder
+        color: VLCStyle.colors.bg
+    }
+    contentItem: TextInput {
+        text: control.textFromValue(control.value, control.locale)
+
+        font: control.font
+        color: enabled ? VLCStyle.colors.buttonText : "grey"
+
+        horizontalAlignment: Qt.AlignRight
+        verticalAlignment: Qt.AlignVCenter
+        selectByMouse: true
+        autoScroll: false
+        readOnly: !control.editable
+        validator: control.validator
+    }
+    up.indicator: Rectangle {
+        x: parent.width - width
+        height: parent.height / 2
+        implicitWidth: 15 * scale
+        implicitHeight: 10 * scale
+        anchors.top: parent.top
+        color: control.up.pressed ? VLCStyle.colors.bgHover : VLCStyle.colors.bg
+        border.color: VLCStyle.colors.buttonBorder
+
+        Text {
+            text: "+"
+            font.pixelSize: control.font.pixelSize * 2
+            color: VLCStyle.colors.buttonText
+            anchors.fill: parent
+            fontSizeMode: Text.Fit
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
+        }
+    }
+
+    down.indicator: Rectangle {
+        x: parent.width - width
+        height: parent.height / 2
+        implicitWidth: 15 * scale
+        implicitHeight: 10 * scale
+        anchors.bottom: parent.bottom
+        color: control.down.pressed ? VLCStyle.colors.bgHover : VLCStyle.colors.bg
+        border.color: VLCStyle.colors.buttonBorder
+
+        Text {
+            text: "-"
+            font.pixelSize: control.font.pixelSize * 2
+            color: VLCStyle.colors.buttonText
+            anchors.fill: parent
+            fontSizeMode: Text.Fit
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
+        }
+    }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 311897bb5d..60b53c889f 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -191,6 +191,7 @@
         <file alias="IconToolButton.qml">qml/utils/IconToolButton.qml</file>
         <file alias="StackViewExt.qml">qml/utils/StackViewExt.qml</file>
         <file alias="ComboBoxExt.qml">qml/utils/ComboBoxExt.qml</file>
+        <file alias="SpinBoxExt.qml">qml/utils/SpinBoxExt.qml</file>
         <file alias="MenuExt.qml">qml/utils/MenuExt.qml</file>
         <file alias="MenuItemExt.qml">qml/utils/MenuItemExt.qml</file>
         <file alias="ExpandGridView.qml">qml/utils/ExpandGridView.qml</file>



More information about the vlc-commits mailing list