1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-04 23:05:48 +02:00

account settings: add plugins

GitLab: #539

Change-Id: I49dd030bc4e80fe30bcf7259777a2527ebd25fe2
This commit is contained in:
agsantos 2021-09-23 13:52:38 -04:00 committed by Sébastien Blin
parent 7fe8843317
commit 77d8cc758d
17 changed files with 346 additions and 219 deletions

View file

@ -44,8 +44,9 @@
<file>src/settingsview/components/VideoSettings.qml</file> <file>src/settingsview/components/VideoSettings.qml</file>
<file>src/settingsview/components/GeneralSettingsPage.qml</file> <file>src/settingsview/components/GeneralSettingsPage.qml</file>
<file>src/settingsview/components/PluginSettingsPage.qml</file> <file>src/settingsview/components/PluginSettingsPage.qml</file>
<file>src/settingsview/components/PluginListSettingsView.qml</file> <file>src/settingsview/components/PluginListView.qml</file>
<file>src/settingsview/components/PluginListPreferencesView.qml</file> <file>src/settingsview/components/PluginPreferencesView.qml</file>
<file>src/settingsview/components/PluginPreferencesListView.qml</file>
<file>src/settingsview/components/CurrentAccountSettings.qml</file> <file>src/settingsview/components/CurrentAccountSettings.qml</file>
<file>src/settingsview/components/UserIdentity.qml</file> <file>src/settingsview/components/UserIdentity.qml</file>
<file>src/settingsview/components/JamiUserIdentity.qml</file> <file>src/settingsview/components/JamiUserIdentity.qml</file>

View file

@ -489,11 +489,9 @@ Item {
property string clearAvatar: qsTr("Clear avatar image") property string clearAvatar: qsTr("Clear avatar image")
property string takePhoto: qsTr("Take photo") property string takePhoto: qsTr("Take photo")
// PluginSettingsPage // Plugins
property string enable: qsTr("Enable") property string enable: qsTr("Enable")
property string pluginPreferences: qsTr("Preferences")
// PluginListPreferencesView
property string pluginPreferences: qsTr("%1\nPreferences")
property string reset: qsTr("Reset") property string reset: qsTr("Reset")
property string uninstall: qsTr("Uninstall") property string uninstall: qsTr("Uninstall")
property string resetPreferences: qsTr("Reset Preferences") property string resetPreferences: qsTr("Reset Preferences")
@ -502,18 +500,17 @@ Item {
property string uninstallPlugin: qsTr("Uninstall plugin") property string uninstallPlugin: qsTr("Uninstall plugin")
property string pluginResetConfirmation: qsTr("Are you sure you wish to reset %1 preferences?") property string pluginResetConfirmation: qsTr("Are you sure you wish to reset %1 preferences?")
property string pluginUninstallConfirmation: qsTr("Are you sure you wish to uninstall %1?") property string pluginUninstallConfirmation: qsTr("Are you sure you wish to uninstall %1?")
// PluginItemDelegate
property string showHidePrefs: qsTr("Display or hide preferences") property string showHidePrefs: qsTr("Display or hide preferences")
// PluginListSettingsView
property string addNewPlugin: qsTr("Add new plugin") property string addNewPlugin: qsTr("Add new plugin")
property string goBackToPluginsList: qsTr("Go back to plugins list") property string goBackToPluginsList: qsTr("Go back to plugins list")
// PreferenceItemDelegate
property string selectFile: qsTr("Select a file") property string selectFile: qsTr("Select a file")
property string select: qsTr("Select") property string select: qsTr("Select")
property string chooseImageFile: qsTr("Choose image file") property string chooseImageFile: qsTr("Choose image file")
property string tipGeneralPluginSettingsDisplay: qsTr("Display or hide General plugin settings")
property string tipAccountPluginSettingsDisplay: qsTr("Display or hide Account plugin settings")
property string installedPlugins: qsTr("Installed plugins")
property string pluginFiles: qsTr("Plugin Files")
property string loadUnload: qsTr("Load/Unload")
// ProfilePage // ProfilePage
property string profileSharedWithContacts: qsTr("Profile is only shared with contacts") property string profileSharedWithContacts: qsTr("Profile is only shared with contacts")

View file

@ -59,7 +59,6 @@ ItemDelegate {
} }
Label { Label {
id: labelDeviceId
Layout.leftMargin: 8 Layout.leftMargin: 8
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter

View file

@ -226,6 +226,7 @@ Popup {
model: PreferenceItemListModel { model: PreferenceItemListModel {
id: handlerPickerPrefsModel id: handlerPickerPrefsModel
lrcInstance: LRCInstance lrcInstance: LRCInstance
accountId_: LRCInstance.currentAccountId
mediaHandlerName_: handlerName mediaHandlerName_: handlerName
pluginId_: pluginId pluginId_: pluginId
} }
@ -250,13 +251,14 @@ Popup {
lrcInstance: LRCInstance lrcInstance: LRCInstance
preferenceKey : PreferenceKey preferenceKey : PreferenceKey
accountId_: LRCInstance.currentAccountId
pluginId: PluginId pluginId: PluginId
} }
onClicked: pluginhandlerPreferencePickerListView.currentIndex = index onClicked: pluginhandlerPreferencePickerListView.currentIndex = index
onBtnPreferenceClicked: { onBtnPreferenceClicked: {
PluginModel.setPluginPreference(pluginId, "", preferenceKey, preferenceNewValue) PluginModel.setPluginPreference(pluginId, LRCInstance.currentAccountId, preferenceKey, preferenceNewValue)
handlerPickerPrefsModel.reset() handlerPickerPrefsModel.reset()
} }
} }

View file

@ -48,10 +48,12 @@ PluginAdapter::getChatHandlerSelectableModel(const QString& accountId, const QSt
} }
QVariant QVariant
PluginAdapter::getPluginPreferencesCategories(const QString& pluginId, bool removeLast) PluginAdapter::getPluginPreferencesCategories(const QString& pluginId,
const QString& accountId,
bool removeLast)
{ {
QStringList categories; QStringList categories;
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId); auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId, accountId);
for (auto& preference : preferences) { for (auto& preference : preferences) {
if (!preference["category"].isEmpty()) if (!preference["category"].isEmpty())
categories.push_back(preference["category"]); categories.push_back(preference["category"]);
@ -65,7 +67,7 @@ PluginAdapter::getPluginPreferencesCategories(const QString& pluginId, bool remo
void void
PluginAdapter::updateHandlersListCount() PluginAdapter::updateHandlersListCount()
{ {
if (lrcInstance_->pluginModel().getPluginsEnabled()) { if (isEnabled_) {
set_callMediaHandlersListCount(lrcInstance_->pluginModel().getCallMediaHandlers().size()); set_callMediaHandlersListCount(lrcInstance_->pluginModel().getCallMediaHandlers().size());
set_chatHandlersListCount(lrcInstance_->pluginModel().getChatHandlers().size()); set_chatHandlersListCount(lrcInstance_->pluginModel().getChatHandlers().size());
} else { } else {

View file

@ -46,6 +46,7 @@ protected:
Q_INVOKABLE QVariant getChatHandlerSelectableModel(const QString& accountId, Q_INVOKABLE QVariant getChatHandlerSelectableModel(const QString& accountId,
const QString& peerId); const QString& peerId);
Q_INVOKABLE QVariant getPluginPreferencesCategories(const QString& pluginId, Q_INVOKABLE QVariant getPluginPreferencesCategories(const QString& pluginId,
const QString& accountId,
bool removeLast = false); bool removeLast = false);
private: private:

View file

@ -87,6 +87,7 @@ PluginListModel::reset()
beginResetModel(); beginResetModel();
installedPlugins_.clear(); installedPlugins_.clear();
installedPlugins_ = lrcInstance_->pluginModel().getInstalledPlugins(); installedPlugins_ = lrcInstance_->pluginModel().getInstalledPlugins();
filterPlugins(installedPlugins_);
endResetModel(); endResetModel();
} }
@ -108,6 +109,7 @@ void
PluginListModel::addPlugin() PluginListModel::addPlugin()
{ {
auto newList = lrcInstance_->pluginModel().getInstalledPlugins(); auto newList = lrcInstance_->pluginModel().getInstalledPlugins();
filterPlugins(newList);
if (newList.size() <= installedPlugins_.size()) if (newList.size() <= installedPlugins_.size())
return; return;
@ -119,6 +121,22 @@ PluginListModel::addPlugin()
} }
beginInsertRows(QModelIndex(), index, index); beginInsertRows(QModelIndex(), index, index);
installedPlugins_ = lrcInstance_->pluginModel().getInstalledPlugins(); installedPlugins_ = newList;
endInsertRows(); endInsertRows();
} }
void
PluginListModel::filterPlugins(VectorString& list)
{
if (!lrcInstance_ || !filterAccount_)
return;
for (auto it = list.begin(); it != list.end();) {
auto prefs = lrcInstance_->pluginModel()
.getPluginPreferences(*it, lrcInstance_->get_currentAccountId());
if (prefs.empty()) {
it = list.erase(it);
} else
it++;
}
}

View file

@ -25,7 +25,7 @@ class LRCInstance;
class PluginListModel : public AbstractListModelBase class PluginListModel : public AbstractListModelBase
{ {
Q_OBJECT Q_OBJECT
QML_PROPERTY(bool, filterAccount)
public: public:
enum Role { PluginName = Qt::UserRole + 1, PluginId, PluginIcon, IsLoaded }; enum Role { PluginName = Qt::UserRole + 1, PluginId, PluginIcon, IsLoaded };
Q_ENUM(Role) Q_ENUM(Role)
@ -53,5 +53,6 @@ public:
Q_INVOKABLE void addPlugin(); Q_INVOKABLE void addPlugin();
private: private:
void filterPlugins(VectorString& list);
VectorString installedPlugins_ {}; VectorString installedPlugins_ {};
}; };

View file

@ -35,7 +35,9 @@ PluginListPreferenceModel::populateLists()
preferenceList_.clear(); preferenceList_.clear();
if (pluginId_.isEmpty()) if (pluginId_.isEmpty())
return; return;
const auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_); auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_, "");
if (!accountId__.isEmpty())
preferences.append(lrcInstance_->pluginModel().getPluginPreferences(pluginId_, accountId__));
for (const auto& preference : preferences) { for (const auto& preference : preferences) {
if (preference["key"] == preferenceKey_) { if (preference["key"] == preferenceKey_) {
if (preference.find("entries") != preference.end() if (preference.find("entries") != preference.end()
@ -92,37 +94,6 @@ PluginListPreferenceModel::roleNames() const
return roles; return roles;
} }
QModelIndex
PluginListPreferenceModel::index(int row, int column, const QModelIndex& parent) const
{
Q_UNUSED(parent);
if (column != 0) {
return QModelIndex();
}
if (row >= 0 && row < rowCount()) {
return createIndex(row, column);
}
return QModelIndex();
}
QModelIndex
PluginListPreferenceModel::parent(const QModelIndex& child) const
{
Q_UNUSED(child);
return QModelIndex();
}
Qt::ItemFlags
PluginListPreferenceModel::flags(const QModelIndex& index) const
{
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
if (!index.isValid()) {
return QAbstractItemModel::flags(index);
}
return flags;
}
void void
PluginListPreferenceModel::reset() PluginListPreferenceModel::reset()
{ {

View file

@ -25,11 +25,11 @@
class PluginListPreferenceModel : public AbstractListModelBase class PluginListPreferenceModel : public AbstractListModelBase
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
Q_PROPERTY(QString preferenceKey READ preferenceKey WRITE setPreferenceKey)
Q_PROPERTY(QString preferenceNewValue READ preferenceNewValue WRITE setPreferenceNewValue) Q_PROPERTY(QString preferenceNewValue READ preferenceNewValue WRITE setPreferenceNewValue)
Q_PROPERTY(int idx READ idx WRITE setIdx) Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
Q_PROPERTY(int optSize READ optSize) QML_PROPERTY(QString, preferenceKey)
QML_PROPERTY(int, idx)
QML_PROPERTY(QString, accountId_)
public: public:
enum Role { PreferenceValue = Qt::UserRole + 1, PreferenceEntryValue }; enum Role { PreferenceValue = Qt::UserRole + 1, PreferenceEntryValue };
Q_ENUM(Role) Q_ENUM(Role)
@ -47,9 +47,6 @@ public:
* Override role name as access point in qml. * Override role name as access point in qml.
*/ */
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& child) const;
Qt::ItemFlags flags(const QModelIndex& index) const;
/* /*
* This function is to reset the model when there's new account added. * This function is to reset the model when there's new account added.
@ -66,29 +63,17 @@ public:
{ {
preferenceNewValue_ = preferenceNewValue; preferenceNewValue_ = preferenceNewValue;
} }
void setPreferenceKey(const QString preferenceKey)
{
preferenceKey_ = preferenceKey;
}
void setPluginId(const QString pluginId) void setPluginId(const QString pluginId)
{ {
pluginId_ = pluginId; pluginId_ = pluginId;
populateLists(); populateLists();
} }
void setIdx(const int index)
{
idx_ = index;
}
int idx()
{
return idx_;
}
QString preferenceCurrentValue() QString preferenceCurrentValue()
{ {
return lrcInstance_->pluginModel().getPluginPreferencesValues(pluginId_, return lrcInstance_->pluginModel().getPluginPreferencesValues(pluginId_,
accountId_)[preferenceKey_]; accountId__)[preferenceKey_];
} }
QString preferenceNewValue() QString preferenceNewValue()
@ -96,25 +81,15 @@ public:
preferenceNewValue_ = preferenceValuesList_[idx_]; preferenceNewValue_ = preferenceValuesList_[idx_];
return preferenceNewValue_; return preferenceNewValue_;
} }
QString preferenceKey()
{
return preferenceKey_;
}
QString pluginId() QString pluginId()
{ {
return pluginId_; return pluginId_;
} }
int optSize()
{
return preferenceValuesList_.size();
}
private: private:
QString pluginId_ = ""; QString pluginId_ = "";
QString preferenceKey_ = "";
QString preferenceNewValue_ = ""; QString preferenceNewValue_ = "";
QStringList preferenceValuesList_; QStringList preferenceValuesList_;
QStringList preferenceList_; QStringList preferenceList_;
int idx_ = 0;
QString accountId_ = "";
}; };

View file

@ -88,7 +88,8 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
} }
} }
const auto dependsOn = details["dependsOn"].split(","); const auto dependsOn = details["dependsOn"].split(",");
const auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__); const auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__,
accountId__);
const auto prefValues = lrcInstance_->pluginModel().getPluginPreferencesValues(pluginId__, const auto prefValues = lrcInstance_->pluginModel().getPluginPreferencesValues(pluginId__,
accountId__); accountId__);
bool enabled = true; bool enabled = true;
@ -182,7 +183,7 @@ PreferenceItemListModel::preferencesCount()
if (!preferenceList_.isEmpty()) if (!preferenceList_.isEmpty())
return preferenceList_.size(); return preferenceList_.size();
if (mediaHandlerName__.isEmpty()) { if (mediaHandlerName__.isEmpty()) {
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__); auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__, accountId__);
if (category__ != "all") if (category__ != "all")
for (auto& preference : preferences) { for (auto& preference : preferences) {
if (preference["category"] == category__) if (preference["category"] == category__)
@ -192,7 +193,9 @@ PreferenceItemListModel::preferencesCount()
preferenceList_ = preferences; preferenceList_ = preferences;
return preferenceList_.size(); return preferenceList_.size();
} else { } else {
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__); auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__, "");
preferences.append(
lrcInstance_->pluginModel().getPluginPreferences(pluginId__, accountId__));
for (auto& preference : preferences) { for (auto& preference : preferences) {
QStringList scopeList = preference["scope"].split(","); QStringList scopeList = preference["scope"].split(",");
if (scopeList.contains(mediaHandlerName__)) if (scopeList.contains(mediaHandlerName__))

View file

@ -30,7 +30,6 @@ class PreferenceItemListModel : public AbstractListModelBase
QML_PROPERTY(QString, category_) QML_PROPERTY(QString, category_)
QML_PROPERTY(QString, mediaHandlerName_) QML_PROPERTY(QString, mediaHandlerName_)
QML_PROPERTY(QString, accountId_) QML_PROPERTY(QString, accountId_)
QML_RO_PROPERTY(int, preferencesCount_)
public: public:
enum Role { enum Role {
PreferenceKey = Qt::UserRole + 1, PreferenceKey = Qt::UserRole + 1,

View file

@ -33,10 +33,25 @@ ItemDelegate {
property string pluginId: "" property string pluginId: ""
property string pluginIcon: "" property string pluginIcon: ""
property bool isLoaded: false property bool isLoaded: false
height: pluginListPreferencesView.visible ? implicitHeight + pluginListPreferencesView.effectiveHeight : implicitHeight property string activeId: ""
height: pluginPreferencesView.visible ? implicitHeight + pluginPreferencesView.childrenRect.height : implicitHeight
signal settingsClicked
onActiveIdChanged: {
pluginPreferencesView.visible = activeId != pluginId ? false : !pluginPreferencesView.visible
}
SimpleMessageDialog {
id: msgDialog
buttonTitles: [JamiStrings.optionOk, JamiStrings.optionCancel]
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue,
SimpleMessageDialog.ButtonStyle.TintedBlack]
}
ColumnLayout { ColumnLayout {
anchors.fill: parent width: parent.width
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
@ -64,7 +79,6 @@ ItemDelegate {
} }
Label { Label {
id: labelDeviceId
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 8 Layout.topMargin: 8
@ -85,8 +99,7 @@ ItemDelegate {
Layout.rightMargin: 8 Layout.rightMargin: 8
width: 20 width: 20
ToolTip.visible: hovered tooltipText: JamiStrings.loadUnload
ToolTip.text: qsTr("Load/Unload")
checked: isLoaded checked: isLoaded
onSwitchToggled: { onSwitchToggled: {
@ -110,17 +123,17 @@ ItemDelegate {
imageColor: JamiTheme.textColor imageColor: JamiTheme.textColor
toolTipText: JamiStrings.showHidePrefs toolTipText: JamiStrings.showHidePrefs
onClicked: pluginListPreferencesView.visible = !pluginListPreferencesView.visible onClicked: settingsClicked()
} }
} }
PluginListPreferencesView { PluginPreferencesView {
id: pluginListPreferencesView id: pluginPreferencesView
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: JamiTheme.preferredMarginSize Layout.leftMargin: JamiTheme.preferredMarginSize
Layout.rightMargin: JamiTheme.preferredMarginSize Layout.rightMargin: JamiTheme.preferredMarginSize
Layout.preferredHeight: effectiveHeight Layout.preferredHeight: pluginPreferencesView.childrenRect.height
} }
} }
} }

View file

@ -30,6 +30,8 @@ import "../../commoncomponents"
Rectangle { Rectangle {
id: root id: root
property string activePlugin: ""
visible: false visible: false
color: JamiTheme.secondaryBackgroundColor color: JamiTheme.secondaryBackgroundColor
@ -40,8 +42,7 @@ Rectangle {
title: JamiStrings.selectPluginInstall title: JamiStrings.selectPluginInstall
folder: StandardPaths.writableLocation(StandardPaths.DownloadLocation) folder: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
nameFilters: [qsTr("Plugin Files") + " (*.jpl)", qsTr( nameFilters: [JamiStrings.pluginFiles + " (*.jpl)", JamiStrings.allFiles + " (*)"]
"All files") + " (*)"]
onAccepted: { onAccepted: {
var url = UtilsAdapter.getAbsPath(file.toString()) var url = UtilsAdapter.getAbsPath(file.toString())
@ -51,15 +52,15 @@ Rectangle {
} }
ColumnLayout { ColumnLayout {
id: pluginListViewLayout
anchors.left: root.left anchors.left: root.left
anchors.right: root.right anchors.right: root.right
anchors.bottomMargin: 20
Label { Label {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 25 Layout.preferredHeight: 25
text: qsTr("Installed plugins") text: JamiStrings.installedPlugins
font.pointSize: JamiTheme.headerFontSize font.pointSize: JamiTheme.headerFontSize
font.kerning: true font.kerning: true
color: JamiTheme.textColor color: JamiTheme.textColor
@ -91,12 +92,13 @@ Rectangle {
} }
ListView { ListView {
id: pluginListView id: pluginList
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: 0 Layout.minimumHeight: 0
Layout.preferredHeight: childrenRect.height
Layout.bottomMargin: 10 Layout.bottomMargin: 10
Layout.preferredHeight: childrenRect.height
clip: true
model: PluginListModel { model: PluginListModel {
id: installedPluginsModel id: installedPluginsModel
@ -107,23 +109,26 @@ Rectangle {
} }
} }
maximumFlickVelocity: 1024
delegate: PluginItemDelegate { delegate: PluginItemDelegate {
id: pluginItemDelegate id: pluginItemDelegate
width: pluginListView.width width: pluginList.width
implicitHeight: 40 implicitHeight: 50
pluginName: PluginName pluginName: PluginName
pluginId: PluginId pluginId: PluginId
pluginIcon: PluginIcon pluginIcon: PluginIcon
isLoaded: IsLoaded isLoaded: IsLoaded
activeId: root.activePlugin
background: Rectangle { background: Rectangle {
anchors.fill: parent anchors.fill: parent
color: "transparent" color: "transparent"
} }
onSettingsClicked: {
root.activePlugin = root.activePlugin === pluginId ? "" : pluginId
}
} }
} }
} }

View file

@ -29,7 +29,9 @@ import "../../commoncomponents"
Rectangle { Rectangle {
id: root id: root
property int effectiveHeight: visible ? implicitHeight : 0 property string accountId: ""
property int count: pluginPreferenceView.count + pluginPreferenceViewCategory.count
implicitHeight: childrenRect.height implicitHeight: childrenRect.height
onVisibleChanged: { onVisibleChanged: {
if (visible) { if (visible) {
@ -38,8 +40,21 @@ Rectangle {
} }
} }
color: "transparent"
Connections {
target: LRCInstance
function onCurrentAccountIdChanged() {
if (accountId) {
preferencesPerCategoryModel.reset()
generalPreferencesModel.reset()
}
}
}
property string category: categories.length > 0 ? categories[0] : category ? category : "" property string category: categories.length > 0 ? categories[0] : category ? category : ""
property var categories: PluginAdapter.getPluginPreferencesCategories(pluginId) property var categories: PluginAdapter.getPluginPreferencesCategories(pluginId, accountId)
property string generalCategory: categories.length <= 1 ? "all" : "" property string generalCategory: categories.length <= 1 ? "all" : ""
visible: false visible: false
@ -48,54 +63,15 @@ Rectangle {
{ {
if (isLoaded) { if (isLoaded) {
PluginModel.unloadPlugin(pluginId) PluginModel.unloadPlugin(pluginId)
PluginModel.setPluginPreference(pluginId, "", preferenceKey, preferenceNewValue) PluginModel.setPluginPreference(pluginId, accountId, preferenceKey, preferenceNewValue)
PluginModel.loadPlugin(pluginId) PluginModel.loadPlugin(pluginId)
} else } else
PluginModel.setPluginPreference(pluginId, "", preferenceKey, preferenceNewValue) PluginModel.setPluginPreference(pluginId, accountId, preferenceKey, preferenceNewValue)
}
SimpleMessageDialog {
id: msgDialog
buttonTitles: [JamiStrings.optionOk, JamiStrings.optionCancel]
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue,
SimpleMessageDialog.ButtonStyle.TintedBlack]
} }
ColumnLayout { ColumnLayout {
anchors.left: root.left anchors.left: root.left
anchors.right: root.right anchors.right: root.right
anchors.bottomMargin: 10
Label{
Layout.topMargin: 34
Layout.alignment: Qt.AlignHCenter
height: 64
background: Rectangle {
Image {
anchors.centerIn: parent
source: pluginIcon === "" ? "" : "file:" + pluginIcon
sourceSize: Qt.size(256, 256)
height: 64
width: 64
mipmap: true
}
}
}
Label {
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 24
height: JamiTheme.preferredFieldHeight
text: JamiStrings.pluginPreferences.arg(pluginName)
font.pointSize: JamiTheme.headerFontSize
font.kerning: true
color: JamiTheme.textColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
Rectangle { Rectangle {
id: prefsByCategory id: prefsByCategory
@ -122,7 +98,7 @@ Rectangle {
Repeater { Repeater {
id: gridModel id: gridModel
model: categories.length % 2 === 1 ? PluginAdapter.getPluginPreferencesCategories(pluginId, true) : root.categories model: categories.length % 2 === 1 ? PluginAdapter.getPluginPreferencesCategories(pluginId, accountId, true) : root.categories
Button { Button {
id: repDelegate id: repDelegate
Layout.fillWidth: true Layout.fillWidth: true
@ -192,6 +168,7 @@ Rectangle {
id: preferencesPerCategoryModel id: preferencesPerCategoryModel
lrcInstance: LRCInstance lrcInstance: LRCInstance
category_: category category_: category
accountId_: accountId
pluginId_: pluginId pluginId_: pluginId
onCategory_Changed: { onCategory_Changed: {
@ -221,6 +198,7 @@ Rectangle {
lrcInstance: LRCInstance lrcInstance: LRCInstance
preferenceKey : PreferenceKey preferenceKey : PreferenceKey
accountId_: accountId
pluginId: PluginId pluginId: PluginId
} }
@ -249,6 +227,7 @@ Rectangle {
id: generalPreferencesModel id: generalPreferencesModel
lrcInstance: LRCInstance lrcInstance: LRCInstance
category_: generalCategory category_: generalCategory
accountId_: accountId
pluginId_: pluginId pluginId_: pluginId
onCategory_Changed: { onCategory_Changed: {
@ -278,6 +257,7 @@ Rectangle {
lrcInstance: LRCInstance lrcInstance: LRCInstance
preferenceKey : PreferenceKey preferenceKey : PreferenceKey
accountId_: accountId
pluginId: PluginId pluginId: PluginId
} }
@ -288,16 +268,12 @@ Rectangle {
} }
} }
RowLayout {
Layout.topMargin: 10
Layout.bottomMargin: 10
Layout.preferredHeight: 30
Layout.fillWidth: true
MaterialButton { MaterialButton {
id: resetButton id: resetButton
Layout.fillWidth: true Layout.alignment: Qt.AlignCenter
preferredWidth: JamiTheme.preferredFieldWidth
preferredHeight: JamiTheme.preferredFieldHeight preferredHeight: JamiTheme.preferredFieldHeight
color: JamiTheme.buttonTintedBlack color: JamiTheme.buttonTintedBlack
@ -313,10 +289,10 @@ Rectangle {
msgDialog.buttonCallBacks = [function () { msgDialog.buttonCallBacks = [function () {
if (isLoaded) { if (isLoaded) {
PluginModel.unloadPlugin(pluginId) PluginModel.unloadPlugin(pluginId)
PluginModel.resetPluginPreferencesValues(pluginId, "") PluginModel.resetPluginPreferencesValues(pluginId, accountId)
PluginModel.loadPlugin(pluginId) PluginModel.loadPlugin(pluginId)
} else { } else {
PluginModel.resetPluginPreferencesValues(pluginId, "") PluginModel.resetPluginPreferencesValues(pluginId, accountId)
} }
preferencesPerCategoryModel.reset() preferencesPerCategoryModel.reset()
generalPreferencesModel.reset() generalPreferencesModel.reset()
@ -325,40 +301,5 @@ Rectangle {
JamiStrings.pluginResetConfirmation.arg(pluginName)) JamiStrings.pluginResetConfirmation.arg(pluginName))
} }
} }
MaterialButton {
id: uninstallButton
Layout.fillWidth: true
preferredHeight: JamiTheme.preferredFieldHeight
color: JamiTheme.buttonTintedBlack
hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed
outlined: true
iconSource: JamiResources.delete_24dp_svg
text: JamiStrings.uninstall
onClicked: {
msgDialog.buttonCallBacks = [function () {
PluginModel.uninstallPlugin(pluginId)
installedPluginsModel.removePlugin(index)
}]
msgDialog.openWithParameters(JamiStrings.uninstallPlugin,
JamiStrings.pluginUninstallConfirmation.arg(pluginName))
}
}
}
Rectangle {
Layout.bottomMargin: 10
height: 2
Layout.fillWidth: true
color: "transparent"
border.width: 1
border.color: JamiTheme.separationLine
}
} }
} }

View file

@ -0,0 +1,196 @@
/*
* Copyright (C) 2022 by Savoir-faire Linux
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import net.jami.Adapters 1.1
import net.jami.Models 1.1
import net.jami.Constants 1.1
import "../../commoncomponents"
Rectangle {
id: root
color: "transparent"
visible: false
ColumnLayout {
anchors.left: root.left
anchors.right: root.right
anchors.bottomMargin: 10
Label{
Layout.topMargin: 34
Layout.alignment: Qt.AlignHCenter
height: 64
background: Rectangle {
Image {
anchors.centerIn: parent
source: pluginIcon === "" ? JamiResources.plugins_24dp_svg : "file:" + pluginIcon
sourceSize: Qt.size(256, 256)
height: 64
width: 64
mipmap: true
}
}
}
Label {
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 24
height: JamiTheme.preferredFieldHeight
text: "%1\n%2".arg(pluginName).arg(JamiStrings.pluginPreferences)
font.pointSize: JamiTheme.headerFontSize
font.kerning: true
color: JamiTheme.textColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
RowLayout {
Layout.fillWidth: true
Text {
Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.preferredFieldHeight
font.pointSize: JamiTheme.headerFontSize
font.kerning: true
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
color: JamiTheme.textColor
text: qsTr("General")
elide: Text.ElideRight
}
PushButton {
Layout.preferredWidth: JamiTheme.preferredFieldHeight
Layout.preferredHeight: JamiTheme.preferredFieldHeight
Layout.alignment: Qt.AlignHCenter
imageColor: JamiTheme.textColor
toolTipText: JamiStrings.tipGeneralPluginSettingsDisplay
preferredSize: 32
source: pluginGeneralSettingsView.visible ?
JamiResources.expand_less_24dp_svg :
JamiResources.expand_more_24dp_svg
onClicked: {
pluginGeneralSettingsView.visible = !pluginGeneralSettingsView.visible
}
}
}
PluginPreferencesListView {
id: pluginGeneralSettingsView
visible: false
Layout.fillWidth: true
}
RowLayout {
Layout.fillWidth: true
visible: pluginAccountSettingsView.count > 0
Text {
Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.preferredFieldHeight
font.pointSize: JamiTheme.headerFontSize
font.kerning: true
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
color: JamiTheme.textColor
text: qsTr("Account")
elide: Text.ElideRight
}
PushButton {
Layout.preferredWidth: JamiTheme.preferredFieldHeight
Layout.preferredHeight: JamiTheme.preferredFieldHeight
Layout.alignment: Qt.AlignHCenter
imageColor: JamiTheme.textColor
toolTipText: JamiStrings.tipAccountPluginSettingsDisplay
preferredSize: 32
source: pluginAccountSettingsView.visible ?
JamiResources.expand_less_24dp_svg :
JamiResources.expand_more_24dp_svg
onClicked: {
pluginAccountSettingsView.visible = !pluginAccountSettingsView.visible
}
}
}
PluginPreferencesListView {
id: pluginAccountSettingsView
visible: false
Layout.fillWidth: true
accountId: LRCInstance.currentAccountId
}
MaterialButton {
id: uninstallButton
Layout.alignment: Qt.AlignCenter
preferredWidth: JamiTheme.preferredFieldWidth
preferredHeight: JamiTheme.preferredFieldHeight
color: JamiTheme.buttonTintedBlack
hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed
outlined: true
toolTipText: JamiStrings.pluginUninstallConfirmation.arg(pluginName)
iconSource: JamiResources.delete_24dp_svg
text: JamiStrings.uninstall
onClicked: {
msgDialog.buttonCallBacks = [function () {
pluginPreferencesView.visible = false
PluginModel.uninstallPlugin(pluginId)
installedPluginsModel.removePlugin(index)
}]
msgDialog.openWithParameters(JamiStrings.uninstallPlugin,
JamiStrings.pluginUninstallConfirmation.arg(pluginName))
}
}
Rectangle {
Layout.bottomMargin: 10
height: 2
Layout.fillWidth: true
color: "transparent"
border.width: 1
border.color: JamiTheme.separationLine
}
}
}

View file

@ -55,11 +55,14 @@ Rectangle {
labelText: JamiStrings.enable labelText: JamiStrings.enable
fontPointSize: JamiTheme.headerFontSize fontPointSize: JamiTheme.headerFontSize
onSwitchToggled: PluginAdapter.isEnabled = checked onSwitchToggled: {
PluginModel.setPluginsEnabled(checked)
PluginAdapter.isEnabled = checked
}
} }
PluginListSettingsView { PluginListView {
id: pluginListSettingsView id: pluginListView
visible: PluginAdapter.isEnabled visible: PluginAdapter.isEnabled