Commit 5e598f53 authored by Aline Gondim Santos's avatar Aline Gondim Santos

plugins: add EditText preference

GitLab: #265
Change-Id: Ibcfba9ee0b142a109bd58553b13aba174842661f
parent a5ec0c8e
......@@ -36,6 +36,7 @@ ItemDelegate {
enum Type {
LIST,
PATH,
EDITTEXT,
DEFAULT
}
......@@ -53,15 +54,15 @@ ItemDelegate {
signal btnPreferenceClicked
function getNewPreferenceValueSlot(index){
switch (preferenceType){
function getNewPreferenceValueSlot(index) {
switch (preferenceType) {
case PreferenceItemDelegate.LIST:
pluginListPreferenceModel.idx = index
preferenceNewValue = pluginListPreferenceModel.preferenceNewValue
btnPreferenceClicked()
break
case PreferenceItemDelegate.PATH:
if(index === 0){
if (index === 0) {
preferenceFilePathDialog.title = qsTr("Select An Image to " + preferenceName)
preferenceFilePathDialog.nameFilters = fileFilters
preferenceFilePathDialog.open()
......@@ -69,6 +70,10 @@ ItemDelegate {
else
btnPreferenceClicked()
break
case PreferenceItemDelegate.EDITTEXT:
preferenceNewValue = editTextPreference.text
btnPreferenceClicked()
break
default:
break
}
......@@ -91,7 +96,7 @@ ItemDelegate {
anchors.fill: parent
Label {
Layout.preferredWidth: root.width / 2
Layout.preferredWidth: root.width / 2 - 8
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
Layout.leftMargin: 8
......@@ -143,11 +148,11 @@ ItemDelegate {
id: pathPreferenceButton
visible: preferenceType === PreferenceItemDelegate.PATH
width: root.width / 2 - 16
width: root.width / 2 - 8
Layout.preferredWidth: width
Layout.preferredHeight: 30
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.rightMargin: 30
Layout.rightMargin: 8
text: UtilsAdapter.fileName(preferenceCurrentValue)
toolTipText: JamiStrings.chooseImageFile
......@@ -158,5 +163,25 @@ ItemDelegate {
onClicked: getNewPreferenceValueSlot(0)
}
MaterialLineEdit {
id: editTextPreference
visible: preferenceType === PreferenceItemDelegate.EDITTEXT
width: root.width / 2 - 8
Layout.preferredWidth: root.width / 2 - 8
Layout.preferredHeight: 30
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.rightMargin: 8
selectByMouse: true
text: preferenceCurrentValue
font.pointSize: JamiTheme.settingsFontSize
padding: 8
wrapMode: Text.NoWrap
onEditingFinished: getNewPreferenceValueSlot(0)
}
}
}
......@@ -278,7 +278,7 @@ Popup {
onBtnPreferenceClicked: {
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
PluginAdapter.pluginHandlersUpdateStatus()
PluginAdapter.preferenceChanged(pluginId)
pluginhandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, pluginhandlerPreferencePickerListView.handlerName)
}
}
......
......@@ -47,6 +47,7 @@ protected:
signals:
void pluginHandlersUpdateStatus();
void preferenceChanged(QString pluginId);
private:
std::unique_ptr<PluginHandlerItemListModel> pluginHandlerListModel_;
......
......@@ -23,7 +23,8 @@
#include <map>
std::map<QString, int> mapType {{QString("List"), PreferenceItemListModel::Type::LIST},
{QString("Path"), PreferenceItemListModel::Type::PATH}};
{QString("Path"), PreferenceItemListModel::Type::PATH},
{QString("EditText"), PreferenceItemListModel::Type::EDITTEXT}};
PreferenceItemListModel::PreferenceItemListModel(QObject* parent)
: QAbstractListModel(parent)
......
......@@ -47,6 +47,7 @@ public:
typedef enum {
LIST,
PATH,
EDITTEXT,
DEFAULT,
} Type;
......
......@@ -34,6 +34,7 @@ Rectangle {
enum Type {
LIST,
PATH,
EDITTEXT,
DEFAULT
}
......@@ -47,6 +48,15 @@ Rectangle {
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"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment