2020-09-03 21:19:10 -04:00
|
|
|
/*
|
2020-08-10 17:36:47 -04:00
|
|
|
* Copyright (C) 2020 by Savoir-faire Linux
|
|
|
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
2020-08-03 13:27:42 -04:00
|
|
|
*
|
|
|
|
* 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.15
|
|
|
|
import QtQuick.Window 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Controls.Universal 2.12
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import Qt.labs.platform 1.1
|
2020-08-18 17:41:05 -04:00
|
|
|
import QtQuick.Dialogs 1.3
|
2020-08-03 13:27:42 -04:00
|
|
|
import QtGraphicalEffects 1.14
|
|
|
|
import net.jami.Models 1.0
|
|
|
|
import "../../commoncomponents"
|
|
|
|
|
|
|
|
Rectangle {
|
2020-08-18 17:41:05 -04:00
|
|
|
id: root
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
enum Type {
|
|
|
|
LIST,
|
2020-09-01 18:19:22 -04:00
|
|
|
PATH,
|
2020-08-03 13:27:42 -04:00
|
|
|
DEFAULT
|
|
|
|
}
|
|
|
|
|
|
|
|
property string pluginName: ""
|
|
|
|
property string pluginIcon: ""
|
|
|
|
property string pluginId: ""
|
|
|
|
property bool isLoaded: false
|
|
|
|
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
function resetPluginSlot(){
|
|
|
|
resetPluginMessageBox.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetPlugin(){
|
2020-08-18 17:41:05 -04:00
|
|
|
if (isLoaded){
|
2020-09-04 17:53:24 -04:00
|
|
|
PluginModel.unloadPlugin(pluginId)
|
|
|
|
PluginModel.resetPluginPreferencesValues(pluginId)
|
|
|
|
PluginModel.loadPlugin(pluginId)
|
2020-08-18 17:41:05 -04:00
|
|
|
} else {
|
2020-09-04 17:53:24 -04:00
|
|
|
PluginModel.resetPluginPreferencesValues(pluginId)
|
2020-08-18 17:41:05 -04:00
|
|
|
}
|
2020-09-01 18:19:22 -04:00
|
|
|
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function uninstallPluginSlot(){
|
|
|
|
uninstallPluginMessageBox.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
function uninstallPlugin(){
|
2020-09-04 17:53:24 -04:00
|
|
|
PluginModel.uninstallPlugin(pluginId)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function setPreference(pluginId, preferenceKey, preferenceNewValue)
|
|
|
|
{
|
2020-08-18 17:41:05 -04:00
|
|
|
if (isLoaded){
|
2020-09-04 17:53:24 -04:00
|
|
|
PluginModel.unloadPlugin(pluginId)
|
|
|
|
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
|
|
|
PluginModel.loadPlugin(pluginId)
|
2020-08-18 17:41:05 -04:00
|
|
|
}
|
|
|
|
else {
|
2020-09-04 17:53:24 -04:00
|
|
|
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
2020-08-18 17:41:05 -04:00
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
2020-08-18 17:41:05 -04:00
|
|
|
MessageDialog{
|
2020-08-03 13:27:42 -04:00
|
|
|
id: uninstallPluginMessageBox
|
|
|
|
|
|
|
|
title:qsTr("Uninstall plugin")
|
|
|
|
text :qsTr("Are you sure you wish to uninstall " + pluginName + " ?")
|
2020-08-18 17:41:05 -04:00
|
|
|
icon: StandardIcon.Warning
|
2020-08-03 13:27:42 -04:00
|
|
|
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
|
|
|
|
|
|
|
onAccepted: {
|
|
|
|
uninstallPlugin()
|
2020-08-18 17:41:05 -04:00
|
|
|
root.visible = false
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-18 17:41:05 -04:00
|
|
|
MessageDialog{
|
2020-08-03 13:27:42 -04:00
|
|
|
id: resetPluginMessageBox
|
|
|
|
|
|
|
|
title:qsTr("Reset preferences")
|
|
|
|
text :qsTr("Are you sure you wish to reset "+ pluginName + " preferences?")
|
2020-08-18 17:41:05 -04:00
|
|
|
icon: StandardIcon.Warning
|
2020-08-03 13:27:42 -04:00
|
|
|
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
|
|
|
|
2020-08-18 17:41:05 -04:00
|
|
|
onAccepted: resetPlugin()
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
2020-08-18 17:41:05 -04:00
|
|
|
anchors.left: root.left
|
|
|
|
anchors.right: root.right
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
Label{
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2020-09-03 21:19:10 -04:00
|
|
|
background: Rectangle {
|
2020-08-03 13:27:42 -04:00
|
|
|
Image {
|
2020-08-18 17:41:05 -04:00
|
|
|
anchors.centerIn: parent
|
2020-09-03 21:19:10 -04:00
|
|
|
source: pluginIcon === "" ? "" : "file:" + pluginIcon
|
2020-08-18 17:41:05 -04:00
|
|
|
height: 35
|
|
|
|
width: 35
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.topMargin: 10
|
|
|
|
|
|
|
|
text: qsTr(pluginName + "\npreferences")
|
2020-08-18 17:41:05 -04:00
|
|
|
font.pointSize: JamiTheme.headerFontSize
|
2020-08-03 13:27:42 -04:00
|
|
|
font.kerning: true
|
|
|
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.topMargin: 10
|
2020-08-18 17:41:05 -04:00
|
|
|
height: 30
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
HoverableRadiusButton {
|
|
|
|
id: resetButton
|
2020-08-18 17:41:05 -04:00
|
|
|
Layout.fillWidth: true
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
radius: height / 2
|
|
|
|
|
|
|
|
icon.source: "qrc:/images/icons/settings_backup_restore-black-18dp.svg"
|
|
|
|
icon.height: 24
|
|
|
|
icon.width: 24
|
|
|
|
|
2020-08-18 17:41:05 -04:00
|
|
|
text: qsTr(" Reset ")
|
|
|
|
fontPointSize: JamiTheme.settingsFontSize
|
2020-08-03 13:27:42 -04:00
|
|
|
font.kerning: true
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
resetPluginSlot()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HoverableRadiusButton {
|
|
|
|
id: uninstallButton
|
2020-08-18 17:41:05 -04:00
|
|
|
Layout.fillWidth: true
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
radius: height / 2
|
|
|
|
|
|
|
|
icon.source: "qrc:/images/icons/ic_delete_black_18dp_2x.png"
|
|
|
|
icon.height: 24
|
|
|
|
icon.width: 24
|
|
|
|
|
|
|
|
text: qsTr("Uninstall")
|
2020-08-18 17:41:05 -04:00
|
|
|
fontPointSize: JamiTheme.settingsFontSize
|
2020-08-03 13:27:42 -04:00
|
|
|
font.kerning: true
|
|
|
|
|
2020-08-18 17:41:05 -04:00
|
|
|
onClicked: uninstallPluginSlot()
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-18 17:41:05 -04:00
|
|
|
ListView {
|
2020-08-03 13:27:42 -04:00
|
|
|
id: pluginPreferenceView
|
|
|
|
|
2020-08-18 17:41:05 -04:00
|
|
|
Layout.fillWidth: true
|
2020-08-03 13:27:42 -04:00
|
|
|
Layout.minimumHeight: 0
|
2020-08-18 17:41:05 -04:00
|
|
|
Layout.preferredHeight: childrenRect.height + 30
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-01 18:19:22 -04:00
|
|
|
model: PluginAdapter.getPluginPreferencesModel(pluginId)
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
delegate: PreferenceItemDelegate{
|
|
|
|
id: preferenceItemDelegate
|
|
|
|
|
|
|
|
width: pluginPreferenceView.width
|
2020-09-01 18:19:22 -04:00
|
|
|
height: childrenRect.height
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
preferenceName: PreferenceName
|
|
|
|
preferenceSummary: PreferenceSummary
|
|
|
|
preferenceType: PreferenceType
|
2020-08-18 17:41:05 -04:00
|
|
|
preferenceCurrentValue: PreferenceCurrentValue
|
|
|
|
pluginId: PluginId
|
2020-09-01 18:19:22 -04:00
|
|
|
currentPath: CurrentPath
|
|
|
|
preferenceKey: PreferenceKey
|
|
|
|
fileFilters: FileFilters
|
|
|
|
isImage: IsImage
|
2020-08-18 17:41:05 -04:00
|
|
|
pluginListPreferenceModel: PluginListPreferenceModel{
|
|
|
|
id: pluginListPreferenceModel
|
|
|
|
preferenceKey : PreferenceKey
|
|
|
|
pluginId: PluginId
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
pluginPreferenceView.currentIndex = index
|
|
|
|
}
|
|
|
|
onBtnPreferenceClicked: {
|
2020-09-01 18:19:22 -04:00
|
|
|
setPreference(pluginId, preferenceKey, preferenceNewValue)
|
|
|
|
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|