diff --git a/qml.qrc b/qml.qrc index 950a8e3bcff05b8c53c7b2448ee104a7351dc599..81ef94d691d88421dda336c99b0ae50e7fe3ce59 100644 --- a/qml.qrc +++ b/qml.qrc @@ -44,8 +44,9 @@ <file>src/settingsview/components/VideoSettings.qml</file> <file>src/settingsview/components/GeneralSettingsPage.qml</file> <file>src/settingsview/components/PluginSettingsPage.qml</file> - <file>src/settingsview/components/PluginListSettingsView.qml</file> - <file>src/settingsview/components/PluginListPreferencesView.qml</file> + <file>src/settingsview/components/PluginListView.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/UserIdentity.qml</file> <file>src/settingsview/components/JamiUserIdentity.qml</file> diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml index 832e170f8558fd1b435b523ad1ea61f1d78bbceb..f8a4856fcab58572103e7d985f494233eaaf8608 100644 --- a/src/constant/JamiStrings.qml +++ b/src/constant/JamiStrings.qml @@ -489,11 +489,9 @@ Item { property string clearAvatar: qsTr("Clear avatar image") property string takePhoto: qsTr("Take photo") - // PluginSettingsPage + // Plugins property string enable: qsTr("Enable") - - // PluginListPreferencesView - property string pluginPreferences: qsTr("%1\nPreferences") + property string pluginPreferences: qsTr("Preferences") property string reset: qsTr("Reset") property string uninstall: qsTr("Uninstall") property string resetPreferences: qsTr("Reset Preferences") @@ -502,18 +500,17 @@ Item { property string uninstallPlugin: qsTr("Uninstall plugin") 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?") - - // PluginItemDelegate property string showHidePrefs: qsTr("Display or hide preferences") - - // PluginListSettingsView property string addNewPlugin: qsTr("Add new plugin") property string goBackToPluginsList: qsTr("Go back to plugins list") - - // PreferenceItemDelegate property string selectFile: qsTr("Select a file") property string select: qsTr("Select") 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 property string profileSharedWithContacts: qsTr("Profile is only shared with contacts") diff --git a/src/mainview/components/PluginHandlerItemDelegate.qml b/src/mainview/components/PluginHandlerItemDelegate.qml index 0785d1c87bbc5183227cfdb44bb7e22891782db6..f59fd662f1312923a7af16c4e984183b24e31ad4 100644 --- a/src/mainview/components/PluginHandlerItemDelegate.qml +++ b/src/mainview/components/PluginHandlerItemDelegate.qml @@ -59,7 +59,6 @@ ItemDelegate { } Label { - id: labelDeviceId Layout.leftMargin: 8 Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter diff --git a/src/mainview/components/PluginHandlerPicker.qml b/src/mainview/components/PluginHandlerPicker.qml index 39f5d944fb3e337a38b916361e86b7d258079254..2c3fb4ce30fca8a5bc37ef582ca59731d4db18ec 100644 --- a/src/mainview/components/PluginHandlerPicker.qml +++ b/src/mainview/components/PluginHandlerPicker.qml @@ -226,6 +226,7 @@ Popup { model: PreferenceItemListModel { id: handlerPickerPrefsModel lrcInstance: LRCInstance + accountId_: LRCInstance.currentAccountId mediaHandlerName_: handlerName pluginId_: pluginId } @@ -250,13 +251,14 @@ Popup { lrcInstance: LRCInstance preferenceKey : PreferenceKey + accountId_: LRCInstance.currentAccountId pluginId: PluginId } onClicked: pluginhandlerPreferencePickerListView.currentIndex = index onBtnPreferenceClicked: { - PluginModel.setPluginPreference(pluginId, "", preferenceKey, preferenceNewValue) + PluginModel.setPluginPreference(pluginId, LRCInstance.currentAccountId, preferenceKey, preferenceNewValue) handlerPickerPrefsModel.reset() } } diff --git a/src/pluginadapter.cpp b/src/pluginadapter.cpp index 4d34dadcca797913770a4a0c281881889ae7955b..2b528c8904e1a649679593f21ccd5b84ff047f43 100644 --- a/src/pluginadapter.cpp +++ b/src/pluginadapter.cpp @@ -48,10 +48,12 @@ PluginAdapter::getChatHandlerSelectableModel(const QString& accountId, const QSt } QVariant -PluginAdapter::getPluginPreferencesCategories(const QString& pluginId, bool removeLast) +PluginAdapter::getPluginPreferencesCategories(const QString& pluginId, + const QString& accountId, + bool removeLast) { QStringList categories; - auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId); + auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId, accountId); for (auto& preference : preferences) { if (!preference["category"].isEmpty()) categories.push_back(preference["category"]); @@ -65,7 +67,7 @@ PluginAdapter::getPluginPreferencesCategories(const QString& pluginId, bool remo void PluginAdapter::updateHandlersListCount() { - if (lrcInstance_->pluginModel().getPluginsEnabled()) { + if (isEnabled_) { set_callMediaHandlersListCount(lrcInstance_->pluginModel().getCallMediaHandlers().size()); set_chatHandlersListCount(lrcInstance_->pluginModel().getChatHandlers().size()); } else { diff --git a/src/pluginadapter.h b/src/pluginadapter.h index a1a5c7cbdc1a43a82b08deb42d4a85c3390b87ea..89ac680e88eb65833f29f5e714b298b23de0736a 100644 --- a/src/pluginadapter.h +++ b/src/pluginadapter.h @@ -46,6 +46,7 @@ protected: Q_INVOKABLE QVariant getChatHandlerSelectableModel(const QString& accountId, const QString& peerId); Q_INVOKABLE QVariant getPluginPreferencesCategories(const QString& pluginId, + const QString& accountId, bool removeLast = false); private: diff --git a/src/pluginlistmodel.cpp b/src/pluginlistmodel.cpp index d8724c814ce1bf500625c5d092991ef2ee7b1582..48c9a918997404d804dad6e30c7a6b93e1669a4e 100644 --- a/src/pluginlistmodel.cpp +++ b/src/pluginlistmodel.cpp @@ -87,6 +87,7 @@ PluginListModel::reset() beginResetModel(); installedPlugins_.clear(); installedPlugins_ = lrcInstance_->pluginModel().getInstalledPlugins(); + filterPlugins(installedPlugins_); endResetModel(); } @@ -108,6 +109,7 @@ void PluginListModel::addPlugin() { auto newList = lrcInstance_->pluginModel().getInstalledPlugins(); + filterPlugins(newList); if (newList.size() <= installedPlugins_.size()) return; @@ -119,6 +121,22 @@ PluginListModel::addPlugin() } beginInsertRows(QModelIndex(), index, index); - installedPlugins_ = lrcInstance_->pluginModel().getInstalledPlugins(); + installedPlugins_ = newList; endInsertRows(); -} \ No newline at end of file +} + +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++; + } +} diff --git a/src/pluginlistmodel.h b/src/pluginlistmodel.h index dd9412b01c565920e451ebf0892303dc673b1fc2..1d571af05559f7cf62e70fc745131782179eb98d 100644 --- a/src/pluginlistmodel.h +++ b/src/pluginlistmodel.h @@ -25,7 +25,7 @@ class LRCInstance; class PluginListModel : public AbstractListModelBase { Q_OBJECT - + QML_PROPERTY(bool, filterAccount) public: enum Role { PluginName = Qt::UserRole + 1, PluginId, PluginIcon, IsLoaded }; Q_ENUM(Role) @@ -53,5 +53,6 @@ public: Q_INVOKABLE void addPlugin(); private: + void filterPlugins(VectorString& list); VectorString installedPlugins_ {}; }; diff --git a/src/pluginlistpreferencemodel.cpp b/src/pluginlistpreferencemodel.cpp index 34c3375e2bae5f918a97268557c2f836dbdfcef0..6e5de44a72931c691ce5a4e91e5b2dfcc05abe37 100644 --- a/src/pluginlistpreferencemodel.cpp +++ b/src/pluginlistpreferencemodel.cpp @@ -35,7 +35,9 @@ PluginListPreferenceModel::populateLists() preferenceList_.clear(); if (pluginId_.isEmpty()) 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) { if (preference["key"] == preferenceKey_) { if (preference.find("entries") != preference.end() @@ -92,37 +94,6 @@ PluginListPreferenceModel::roleNames() const 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 PluginListPreferenceModel::reset() { diff --git a/src/pluginlistpreferencemodel.h b/src/pluginlistpreferencemodel.h index a364b8dfde437ee5db943a5a6c26cd8fb973b5ac..e72a42f8a60619757ebb6d7a7b80e05fd8e3acb3 100644 --- a/src/pluginlistpreferencemodel.h +++ b/src/pluginlistpreferencemodel.h @@ -25,11 +25,11 @@ class PluginListPreferenceModel : public AbstractListModelBase { 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(int idx READ idx WRITE setIdx) - Q_PROPERTY(int optSize READ optSize) + Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId) + QML_PROPERTY(QString, preferenceKey) + QML_PROPERTY(int, idx) + QML_PROPERTY(QString, accountId_) public: enum Role { PreferenceValue = Qt::UserRole + 1, PreferenceEntryValue }; Q_ENUM(Role) @@ -47,9 +47,6 @@ public: * Override role name as access point in qml. */ 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. @@ -66,29 +63,17 @@ public: { preferenceNewValue_ = preferenceNewValue; } - void setPreferenceKey(const QString preferenceKey) - { - preferenceKey_ = preferenceKey; - } + void setPluginId(const QString pluginId) { pluginId_ = pluginId; populateLists(); } - void setIdx(const int index) - { - idx_ = index; - } - - int idx() - { - return idx_; - } QString preferenceCurrentValue() { return lrcInstance_->pluginModel().getPluginPreferencesValues(pluginId_, - accountId_)[preferenceKey_]; + accountId__)[preferenceKey_]; } QString preferenceNewValue() @@ -96,25 +81,15 @@ public: preferenceNewValue_ = preferenceValuesList_[idx_]; return preferenceNewValue_; } - QString preferenceKey() - { - return preferenceKey_; - } + QString pluginId() { return pluginId_; } - int optSize() - { - return preferenceValuesList_.size(); - } private: QString pluginId_ = ""; - QString preferenceKey_ = ""; QString preferenceNewValue_ = ""; QStringList preferenceValuesList_; QStringList preferenceList_; - int idx_ = 0; - QString accountId_ = ""; }; diff --git a/src/preferenceitemlistmodel.cpp b/src/preferenceitemlistmodel.cpp index 2fa13a3a9d6f6ffa6400624ed8e6c578c1252a6a..1db871a959e79fa68d41a7748d8bf232069a40d6 100644 --- a/src/preferenceitemlistmodel.cpp +++ b/src/preferenceitemlistmodel.cpp @@ -88,7 +88,8 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const } } 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__, accountId__); bool enabled = true; @@ -182,7 +183,7 @@ PreferenceItemListModel::preferencesCount() if (!preferenceList_.isEmpty()) return preferenceList_.size(); if (mediaHandlerName__.isEmpty()) { - auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__); + auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__, accountId__); if (category__ != "all") for (auto& preference : preferences) { if (preference["category"] == category__) @@ -192,7 +193,9 @@ PreferenceItemListModel::preferencesCount() preferenceList_ = preferences; return preferenceList_.size(); } else { - auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__); + auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__, ""); + preferences.append( + lrcInstance_->pluginModel().getPluginPreferences(pluginId__, accountId__)); for (auto& preference : preferences) { QStringList scopeList = preference["scope"].split(","); if (scopeList.contains(mediaHandlerName__)) diff --git a/src/preferenceitemlistmodel.h b/src/preferenceitemlistmodel.h index 6be16f8bd3b3e50d35525289047b355849dd3f8f..c6d6f64385fd6947263576d4277c35c0cf708254 100644 --- a/src/preferenceitemlistmodel.h +++ b/src/preferenceitemlistmodel.h @@ -30,7 +30,6 @@ class PreferenceItemListModel : public AbstractListModelBase QML_PROPERTY(QString, category_) QML_PROPERTY(QString, mediaHandlerName_) QML_PROPERTY(QString, accountId_) - QML_RO_PROPERTY(int, preferencesCount_) public: enum Role { PreferenceKey = Qt::UserRole + 1, diff --git a/src/settingsview/components/PluginItemDelegate.qml b/src/settingsview/components/PluginItemDelegate.qml index 54cb8b0f1219c779f9430d7d7359ff163e661500..a7c51aff6e94019a3e589b649a0e27f529ebb737 100644 --- a/src/settingsview/components/PluginItemDelegate.qml +++ b/src/settingsview/components/PluginItemDelegate.qml @@ -29,14 +29,29 @@ import "../../commoncomponents" ItemDelegate { id: root - property string pluginName : "" + property string pluginName: "" property string pluginId: "" property string pluginIcon: "" 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 { - anchors.fill: parent + width: parent.width RowLayout { Layout.fillWidth: true @@ -64,7 +79,6 @@ ItemDelegate { } Label { - id: labelDeviceId Layout.fillHeight: true Layout.fillWidth: true Layout.topMargin: 8 @@ -85,8 +99,7 @@ ItemDelegate { Layout.rightMargin: 8 width: 20 - ToolTip.visible: hovered - ToolTip.text: qsTr("Load/Unload") + tooltipText: JamiStrings.loadUnload checked: isLoaded onSwitchToggled: { @@ -110,17 +123,17 @@ ItemDelegate { imageColor: JamiTheme.textColor toolTipText: JamiStrings.showHidePrefs - onClicked: pluginListPreferencesView.visible = !pluginListPreferencesView.visible + onClicked: settingsClicked() } } - PluginListPreferencesView { - id: pluginListPreferencesView + PluginPreferencesView { + id: pluginPreferencesView Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize Layout.rightMargin: JamiTheme.preferredMarginSize - Layout.preferredHeight: effectiveHeight + Layout.preferredHeight: pluginPreferencesView.childrenRect.height } } } diff --git a/src/settingsview/components/PluginListSettingsView.qml b/src/settingsview/components/PluginListView.qml similarity index 86% rename from src/settingsview/components/PluginListSettingsView.qml rename to src/settingsview/components/PluginListView.qml index 4eab6ed6fc0bf01ac6ca3b1b9ee90c8b85adf5ae..423d2f2dc8d50806462bed6ff94ca10917d8fec4 100644 --- a/src/settingsview/components/PluginListSettingsView.qml +++ b/src/settingsview/components/PluginListView.qml @@ -30,6 +30,8 @@ import "../../commoncomponents" Rectangle { id: root + property string activePlugin: "" + visible: false color: JamiTheme.secondaryBackgroundColor @@ -40,8 +42,7 @@ Rectangle { title: JamiStrings.selectPluginInstall folder: StandardPaths.writableLocation(StandardPaths.DownloadLocation) - nameFilters: [qsTr("Plugin Files") + " (*.jpl)", qsTr( - "All files") + " (*)"] + nameFilters: [JamiStrings.pluginFiles + " (*.jpl)", JamiStrings.allFiles + " (*)"] onAccepted: { var url = UtilsAdapter.getAbsPath(file.toString()) @@ -51,15 +52,15 @@ Rectangle { } ColumnLayout { - id: pluginListViewLayout anchors.left: root.left anchors.right: root.right + anchors.bottomMargin: 20 Label { Layout.fillWidth: true Layout.preferredHeight: 25 - text: qsTr("Installed plugins") + text: JamiStrings.installedPlugins font.pointSize: JamiTheme.headerFontSize font.kerning: true color: JamiTheme.textColor @@ -91,12 +92,13 @@ Rectangle { } ListView { - id: pluginListView + id: pluginList Layout.fillWidth: true Layout.minimumHeight: 0 - Layout.preferredHeight: childrenRect.height Layout.bottomMargin: 10 + Layout.preferredHeight: childrenRect.height + clip: true model: PluginListModel { id: installedPluginsModel @@ -107,23 +109,26 @@ Rectangle { } } - maximumFlickVelocity: 1024 - delegate: PluginItemDelegate { id: pluginItemDelegate - width: pluginListView.width - implicitHeight: 40 + width: pluginList.width + implicitHeight: 50 pluginName: PluginName pluginId: PluginId pluginIcon: PluginIcon isLoaded: IsLoaded + activeId: root.activePlugin background: Rectangle { anchors.fill: parent color: "transparent" } + + onSettingsClicked: { + root.activePlugin = root.activePlugin === pluginId ? "" : pluginId + } } } } diff --git a/src/settingsview/components/PluginListPreferencesView.qml b/src/settingsview/components/PluginPreferencesListView.qml similarity index 68% rename from src/settingsview/components/PluginListPreferencesView.qml rename to src/settingsview/components/PluginPreferencesListView.qml index 16409c286f84cf00dbadfdec6d115728bd380729..d9ce915c3d3637b497f1ca1945ecaaff535592e0 100644 --- a/src/settingsview/components/PluginListPreferencesView.qml +++ b/src/settingsview/components/PluginPreferencesListView.qml @@ -29,7 +29,9 @@ import "../../commoncomponents" Rectangle { id: root - property int effectiveHeight: visible ? implicitHeight : 0 + property string accountId: "" + property int count: pluginPreferenceView.count + pluginPreferenceViewCategory.count + implicitHeight: childrenRect.height onVisibleChanged: { 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 var categories: PluginAdapter.getPluginPreferencesCategories(pluginId) + property var categories: PluginAdapter.getPluginPreferencesCategories(pluginId, accountId) property string generalCategory: categories.length <= 1 ? "all" : "" visible: false @@ -48,54 +63,15 @@ Rectangle { { if (isLoaded) { PluginModel.unloadPlugin(pluginId) - PluginModel.setPluginPreference(pluginId, "", preferenceKey, preferenceNewValue) + PluginModel.setPluginPreference(pluginId, accountId, preferenceKey, preferenceNewValue) PluginModel.loadPlugin(pluginId) } else - PluginModel.setPluginPreference(pluginId, "", preferenceKey, preferenceNewValue) - } - - SimpleMessageDialog { - id: msgDialog - - buttonTitles: [JamiStrings.optionOk, JamiStrings.optionCancel] - buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue, - SimpleMessageDialog.ButtonStyle.TintedBlack] + PluginModel.setPluginPreference(pluginId, accountId, preferenceKey, preferenceNewValue) } 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 === "" ? "" : "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 { id: prefsByCategory @@ -122,7 +98,7 @@ Rectangle { Repeater { 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 { id: repDelegate Layout.fillWidth: true @@ -192,6 +168,7 @@ Rectangle { id: preferencesPerCategoryModel lrcInstance: LRCInstance category_: category + accountId_: accountId pluginId_: pluginId onCategory_Changed: { @@ -221,6 +198,7 @@ Rectangle { lrcInstance: LRCInstance preferenceKey : PreferenceKey + accountId_: accountId pluginId: PluginId } @@ -249,6 +227,7 @@ Rectangle { id: generalPreferencesModel lrcInstance: LRCInstance category_: generalCategory + accountId_: accountId pluginId_: pluginId onCategory_Changed: { @@ -278,6 +257,7 @@ Rectangle { lrcInstance: LRCInstance preferenceKey : PreferenceKey + accountId_: accountId pluginId: PluginId } @@ -288,77 +268,38 @@ Rectangle { } } - RowLayout { - Layout.topMargin: 10 - Layout.bottomMargin: 10 - Layout.preferredHeight: 30 - Layout.fillWidth: true - - MaterialButton { - id: resetButton - - Layout.fillWidth: true - preferredHeight: JamiTheme.preferredFieldHeight - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - - iconSource: JamiResources.settings_backup_restore_24dp_svg + MaterialButton { + id: resetButton - text: JamiStrings.reset - - onClicked: { - msgDialog.buttonCallBacks = [function () { - if (isLoaded) { - PluginModel.unloadPlugin(pluginId) - PluginModel.resetPluginPreferencesValues(pluginId, "") - PluginModel.loadPlugin(pluginId) - } else { - PluginModel.resetPluginPreferencesValues(pluginId, "") - } - preferencesPerCategoryModel.reset() - generalPreferencesModel.reset() - }] - msgDialog.openWithParameters(JamiStrings.resetPreferences, - JamiStrings.pluginResetConfirmation.arg(pluginName)) - } - } + Layout.alignment: Qt.AlignCenter - MaterialButton { - id: uninstallButton + preferredWidth: JamiTheme.preferredFieldWidth + preferredHeight: JamiTheme.preferredFieldHeight - Layout.fillWidth: true - preferredHeight: JamiTheme.preferredFieldHeight + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true + iconSource: JamiResources.settings_backup_restore_24dp_svg - iconSource: JamiResources.delete_24dp_svg + text: JamiStrings.reset - text: JamiStrings.uninstall - - onClicked: { - msgDialog.buttonCallBacks = [function () { - PluginModel.uninstallPlugin(pluginId) - installedPluginsModel.removePlugin(index) - }] - msgDialog.openWithParameters(JamiStrings.uninstallPlugin, - JamiStrings.pluginUninstallConfirmation.arg(pluginName)) - } + onClicked: { + msgDialog.buttonCallBacks = [function () { + if (isLoaded) { + PluginModel.unloadPlugin(pluginId) + PluginModel.resetPluginPreferencesValues(pluginId, accountId) + PluginModel.loadPlugin(pluginId) + } else { + PluginModel.resetPluginPreferencesValues(pluginId, accountId) + } + preferencesPerCategoryModel.reset() + generalPreferencesModel.reset() + }] + msgDialog.openWithParameters(JamiStrings.resetPreferences, + JamiStrings.pluginResetConfirmation.arg(pluginName)) } } - - Rectangle { - Layout.bottomMargin: 10 - height: 2 - Layout.fillWidth: true - color: "transparent" - border.width: 1 - border.color: JamiTheme.separationLine - } } } diff --git a/src/settingsview/components/PluginPreferencesView.qml b/src/settingsview/components/PluginPreferencesView.qml new file mode 100644 index 0000000000000000000000000000000000000000..d8b570743cf8aef90b12f800b6cf276637bef797 --- /dev/null +++ b/src/settingsview/components/PluginPreferencesView.qml @@ -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 + } + } +} diff --git a/src/settingsview/components/PluginSettingsPage.qml b/src/settingsview/components/PluginSettingsPage.qml index 3c0e401b4aa9846b92e47099d05078f776953cfe..a10da491ad3be82e3acf8cb8d93ab5543c811338 100644 --- a/src/settingsview/components/PluginSettingsPage.qml +++ b/src/settingsview/components/PluginSettingsPage.qml @@ -55,11 +55,14 @@ Rectangle { labelText: JamiStrings.enable fontPointSize: JamiTheme.headerFontSize - onSwitchToggled: PluginAdapter.isEnabled = checked + onSwitchToggled: { + PluginModel.setPluginsEnabled(checked) + PluginAdapter.isEnabled = checked + } } - PluginListSettingsView { - id: pluginListSettingsView + PluginListView { + id: pluginListView visible: PluginAdapter.isEnabled