1
mirror of https://code.videolan.org/videolan/vlc synced 2024-08-27 04:21:53 +02:00

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@videolabs.io>
This commit is contained in:
Fatih Uzunoglu 2021-04-02 01:22:26 +03:00 committed by Pierre Lamot
parent f1fbc0265c
commit a1d9020d5a
4 changed files with 174 additions and 0 deletions

View File

@ -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 \

View File

@ -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
}
}
}
}

View File

@ -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>

View File

@ -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