Commit 46a3cbd7 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[*cloud] Cancel configuration when window is closed

Otherwise the account creation job is never finished, preventing the calling application from quitting.

BUG: 427200
parent 33cf32b2
......@@ -39,14 +39,24 @@ void NextcloudWizard::init(KAccountsUiPlugin::UiType type)
m_object->loadPackage(packagePath);
NextcloudController *helper = new NextcloudController(m_object);
connect(helper, &NextcloudController::wizardFinished, this, &NextcloudWizard::success);
connect(helper, &NextcloudController::wizardFinished, [=] {
connect(helper, &NextcloudController::wizardFinished, this, [this](const QString &username, const QString &password, const QVariantMap &data) {
QWindow *window = qobject_cast<QWindow *>(m_object->rootObject());
if (window) {
window->close();
}
m_object->deleteLater();
Q_EMIT success(username, password, data);
});
connect(helper, &NextcloudController::wizardCancelled, this, [this] {
m_object->deleteLater();
Q_EMIT cancelled();
});
m_object->engine()->rootContext()->setContextProperty("helper", helper);
m_object->completeInitialization();
......
......@@ -186,6 +186,11 @@ QString NextcloudController::errorMessage() const
return m_errorMessage;
}
void NextcloudController::cancel()
{
Q_EMIT wizardCancelled();
}
void NextcloudController::finish(const QStringList disabledServices)
{
QVariantMap data;
......
......@@ -64,6 +64,7 @@ public:
Q_INVOKABLE void checkServer(const QString &server);
Q_INVOKABLE void finish(const QStringList disabledServices);
Q_INVOKABLE void cancel();
bool isWorking();
bool isLoginComplete();
QString errorMessage() const;
......@@ -75,6 +76,7 @@ Q_SIGNALS:
void wizardFinished(const QString &username, const QString &password, const QVariantMap &data);
void stateChanged();
void loginUrlChanged();
void wizardCancelled();
private Q_SLOTS:
void fileChecked(KJob *job);
......
......@@ -23,6 +23,10 @@ Kirigami.ApplicationWindow {
pageStack.initialPage: Qt.resolvedUrl("Server.qml");
onClosing: {
helper.cancel()
}
Connections {
target: helper
......
......@@ -37,14 +37,24 @@ void OwnCloudWizard::init(KAccountsUiPlugin::UiType type)
m_object->loadPackage(packagePath);
OwncloudController *helper = new OwncloudController(m_object);
connect(helper, &OwncloudController::wizardFinished, this, &OwnCloudWizard::success);
connect(helper, &OwncloudController::wizardFinished, [=] {
connect(helper, &OwncloudController::wizardFinished, this, [this](const QString &username, const QString &password, const QVariantMap &data) {
QWindow *window = qobject_cast<QWindow *>(m_object->rootObject());
if (window) {
window->close();
}
m_object->deleteLater();
Q_EMIT success(username, password, data);
});
connect(helper, &OwncloudController::wizardCancelled, this, [this] {
m_object->deleteLater();
Q_EMIT cancelled();
});
m_object->engine()->rootContext()->setContextProperty("helper", helper);
m_object->completeInitialization();
......
......@@ -211,6 +211,11 @@ void OwncloudController::finish(const QStringList &disabledServices)
Q_EMIT wizardFinished(m_username, m_password, data);
}
void OwncloudController::cancel()
{
Q_EMIT wizardCancelled();
}
QVariantList OwncloudController::availableServices() const
{
// TODO Find a way to not hardcode this
......
......@@ -52,6 +52,7 @@ public:
Q_INVOKABLE void checkServer(const QString &username, const QString &password, const QString &server);
Q_INVOKABLE void finish(const QStringList &disabledServices);
Q_INVOKABLE void cancel();
bool isWorking();
QString errorMessage() const;
State state() const;
......@@ -62,6 +63,7 @@ Q_SIGNALS:
void errorMessageChanged();
void wizardFinished(const QString &username, const QString &password, const QVariantMap &data);
void stateChanged();
void wizardCancelled();
private Q_SLOTS:
void fileChecked(KJob *job);
......
......@@ -24,6 +24,10 @@ Kirigami.ApplicationWindow {
pageStack.initialPage: Qt.resolvedUrl("Server.qml");
onClosing: {
helper.cancel()
}
Connections {
target: helper
......
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