mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
add a wizard page to check terms of service
should enable proper polling while the user check and signs the terms of service via teh web browser Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com> Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
This commit is contained in:
parent
ea0a3b7545
commit
0e829edef1
@ -240,6 +240,8 @@ set(client_SRCS
|
||||
wizard/flow2authwidget.cpp
|
||||
wizard/owncloudsetuppage.h
|
||||
wizard/owncloudsetuppage.cpp
|
||||
wizard/termsofservicewizardpage.h
|
||||
wizard/termsofservicewizardpage.cpp
|
||||
wizard/owncloudwizardcommon.h
|
||||
wizard/owncloudwizardcommon.cpp
|
||||
wizard/owncloudwizard.h
|
||||
|
||||
@ -104,7 +104,7 @@ void Flow2AuthCredsPage::slotFlow2AuthResult(Flow2Auth::Result r, const QString
|
||||
|
||||
int Flow2AuthCredsPage::nextId() const
|
||||
{
|
||||
return WizardCommon::Page_AdvancedSetup;
|
||||
return WizardCommon::Page_TermsOfService;
|
||||
}
|
||||
|
||||
void Flow2AuthCredsPage::setConnected()
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include "wizard/welcomepage.h"
|
||||
#include "wizard/owncloudsetuppage.h"
|
||||
#include "wizard/owncloudhttpcredspage.h"
|
||||
#include "wizard/termsofservicewizardpage.h"
|
||||
#include "wizard/owncloudadvancedsetuppage.h"
|
||||
#include "wizard/webviewpage.h"
|
||||
#include "wizard/flow2authcredspage.h"
|
||||
@ -239,9 +240,12 @@ void OwncloudWizard::setRemoteFolder(const QString &remoteFolder)
|
||||
|
||||
void OwncloudWizard::successfulStep()
|
||||
{
|
||||
const int id(currentId());
|
||||
const WizardCommon::Pages id{static_cast<WizardCommon::Pages>(currentId())};
|
||||
|
||||
switch (id) {
|
||||
case WizardCommon::Page_Welcome:
|
||||
break;
|
||||
|
||||
case WizardCommon::Page_HttpCreds:
|
||||
_httpCredsPage->setConnected();
|
||||
break;
|
||||
@ -258,6 +262,10 @@ void OwncloudWizard::successfulStep()
|
||||
break;
|
||||
#endif // WITH_WEBENGINE
|
||||
|
||||
case WizardCommon::Page_TermsOfService:
|
||||
_termsOfServicePage->initializePage();
|
||||
break;
|
||||
|
||||
case WizardCommon::Page_AdvancedSetup:
|
||||
_advancedSetupPage->directoriesCreated();
|
||||
break;
|
||||
@ -351,7 +359,13 @@ void OwncloudWizard::slotCurrentPageChanged(int id)
|
||||
|
||||
void OwncloudWizard::displayError(const QString &msg, bool retryHTTPonly)
|
||||
{
|
||||
switch (currentId()) {
|
||||
switch (static_cast<WizardCommon::Pages>(currentId())) {
|
||||
case WizardCommon::Page_Welcome:
|
||||
case WizardCommon::Page_Flow2AuthCreds:
|
||||
case WizardCommon::Page_WebView:
|
||||
case WizardCommon::Page_TermsOfService:
|
||||
break;
|
||||
|
||||
case WizardCommon::Page_ServerSetup:
|
||||
_setupPage->setErrorString(msg, retryHTTPonly);
|
||||
break;
|
||||
|
||||
@ -33,6 +33,7 @@ Q_DECLARE_LOGGING_CATEGORY(lcWizard)
|
||||
class WelcomePage;
|
||||
class OwncloudSetupPage;
|
||||
class OwncloudHttpCredsPage;
|
||||
class TermsOfServiceWizardPage;
|
||||
class OwncloudAdvancedSetupPage;
|
||||
class OwncloudWizardResultPage;
|
||||
class AbstractCredentials;
|
||||
@ -123,14 +124,15 @@ private:
|
||||
[[nodiscard]] QList<QSize> calculateWizardPageSizes() const;
|
||||
|
||||
AccountPtr _account;
|
||||
WelcomePage *_welcomePage;
|
||||
OwncloudSetupPage *_setupPage;
|
||||
OwncloudHttpCredsPage *_httpCredsPage;
|
||||
Flow2AuthCredsPage *_flow2CredsPage;
|
||||
OwncloudAdvancedSetupPage *_advancedSetupPage;
|
||||
WelcomePage *_welcomePage = nullptr;
|
||||
OwncloudSetupPage *_setupPage = nullptr;
|
||||
OwncloudHttpCredsPage *_httpCredsPage = nullptr;
|
||||
Flow2AuthCredsPage *_flow2CredsPage = nullptr;
|
||||
TermsOfServiceWizardPage *_termsOfServicePage = nullptr;
|
||||
OwncloudAdvancedSetupPage *_advancedSetupPage = nullptr;
|
||||
OwncloudWizardResultPage *_resultPage = nullptr;
|
||||
AbstractCredentialsWizardPage *_credentialsPage = nullptr;
|
||||
WebViewPage *_webViewPage = nullptr;
|
||||
WebViewPage*_webViewPage = nullptr;
|
||||
|
||||
QStringList _setupLog;
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ namespace WizardCommon {
|
||||
#ifdef WITH_WEBENGINE
|
||||
Page_WebView,
|
||||
#endif // WITH_WEBENGINE
|
||||
Page_TermsOfService,
|
||||
Page_AdvancedSetup,
|
||||
};
|
||||
|
||||
|
||||
71
src/gui/wizard/termsofservicewizardpage.cpp
Normal file
71
src/gui/wizard/termsofservicewizardpage.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) by Matthieu Gallien <matthieu.gallien@nextcloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "termsofservicewizardpage.h"
|
||||
|
||||
#include "account.h"
|
||||
#include "owncloudsetupwizard.h"
|
||||
#include "wizard/owncloudwizard.h"
|
||||
#include "wizard/owncloudwizardcommon.h"
|
||||
#include "connectionvalidator.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QDesktopServices>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
OCC::TermsOfServiceWizardPage::TermsOfServiceWizardPage()
|
||||
: QWizardPage()
|
||||
{
|
||||
_layout = new QVBoxLayout(this);
|
||||
}
|
||||
|
||||
void OCC::TermsOfServiceWizardPage::initializePage()
|
||||
{
|
||||
}
|
||||
|
||||
void OCC::TermsOfServiceWizardPage::cleanupPage()
|
||||
{
|
||||
}
|
||||
|
||||
int OCC::TermsOfServiceWizardPage::nextId() const
|
||||
{
|
||||
return WizardCommon::Page_AdvancedSetup;
|
||||
}
|
||||
|
||||
bool OCC::TermsOfServiceWizardPage::isComplete() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void TermsOfServiceWizardPage::slotPollNow()
|
||||
{
|
||||
_termsOfServiceChecker = new TermsOfServiceChecker{_ocWizard->account(), this};
|
||||
|
||||
connect(_termsOfServiceChecker, &TermsOfServiceChecker::done, this, &TermsOfServiceWizardPage::termsOfServiceChecked);
|
||||
_termsOfServiceChecker->start();
|
||||
}
|
||||
|
||||
void TermsOfServiceWizardPage::termsOfServiceChecked()
|
||||
{
|
||||
if (_termsOfServiceChecker && _termsOfServiceChecker->needToSign()) {
|
||||
QDesktopServices::openUrl(_ocWizard->account()->url());
|
||||
} else {
|
||||
_ocWizard->successfulStep();
|
||||
delete _termsOfServiceChecker;
|
||||
_termsOfServiceChecker = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
54
src/gui/wizard/termsofservicewizardpage.h
Normal file
54
src/gui/wizard/termsofservicewizardpage.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) by Matthieu Gallien <matthieu.gallien@nextcloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef TERMSOFSERVICEWIZARDPAGE_H
|
||||
#define TERMSOFSERVICEWIZARDPAGE_H
|
||||
|
||||
#include <QWizardPage>
|
||||
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class OwncloudWizard;
|
||||
class TermsOfServiceChecker;
|
||||
|
||||
class TermsOfServiceWizardPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TermsOfServiceWizardPage();
|
||||
|
||||
void initializePage() override;
|
||||
void cleanupPage() override;
|
||||
[[nodiscard]] int nextId() const override;
|
||||
[[nodiscard]] bool isComplete() const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void connectToOCUrl(const QString &);
|
||||
void pollNow();
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotPollNow();
|
||||
void termsOfServiceChecked();
|
||||
|
||||
private:
|
||||
QVBoxLayout *_layout = nullptr;
|
||||
OwncloudWizard *_ocWizard = nullptr;
|
||||
TermsOfServiceChecker *_termsOfServiceChecker = nullptr;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
#endif // TERMSOFSERVICEWIZARDPAGE_H
|
||||
@ -92,7 +92,7 @@ void WebViewPage::cleanupPage()
|
||||
}
|
||||
|
||||
int WebViewPage::nextId() const {
|
||||
return WizardCommon::Page_AdvancedSetup;
|
||||
return WizardCommon::Page_TermsOfService;
|
||||
}
|
||||
|
||||
bool WebViewPage::isComplete() const {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user