Use proper URL

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-06-21 16:15:30 +02:00 committed by Roeland Jago Douma
parent 18f1452b04
commit 156605c2fa
No known key found for this signature in database
GPG Key ID: F941078878347C0C
7 changed files with 430 additions and 118 deletions

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>506</width>
<height>515</height>
<width>802</width>
<height>629</height>
</rect>
</property>
<property name="sizePolicy">
@ -19,9 +19,21 @@
<property name="windowTitle">
<string>Form</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color:#faf;</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0">
<item row="16" column="0">
<widget class="QLabel" name="bottomLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>TextLabel</string>
</property>
@ -30,16 +42,16 @@
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item row="14" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
@ -49,83 +61,31 @@
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Ser&amp;ver Address</string>
</property>
<property name="buddy">
<cstring>leUrl</cstring>
</property>
</widget>
</item>
<item>
<widget class="OCC::PostfixLineEdit" name="leUrl">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>https://...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="urlLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QPushButton" name="hostButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<underline>true</underline>
</font>
</property>
<property name="text">
<string>Host your own server</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
@ -136,26 +96,7 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="errorLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Error Label</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<item row="3" column="0">
<widget class="QLabel" name="topLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -177,8 +118,113 @@
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<item row="11" column="0" rowspan="2">
<layout class="QHBoxLayout" name="buttons" stretch="0,0,0,0">
<property name="spacing">
<number>6</number>
</property>
<property name="topMargin">
<number>20</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="createAccountButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Register with a provider</string>
</property>
<property name="default">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loginButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Log in</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="slideImage">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../theme.qrc">:/client/theme/colored/wizard-files.svg</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@ -188,25 +234,212 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>200</height>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="resultLayout">
<property name="spacing">
<number>0</number>
<item row="2" column="0">
<widget class="QLabel" name="slideLabel">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
</layout>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="createAccountButton">
<property name="text">
<string>Create a new account</string>
<string>SlideshowLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QWidget" name="login" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>80</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="serverBox">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ser&amp;ver Address</string>
</property>
<property name="buddy">
<cstring>leUrl</cstring>
</property>
</widget>
</item>
<item>
<widget class="OCC::PostfixLineEdit" name="leUrl">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>https://...</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="resultLayout">
<property name="spacing">
<number>0</number>
</property>
</layout>
</item>
<item>
<widget class="QLabel" name="urlLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="errorLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Error Label</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
@ -216,6 +449,8 @@
<header>wizard/postfixlineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../../../theme.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -22,6 +22,9 @@
#include <QSsl>
#include <QSslCertificate>
#include <QNetworkAccessManager>
#include <QPropertyAnimation>
#include <QGraphicsPixmapItem>
#include <QtSvg/QSvgRenderer>
#include "QProgressIndicator.h"
@ -68,13 +71,43 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent)
slotUrlChanged(QLatin1String("")); // don't jitter UI
connect(_ui.leUrl, &QLineEdit::textChanged, this, &OwncloudSetupPage::slotUrlChanged);
connect(_ui.leUrl, &QLineEdit::editingFinished, this, &OwncloudSetupPage::slotUrlEditFinished);
connect(_ui.loginButton, &QPushButton::clicked, this, &OwncloudSetupPage::slotLogin);
connect(_ui.createAccountButton, &QPushButton::clicked, this, &OwncloudSetupPage::slotGotoProviderList);
addCertDial = new AddCertificateDialog(this);
_ui.login->hide();
_slideshow.append(qMakePair(QString("nextcloud"), tr("Keep your data secure and under your control")));
_slideshow.append(qMakePair(QString("files"), tr("Secure collaboration & file exchange")));
_slideshow.append(qMakePair(QString("groupware"), tr("Easy-to-use web mail, calendaring & contacts")));
_slideshow.append(qMakePair(QString("talk"), tr("Screensharing, online meetings & web conferences")));
_ui.slideLabel->setStyleSheet(QString("color:%1;").arg(theme->wizardHeaderBackgroundColor().name()));
_currentSlide = -1;
nextSlide();
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(nextSlide()));
timer->start(2500);
setStyleSheet(QString("background-color:%1; color:%2 QLabel { color:%2; } QSpacerItem { color: red; }").arg(theme->wizardHeaderBackgroundColor().name(), theme->wizardHeaderTitleColor().name()));
}
void OwncloudSetupPage::nextSlide()
{
if (_currentSlide < _slideshow.length()-1) {
_currentSlide++;
} else {
_currentSlide = 0;
}
QPixmap pixmap = QIcon(Theme::hidpiFileName(":/client/theme/colored/wizard-" + _slideshow.at(_currentSlide).first + ".svg")).pixmap(QSize(1024, 1024));
_ui.slideImage->setPixmap(pixmap.scaled(QSize(_ui.slideImage->size().height(), _ui.slideImage->size().height()), Qt::KeepAspectRatio, Qt::SmoothTransformation));
_ui.slideLabel->setText(_slideshow.at(_currentSlide).second);
}
void OwncloudSetupPage::setServerUrl(const QString &newUrl)
{
_ocWizard->setRegistration(false);
_oCUrl = newUrl;
if (_oCUrl.isEmpty()) {
_ui.leUrl->clear();
@ -100,10 +133,21 @@ void OwncloudSetupPage::setupCustomization()
WizardCommon::setupCustomMedia(variant, _ui.bottomLabel);
}
void OwncloudSetupPage::slotLogin()
{
_ui.login->setMaximumHeight(0);
QPropertyAnimation *animation = new QPropertyAnimation(_ui.login, "maximumHeight");
animation->setDuration(0);
animation->setStartValue(500);
animation->setEndValue(500);
_ui.login->show();
wizard()->resize(wizard()->sizeHint());
animation->start();
}
void OwncloudSetupPage::slotGotoProviderList()
{
setServerUrl("http://localhost:8113/");
// todo set _ocWizard->registation so we have the url in webview.cpp
_ocWizard->setRegistration(true);
_ocWizard->setAuthType(DetermineAuthTypeJob::AuthType::WebViewFlow);
_authTypeKnown = true;
_checking = false;
@ -184,6 +228,7 @@ void OwncloudSetupPage::initializePage()
validatePage();
setVisible(false);
}
wizard()->resize(wizard()->sizeHint());
}
bool OwncloudSetupPage::urlHasChanged()
@ -300,11 +345,13 @@ void OwncloudSetupPage::setErrorString(const QString &err, bool retryHTTPonly)
_checking = false;
emit completeChanged();
stopSpinner();
wizard()->resize(wizard()->sizeHint());
}
void OwncloudSetupPage::startSpinner()
{
_ui.resultLayout->setEnabled(true);
_ui.urlLabel->setVisible(false);
_progressIndi->setVisible(true);
_progressIndi->startAnimation();
}
@ -312,6 +359,7 @@ void OwncloudSetupPage::startSpinner()
void OwncloudSetupPage::stopSpinner()
{
_ui.resultLayout->setEnabled(false);
_ui.urlLabel->setVisible(true);
_progressIndi->setVisible(false);
_progressIndi->stopAnimation();
}

View File

@ -60,10 +60,12 @@ public slots:
void startSpinner();
void stopSpinner();
void slotCertificateAccepted();
void nextSlide();
protected slots:
void slotUrlChanged(const QString &);
void slotUrlEditFinished();
void slotLogin();
void slotGotoProviderList();
void setupCustomization();
@ -88,6 +90,10 @@ private:
QString _remoteFolder;
AddCertificateDialog *addCertDial;
OwncloudWizard *_ocWizard;
QList<QPair<QString, QString>> _slideshow;
int _currentSlide;
};
} // namespace OCC

View File

@ -53,6 +53,7 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
, _credentialsPage(0)
, _webViewPage(new WebViewPage(this))
, _setupLog()
, _registration(false)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setPage(WizardCommon::Page_ServerSetup, _setupPage);
@ -128,6 +129,15 @@ QString OwncloudWizard::ocUrl() const
return url;
}
bool OwncloudWizard::registration() {
return _registration;
}
void OwncloudWizard::setRegistration(bool registration) {
_registration = registration;
}
void OwncloudWizard::enableFinishOnResultWidget(bool enable)
{
_resultPage->setComplete(enable);

View File

@ -59,6 +59,8 @@ public:
void setAccount(AccountPtr account);
AccountPtr account() const;
void setOCUrl(const QString &);
bool registration();
void setRegistration(bool registration);
void setupCustomMedia(QVariant, QLabel *);
QString ocUrl() const;
@ -108,6 +110,8 @@ private:
QStringList _setupLog;
bool _registration;
friend class OwncloudSetupWizard;
};

View File

@ -30,8 +30,13 @@ WebViewPage::WebViewPage(QWidget *parent)
}
void WebViewPage::initializePage() {
auto url = _ocWizard->ocUrl();
url += "/index.php/login/flow";
QString url;
if (_ocWizard->registration()) {
url = "https://nextcloud.com/register";
} else {
url = _ocWizard->ocUrl();
url += "/index.php/login/flow";
}
qCInfo(lcWizardWebiewPage()) << "Url to auth at: " << url;
_webView->setUrl(QUrl(url));
}

View File

@ -117,5 +117,9 @@
<file>theme/white/state-warning-64.png</file>
<file>theme/white/state-warning-128.png</file>
<file>theme/white/state-warning-256.png</file>
<file>theme/colored/wizard-files.svg</file>
<file>theme/colored/wizard-groupware.svg</file>
<file>theme/colored/wizard-nextcloud.svg</file>
<file>theme/colored/wizard-talk.svg</file>
</qresource>
</RCC>