[vlc-commits] qml: add ToolbarEditorDialog
Fatih Uzunoglu
git at videolan.org
Tue Apr 6 09:54:54 UTC 2021
vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Fri Apr 2 01:22:26 2021 +0300| [a1d9020d5a7fa7ef999bb7539a356af72a0898e9] | committer: Pierre Lamot
qml: add ToolbarEditorDialog
This patch brings a QML dialog to replace
the removed dialog. It should also fix the
dialog looking weird issue #25575 /
https://code.videolan.org/videolan/vlc/-/issues/25575
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a1d9020d5a7fa7ef999bb7539a356af72a0898e9
---
modules/gui/qt/Makefile.am | 1 +
.../qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml | 171 +++++++++++++++++++++
modules/gui/qt/vlc.qrc | 1 +
po/POTFILES.in | 1 +
4 files changed, 174 insertions(+)
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 287eb79ac6..7672343d3c 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -653,6 +653,7 @@ libqt_plugin_la_QML = \
gui/qt/dialogs/toolbar/qml/EditorDummyButton.qml \
gui/qt/dialogs/toolbar/qml/EditorTabButton.qml \
gui/qt/dialogs/toolbar/qml/ToolbarEditor.qml \
+ gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml \
gui/qt/dialogs/toolbar/qml/ToolbarEditorButtonList.qml \
gui/qt/maininterface/qml/BannerSources.qml \
gui/qt/maininterface/qml/MainInterface.qml \
diff --git a/modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml b/modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml
new file mode 100644
index 0000000000..2f01206e52
--- /dev/null
+++ b/modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml
@@ -0,0 +1,171 @@
+/*****************************************************************************
+ * 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.Controls 2.4
+import QtQuick.Layouts 1.11
+
+import "qrc:///widgets/" as Widgets
+import "qrc:///style/"
+
+import org.videolan.vlc 0.1
+
+WindowDialog {
+ id: root
+
+ width: 800
+ height: 600
+
+ modal: true
+ title: i18n.qtr("Toolbar Editor")
+
+ signal unload()
+
+ Component.onCompleted: {
+ // Save first, in case the dialog is rejected.
+ mainInterface.controlbarProfileModel.save(false)
+ }
+
+ onAccepted: {
+ mainInterface.controlbarProfileModel.save()
+ unload()
+ }
+
+ onRejected: {
+ // Load saved to discard the changes
+ mainInterface.controlbarProfileModel.reload()
+ unload()
+ }
+
+ function _markDirty(text) {
+ return (text += " *")
+ }
+
+ contentComponent: Item {
+ ColumnLayout {
+ anchors.fill: parent
+
+ RowLayout {
+ Widgets.MenuLabel {
+ Layout.fillWidth: true
+
+ text: i18n.qtr("Select profile:")
+ }
+
+ Widgets.ComboBoxExt {
+ id: comboBox
+ font.pixelSize: VLCStyle.fontSize_normal
+
+ width: VLCStyle.combobox_width_large
+ height: VLCStyle.combobox_height_normal
+
+ delegate: ItemDelegate {
+ width: comboBox.width
+ leftPadding: comboBox.leftPadding
+ background: Item {}
+ contentItem: Text {
+ text: model.dirty ? _markDirty(model.name)
+ : model.name
+ color: comboBox.color
+ font: comboBox.font
+ elide: Text.ElideRight
+ verticalAlignment: Text.AlignVCenter
+ }
+ highlighted: (comboBox.highlightedIndex === index)
+ }
+
+ displayText: {
+ var text
+
+ if (!!mainInterface.controlbarProfileModel.currentModel)
+ text = mainInterface.controlbarProfileModel.currentModel.name
+ else {
+ text = "N/A"
+ return text
+ }
+
+ if (mainInterface.controlbarProfileModel.currentModel.dirty)
+ return _markDirty(text)
+ else
+ return text
+ }
+
+ model: mainInterface.controlbarProfileModel
+
+ currentIndex: mainInterface.controlbarProfileModel.selectedProfile
+
+ onCurrentIndexChanged: {
+ mainInterface.controlbarProfileModel.selectedProfile = currentIndex
+ }
+
+ Accessible.name: i18n.qtr("Profiles")
+ }
+
+ Widgets.IconToolButton {
+ text: i18n.qtr("New Profile")
+ iconText: VLCIcons.profile_new
+
+ onClicked: {
+ var npDialog = dialogProvider.getTextDialog(null,
+ i18n.qtr("Profile Name"),
+ i18n.qtr("Please enter the new profile name:"),
+ i18n.qtr("Profile %1").arg(comboBox.count + 1))
+ if (!npDialog.ok)
+ return
+
+ mainInterface.controlbarProfileModel.cloneSelectedProfile(npDialog.text)
+ mainInterface.controlbarProfileModel.selectedProfile = (mainInterface.controlbarProfileModel.rowCount() - 1)
+ }
+
+ ToolTip.visible: hovered
+ }
+
+ Widgets.IconToolButton {
+ id: useDefaultButton
+
+ text: i18n.qtr("Use Default")
+ iconText: VLCIcons.history
+
+ onClicked: {
+ mainInterface.controlbarProfileModel.currentModel.injectDefaults(false)
+ }
+
+ ToolTip.visible: hovered
+ }
+
+ Widgets.IconToolButton {
+ text: i18n.qtr("Delete the current profile")
+ iconText: VLCIcons.del
+
+ onClicked: {
+ mainInterface.controlbarProfileModel.deleteSelectedProfile()
+ }
+
+ ToolTip.visible: hovered
+ }
+ }
+
+ // The main context of the toolbareditor dialog:
+ ToolbarEditor {
+ id: toolbarEditor
+
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+ }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 5ea2ae71b9..05bcc008c3 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -344,6 +344,7 @@
<file alias="EditorDNDDelegate.qml">dialogs/toolbar/qml/EditorDNDDelegate.qml</file>
<file alias="ToolbarEditorButtonList.qml">dialogs/toolbar/qml/ToolbarEditorButtonList.qml</file>
<file alias="ToolbarEditor.qml">dialogs/toolbar/qml/ToolbarEditor.qml</file>
+ <file alias="ToolbarEditorDialog.qml">dialogs/toolbar/qml/ToolbarEditorDialog.qml</file>
<file alias="EditorDNDView.qml">dialogs/toolbar/qml/EditorDNDView.qml</file>
<file alias="EditorTabButton.qml">dialogs/toolbar/qml/EditorTabButton.qml</file>
</qresource>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9648c2b60d..2631ce0715 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -804,6 +804,7 @@ 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/dialogs/toolbar/qml/ToolbarEditorDialog.qml
modules/gui/qt/maininterface/qml/BannerSources.qml
modules/gui/qt/maininterface/qml/MainDisplay.qml
modules/gui/qt/maininterface/qml/MainInterface.qml
More information about the vlc-commits
mailing list