diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am index 287eb79ac61ad82c0aeffdcca15cfca9318f68ba..7672343d3c46267fd5e7c3299ff4666c9a40d5b0 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 0000000000000000000000000000000000000000..2f01206e526cb25fbc5647b2ca0d33c25b4705fc --- /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 5ea2ae71b997b01b160c5bc3df8a40ee1835a968..05bcc008c34b9e7adcd1e3f66abf6ba120513075 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 9648c2b60d4f41c9d1d34de4f3893df703155239..2631ce0715d7942f2f94f8b45cc586ad8c4ab24d 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