plugin: implement PATH preference

Change-Id: If86856104409c9c6f8402e0c9229481d18c5b84f
diff --git a/src/settingsview/components/PluginItemDelegate.qml b/src/settingsview/components/PluginItemDelegate.qml
index ce8f736..c9e6a5c 100644
--- a/src/settingsview/components/PluginItemDelegate.qml
+++ b/src/settingsview/components/PluginItemDelegate.qml
@@ -120,7 +120,7 @@
             }
 
             ToolTip.visible: hovered
-            ToolTip.text: qsTr("Show preferences")
+            ToolTip.text: qsTr("Show/Hide preferences")
 
             onClicked: btnPreferencesPluginClicked()
         }
diff --git a/src/settingsview/components/PluginListPreferencesView.qml b/src/settingsview/components/PluginListPreferencesView.qml
index 6e3f584..9d0eb1c 100644
--- a/src/settingsview/components/PluginListPreferencesView.qml
+++ b/src/settingsview/components/PluginListPreferencesView.qml
@@ -32,12 +32,10 @@
 
     enum Type {
         LIST,
-        USERLIST,
+        PATH,
         DEFAULT
     }
 
-    signal updatePluginList
-
     property string pluginName: ""
     property string pluginIcon: ""
     property string pluginId: ""
@@ -45,14 +43,6 @@
 
     visible: false
 
-    function updatePreferenceListDisplayed(){
-        // settings
-        preferenceItemListModel.pluginId = pluginId
-        preferenceItemListModel.reset()
-        var size = 50 * preferenceItemListModel.preferencesCount
-        pluginPreferenceView.height = size
-    }
-
     function resetPluginSlot(){
         resetPluginMessageBox.open()
     }
@@ -65,8 +55,7 @@
         } else {
             ClientWrapper.pluginModel.resetPluginPreferencesValues(pluginId)
         }
-        updatePluginList()
-        updatePreferenceListDisplayed()
+        pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
     }
 
     function uninstallPluginSlot(){
@@ -75,7 +64,6 @@
 
     function uninstallPlugin(){
         ClientWrapper.pluginModel.uninstallPlugin(pluginId)
-        updatePluginList()
     }
 
     function setPreference(pluginId, preferenceKey, preferenceNewValue)
@@ -115,10 +103,6 @@
         onAccepted: resetPlugin()
     }
 
-    PreferenceItemListModel {
-        id: preferenceItemListModel
-    }
-
     ColumnLayout {
         anchors.left: root.left
         anchors.right: root.right
@@ -195,19 +179,23 @@
             Layout.minimumHeight: 0
             Layout.preferredHeight: childrenRect.height + 30
 
-            model: preferenceItemListModel
+            model: PluginAdapter.getPluginPreferencesModel(pluginId)
 
             delegate: PreferenceItemDelegate{
                 id: preferenceItemDelegate
 
                 width: pluginPreferenceView.width
-                height: 50
+                height: childrenRect.height
 
                 preferenceName: PreferenceName
                 preferenceSummary: PreferenceSummary
                 preferenceType: PreferenceType
                 preferenceCurrentValue: PreferenceCurrentValue
                 pluginId: PluginId
+                currentPath: CurrentPath
+                preferenceKey: PreferenceKey
+                fileFilters: FileFilters
+                isImage: IsImage
                 pluginListPreferenceModel: PluginListPreferenceModel{
                     id: pluginListPreferenceModel
                     preferenceKey : PreferenceKey
@@ -218,12 +206,9 @@
                     pluginPreferenceView.currentIndex = index
                 }
                 onBtnPreferenceClicked: {
-                    setPreference(pluginListPreferenceModel.pluginId,
-                                  pluginListPreferenceModel.preferenceKey,
-                                  pluginListPreferenceModel.preferenceNewValue)
-                    updatePreferenceListDisplayed()
+                    setPreference(pluginId, preferenceKey, preferenceNewValue)
+                    pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
                 }
-                onPreferenceAdded: preferenceItemListModel.reset()
             }
         }
     }
diff --git a/src/settingsview/components/PluginListSettingsView.qml b/src/settingsview/components/PluginListSettingsView.qml
index 389ab4f..3d1c1f1 100644
--- a/src/settingsview/components/PluginListSettingsView.qml
+++ b/src/settingsview/components/PluginListSettingsView.qml
@@ -33,13 +33,6 @@
 
     visible: false
 
-    function updatePluginListDisplayed() {
-        // settings
-        pluginItemListModel.reset()
-        var size = 50 * pluginItemListModel.pluginsCount
-        pluginListView.height = size + 15
-    }
-
     function openPluginFileSlot(){
         pluginPathDialog.open()
     }
@@ -52,7 +45,6 @@
             loaded = ClientWrapper.pluginModel.loadPlugin(pluginId)
         if(pluginListPreferencesView.pluginId === pluginId)
             pluginListPreferencesView.isLoaded = loaded
-        updatePluginListDisplayed()
     }
 
     function openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded){
@@ -67,13 +59,11 @@
             pluginListPreferencesView.pluginId = pluginId
             pluginListPreferencesView.isLoaded = isLoaded
         }
-        pluginListPreferencesView.updatePreferenceListDisplayed()
     }
 
     function hidePreferences(){
         pluginListPreferencesView.pluginId = ""
         pluginListPreferencesView.visible = false
-        pluginListPreferencesView.updatePreferenceListDisplayed()
     }
 
     JamiFileDialog {
@@ -97,7 +87,6 @@
         onAccepted: {
             var url = ClientWrapper.utilsAdaptor.getAbsPath(file.toString())
             ClientWrapper.pluginModel.installPlugin(url, true)
-            updatePluginListDisplayed()
         }
     }
 
@@ -122,8 +111,8 @@
             id: installButton
 
             Layout.alignment: Qt.AlignCenter
-            Layout.preferredWidth: preferredWidth
-            Layout.preferredHeight: preferredHeight
+            Layout.preferredWidth: JamiTheme.preferredFieldWidth
+            Layout.preferredHeight: JamiTheme.preferredFieldHeight
 
             color: JamiTheme.buttonTintedBlack
             hoveredColor: JamiTheme.buttonTintedBlackHovered
@@ -149,9 +138,7 @@
             Layout.minimumHeight: 0
             Layout.preferredHeight: childrenRect.height
 
-            model: PluginItemListModel{
-                id: pluginItemListModel
-            }
+            model: PluginAdapter.getPluginSelectableModel()
 
             delegate: PluginItemDelegate{
                 id: pluginItemDelegate
diff --git a/src/settingsview/components/PluginSettingsPage.qml b/src/settingsview/components/PluginSettingsPage.qml
index 3cff938..156706d 100644
--- a/src/settingsview/components/PluginSettingsPage.qml
+++ b/src/settingsview/components/PluginSettingsPage.qml
@@ -33,9 +33,6 @@
         // settings
         enabledplugin.checked = ClientWrapper.pluginModel.getPluginsEnabled()
         pluginListSettingsView.visible = enabledplugin.checked
-        if (pluginListSettingsView.visible) {
-            pluginListSettingsView.updatePluginListDisplayed()
-        }
     }
 
     function slotSetPluginEnabled(state){
@@ -114,9 +111,7 @@
                         slotSetPluginEnabled(checked)
 
                         pluginListSettingsView.visible = checked
-                        if (pluginListSettingsView.visible) {
-                            pluginListSettingsView.updatePluginListDisplayed()
-                        } else {
+                        if (!pluginListSettingsView.visible) {
                             ClientWrapper.pluginModel.toggleCallMediaHandler("", true)
                             pluginListSettingsView.hidePreferences()
                         }
@@ -144,10 +139,6 @@
                     Layout.rightMargin: 16
                     Layout.minimumHeight: 0
                     Layout.preferredHeight: childrenRect.height
-
-                    onUpdatePluginList:{
-                        pluginListSettingsView.updatePluginListDisplayed()
-                    }
                 }
             }
         }