From 7452f1956e6058e579a6881e37b17df61556ccf3 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Fri, 30 Sep 2011 12:51:56 +0200 Subject: [PATCH] Added owncloud credentials page --- src/CMakeLists.txt | 1 + src/mirall/owncloudcredentialspage.ui | 135 ++++++++++++++++++++++++++ src/mirall/owncloudsetup.cpp | 3 + src/mirall/owncloudwizard.cpp | 44 +++++++-- src/mirall/owncloudwizard.h | 18 ++++ 5 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 src/mirall/owncloudcredentialspage.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83f8ef1c6..caeeafc98 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,7 @@ mirall/owncloudwizardselecttypepage.ui mirall/createanowncloudpage.ui mirall/owncloudftpaccesspage.ui mirall/owncloudwizardresultpage.ui +mirall/owncloudcredentialspage.ui ) qt4_wrap_ui(mirall_UI_SRCS ${mirall_UI}) diff --git a/src/mirall/owncloudcredentialspage.ui b/src/mirall/owncloudcredentialspage.ui new file mode 100644 index 000000000..5e63c0b6e --- /dev/null +++ b/src/mirall/owncloudcredentialspage.ui @@ -0,0 +1,135 @@ + + + OwncloudCredentialsPage + + + + 0 + 0 + 587 + 374 + + + + Form + + + + + + + + + 14 + 50 + false + + + + Owncloud Credentials: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Provide Owncloud Credentials + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#585858;">Provide the credentials to your ownCloud Instance. If you do not have credentials yet, quickly open the ownCloud link and finish the setup.</span></p></body></html> + + + Qt::AutoText + + + true + + + true + + + + + + + + + Owncloud-User: + + + + + + + + + + john + + + + + + + Password: + + + + + + + + + + QLineEdit::Password + + + secret + + + + + + + + + + + + Qt::Vertical + + + + 530 + 194 + + + + + + + + + diff --git a/src/mirall/owncloudsetup.cpp b/src/mirall/owncloudsetup.cpp index 0f2967057..f035385d6 100644 --- a/src/mirall/owncloudsetup.cpp +++ b/src/mirall/owncloudsetup.cpp @@ -180,6 +180,9 @@ void OwncloudSetup::writeOwncloudConfig() qDebug() << "*** writing mirall config to " << mirallConfigFile(); QSettings settings( mirallConfigFile(), QSettings::IniFormat); settings.setValue("ownCloud/url", _ocWizard->field("OCUrl").toString() ); + settings.setValue("ownCloud/user", _ocWizard->field("OCUser").toString() ); + settings.setValue("ownCloud/password", _ocWizard->field("OCPasswd").toString() ); + settings.sync(); } diff --git a/src/mirall/owncloudwizard.cpp b/src/mirall/owncloudwizard.cpp index f98106404..736fb42e7 100644 --- a/src/mirall/owncloudwizard.cpp +++ b/src/mirall/owncloudwizard.cpp @@ -52,7 +52,7 @@ void OwncloudWizardSelectTypePage::initializePage() int OwncloudWizardSelectTypePage::nextId() const { if( _ui.connectMyOCRadioBtn->isChecked() ) { - return OwncloudWizard::Page_Install; + return OwncloudWizard::Page_OC_Credentials; } return OwncloudWizard::Page_Create_OC; } @@ -79,6 +79,37 @@ void OwncloudWizardSelectTypePage::setOCUrl( const QString& url ) // ====================================================================== +OwncloudCredentialsPage::OwncloudCredentialsPage() +{ + _ui.setupUi(this); + registerField( "OCUser", _ui.OCUserEdit ); + registerField( "OCPasswd", _ui.OCPasswdEdit ); +} + +OwncloudCredentialsPage::~OwncloudCredentialsPage() +{ + +} + +bool OwncloudCredentialsPage::isComplete() const +{ + +} + +void OwncloudCredentialsPage::initializePage() +{ + QString user = getenv( "USER" ); + _ui.OCUserEdit->setText( user ); +} + +int OwncloudCredentialsPage::nextId() const +{ + return OwncloudWizard::Page_Install; +} + +// ====================================================================== + + OwncloudFTPAccessPage::OwncloudFTPAccessPage() { _ui.setupUi(this); @@ -140,7 +171,7 @@ void CreateAnOwncloudPage::initializePage() int CreateAnOwncloudPage::nextId() const { if( _ui.createLocalRadioBtn->isChecked() ) { - return OwncloudWizard::Page_Install; + return OwncloudWizard::Page_OC_Credentials; } return OwncloudWizard::Page_FTP; @@ -203,10 +234,11 @@ void OwncloudWizardResultPage::appendResultText( const QString& msg ) OwncloudWizard::OwncloudWizard(QWidget *parent) : QWizard(parent) { - setPage(Page_SelectType, new OwncloudWizardSelectTypePage() ); - setPage(Page_Create_OC, new CreateAnOwncloudPage() ); - setPage(Page_FTP, new OwncloudFTPAccessPage() ); - setPage(Page_Install, new OwncloudWizardResultPage() ); + setPage(Page_SelectType, new OwncloudWizardSelectTypePage() ); + setPage(Page_Create_OC, new CreateAnOwncloudPage() ); + setPage(Page_FTP, new OwncloudFTPAccessPage() ); + setPage(Page_OC_Credentials, new OwncloudCredentialsPage() ); + setPage(Page_Install, new OwncloudWizardResultPage() ); setWizardStyle( QWizard::ClassicStyle ); diff --git a/src/mirall/owncloudwizard.h b/src/mirall/owncloudwizard.h index 2cdfc47a8..98713e223 100644 --- a/src/mirall/owncloudwizard.h +++ b/src/mirall/owncloudwizard.h @@ -21,6 +21,7 @@ #include "ui_createanowncloudpage.h" #include "ui_owncloudftpaccesspage.h" #include "ui_owncloudwizardresultpage.h" +#include "ui_owncloudcredentialspage.h" namespace Mirall { @@ -62,6 +63,22 @@ private: }; +class OwncloudCredentialsPage: public QWizardPage +{ + Q_OBJECT +public: + OwncloudCredentialsPage(); + ~OwncloudCredentialsPage(); + + virtual bool isComplete() const; + virtual void initializePage(); + virtual int nextId() const; + + +private: + Ui_OwncloudCredentialsPage _ui; + +}; /** * page to ask for the ftp credentials etc. for ftp install */ @@ -115,6 +132,7 @@ public: enum { Page_SelectType, Page_Create_OC, + Page_OC_Credentials, Page_FTP, Page_Install };