Newer
Older
* 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.Controls.Universal 2.14
import QtQuick.Layouts 1.14
import QtQuick.Dialogs 1.3
import net.jami.Constants 1.0
import "../../commoncomponents"
Rectangle {
DEFAULT
}
property string pluginName: ""
property string pluginIcon: ""
property string pluginId: ""
property bool isLoaded: false
visible: false
target: PluginAdapter
function onPreferenceChanged(pluginId) {
if (root.pluginId == pluginId)
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
}
}
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)
PluginModel.resetPluginPreferencesValues(pluginId)
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
PluginAdapter.pluginHandlersUpdateStatus()
msgDialog.buttonCallBacks = [function () {
uninstallPlugin()
}]
msgDialog.openWithParameters(qsTr("Uninstall plugin"),
qsTr("Are you sure you wish to uninstall " + pluginName + " ?"))
PluginModel.uninstallPlugin(pluginId)
PluginAdapter.pluginHandlersUpdateStatus()
}
function setPreference(pluginId, preferenceKey, preferenceNewValue)
{
PluginModel.unloadPlugin(pluginId)
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
PluginModel.loadPlugin(pluginId)
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
PluginAdapter.pluginHandlersUpdateStatus()
SimpleMessageDialog {
id: msgDialog
buttonTitles: [qsTr("Ok"), qsTr("Cancel")]
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue,
SimpleMessageDialog.ButtonStyle.TintedBlack]
anchors.left: root.left
anchors.right: root.right
Label{
Layout.alignment: Qt.AlignHCenter
anchors.centerIn: parent
source: pluginIcon === "" ? "" : "file:" + pluginIcon
sourceSize: Qt.size(256, 256)
height: 48
width: 48
}
}
}
Label {
Layout.alignment: Qt.AlignHCenter
text: qsTr(pluginName + "\npreferences")
font.pointSize: JamiTheme.headerFontSize
color: JamiTheme.textColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
RowLayout {
Layout.topMargin: 10
Layout.preferredHeight: JamiTheme.preferredFieldHeight
color: JamiTheme.buttonTintedBlack
hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed
outlined: true
source: "qrc:/images/icons/settings_backup_restore-24px.svg"
Layout.preferredHeight: JamiTheme.preferredFieldHeight
color: JamiTheme.buttonTintedBlack
hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed
outlined: true
source: "qrc:/images/icons/delete-24px.svg"
onClicked: uninstallPluginSlot()
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height + 30
model: PluginAdapter.getPluginPreferencesModel(pluginId)
id: preferenceItemDelegate
width: pluginPreferenceView.width
preferenceName: PreferenceName
preferenceSummary: PreferenceSummary
preferenceType: PreferenceType
preferenceCurrentValue: PreferenceCurrentValue
pluginId: PluginId
currentPath: CurrentPath
preferenceKey: PreferenceKey
fileFilters: FileFilters
isImage: IsImage
pluginListPreferenceModel: PluginListPreferenceModel {
id: pluginListPreferenceModel
preferenceKey : PreferenceKey
pluginId: PluginId
}
setPreference(pluginId, preferenceKey, preferenceNewValue)
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
background: Rectangle {
anchors.fill: parent
color: JamiTheme.secondaryBackgroundColor