[vlc-devel] [RFC 70/82] qml: add a simple About dialog

Pierre Lamot pierre at videolabs.io
Fri Feb 1 14:02:14 CET 2019


---
 modules/gui/qt/Makefile.am         |   1 +
 modules/gui/qt/qml/about/About.qml | 170 +++++++++++++++++++++++++++++
 modules/gui/qt/vlc.qrc             |   3 +
 3 files changed, 174 insertions(+)
 create mode 100644 modules/gui/qt/qml/about/About.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 816f18a014..9276c066f3 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -522,6 +522,7 @@ libqt_plugin_la_RES = \
 	gui/qt/pixmaps/valid.svg \
 	gui/qt/pixmaps/search_clear.svg \
 	gui/qt/pixmaps/lock.svg \
+	gui/qt/qml/about/About.qml \
 	gui/qt/qml/utils/DNDLabel.qml \
 	gui/qt/qml/utils/ToolTipArea.qml \
 	gui/qt/qml/utils/Drawer.qml \
diff --git a/modules/gui/qt/qml/about/About.qml b/modules/gui/qt/qml/about/About.qml
new file mode 100644
index 0000000000..160601517f
--- /dev/null
+++ b/modules/gui/qt/qml/about/About.qml
@@ -0,0 +1,170 @@
+/*****************************************************************************
+ * 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 QtQuick.Layouts 1.3
+import org.videolan.medialib 0.1
+import org.videolan.vlc 0.1
+
+import "qrc:///style/"
+import "qrc:///utils/" as Utils
+
+Utils.NavigableFocusScope {
+    id: root
+    property alias columnLayout: columnLayout
+
+    AboutModel {
+        id: about
+    }
+
+    ButtonGroup {
+        buttons: columnLayout.children
+    }
+
+    RowLayout {
+        id: rowLayout
+        anchors.fill: parent
+        spacing: 0
+
+        Rectangle {
+
+            Layout.preferredWidth: columnLayout.implicitWidth
+            Layout.fillHeight: true
+            color: VLCStyle.colors.banner
+
+            ColumnLayout {
+                id: columnLayout
+                anchors.fill: parent
+
+                Utils.TextToolButton {
+                    id: authorsBtn
+                    text: qsTr("Authors")
+                    Layout.alignment: Qt.AlignLeft | Qt.AlignTop
+                    onClicked: {
+                        checked = true
+                        textArea.text = about.authors
+                    }
+                    KeyNavigation.down: licenseBtn
+                    KeyNavigation.right: textScroll
+                    focus: true
+                }
+
+                Utils.TextToolButton {
+                    id: licenseBtn
+                    text: qsTr("License")
+                    Layout.alignment: Qt.AlignLeft | Qt.AlignTop
+                    onClicked: textArea.text = about.license
+                    KeyNavigation.down: creditBtn
+                    KeyNavigation.right: textScroll
+                }
+
+                Utils.TextToolButton {
+                    id: creditBtn
+                    text: qsTr("Credit")
+                    Layout.alignment: Qt.AlignLeft | Qt.AlignTop
+                    KeyNavigation.down: backBtn
+                    KeyNavigation.right: textScroll
+
+                    onClicked: {
+                        checked = true
+                        textArea.text = about.thanks
+                    }
+                }
+
+                Item {
+                    Layout.fillHeight: true
+                }
+
+                Utils.IconToolButton {
+                    id: backBtn
+                    size: VLCStyle.icon_large
+                    text: VLCIcons.exit
+                    Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
+                    KeyNavigation.right: textScroll
+
+                    onClicked: {
+                        history.pop(History.Go)
+                    }
+                }
+            }
+        }
+
+
+        Rectangle {
+
+            Layout.fillWidth: true
+            Layout.fillHeight: true
+            Layout.alignment:  Qt.AlignHCenter
+
+            color: VLCStyle.colors.bg
+
+            ColumnLayout {
+                id: columnLayout1
+                anchors.fill: parent
+                anchors.margins: 10
+
+                Text {
+                    id: text1
+                    text: qsTr("VLC Media Player")
+                    color: VLCStyle.colors.text
+                    font.pixelSize: VLCStyle.fontSize_xxxlarge
+                }
+
+
+                Text {
+                    text: about.version
+                    color: VLCStyle.colors.text
+                    font.pixelSize: VLCStyle.fontSize_xlarge
+                }
+
+
+                ScrollView {
+                    id: textScroll
+                    Layout.fillHeight: true
+                    Layout.fillWidth: true
+                    Layout.alignment:  Qt.AlignHCenter
+
+                    Keys.onPressed:  {
+                        if (event.key === Qt.Key_Left) {
+                            backBtn.focus = true
+                            event.accepted = true
+                        }
+                    }
+
+                    clip: true
+
+                    Text {
+                        id: textArea
+                        text: about.thanks
+                        horizontalAlignment: Text.AlignHCenter
+                        anchors.fill: parent
+                        Layout.fillHeight: true
+                        Layout.fillWidth: true
+                        Layout.alignment: Qt.AlignHCenter
+
+                        color: VLCStyle.colors.text
+                        enabled: false
+                    }
+                }
+            }
+        }
+    }
+
+    Keys.priority: Keys.AfterItem
+    Keys.onPressed: defaultKeyAction(event, 0)
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index cfa72ada87..26d83acc34 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -185,4 +185,7 @@
         <file alias="VLCColors.qml">qml/style/VLCColors.qml</file>
         <file alias="VLCIcons.qml">qml/style/VLCIcons.qml</file>
     </qresource>
+    <qresource prefix="/about">
+        <file alias="About.qml">qml/about/About.qml</file>
+    </qresource>
 </RCC>
-- 
2.19.1



More information about the vlc-devel mailing list