[vlc-devel] [PATCH 4/5] qml: Add a spinbox

Rohan Rajpal rohan17089 at iiitd.ac.in
Fri Jun 28 11:46:06 CEST 2019


Add a generic spinbox
---
 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(+)
 create mode 100644 modules/gui/qt/qml/utils/SpinBoxExt.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 08ec11fc28..966dd37924 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -559,6 +559,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 5e53345ce9..aa6988cd1e 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -193,6 +193,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>
-- 
2.17.1



More information about the vlc-devel mailing list