mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 14:55:43 +02:00
account settings: add plugins
GitLab: #539 Change-Id: I49dd030bc4e80fe30bcf7259777a2527ebd25fe2
This commit is contained in:
parent
7fe8843317
commit
77d8cc758d
17 changed files with 346 additions and 219 deletions
5
qml.qrc
5
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>
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -59,7 +59,6 @@ ItemDelegate {
|
|||
}
|
||||
|
||||
Label {
|
||||
id: labelDeviceId
|
||||
Layout.leftMargin: 8
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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_ {};
|
||||
};
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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_ = "";
|
||||
};
|
||||
|
|
|
@ -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__))
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -33,10 +33,25 @@ ItemDelegate {
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,16 +268,12 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.topMargin: 10
|
||||
Layout.bottomMargin: 10
|
||||
Layout.preferredHeight: 30
|
||||
Layout.fillWidth: true
|
||||
|
||||
MaterialButton {
|
||||
id: resetButton
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
|
||||
preferredWidth: JamiTheme.preferredFieldWidth
|
||||
preferredHeight: JamiTheme.preferredFieldHeight
|
||||
|
||||
color: JamiTheme.buttonTintedBlack
|
||||
|
@ -313,10 +289,10 @@ Rectangle {
|
|||
msgDialog.buttonCallBacks = [function () {
|
||||
if (isLoaded) {
|
||||
PluginModel.unloadPlugin(pluginId)
|
||||
PluginModel.resetPluginPreferencesValues(pluginId, "")
|
||||
PluginModel.resetPluginPreferencesValues(pluginId, accountId)
|
||||
PluginModel.loadPlugin(pluginId)
|
||||
} else {
|
||||
PluginModel.resetPluginPreferencesValues(pluginId, "")
|
||||
PluginModel.resetPluginPreferencesValues(pluginId, accountId)
|
||||
}
|
||||
preferencesPerCategoryModel.reset()
|
||||
generalPreferencesModel.reset()
|
||||
|
@ -325,40 +301,5 @@ Rectangle {
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
196
src/settingsview/components/PluginPreferencesView.qml
Normal file
196
src/settingsview/components/PluginPreferencesView.qml
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue