mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 14:55:43 +02:00
plugin: fix load/unload
Change-Id: If527d5c8ca3947943ac17ef627cb5bf73a4530bd
This commit is contained in:
parent
be70e36bf7
commit
72646960da
2 changed files with 36 additions and 30 deletions
|
@ -43,12 +43,14 @@ Rectangle {
|
||||||
|
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
function resetPluginSlot(){
|
signal uninstalled
|
||||||
|
|
||||||
|
function resetPluginSlot() {
|
||||||
resetPluginMessageBox.open()
|
resetPluginMessageBox.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetPlugin(){
|
function resetPlugin() {
|
||||||
if (isLoaded){
|
if (isLoaded) {
|
||||||
PluginModel.unloadPlugin(pluginId)
|
PluginModel.unloadPlugin(pluginId)
|
||||||
PluginModel.resetPluginPreferencesValues(pluginId)
|
PluginModel.resetPluginPreferencesValues(pluginId)
|
||||||
PluginModel.loadPlugin(pluginId)
|
PluginModel.loadPlugin(pluginId)
|
||||||
|
@ -58,27 +60,26 @@ Rectangle {
|
||||||
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstallPluginSlot(){
|
function uninstallPluginSlot() {
|
||||||
uninstallPluginMessageBox.open()
|
uninstallPluginMessageBox.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstallPlugin(){
|
function uninstallPlugin() {
|
||||||
PluginModel.uninstallPlugin(pluginId)
|
PluginModel.uninstallPlugin(pluginId)
|
||||||
|
uninstalled()
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPreference(pluginId, preferenceKey, preferenceNewValue)
|
function setPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
{
|
{
|
||||||
if (isLoaded){
|
if (isLoaded) {
|
||||||
PluginModel.unloadPlugin(pluginId)
|
PluginModel.unloadPlugin(pluginId)
|
||||||
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
PluginModel.loadPlugin(pluginId)
|
PluginModel.loadPlugin(pluginId)
|
||||||
}
|
} else
|
||||||
else {
|
|
||||||
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDialog{
|
MessageDialog {
|
||||||
id: uninstallPluginMessageBox
|
id: uninstallPluginMessageBox
|
||||||
|
|
||||||
title:qsTr("Uninstall plugin")
|
title:qsTr("Uninstall plugin")
|
||||||
|
@ -92,7 +93,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDialog{
|
MessageDialog {
|
||||||
id: resetPluginMessageBox
|
id: resetPluginMessageBox
|
||||||
|
|
||||||
title:qsTr("Reset preferences")
|
title:qsTr("Reset preferences")
|
||||||
|
|
|
@ -24,6 +24,7 @@ import QtQuick.Layouts 1.3
|
||||||
import Qt.labs.platform 1.1
|
import Qt.labs.platform 1.1
|
||||||
import QtGraphicalEffects 1.14
|
import QtGraphicalEffects 1.14
|
||||||
import net.jami.Models 1.0
|
import net.jami.Models 1.0
|
||||||
|
import net.jami.Adapters 1.0
|
||||||
import "../../commoncomponents"
|
import "../../commoncomponents"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -31,29 +32,37 @@ Rectangle {
|
||||||
|
|
||||||
property PluginListPreferencesView pluginListPreferencesView
|
property PluginListPreferencesView pluginListPreferencesView
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: pluginListPreferencesView
|
||||||
|
|
||||||
|
function onUninstalled() {
|
||||||
|
pluginListView.model = PluginAdapter.getPluginSelectableModel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
function openPluginFileSlot(){
|
function openPluginFileSlot() {
|
||||||
pluginPathDialog.open()
|
pluginPathDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPluginSlot(pluginId, isLoaded){
|
function loadPluginSlot(pluginId, isLoaded) {
|
||||||
var loaded = false
|
var loaded = false
|
||||||
if (isLoaded)
|
if (isLoaded)
|
||||||
PluginModel.unloadPlugin(pluginId)
|
PluginModel.unloadPlugin(pluginId)
|
||||||
else
|
else
|
||||||
loaded = PluginModel.loadPlugin(pluginId)
|
loaded = PluginModel.loadPlugin(pluginId)
|
||||||
if(pluginListPreferencesView.pluginId === pluginId)
|
if (pluginListPreferencesView.pluginId === pluginId)
|
||||||
pluginListPreferencesView.isLoaded = loaded
|
pluginListPreferencesView.isLoaded = loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
function openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded){
|
function openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded) {
|
||||||
if (pluginListPreferencesView.pluginId == pluginId || pluginListPreferencesView.pluginId == "")
|
if (pluginListPreferencesView.pluginId == pluginId || pluginListPreferencesView.pluginId == "")
|
||||||
pluginListPreferencesView.visible = !pluginListPreferencesView.visible
|
pluginListPreferencesView.visible = !pluginListPreferencesView.visible
|
||||||
|
|
||||||
if(!pluginListPreferencesView.visible){
|
if (!pluginListPreferencesView.visible) {
|
||||||
pluginListPreferencesView.pluginId = ""
|
pluginListPreferencesView.pluginId = ""
|
||||||
} else{
|
} else {
|
||||||
pluginListPreferencesView.pluginName = pluginName
|
pluginListPreferencesView.pluginName = pluginName
|
||||||
pluginListPreferencesView.pluginIcon = pluginIcon
|
pluginListPreferencesView.pluginIcon = pluginIcon
|
||||||
pluginListPreferencesView.pluginId = pluginId
|
pluginListPreferencesView.pluginId = pluginId
|
||||||
|
@ -61,7 +70,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hidePreferences(){
|
function hidePreferences() {
|
||||||
pluginListPreferencesView.pluginId = ""
|
pluginListPreferencesView.pluginId = ""
|
||||||
pluginListPreferencesView.visible = false
|
pluginListPreferencesView.visible = false
|
||||||
}
|
}
|
||||||
|
@ -79,6 +88,7 @@ Rectangle {
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
var url = UtilsAdapter.getAbsPath(file.toString())
|
var url = UtilsAdapter.getAbsPath(file.toString())
|
||||||
PluginModel.installPlugin(url, true)
|
PluginModel.installPlugin(url, true)
|
||||||
|
pluginListView.model = PluginAdapter.getPluginSelectableModel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,9 +127,7 @@ Rectangle {
|
||||||
|
|
||||||
text: qsTr("Install Plugin")
|
text: qsTr("Install Plugin")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: openPluginFileSlot()
|
||||||
openPluginFileSlot()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
|
@ -131,28 +139,25 @@ Rectangle {
|
||||||
|
|
||||||
model: PluginAdapter.getPluginSelectableModel()
|
model: PluginAdapter.getPluginSelectableModel()
|
||||||
|
|
||||||
delegate: PluginItemDelegate{
|
delegate: PluginItemDelegate {
|
||||||
id: pluginItemDelegate
|
id: pluginItemDelegate
|
||||||
|
|
||||||
width: pluginListView.width
|
width: pluginListView.width
|
||||||
height: 50
|
height: 50
|
||||||
|
|
||||||
pluginName : PluginName
|
pluginName: PluginName
|
||||||
pluginId: PluginId
|
pluginId: PluginId
|
||||||
pluginIcon: PluginIcon
|
pluginIcon: PluginIcon
|
||||||
isLoaded: IsLoaded
|
isLoaded: IsLoaded
|
||||||
|
|
||||||
onClicked: {
|
onClicked: pluginListView.currentIndex = index
|
||||||
pluginListView.currentIndex = index
|
|
||||||
}
|
|
||||||
|
|
||||||
onBtnLoadPluginToggled:{
|
onBtnLoadPluginToggled: {
|
||||||
loadPluginSlot(pluginId, isLoaded)
|
loadPluginSlot(pluginId, isLoaded)
|
||||||
|
pluginListView.model = PluginAdapter.getPluginSelectableModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
onBtnPreferencesPluginClicked:{
|
onBtnPreferencesPluginClicked: openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded)
|
||||||
openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue