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