mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-07 00:05:54 +02:00
settings: redesign plugin preferences view
GitLab: #341 Change-Id: Ibe7ad479845bf9390e8634c6b80cb0be79976143
This commit is contained in:
parent
37d548bb75
commit
5f6eb2151b
12 changed files with 364 additions and 80 deletions
|
@ -113,6 +113,7 @@ ItemDelegate {
|
||||||
font.pointSize: JamiTheme.settingsFontSize
|
font.pointSize: JamiTheme.settingsFontSize
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: preferenceSummary
|
ToolTip.text: preferenceSummary
|
||||||
|
opacity: enabled ? 1.0 : 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
PushButton {
|
PushButton {
|
||||||
|
@ -130,6 +131,7 @@ ItemDelegate {
|
||||||
source: "qrc:/images/icons/round-settings-24px.svg"
|
source: "qrc:/images/icons/round-settings-24px.svg"
|
||||||
|
|
||||||
toolTipText: qsTr("Edit preference")
|
toolTipText: qsTr("Edit preference")
|
||||||
|
opacity: enabled ? 1.0 : 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
Switch {
|
Switch {
|
||||||
|
@ -143,6 +145,7 @@ ItemDelegate {
|
||||||
checked: preferenceCurrentValue === "1"
|
checked: preferenceCurrentValue === "1"
|
||||||
|
|
||||||
onToggled: getNewPreferenceValueSlot(checked)
|
onToggled: getNewPreferenceValueSlot(checked)
|
||||||
|
opacity: enabled ? 1.0 : 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingParaCombobox {
|
SettingParaCombobox {
|
||||||
|
@ -161,6 +164,8 @@ ItemDelegate {
|
||||||
textRole: "PreferenceValue"
|
textRole: "PreferenceValue"
|
||||||
tooltipText: JamiStrings.select
|
tooltipText: JamiStrings.select
|
||||||
onActivated: getNewPreferenceValueSlot(index)
|
onActivated: getNewPreferenceValueSlot(index)
|
||||||
|
opacity: enabled ? 1.0 : 0.5
|
||||||
|
comboBoxBackgroundColor: JamiTheme.comboBoxBackgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialButton {
|
MaterialButton {
|
||||||
|
@ -181,6 +186,7 @@ ItemDelegate {
|
||||||
pressedColor: JamiTheme.buttonTintedGreyPressed
|
pressedColor: JamiTheme.buttonTintedGreyPressed
|
||||||
|
|
||||||
onClicked: getNewPreferenceValueSlot(0)
|
onClicked: getNewPreferenceValueSlot(0)
|
||||||
|
opacity: enabled ? 1.0 : 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialLineEdit {
|
MaterialLineEdit {
|
||||||
|
@ -201,6 +207,7 @@ ItemDelegate {
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
|
|
||||||
onEditingFinished: getNewPreferenceValueSlot(0)
|
onEditingFinished: getNewPreferenceValueSlot(0)
|
||||||
|
opacity: enabled ? 1.0 : 0.5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ ComboBox {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string tooltipText:""
|
property string tooltipText:""
|
||||||
|
property string comboBoxBackgroundColor: JamiTheme.editBackgroundColor
|
||||||
|
|
||||||
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
||||||
ToolTip.visible: hovered && (tooltipText.length > 0)
|
ToolTip.visible: hovered && (tooltipText.length > 0)
|
||||||
|
@ -90,10 +91,10 @@ ComboBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: JamiTheme.editBackgroundColor
|
color: root.comboBoxBackgroundColor
|
||||||
implicitWidth: 120
|
implicitWidth: 120
|
||||||
implicitHeight: 40
|
implicitHeight: 40
|
||||||
border.color: JamiTheme.editBackgroundColor
|
border.color: root.comboBoxBackgroundColor
|
||||||
border.width: root.visualFocus ? 2 : 1
|
border.width: root.visualFocus ? 2 : 1
|
||||||
radius: 2
|
radius: 2
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,10 @@ Item {
|
||||||
property color successLabelColor: "#2b5084"
|
property color successLabelColor: "#2b5084"
|
||||||
property color rubberBandSelectionBlue: "steelblue"
|
property color rubberBandSelectionBlue: "steelblue"
|
||||||
property color screenSelectionBorderGreen: "green"
|
property color screenSelectionBorderGreen: "green"
|
||||||
|
property color separationLine: darkTheme ? selectedColor : backgroundColor
|
||||||
|
|
||||||
|
// Plugin Preferences View
|
||||||
|
property color comboBoxBackgroundColor: darkTheme ? editBackgroundColor : selectedColor
|
||||||
|
|
||||||
// Chatview
|
// Chatview
|
||||||
property color jamiLightBlue: darkTheme? "#003b4e" : Qt.rgba(59, 193, 211, 0.3)
|
property color jamiLightBlue: darkTheme? "#003b4e" : Qt.rgba(59, 193, 211, 0.3)
|
||||||
|
|
|
@ -188,7 +188,7 @@ Popup {
|
||||||
function onUpdateProperties() {
|
function onUpdateProperties() {
|
||||||
pluginhandlerPreferencePickerListView.pluginId = root.pluginId
|
pluginhandlerPreferencePickerListView.pluginId = root.pluginId
|
||||||
pluginhandlerPreferencePickerListView.handlerName = root.handlerName
|
pluginhandlerPreferencePickerListView.handlerName = root.handlerName
|
||||||
pluginhandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(root.pluginId, root.handlerName)
|
pluginhandlerPreferencePickerListView.model = PluginAdapter.getHandlerPreferencesModel(root.pluginId, root.handlerName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ Popup {
|
||||||
property string pluginId: ""
|
property string pluginId: ""
|
||||||
property string handlerName: ""
|
property string handlerName: ""
|
||||||
|
|
||||||
model: PluginAdapter.getPluginPreferencesModel(pluginId, handlerName)
|
model: PluginAdapter.getHandlerPreferencesModel(pluginId, handlerName)
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
|
@ -269,6 +269,7 @@ Popup {
|
||||||
preferenceKey : PreferenceKey
|
preferenceKey : PreferenceKey
|
||||||
fileFilters: FileFilters
|
fileFilters: FileFilters
|
||||||
isImage: IsImage
|
isImage: IsImage
|
||||||
|
enabled: Enabled
|
||||||
pluginListPreferenceModel: PluginListPreferenceModel {
|
pluginListPreferenceModel: PluginListPreferenceModel {
|
||||||
id: handlerPickerPreferenceModel
|
id: handlerPickerPreferenceModel
|
||||||
|
|
||||||
|
@ -282,7 +283,7 @@ Popup {
|
||||||
onBtnPreferenceClicked: {
|
onBtnPreferenceClicked: {
|
||||||
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
PluginAdapter.preferenceChanged(pluginId)
|
PluginAdapter.preferenceChanged(pluginId)
|
||||||
pluginhandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, pluginhandlerPreferencePickerListView.handlerName)
|
pluginhandlerPreferencePickerListView.model = PluginAdapter.getHandlerPreferencesModel(pluginId, pluginhandlerPreferencePickerListView.handlerName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,17 @@ PluginAdapter::getPluginSelectableModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
PluginAdapter::getPluginPreferencesModel(const QString& pluginId, const QString& mediaHandlerName)
|
PluginAdapter::getPluginPreferencesModel(const QString& pluginId, const QString& category)
|
||||||
|
{
|
||||||
|
preferenceItemListModel_.reset(new PreferenceItemListModel(this, lrcInstance_));
|
||||||
|
preferenceItemListModel_->setCategory(category);
|
||||||
|
preferenceItemListModel_->setPluginId(pluginId);
|
||||||
|
|
||||||
|
return QVariant::fromValue(preferenceItemListModel_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
PluginAdapter::getHandlerPreferencesModel(const QString& pluginId, const QString& mediaHandlerName)
|
||||||
{
|
{
|
||||||
preferenceItemListModel_.reset(new PreferenceItemListModel(this, lrcInstance_));
|
preferenceItemListModel_.reset(new PreferenceItemListModel(this, lrcInstance_));
|
||||||
preferenceItemListModel_->setMediaHandlerName(mediaHandlerName);
|
preferenceItemListModel_->setMediaHandlerName(mediaHandlerName);
|
||||||
|
@ -56,3 +66,18 @@ PluginAdapter::getPluginPreferencesModel(const QString& pluginId, const QString&
|
||||||
|
|
||||||
return QVariant::fromValue(preferenceItemListModel_.get());
|
return QVariant::fromValue(preferenceItemListModel_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
PluginAdapter::getPluginPreferencesCategories(const QString& pluginId, bool removeLast)
|
||||||
|
{
|
||||||
|
QStringList categories;
|
||||||
|
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId);
|
||||||
|
for (auto& preference : preferences) {
|
||||||
|
if (!preference["category"].isEmpty())
|
||||||
|
categories.push_back(preference["category"]);
|
||||||
|
}
|
||||||
|
categories.removeDuplicates();
|
||||||
|
if (removeLast)
|
||||||
|
categories.pop_back();
|
||||||
|
return categories;
|
||||||
|
}
|
||||||
|
|
|
@ -43,7 +43,11 @@ protected:
|
||||||
const QString& peerId);
|
const QString& peerId);
|
||||||
Q_INVOKABLE QVariant getPluginSelectableModel();
|
Q_INVOKABLE QVariant getPluginSelectableModel();
|
||||||
Q_INVOKABLE QVariant getPluginPreferencesModel(const QString& pluginId,
|
Q_INVOKABLE QVariant getPluginPreferencesModel(const QString& pluginId,
|
||||||
|
const QString& category = "all");
|
||||||
|
Q_INVOKABLE QVariant getHandlerPreferencesModel(const QString& pluginId,
|
||||||
const QString& mediaHandlerName = "");
|
const QString& mediaHandlerName = "");
|
||||||
|
Q_INVOKABLE QVariant getPluginPreferencesCategories(const QString& pluginId,
|
||||||
|
bool removeLast = false);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pluginHandlersUpdateStatus();
|
void pluginHandlersUpdateStatus();
|
||||||
|
|
|
@ -33,6 +33,8 @@ PluginListPreferenceModel::populateLists()
|
||||||
{
|
{
|
||||||
preferenceValuesList_.clear();
|
preferenceValuesList_.clear();
|
||||||
preferenceList_.clear();
|
preferenceList_.clear();
|
||||||
|
if (pluginId_.isEmpty())
|
||||||
|
return;
|
||||||
const auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_);
|
const auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_);
|
||||||
for (const auto& preference : preferences) {
|
for (const auto& preference : preferences) {
|
||||||
if (preference["key"] == preferenceKey_) {
|
if (preference["key"] == preferenceKey_) {
|
||||||
|
|
|
@ -89,6 +89,26 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
|
||||||
acceptedFiles.append(QString("All (*.%1)").arg(mimeTypeList.join(" *.")));
|
acceptedFiles.append(QString("All (*.%1)").arg(mimeTypeList.join(" *.")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const auto dependsOn = details["dependsOn"].split(",");
|
||||||
|
const auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_);
|
||||||
|
const auto prefValues = lrcInstance_->pluginModel().getPluginPreferencesValues(pluginId_);
|
||||||
|
bool enabled = true;
|
||||||
|
for (auto& preference : preferences) {
|
||||||
|
auto key = preference["key"];
|
||||||
|
auto prefValue = prefValues[key];
|
||||||
|
for (auto& item : dependsOn) {
|
||||||
|
if (preference["type"] == "Switch" && item.endsWith(key)) {
|
||||||
|
if (!item.startsWith("!") && prefValue == "0") {
|
||||||
|
enabled = false;
|
||||||
|
break;
|
||||||
|
} else if (item.startsWith("!") && prefValue == "1") {
|
||||||
|
enabled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Role::PreferenceKey:
|
case Role::PreferenceKey:
|
||||||
return QVariant(details["key"]);
|
return QVariant(details["key"]);
|
||||||
|
@ -108,6 +128,8 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
|
||||||
return QVariant(acceptedFiles);
|
return QVariant(acceptedFiles);
|
||||||
case Role::IsImage:
|
case Role::IsImage:
|
||||||
return QVariant(checkImage);
|
return QVariant(checkImage);
|
||||||
|
case Role::Enabled:
|
||||||
|
return QVariant(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -126,6 +148,7 @@ PreferenceItemListModel::roleNames() const
|
||||||
roles[CurrentPath] = "CurrentPath";
|
roles[CurrentPath] = "CurrentPath";
|
||||||
roles[FileFilters] = "FileFilters";
|
roles[FileFilters] = "FileFilters";
|
||||||
roles[IsImage] = "IsImage";
|
roles[IsImage] = "IsImage";
|
||||||
|
roles[Enabled] = "Enabled";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,13 +215,32 @@ PreferenceItemListModel::setMediaHandlerName(const QString mediaHandlerName)
|
||||||
mediaHandlerName_ = mediaHandlerName;
|
mediaHandlerName_ = mediaHandlerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
PreferenceItemListModel::category() const
|
||||||
|
{
|
||||||
|
return category_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PreferenceItemListModel::setCategory(const QString category)
|
||||||
|
{
|
||||||
|
category_ = category;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PreferenceItemListModel::preferencesCount()
|
PreferenceItemListModel::preferencesCount()
|
||||||
{
|
{
|
||||||
if (!preferenceList_.isEmpty())
|
if (!preferenceList_.isEmpty())
|
||||||
return preferenceList_.size();
|
return preferenceList_.size();
|
||||||
if (mediaHandlerName_.isEmpty()) {
|
if (mediaHandlerName_.isEmpty()) {
|
||||||
preferenceList_ = lrcInstance_->pluginModel().getPluginPreferences(pluginId_);
|
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_);
|
||||||
|
if (category_ != "all")
|
||||||
|
for (auto& preference : preferences) {
|
||||||
|
if (preference["category"] == category_)
|
||||||
|
preferenceList_.push_back(preference);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
preferenceList_ = preferences;
|
||||||
return preferenceList_.size();
|
return preferenceList_.size();
|
||||||
} else {
|
} else {
|
||||||
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_);
|
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_);
|
||||||
|
|
|
@ -39,7 +39,8 @@ public:
|
||||||
PreferenceCurrentValue,
|
PreferenceCurrentValue,
|
||||||
CurrentPath,
|
CurrentPath,
|
||||||
FileFilters,
|
FileFilters,
|
||||||
IsImage
|
IsImage,
|
||||||
|
Enabled
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -78,10 +79,13 @@ public:
|
||||||
void setPluginId(const QString& pluginId);
|
void setPluginId(const QString& pluginId);
|
||||||
QString mediaHandlerName() const;
|
QString mediaHandlerName() const;
|
||||||
void setMediaHandlerName(const QString mediaHandlerName);
|
void setMediaHandlerName(const QString mediaHandlerName);
|
||||||
|
QString category() const;
|
||||||
|
void setCategory(const QString category);
|
||||||
int preferencesCount();
|
int preferencesCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString pluginId_;
|
QString pluginId_;
|
||||||
QString mediaHandlerName_ = "";
|
QString mediaHandlerName_ = "";
|
||||||
VectorMapStringString preferenceList_;
|
VectorMapStringString preferenceList_;
|
||||||
|
QString category_ = "all";
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,6 +23,7 @@ import QtQuick.Layouts 1.14
|
||||||
import QtGraphicalEffects 1.14
|
import QtGraphicalEffects 1.14
|
||||||
|
|
||||||
import net.jami.Models 1.0
|
import net.jami.Models 1.0
|
||||||
|
import net.jami.Adapters 1.0
|
||||||
import net.jami.Constants 1.0
|
import net.jami.Constants 1.0
|
||||||
|
|
||||||
import "../../commoncomponents"
|
import "../../commoncomponents"
|
||||||
|
@ -34,45 +35,39 @@ ItemDelegate {
|
||||||
property string pluginId: ""
|
property string pluginId: ""
|
||||||
property string pluginIcon: ""
|
property string pluginIcon: ""
|
||||||
property bool isLoaded: false
|
property bool isLoaded: false
|
||||||
|
property int rowHeight: implicitHeight
|
||||||
|
|
||||||
signal btnLoadPluginToggled
|
signal btnLoadPluginToggled
|
||||||
|
|
||||||
function btnPreferencesPluginClicked() {
|
function btnPreferencesPluginClicked() {
|
||||||
pluginListPreferencesView.pluginName = pluginName
|
|
||||||
pluginListPreferencesView.pluginIcon = pluginIcon
|
|
||||||
pluginListPreferencesView.pluginId = pluginId
|
|
||||||
pluginListPreferencesView.isLoaded = isLoaded
|
|
||||||
if (!pluginListPreferencesView.visible) {
|
|
||||||
pluginListPreferencesView.visible = !pluginListPreferencesView.visible
|
pluginListPreferencesView.visible = !pluginListPreferencesView.visible
|
||||||
root.height += pluginListPreferencesView.childrenRect.height
|
pluginListPreferencesView.updateProperties(root.pluginName, root.pluginIcon, root.pluginId, root.isLoaded)
|
||||||
} else {
|
|
||||||
root.height -= pluginListPreferencesView.childrenRect.height
|
|
||||||
pluginListPreferencesView.visible = !pluginListPreferencesView.visible
|
|
||||||
}
|
|
||||||
PluginAdapter.preferenceChanged(pluginId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: enabledplugin
|
target: enabledplugin
|
||||||
|
|
||||||
function onHidePreferences() {
|
function onHidePreferences() {
|
||||||
root.height = 50
|
|
||||||
pluginListPreferencesView.visible = false
|
pluginListPreferencesView.visible = false
|
||||||
|
pluginListPreferencesView.updatePluginPrefListView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
Layout.preferredHeight: childrenRect.height
|
implicitHeight: childrenRect.height
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: root.rowHeight
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: pluginImage
|
id: pluginImage
|
||||||
Layout.leftMargin: 8
|
Layout.leftMargin: 8
|
||||||
|
Layout.topMargin: 8
|
||||||
Layout.alignment: Qt.AlignLeft | Qt.AlingVCenter
|
Layout.alignment: Qt.AlignLeft | Qt.AlingVCenter
|
||||||
width: 30
|
width: JamiTheme.preferredFieldHeight
|
||||||
|
Layout.fillHeight: true
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
@ -81,26 +76,31 @@ ItemDelegate {
|
||||||
source: "file:" + pluginIcon
|
source: "file:" + pluginIcon
|
||||||
sourceSize: Qt.size(256, 256)
|
sourceSize: Qt.size(256, 256)
|
||||||
mipmap: true
|
mipmap: true
|
||||||
width: 32
|
width: JamiTheme.preferredFieldHeight
|
||||||
height: 32
|
height: JamiTheme.preferredFieldHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: labelDeviceId
|
id: labelDeviceId
|
||||||
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 8
|
||||||
Layout.leftMargin: 8
|
Layout.leftMargin: 8
|
||||||
color: JamiTheme.textColor
|
color: JamiTheme.textColor
|
||||||
|
|
||||||
font.pointSize: JamiTheme.settingsFontSize
|
font.pointSize: JamiTheme.settingsFontSize
|
||||||
font.kerning: true
|
font.kerning: true
|
||||||
text: pluginName === "" ? pluginId : pluginName
|
text: pluginName === "" ? pluginId : pluginName
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Switch {
|
Switch {
|
||||||
id: loadSwitch
|
id: loadSwitch
|
||||||
|
Layout.fillHeight: true
|
||||||
property bool isHovering: false
|
property bool isHovering: false
|
||||||
|
Layout.topMargin: 8
|
||||||
Layout.rightMargin: 8
|
Layout.rightMargin: 8
|
||||||
width: 20
|
width: 20
|
||||||
|
|
||||||
|
@ -137,6 +137,7 @@ ItemDelegate {
|
||||||
id: btnPreferencesPlugin
|
id: btnPreferencesPlugin
|
||||||
|
|
||||||
Layout.alignment: Qt.AlingVCenter | Qt.AlignRight
|
Layout.alignment: Qt.AlingVCenter | Qt.AlignRight
|
||||||
|
Layout.topMargin: 8
|
||||||
Layout.rightMargin: 8
|
Layout.rightMargin: 8
|
||||||
|
|
||||||
source: "qrc:/images/icons/round-settings-24px.svg"
|
source: "qrc:/images/icons/round-settings-24px.svg"
|
||||||
|
@ -151,13 +152,18 @@ ItemDelegate {
|
||||||
PluginListPreferencesView {
|
PluginListPreferencesView {
|
||||||
id: pluginListPreferencesView
|
id: pluginListPreferencesView
|
||||||
|
|
||||||
Layout.topMargin: 10
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: JamiTheme.preferredMarginSize
|
Layout.leftMargin: JamiTheme.preferredMarginSize
|
||||||
Layout.rightMargin: JamiTheme.preferredMarginSize
|
Layout.rightMargin: JamiTheme.preferredMarginSize
|
||||||
Layout.bottomMargin: JamiTheme.preferredMarginSize
|
|
||||||
Layout.minimumHeight: 1
|
Layout.minimumHeight: 1
|
||||||
Layout.preferredHeight: childrenRect.height
|
Layout.preferredHeight: childrenRect.height
|
||||||
|
|
||||||
|
onUpdatePluginPrefListView: {
|
||||||
|
if (pluginListPreferencesView.visible)
|
||||||
|
root.implicitHeight = root.rowHeight + pluginListPreferencesView.childrenRect.height
|
||||||
|
else
|
||||||
|
root.implicitHeight = root.rowHeight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,18 +44,56 @@ Rectangle {
|
||||||
property string pluginIcon: ""
|
property string pluginIcon: ""
|
||||||
property string pluginId: ""
|
property string pluginId: ""
|
||||||
property bool isLoaded: false
|
property bool isLoaded: false
|
||||||
|
property string category: ""
|
||||||
|
property var categories: ["all"]
|
||||||
|
property string generalCategory: ""
|
||||||
|
|
||||||
visible: false
|
visible: false
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
signal uninstalled
|
signal uninstalled
|
||||||
|
signal updatePluginPrefListView
|
||||||
|
|
||||||
|
function updateProperties(name, icon, path, status) {
|
||||||
|
root.pluginName = name
|
||||||
|
root.pluginIcon = icon
|
||||||
|
root.pluginId = path
|
||||||
|
root.isLoaded = status
|
||||||
|
root.categories = PluginAdapter.getPluginPreferencesCategories(path)
|
||||||
|
if (root.category === "" && root.categories.length > 0)
|
||||||
|
root.category = root.categories[0]
|
||||||
|
resetModels()
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetModels() {
|
||||||
|
updatePluginPrefListView()
|
||||||
|
root.categories = PluginAdapter.getPluginPreferencesCategories(root.pluginId)
|
||||||
|
if (root.categories.length <= 1) {
|
||||||
|
root.generalCategory = "all"
|
||||||
|
categoriesGrid.visible = false
|
||||||
|
prefsByCategory.visible = false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gridModel.model = root.categories
|
||||||
|
if (root.categories.length % 2 == 1) {
|
||||||
|
gridModel.model = PluginAdapter.getPluginPreferencesCategories(pluginId, true)
|
||||||
|
oddCategoryButton.text = root.categories[root.categories.length - 1]
|
||||||
|
oddCategoryButton.highlighted = root.category == oddCategoryButton.text
|
||||||
|
}
|
||||||
|
oddCategoryButton.visible = root.categories.length % 2 == 1
|
||||||
|
root.generalCategory = ""
|
||||||
|
}
|
||||||
|
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(root.pluginId, root.generalCategory)
|
||||||
|
pluginPreferenceViewCategory.model = PluginAdapter.getPluginPreferencesModel(root.pluginId, root.category)
|
||||||
|
updatePluginPrefListView()
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: PluginAdapter
|
target: PluginAdapter
|
||||||
|
|
||||||
function onPreferenceChanged(pluginId) {
|
function onPreferenceChanged(pluginId) {
|
||||||
if (root.pluginId == pluginId)
|
if (root.pluginId === pluginId)
|
||||||
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
resetModels()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +114,8 @@ Rectangle {
|
||||||
} else {
|
} else {
|
||||||
PluginModel.resetPluginPreferencesValues(pluginId)
|
PluginModel.resetPluginPreferencesValues(pluginId)
|
||||||
}
|
}
|
||||||
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(root.pluginId, root.generalCategory)
|
||||||
|
pluginPreferenceViewCategory.model = PluginAdapter.getPluginPreferencesModel(root.pluginId, root.category)
|
||||||
PluginAdapter.pluginHandlersUpdateStatus()
|
PluginAdapter.pluginHandlersUpdateStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +128,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstallPlugin() {
|
function uninstallPlugin() {
|
||||||
PluginModel.uninstallPlugin(pluginId)
|
PluginModel.uninstallPlugin(root.pluginId)
|
||||||
PluginAdapter.pluginUninstalled()
|
PluginAdapter.pluginUninstalled()
|
||||||
PluginAdapter.pluginHandlersUpdateStatus()
|
PluginAdapter.pluginHandlersUpdateStatus()
|
||||||
root.visible = false
|
root.visible = false
|
||||||
|
@ -117,16 +156,19 @@ Rectangle {
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.left: root.left
|
anchors.left: root.left
|
||||||
anchors.right: root.right
|
anchors.right: root.right
|
||||||
|
anchors.bottomMargin: 10
|
||||||
|
|
||||||
Label{
|
Label{
|
||||||
|
Layout.topMargin: 34
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
height: 64
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
Image {
|
Image {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
source: pluginIcon === "" ? "" : "file:" + pluginIcon
|
source: pluginIcon === "" ? "" : "file:" + pluginIcon
|
||||||
sourceSize: Qt.size(256, 256)
|
sourceSize: Qt.size(256, 256)
|
||||||
height: 48
|
height: 64
|
||||||
width: 48
|
width: 64
|
||||||
mipmap: true
|
mipmap: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,9 +176,10 @@ Rectangle {
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 24
|
||||||
|
height: JamiTheme.preferredFieldHeight
|
||||||
|
|
||||||
text: qsTr(pluginName + "\npreferences")
|
text: qsTr(pluginName + "\nPreferences")
|
||||||
font.pointSize: JamiTheme.headerFontSize
|
font.pointSize: JamiTheme.headerFontSize
|
||||||
font.kerning: true
|
font.kerning: true
|
||||||
color: JamiTheme.textColor
|
color: JamiTheme.textColor
|
||||||
|
@ -145,8 +188,183 @@ Rectangle {
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: prefsByCategory
|
||||||
|
Layout.topMargin: 24
|
||||||
|
Layout.fillWidth: true
|
||||||
|
implicitHeight: childrenRect.height
|
||||||
|
color: JamiTheme.backgroundColor
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
GridLayout {
|
||||||
|
id: categoriesGrid
|
||||||
|
Layout.fillWidth: true
|
||||||
|
implicitHeight: childrenRect.height
|
||||||
|
columns: 2
|
||||||
|
columnSpacing: 0
|
||||||
|
rowSpacing: 0
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: gridModel
|
||||||
|
model: root.categories
|
||||||
|
Button {
|
||||||
|
id: repDelegate
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: JamiTheme.preferredFieldHeight
|
||||||
|
highlighted: root.category === modelData
|
||||||
|
text: modelData
|
||||||
|
flat: true
|
||||||
|
onClicked: {
|
||||||
|
root.category = modelData
|
||||||
|
PluginAdapter.preferenceChanged(root.pluginId)
|
||||||
|
}
|
||||||
|
background: Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: repDelegate.highlighted ? JamiTheme.selectedColor : JamiTheme.primaryBackgroundColor
|
||||||
|
border.color: JamiTheme.selectedColor
|
||||||
|
border.width: 1
|
||||||
|
}
|
||||||
|
contentItem: Text {
|
||||||
|
text: repDelegate.text
|
||||||
|
font: repDelegate.font
|
||||||
|
opacity: enabled ? 1.0 : 0.3
|
||||||
|
color: JamiTheme.primaryForegroundColor
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: oddCategoryButton
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: JamiTheme.preferredFieldHeight
|
||||||
|
flat: true
|
||||||
|
visible: false
|
||||||
|
onClicked: {
|
||||||
|
root.category = oddCategoryButton.text
|
||||||
|
PluginAdapter.preferenceChanged(root.pluginId)
|
||||||
|
}
|
||||||
|
background: Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: oddCategoryButton.highlighted ? JamiTheme.selectedColor : JamiTheme.primaryBackgroundColor
|
||||||
|
border.color: JamiTheme.selectedColor
|
||||||
|
border.width: 1
|
||||||
|
}
|
||||||
|
contentItem: Text {
|
||||||
|
text: oddCategoryButton.text
|
||||||
|
font: oddCategoryButton.font
|
||||||
|
opacity: enabled ? 1.0 : 0.3
|
||||||
|
color: JamiTheme.primaryForegroundColor
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: pluginPreferenceViewCategory
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.minimumHeight: 1
|
||||||
|
Layout.preferredHeight: childrenRect.height
|
||||||
|
implicitHeight: childrenRect.height
|
||||||
|
|
||||||
|
model: PluginAdapter.getPluginPreferencesModel(root.pluginId, root.category)
|
||||||
|
interactive: false
|
||||||
|
|
||||||
|
delegate: PreferenceItemDelegate {
|
||||||
|
id: preferenceItemDelegateCategory
|
||||||
|
|
||||||
|
width: pluginPreferenceViewCategory.width
|
||||||
|
height: 50
|
||||||
|
|
||||||
|
preferenceName: PreferenceName
|
||||||
|
preferenceSummary: PreferenceSummary
|
||||||
|
preferenceType: PreferenceType
|
||||||
|
preferenceCurrentValue: PreferenceCurrentValue
|
||||||
|
pluginId: PluginId
|
||||||
|
currentPath: CurrentPath
|
||||||
|
preferenceKey: PreferenceKey
|
||||||
|
fileFilters: FileFilters
|
||||||
|
isImage: IsImage
|
||||||
|
enabled: Enabled
|
||||||
|
pluginListPreferenceModel: PluginListPreferenceModel {
|
||||||
|
id: pluginListPreferenceCategoryModel
|
||||||
|
|
||||||
|
lrcInstance: LRCInstance
|
||||||
|
preferenceKey : PreferenceKey
|
||||||
|
pluginId: PluginId
|
||||||
|
}
|
||||||
|
|
||||||
|
onBtnPreferenceClicked: {
|
||||||
|
setPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
|
pluginPreferenceViewCategory.model = PluginAdapter.getPluginPreferencesModel(pluginId, root.category)
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: JamiTheme.backgroundColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: pluginPreferenceView
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.minimumHeight: 1
|
||||||
|
|
||||||
|
implicitHeight: childrenRect.height
|
||||||
|
Layout.preferredHeight: childrenRect.height
|
||||||
|
|
||||||
|
model: PluginAdapter.getPluginPreferencesModel(root.pluginId)
|
||||||
|
interactive: false
|
||||||
|
|
||||||
|
delegate: PreferenceItemDelegate {
|
||||||
|
id: preferenceItemDelegate
|
||||||
|
|
||||||
|
width: pluginPreferenceView.width
|
||||||
|
height: 50
|
||||||
|
|
||||||
|
preferenceName: PreferenceName
|
||||||
|
preferenceSummary: PreferenceSummary
|
||||||
|
preferenceType: PreferenceType
|
||||||
|
preferenceCurrentValue: PreferenceCurrentValue
|
||||||
|
pluginId: PluginId
|
||||||
|
currentPath: CurrentPath
|
||||||
|
preferenceKey: PreferenceKey
|
||||||
|
fileFilters: FileFilters
|
||||||
|
isImage: IsImage
|
||||||
|
enabled: Enabled
|
||||||
|
pluginListPreferenceModel: PluginListPreferenceModel {
|
||||||
|
id: pluginListPreferenceModel
|
||||||
|
|
||||||
|
lrcInstance: LRCInstance
|
||||||
|
preferenceKey : PreferenceKey
|
||||||
|
pluginId: PluginId
|
||||||
|
}
|
||||||
|
|
||||||
|
onBtnPreferenceClicked: {
|
||||||
|
setPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
|
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId, generalCategory)
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "transparent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.topMargin: 10
|
Layout.topMargin: 10
|
||||||
|
Layout.bottomMargin: 10
|
||||||
height: 30
|
height: 30
|
||||||
|
|
||||||
MaterialButton {
|
MaterialButton {
|
||||||
|
@ -186,49 +404,14 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
Rectangle {
|
||||||
id: pluginPreferenceView
|
id: endline
|
||||||
|
Layout.bottomMargin: 10
|
||||||
|
height: 2
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.minimumHeight: 1
|
color: "transparent"
|
||||||
Layout.preferredHeight: childrenRect.height + 30
|
border.width: 1
|
||||||
|
border.color: JamiTheme.separationLine
|
||||||
model: PluginAdapter.getPluginPreferencesModel(pluginId)
|
|
||||||
interactive: false
|
|
||||||
|
|
||||||
delegate: PreferenceItemDelegate {
|
|
||||||
id: preferenceItemDelegate
|
|
||||||
|
|
||||||
width: pluginPreferenceView.width
|
|
||||||
height: 50
|
|
||||||
|
|
||||||
preferenceName: PreferenceName
|
|
||||||
preferenceSummary: PreferenceSummary
|
|
||||||
preferenceType: PreferenceType
|
|
||||||
preferenceCurrentValue: PreferenceCurrentValue
|
|
||||||
pluginId: PluginId
|
|
||||||
currentPath: CurrentPath
|
|
||||||
preferenceKey: PreferenceKey
|
|
||||||
fileFilters: FileFilters
|
|
||||||
isImage: IsImage
|
|
||||||
pluginListPreferenceModel: PluginListPreferenceModel {
|
|
||||||
id: pluginListPreferenceModel
|
|
||||||
|
|
||||||
lrcInstance: LRCInstance
|
|
||||||
preferenceKey : PreferenceKey
|
|
||||||
pluginId: PluginId
|
|
||||||
}
|
|
||||||
|
|
||||||
onBtnPreferenceClicked: {
|
|
||||||
setPreference(pluginId, preferenceKey, preferenceNewValue)
|
|
||||||
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
|
||||||
}
|
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
color: JamiTheme.secondaryBackgroundColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,13 +124,13 @@ Rectangle {
|
||||||
Layout.bottomMargin: 10
|
Layout.bottomMargin: 10
|
||||||
|
|
||||||
model: PluginAdapter.getPluginSelectableModel()
|
model: PluginAdapter.getPluginSelectableModel()
|
||||||
interactive: false
|
|
||||||
|
|
||||||
delegate: PluginItemDelegate {
|
delegate: PluginItemDelegate {
|
||||||
id: pluginItemDelegate
|
id: pluginItemDelegate
|
||||||
|
|
||||||
width: pluginListView.width
|
width: pluginListView.width
|
||||||
implicitHeight: 50
|
rowHeight: 40
|
||||||
|
implicitHeight: 40
|
||||||
|
|
||||||
pluginName: PluginName
|
pluginName: PluginName
|
||||||
pluginId: PluginId
|
pluginId: PluginId
|
||||||
|
@ -140,6 +140,11 @@ Rectangle {
|
||||||
onBtnLoadPluginToggled: {
|
onBtnLoadPluginToggled: {
|
||||||
isLoaded = loadPluginSlot(pluginId, isLoaded)
|
isLoaded = loadPluginSlot(pluginId, isLoaded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "transparent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue