Updated plugins page

This commit is contained in:
Eism 2022-02-11 15:52:11 +02:00
parent 97e71c3f34
commit ad70cad86b
4 changed files with 87 additions and 43 deletions

View file

@ -65,80 +65,114 @@ FocusScope {
color: ui.theme.backgroundSecondaryColor color: ui.theme.backgroundSecondaryColor
} }
RowLayout { NavigationPanel {
id: navTopPanel
name: "PluginsTopPanel"
section: navSec
order: 1
accessible.name: qsTrc("appshell", "Plugins")
}
Column {
id: topLayout id: topLayout
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: prv.sideMargin anchors.topMargin: prv.sideMargin
anchors.left: parent.left
anchors.leftMargin: prv.sideMargin
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: prv.sideMargin anchors.rightMargin: prv.sideMargin
spacing: 12 spacing: 24
NavigationPanel { RowLayout {
id: navSearchPanel width: parent.width
name: "PluginsSearch"
enabled: topLayout.enabled && topLayout.visible
section: navSec
order: 1
accessible.name: qsTrc("appshell", "Plugins")
}
SearchField { spacing: 12
id: searchField
Layout.preferredWidth: 220 StyledTextLabel {
id: pageTitle
Layout.fillWidth: true
navigation.name: "PluginsSearch" text: qsTrc("project", "Plugins")
navigation.panel: navSearchPanel font: ui.theme.titleBoldFont
navigation.order: 1 horizontalAlignment: Text.AlignLeft
accessible.name: qsTrc("appshell", "Plugins search")
onSearchTextChanged: {
categoryComboBox.selectedCategory = ""
} }
}
Dropdown { SearchField {
id: categoryComboBox id: searchField
width: searchField.width Layout.preferredWidth: 220
navigation.name: "CategoryComboBox" navigation.name: "PluginsSearch"
navigation.panel: navSearchPanel navigation.panel: navTopPanel
navigation.order: 2 navigation.order: 1
accessible.name: qsTrc("appshell", "Plugins search")
readonly property string allCategoryValue: "ALL_CATEGORY" onSearchTextChanged: {
property string selectedCategory: (currentValue !== allCategoryValue) ? currentValue : "" categoryComboBox.selectedCategory = ""
}
}
displayText: qsTrc("appshell", "Category: ") + categoryComboBox.currentText Dropdown {
currentIndex: indexOfValue(allCategoryValue) id: categoryComboBox
function initModel() { width: searchField.width
var categories = pluginsComp.categories()
var result = []
result.push({ "text": qsTrc("appshell", "All"), "value": allCategoryValue }) navigation.name: "CategoryComboBox"
navigation.panel: navTopPanel
navigation.order: 2
for (var i = 0; i < categories.length; ++i) { readonly property string allCategoryValue: "ALL_CATEGORY"
var category = categories[i] property string selectedCategory: (currentValue !== allCategoryValue) ? currentValue : ""
result.push({ "text": category, "value": category })
displayText: qsTrc("appshell", "Category: ") + categoryComboBox.currentText
currentIndex: indexOfValue(allCategoryValue)
function initModel() {
var categories = pluginsPage.categories()
var result = []
result.push({ "text": qsTrc("appshell", "All"), "value": allCategoryValue })
for (var i = 0; i < categories.length; ++i) {
var category = categories[i]
result.push({ "text": category, "value": category })
}
model = result
} }
model = result Component.onCompleted: {
initModel()
}
} }
}
Component.onCompleted: { FlatButton {
initModel() id: reloadButton
anchors.right: parent.right
text: qsTrc("plugins", "Reload plugins")
icon: IconCode.UPDATE
orientation: Qt.Horizontal
navigation.name: "PluginsReloadButton"
navigation.panel: navTopPanel
navigation.order: 3
onClicked: {
pluginsPage.reloadPlugins()
} }
} }
} }
PluginsPage { PluginsPage {
id: pluginsComp id: pluginsPage
anchors.top: topLayout.bottom anchors.top: topLayout.bottom
anchors.topMargin: 36 anchors.topMargin: 24
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom

View file

@ -43,6 +43,10 @@ Item {
return pluginsModel.categories() return pluginsModel.categories()
} }
function reloadPlugins() {
pluginsModel.reloadPlugins()
}
PluginsModel { PluginsModel {
id: pluginsModel id: pluginsModel

View file

@ -162,6 +162,11 @@ void PluginsModel::editShortcut(QString codeKey)
} }
} }
void PluginsModel::reloadPlugins()
{
service()->reloadPlugins();
}
QStringList PluginsModel::categories() const QStringList PluginsModel::categories() const
{ {
QSet<QString> result; QSet<QString> result;

View file

@ -49,6 +49,7 @@ public:
Q_INVOKABLE void load(); Q_INVOKABLE void load();
Q_INVOKABLE void setEnable(const QString& codeKey, bool enable); Q_INVOKABLE void setEnable(const QString& codeKey, bool enable);
Q_INVOKABLE void editShortcut(QString codeKey); Q_INVOKABLE void editShortcut(QString codeKey);
Q_INVOKABLE void reloadPlugins();
Q_INVOKABLE QStringList categories() const; Q_INVOKABLE QStringList categories() const;