Commit 58cab906 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[nextcloud] Rework services page

Instead of a single checkbox for contacts show a proper list (still one entry for now)
parent 12e83a96
......@@ -197,7 +197,7 @@ QString NextcloudController::errorMessage() const
return m_errorMessage;
}
void NextcloudController::finish(bool contactsEnabled)
void NextcloudController::finish(const QStringList disabledServices)
{
QVariantMap data;
data.insert("server", m_server);
......@@ -208,9 +208,17 @@ void NextcloudController::finish(bool contactsEnabled)
data.insert("dav/storagePath", QStringLiteral("/remote.php/dav/files/%1").arg(m_username));
data.insert("dav/contactsPath", QStringLiteral("/remote.php/dav/addressbooks/users/%1").arg(m_username));
if (!contactsEnabled) {
data.insert("__service/nextcloud-contacts", false);
for (const QString &service : disabledServices) {
data.insert("__service/" + service, false);
}
Q_EMIT wizardFinished(m_username, m_password, data);
}
QVariantList NextcloudController::availableServices() const
{
// TODO Find a way to not hardcode this
return {
QVariant::fromValue(Service{QStringLiteral("nextcloud-contacts"), i18n("Contacts"), i18n("Synchronize contacts")})
};
}
......@@ -20,6 +20,20 @@ namespace KIO
class KJob;
class Service
{
Q_GADGET
Q_PROPERTY(QString id MEMBER m_id)
Q_PROPERTY(QString name MEMBER m_name)
Q_PROPERTY(QString description MEMBER m_description);
public:
QString m_id;
QString m_name;
QString m_description;
};
class NextcloudUrlIntercepter : public QWebEngineUrlRequestInterceptor
{
void interceptRequest(QWebEngineUrlRequestInfo &info) override;
......@@ -33,6 +47,7 @@ class NextcloudController : public QObject
Q_PROPERTY(State state MEMBER m_state NOTIFY stateChanged)
Q_PROPERTY(QQuickWebEngineProfile *webengineProfile MEMBER m_webengineProfile CONSTANT)
Q_PROPERTY(QString loginUrl MEMBER m_loginUrl NOTIFY loginUrlChanged)
Q_PROPERTY(QVariantList availableServices READ availableServices CONSTANT)
public:
......@@ -47,10 +62,11 @@ public:
~NextcloudController();
Q_INVOKABLE void checkServer(const QString &server);
Q_INVOKABLE void finish(bool contactsEnabled);
Q_INVOKABLE void finish(const QStringList disabledServices);
bool isWorking();
bool isLoginComplete();
QString errorMessage() const;
QVariantList availableServices() const;
Q_SIGNALS:
void isWorkingChanged();
......
......@@ -10,25 +10,77 @@ import org.kde.kirigami 2.5 as Kirigami
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.5
Kirigami.Page {
Kirigami.ScrollablePage {
id: root
title: i18n("Services")
title: i18n("Choose services to enable")
property var disabledServices: []
ColumnLayout {
anchors.fill: parent
ListView {
model: helper.availableServices
CheckBox {
id: contactsService
text: i18n("Contacts")
}
Button {
id: finishButton
Layout.fillWidth: true
text: i18n("Finish")
clip: true
// Cheap copy of Kirigami.BasicListItem with CheckBox instead of Icon
delegate: Kirigami.AbstractListItem {
id: listItem
highlighted: false
onClicked: serviceCheck.toggle()
RowLayout {
CheckBox {
id: serviceCheck
Layout.alignment: Qt.AlignVCenter
checked: true
onCheckedChanged: {
if (serviceCheck.checked) {
const idx = root.disabledServices.indexOf(modelData.id);
if (idx > -1) {
root.disabledServices.splice(idx, 1);
}
} else {
root.disabledServices.push(modelData.id)
}
}
}
ColumnLayout {
spacing: 0
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Label {
Layout.fillWidth: true
text: modelData.name
color: listItem.pressed ? listItem.activeTextColor : listItem.textColor
elide: Text.ElideRight
}
onClicked: {
helper.finish(contactsService.checked);
Label {
Layout.fillWidth: true
text: modelData.description
color: listItem.pressed ? listItem.activeTextColor : listItem.textColor
elide: Text.ElideRight
font: Kirigami.Theme.smallFont
opacity: 0.7
visible: text.length > 0
}
}
}
}
}
footer: ToolBar {
RowLayout {
anchors.fill: parent
Button {
text: i18n("Finish")
Layout.alignment: Qt.AlignRight
onClicked: {
helper.finish(root.disabledServices)
}
}
}
}
}
Markdown is supported
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