Commit 5af64380 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

flatpak: Move the apply changes button into an InlineMessage

It's easier to spot.
parent 95996771
Pipeline #193945 failed with stage
in 1 minute and 38 seconds
......@@ -52,75 +52,91 @@ DiscoverPage {
}
}
contentItem: RowLayout {
Kirigami.Heading {
text: resourcesBackend.displayName
level: 3
font.weight: backendItem.isDefault ? Font.Bold : Font.Normal
}
contentItem: ColumnLayout {
RowLayout {
Kirigami.Heading {
text: resourcesBackend.displayName
level: 3
font.weight: backendItem.isDefault ? Font.Bold : Font.Normal
}
Kirigami.ActionToolBar {
id: actionBar
Kirigami.ActionToolBar {
id: actionBar
alignment: Qt.AlignRight
alignment: Qt.AlignRight
Kirigami.Action {
id: isDefaultbackendLabelAction
Kirigami.Action {
id: isDefaultbackendLabelAction
visible: backendItem.isDefault
displayHint: Kirigami.DisplayHint.KeepVisible
displayComponent: Kirigami.Heading {
text: i18n("Default source")
level: 3
font.weight: Font.Bold
visible: backendItem.isDefault
displayHint: Kirigami.DisplayHint.KeepVisible
displayComponent: Kirigami.Heading {
text: i18n("Default source")
level: 3
font.weight: Font.Bold
}
}
}
Kirigami.Action {
id: addSourceAction
text: i18n("Add Source…")
icon.name: "list-add"
visible: backendItem.backend && backendItem.backend.supportsAdding
Kirigami.Action {
id: addSourceAction
text: i18n("Add Source…")
icon.name: "list-add"
visible: backendItem.backend && backendItem.backend.supportsAdding
readonly property Component p0: Component {
id: dialogComponent
AddSourceDialog {
source: backendItem.backend
readonly property Component p0: Component {
id: dialogComponent
AddSourceDialog {
source: backendItem.backend
onSheetOpenChanged: if(!sheetOpen) {
destroy(1000)
onSheetOpenChanged: if(!sheetOpen) {
destroy(1000)
}
}
}
onTriggered: {
var addSourceDialog = dialogComponent.createObject(window, {displayName: backendItem.backend.resourcesBackend.displayName })
addSourceDialog.open()
}
}
Kirigami.Action {
id: makeDefaultAction
visible: resourcesBackend && resourcesBackend.hasApplications && !backendItem.isDefault
onTriggered: {
var addSourceDialog = dialogComponent.createObject(window, {displayName: backendItem.backend.resourcesBackend.displayName })
addSourceDialog.open()
text: i18n("Make default")
icon.name: "favorite"
onTriggered: ResourcesModel.currentApplicationBackend = backendItem.backend.resourcesBackend
}
}
Kirigami.Action {
id: makeDefaultAction
visible: resourcesBackend && resourcesBackend.hasApplications && !backendItem.isDefault
text: i18n("Make default")
icon.name: "favorite"
onTriggered: ResourcesModel.currentApplicationBackend = backendItem.backend.resourcesBackend
}
Component {
id: kirigamiAction
ConvertDiscoverAction {}
}
Component {
id: kirigamiAction
ConvertDiscoverAction {}
function mergeActions(moreActions) {
var actions = [isDefaultbackendLabelAction,
makeDefaultAction,
addSourceAction]
for(var i in moreActions) {
actions.push(kirigamiAction.createObject(actionBar, {action: moreActions[i]}))
}
return actions;
}
actions: mergeActions(backendItem.backend.actions)
}
}
function mergeActions(moreActions) {
var actions = [isDefaultbackendLabelAction,
makeDefaultAction,
addSourceAction]
for(var i in moreActions) {
actions.push(kirigamiAction.createObject(actionBar, {action: moreActions[i]}))
Kirigami.InlineMessage {
Layout.fillWidth: true
text: backendItem.backend.inlineAction.toolTip
visible: backendItem.backend.inlineAction && backendItem.backend.inlineAction.visible
actions: [
Kirigami.Action {
icon.name: backendItem.backend.inlineAction.iconName
text: backendItem.backend.inlineAction.text
onTriggered: backendItem.backend.inlineAction.trigger()
}
return actions;
}
actions: mergeActions(backendItem.backend.actions)
]
}
}
}
......
......@@ -135,6 +135,7 @@ void FlatpakSourcesBackend::save()
last = prio;
}
}
m_saveAction->setVisible(false);
}
QAbstractItemModel *FlatpakSourcesBackend::sources()
......@@ -301,7 +302,7 @@ bool FlatpakSourcesBackend::removeSource(const QString &id)
QVariantList FlatpakSourcesBackend::actions() const
{
return {QVariant::fromValue<QObject *>(m_flathubAction), QVariant::fromValue<QObject *>(m_saveAction)};
return {QVariant::fromValue<QObject *>(m_flathubAction)};
}
void FlatpakSourcesBackend::addRemote(FlatpakRemote *remote, FlatpakInstallation *installation)
......
......@@ -53,6 +53,10 @@ public:
int originIndex(const QString &sourceId) const;
QStandardItem *sourceByUrl(const QString &url) const;
QStandardItem *sourceById(const QString &sourceId) const;
DiscoverAction *inlineAction() const override
{
return m_saveAction;
}
void cancel() override;
void proceed() override;
......
......@@ -10,6 +10,7 @@
#include "discovercommon_export.h"
#include <QObject>
class DiscoverAction;
class QAbstractItemModel;
class AbstractResourcesBackend;
......@@ -20,6 +21,7 @@ class DISCOVERCOMMON_EXPORT AbstractSourcesBackend : public QObject
Q_PROPERTY(QAbstractItemModel *sources READ sources CONSTANT)
Q_PROPERTY(QString idDescription READ idDescription CONSTANT)
Q_PROPERTY(QVariantList actions READ actions CONSTANT) // TODO Make it a QVector<DiscoverAction*> again when we depend on newer than Qt 5.12
Q_PROPERTY(DiscoverAction *inlineAction READ inlineAction CONSTANT) // TODO Make it a QVector<DiscoverAction*> again when we depend on newer than Qt 5.12
Q_PROPERTY(bool supportsAdding READ supportsAdding CONSTANT)
Q_PROPERTY(bool canMoveSources READ canMoveSources CONSTANT)
Q_PROPERTY(bool canFilterSources READ canFilterSources CONSTANT)
......@@ -44,6 +46,10 @@ public:
virtual QVariantList actions() const = 0;
virtual bool supportsAdding() const = 0;
virtual DiscoverAction *inlineAction() const
{
return nullptr;
}
AbstractResourcesBackend *resourcesBackend() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment