Commit b55be608 authored by Aline Gondim Santos's avatar Aline Gondim Santos

settings: add always preference by handler

GitLab: #266
GItLab: #267
Change-Id: I0f2d31f9d5aebbbc645f4f85cad2ba5fdee45a79
parent ebc07155
......@@ -37,6 +37,7 @@ ItemDelegate {
LIST,
PATH,
EDITTEXT,
SWITCH,
DEFAULT
}
......@@ -75,19 +76,23 @@ ItemDelegate {
preferenceNewValue = editTextPreference.text
btnPreferenceClicked()
break
case PreferenceItemDelegate.SWITCH:
preferenceNewValue = index ? "1" : "0"
btnPreferenceClicked()
break
default:
break
}
}
FileDialog {
JamiFileDialog {
id: preferenceFilePathDialog
title: JamiStrings.selectFile
folder: "file:///" + currentPath
onAccepted: {
var url = UtilsAdapter.getAbsPath(fileUrl.toString())
var url = UtilsAdapter.getAbsPath(file.toString())
preferenceNewValue = url
btnPreferenceClicked()
}
......@@ -96,20 +101,22 @@ ItemDelegate {
RowLayout{
anchors.fill: parent
Label {
Layout.preferredWidth: root.width / 2 - 8
Text {
id: prefLlabel
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
Layout.leftMargin: 8
text: preferenceName
color: JamiTheme.textColor
elide: Text.ElideRight
font.pointSize: JamiTheme.settingsFontSize
ToolTip.visible: hovered
ToolTip.text: preferenceSummary
}
PushButton {
id: btnPreference
id: btnPreferenceDefault
visible: preferenceType === PreferenceItemDelegate.DEFAULT
normalColor: JamiTheme.primaryBackgroundColor
......@@ -123,8 +130,19 @@ ItemDelegate {
source: "qrc:/images/icons/round-settings-24px.svg"
toolTipText: qsTr("Edit preference")
}
Switch {
id: btnPreferenceSwitch
onClicked: btnPreferenceClicked()
visible: preferenceType === PreferenceItemDelegate.SWITCH
Layout.alignment: Qt.AlignRight | Qt.AlingVCenter
Layout.rightMargin: 16
Layout.preferredHeight: 30
Layout.preferredWidth: 30
checked: preferenceCurrentValue === "1"
onToggled: getNewPreferenceValueSlot(checked)
}
SettingParaCombobox {
......@@ -133,7 +151,7 @@ ItemDelegate {
visible: preferenceType === PreferenceItemDelegate.LIST
Layout.preferredWidth: root.width / 2 - 8
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.rightMargin: 8
Layout.rightMargin: 4
font.pointSize: JamiTheme.settingsFontSize
font.kerning: true
......@@ -153,7 +171,7 @@ ItemDelegate {
Layout.preferredWidth: width
Layout.preferredHeight: 30
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.rightMargin: 8
Layout.rightMargin: 4
text: UtilsAdapter.fileName(preferenceCurrentValue)
toolTipText: JamiStrings.chooseImageFile
......@@ -173,7 +191,7 @@ ItemDelegate {
Layout.preferredWidth: root.width / 2 - 8
Layout.preferredHeight: 30
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.rightMargin: 8
Layout.rightMargin: 4
selectByMouse: true
text: preferenceCurrentValue
......
......@@ -44,7 +44,6 @@ Rectangle {
function toggleMessagingHeaderButtonsVisible(visible) {
startAAudioCallButton.visible = visible
startAVideoCallButton.visible = visible
selectPluginButton.visible = visible
}
color: JamiTheme.secondaryBackgroundColor
......
......@@ -24,7 +24,8 @@
std::map<QString, int> mapType {{QString("List"), PreferenceItemListModel::Type::LIST},
{QString("Path"), PreferenceItemListModel::Type::PATH},
{QString("EditText"), PreferenceItemListModel::Type::EDITTEXT}};
{QString("EditText"), PreferenceItemListModel::Type::EDITTEXT},
{QString("Switch"), PreferenceItemListModel::Type::SWITCH}};
PreferenceItemListModel::PreferenceItemListModel(QObject* parent)
: QAbstractListModel(parent)
......@@ -58,14 +59,15 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
return QVariant();
}
auto details = preferenceList_.at(index.row());
QString preferenceCurrent = LRCInstance::pluginModel().getPluginPreferencesValues(
pluginId_)[details["key"]];
QString preferenceCurrent = QString("");
int type = Type::DEFAULT;
QString currentPath = "";
QString currentPath = QString("");
QStringList acceptedFiles = {};
bool checkImage = false;
auto details = preferenceList_.at(index.row());
preferenceCurrent = LRCInstance::pluginModel().getPluginPreferencesValues(
pluginId_)[details["key"]];
auto it = mapType.find(details["type"]);
if (it != mapType.end()) {
type = mapType[details["type"]];
......@@ -101,6 +103,7 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
case Role::IsImage:
return QVariant(checkImage);
}
return QVariant();
}
......
......@@ -48,6 +48,7 @@ public:
LIST,
PATH,
EDITTEXT,
SWITCH,
DEFAULT,
} Type;
......
......@@ -52,6 +52,7 @@ Rectangle {
PluginModel.unloadPlugin(pluginId)
else
loaded = PluginModel.loadPlugin(pluginId)
pluginListView.model = PluginAdapter.getPluginSelectableModel()
PluginAdapter.pluginHandlersUpdateStatus()
return loaded
}
......@@ -70,6 +71,7 @@ Rectangle {
var url = UtilsAdapter.getAbsPath(file.toString())
PluginModel.installPlugin(url, true)
pluginListView.model = PluginAdapter.getPluginSelectableModel()
PluginAdapter.pluginHandlersUpdateStatus()
}
}
......
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