[vlc-devel] [PATCH 11/29] qml: add WindowDialog
Fatih Uzunoglu
fuzun54 at outlook.com
Thu Apr 1 22:22:23 UTC 2021
WindowDialog is a wrapper of QtQuick.Window which
provides a simple base for qml based dialogs. It
is intended to be an alternative to Qt.labs.platform
Dialog and Qt Quick Controls 2 Dialog.
---
modules/gui/qt/Makefile.am | 1 +
.../qt/dialogs/dialogs/qml/WindowDialog.qml | 101 ++++++++++++++++++
modules/gui/qt/vlc.qrc | 1 +
po/POTFILES.in | 1 +
4 files changed, 104 insertions(+)
create mode 100644 modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 5412589ca8..287eb79ac6 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -646,6 +646,7 @@ libqt_plugin_la_QML = \
gui/qt/dialogs/dialogs/qml/CustomDialog.qml \
gui/qt/dialogs/dialogs/qml/Dialogs.qml \
gui/qt/dialogs/dialogs/qml/ModalDialog.qml \
+ gui/qt/dialogs/dialogs/qml/WindowDialog.qml \
gui/qt/dialogs/help/qml/About.qml \
gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml \
gui/qt/dialogs/toolbar/qml/EditorDNDView.qml\
diff --git a/modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml b/modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
new file mode 100644
index 0000000000..053d7a6a7a
--- /dev/null
+++ b/modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * Copyright (C) 2021 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.Window 2.11
+import QtQuick.Layouts 1.11
+import QtQuick.Controls 2.4
+
+import "qrc:///widgets/" as Widgets
+import "qrc:///style/"
+
+Window {
+ id: root
+
+ flags: Qt.Dialog
+
+ property bool modal: false
+ modality: modal ? Qt.ApplicationModal : Qt.NonModal
+
+ width: VLCStyle.appWidth * 0.75
+ height: VLCStyle.appHeight * 0.85
+
+ title: i18n.qtr("Dialog")
+ color: VLCStyle.colors.bg
+
+ property alias contentComponent: loader.sourceComponent
+ property alias standardButtons: buttonBox.standardButtons
+
+ signal accepted()
+ signal rejected(bool byButton)
+ signal applied()
+ signal discarded()
+ signal reset()
+
+ onAccepted: hide()
+ onRejected: if (byButton) hide()
+ onApplied: hide()
+ onDiscarded: hide()
+ onReset: hide()
+
+ onClosing: {
+ rejected(false)
+ }
+
+ function open() {
+ show()
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+ anchors.margins: VLCStyle.margin_small
+
+ Loader {
+ id: loader
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+
+ clip: true
+ sourceComponent: contentComponent
+ }
+
+ DialogButtonBox {
+ id: buttonBox
+
+ bottomPadding: 0
+ topPadding: 0
+ padding: VLCStyle.margin_small
+ spacing: VLCStyle.margin_small
+
+ Layout.fillWidth: true
+ Layout.minimumHeight: VLCStyle.icon_normal
+
+ standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
+
+ onAccepted: root.accepted()
+ onRejected: root.rejected(true)
+ onApplied: root.applied()
+ onDiscarded: root.discarded()
+ onReset: root.reset()
+
+ // Customize DialogButtonBox so that it matches with the app theme
+ background: Item { }
+ delegate: Widgets.TextToolButton { }
+ }
+ }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 3cda8faf6c..5ea2ae71b9 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -339,6 +339,7 @@
<file alias="CustomDialog.qml">dialogs/dialogs/qml/CustomDialog.qml</file>
<file alias="Dialogs.qml">dialogs/dialogs/qml/Dialogs.qml</file>
<file alias="ModalDialog.qml">dialogs/dialogs/qml/ModalDialog.qml</file>
+ <file alias="WindowDialog.qml">dialogs/dialogs/qml/WindowDialog.qml</file>
<file alias="EditorDummyButton.qml">dialogs/toolbar/qml/EditorDummyButton.qml</file>
<file alias="EditorDNDDelegate.qml">dialogs/toolbar/qml/EditorDNDDelegate.qml</file>
<file alias="ToolbarEditorButtonList.qml">dialogs/toolbar/qml/ToolbarEditorButtonList.qml</file>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0df7774a5e..9648c2b60d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -801,6 +801,7 @@ modules/gui/qt/util/validators.cpp
modules/gui/qt/util/validators.hpp
modules/gui/qt/dialogs/dialogs/qml/CustomDialog.qml
modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
+modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
modules/gui/qt/dialogs/help/qml/About.qml
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditor.qml
modules/gui/qt/maininterface/qml/BannerSources.qml
--
2.27.0
More information about the vlc-devel
mailing list