1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-10 09:45:40 +02:00
jami-client-qt/src/settingsview/components/PluginListPreferencesView.qml
Ming Rui Zhang fcb56bfb87 misc: qml module import clean up
The main reason for this change is to remove the misusage
of QQuick one in ElidedTextLabel and useless QQuick one
module import

Change-Id: Ie296c0f7a90c6ec26ab85bcf3d8b75393463fbed
2021-03-25 14:40:22 -04:00

234 lines
7.2 KiB
QML

/*
* Copyright (C) 2020 by Savoir-faire Linux
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Controls.Universal 2.14
import QtQuick.Layouts 1.14
import Qt.labs.platform 1.1
import QtQuick.Dialogs 1.3
import QtGraphicalEffects 1.14
import net.jami.Adapters 1.0
import net.jami.Models 1.0
import net.jami.Constants 1.0
import "../../commoncomponents"
Rectangle {
id: root
enum Type {
LIST,
PATH,
EDITTEXT,
DEFAULT
}
property string pluginName: ""
property string pluginIcon: ""
property string pluginId: ""
property bool isLoaded: false
visible: false
color: "transparent"
signal uninstalled
Connections {
target: PluginAdapter
function onPreferenceChanged(pluginId) {
if (root.pluginId == pluginId)
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
}
}
function resetPluginSlot() {
msgDialog.buttonCallBacks = [function () {
resetPlugin()
}]
msgDialog.openWithParameters(qsTr("Reset preferences"),
qsTr("Are you sure you wish to reset "+ pluginName +
" preferences?"))
}
function resetPlugin() {
if (isLoaded) {
PluginModel.unloadPlugin(pluginId)
PluginModel.resetPluginPreferencesValues(pluginId)
PluginModel.loadPlugin(pluginId)
} else {
PluginModel.resetPluginPreferencesValues(pluginId)
}
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
PluginAdapter.pluginHandlersUpdateStatus()
}
function uninstallPluginSlot() {
msgDialog.buttonCallBacks = [function () {
uninstallPlugin()
}]
msgDialog.openWithParameters(qsTr("Uninstall plugin"),
qsTr("Are you sure you wish to uninstall " + pluginName + " ?"))
}
function uninstallPlugin() {
PluginModel.uninstallPlugin(pluginId)
PluginAdapter.pluginUninstalled()
PluginAdapter.pluginHandlersUpdateStatus()
root.visible = false
}
function setPreference(pluginId, preferenceKey, preferenceNewValue)
{
if (isLoaded) {
PluginModel.unloadPlugin(pluginId)
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
PluginModel.loadPlugin(pluginId)
} else
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
PluginAdapter.pluginHandlersUpdateStatus()
}
SimpleMessageDialog {
id: msgDialog
buttonTitles: [qsTr("Ok"), qsTr("Cancel")]
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue,
SimpleMessageDialog.ButtonStyle.TintedBlack]
}
ColumnLayout {
anchors.left: root.left
anchors.right: root.right
Label{
Layout.alignment: Qt.AlignHCenter
background: Rectangle {
Image {
anchors.centerIn: parent
source: pluginIcon === "" ? "" : "file:" + pluginIcon
sourceSize: Qt.size(256, 256)
height: 48
width: 48
mipmap: true
}
}
}
Label {
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 16
text: qsTr(pluginName + "\npreferences")
font.pointSize: JamiTheme.headerFontSize
font.kerning: true
color: JamiTheme.textColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
RowLayout {
Layout.topMargin: 10
height: 30
MaterialButton {
id: resetButton
Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.preferredFieldHeight
color: JamiTheme.buttonTintedBlack
hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed
outlined: true
source: "qrc:/images/icons/settings_backup_restore-24px.svg"
text: JamiStrings.reset
onClicked: resetPluginSlot()
}
MaterialButton {
id: uninstallButton
Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.preferredFieldHeight
color: JamiTheme.buttonTintedBlack
hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed
outlined: true
source: "qrc:/images/icons/delete-24px.svg"
text: qsTr("Uninstall")
onClicked: uninstallPluginSlot()
}
}
ListView {
id: pluginPreferenceView
Layout.fillWidth: true
Layout.minimumHeight: 1
Layout.preferredHeight: childrenRect.height + 30
model: PluginAdapter.getPluginPreferencesModel(pluginId)
interactive: false
delegate: PreferenceItemDelegate {
id: preferenceItemDelegate
width: pluginPreferenceView.width
height: 50
preferenceName: PreferenceName
preferenceSummary: PreferenceSummary
preferenceType: PreferenceType
preferenceCurrentValue: PreferenceCurrentValue
pluginId: PluginId
currentPath: CurrentPath
preferenceKey: PreferenceKey
fileFilters: FileFilters
isImage: IsImage
pluginListPreferenceModel: PluginListPreferenceModel {
id: pluginListPreferenceModel
lrcInstance: LRCInstance
preferenceKey : PreferenceKey
pluginId: PluginId
}
onBtnPreferenceClicked: {
setPreference(pluginId, preferenceKey, preferenceNewValue)
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
}
background: Rectangle {
anchors.fill: parent
color: JamiTheme.secondaryBackgroundColor
}
}
}
}
}