Merge branch 'master' of gitorious.org:owncloud/mirall

This commit is contained in:
Klaas Freitag 2012-07-26 10:16:59 +02:00
commit b2580b4b0e
8 changed files with 470 additions and 16 deletions

View file

@ -11,6 +11,7 @@ mirall/folderwizardnetworkpage.ui
mirall/folderwizardowncloudpage.ui
mirall/statusdialog.ui
mirall/owncloudwizardselecttypepage.ui
mirall/owncloudsetuppage.ui
mirall/createanowncloudpage.ui
mirall/owncloudftpaccesspage.ui
mirall/owncloudwizardresultpage.ui

View file

@ -84,7 +84,9 @@ int FolderMan::setupKnownFolders()
foreach ( const QString& alias, list ) {
Folder *f = setupFolderFromConfigFile( alias );
emit( folderSyncStateChange( f->alias() ) );
if( f ) {
emit( folderSyncStateChange( f->alias() ) );
}
}
// return the number of valid folders.
return _folderMap.size();

View file

@ -35,6 +35,9 @@
#define DEFAULT_LOCAL_POLL_INTERVAL 10000 // default local poll time in milliseconds
#define DEFAULT_POLL_TIMER_EXEED 10
#define OC_ORGANIZATION QLatin1String("ownCloud")
#define OC_APPLICATION QLatin1String("ownCloudClient")
namespace Mirall {
QString MirallConfigFile::_passwd;
@ -428,5 +431,46 @@ void MirallConfigFile::acceptCustomConfig()
QFile::remove( targetBak );
}
QVariant MirallConfigFile::customMedia( customMediaType type )
{
QVariant re;
QString key;
if( type == oCSetupTop ) {
key = QLatin1String("oCSetupTop");
} else if( type == oCSetupSide ) {
key = QLatin1String("oCSetupSide");
} else if( type == oCSetupBottom) {
key = QLatin1String("oCSetupBottom");
} else if( type == oCSetupFixUrl ) {
key = QLatin1String("oCSetupFixUrl");
} else if( type == oCSetupResultTop ) {
key = QLatin1String("oCSetupResultTop");
} else {
qDebug() << "Wrong media type.";
}
if( !key.isEmpty() ) {
QSettings settings( QSettings::IniFormat, QSettings::SystemScope, OC_ORGANIZATION, OC_APPLICATION );
QString cfg = settings.fileName();
qDebug() << "Trying to read config ini file at " << cfg;
settings.setIniCodec( "UTF-8" );
settings.beginGroup(QLatin1String("GUICustomize"));
QString val = settings.value( key, QString() ).toString();
if( !val.isEmpty() ) {
QPixmap pix( val );
if( pix.isNull() ) {
// pixmap loading hasn't succeeded. We take the text instead.
re.setValue( val );
} else {
re.setValue( pix );
}
}
}
return re;
}
}

View file

@ -17,6 +17,7 @@
#include <QString>
class QVariant;
namespace Mirall {
@ -26,6 +27,14 @@ class MirallConfigFile
public:
MirallConfigFile( const QString& appendix = QString() );
enum customMediaType {
oCSetupTop, // ownCloud connect page
oCSetupSide,
oCSetupBottom,
oCSetupFixUrl,
oCSetupResultTop // ownCloud connect result page
};
QString configPath() const;
QString configFile() const;
QString excludeFile() const;
@ -51,6 +60,8 @@ public:
QString ownCloudVersion() const;
void setOwnCloudVersion( const QString& );
QVariant customMedia( customMediaType );
// max count of lines in the log window
int maxLogLines() const;

View file

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OwncloudSetupPage</class>
<widget class="QWidget" name="OwncloudSetupPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>271</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Create the ownCloud Connection</string>
</property>
</widget>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="serverAddressLabel">
<property name="text">
<string>Server &amp;address:</string>
</property>
<property name="buddy">
<cstring>leUrl</cstring>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="protocolLabel">
<property name="text">
<string>https://</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leUrl">
<property name="toolTip">
<string>Enter the url of the ownCloud you want to connect to (without http or https).</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="cbSecureConnect">
<property name="text">
<string>Use &amp;secure connection</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbConnectOC">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>CheckBox</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Username:</string>
</property>
<property name="buddy">
<cstring>leUsername</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leUsername">
<property name="toolTip">
<string>Enter the ownCloud username.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&amp;Password:</string>
</property>
<property name="buddy">
<cstring>lePassword</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lePassword">
<property name="toolTip">
<string>Enter the ownCloud password.</string>
</property>
<property name="text">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="cbNoPasswordStore">
<property name="toolTip">
<string>Do not allow the local storage of the password.</string>
</property>
<property name="text">
<string>&amp;do not store Password on local machine.</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="sideLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>344</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="topLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="bottomLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -13,6 +13,7 @@
* for more details.
*/
#include "mirall/owncloudwizard.h"
#include "mirall/mirallconfigfile.h"
#include <QDebug>
#include <QDesktopServices>
@ -29,6 +30,142 @@
namespace Mirall
{
void setupCustomMedia( QVariant variant, QLabel *label )
{
if( ! label ) return;
QPixmap pix = variant.value<QPixmap>();
if( ! pix.isNull() ) {
label->setPixmap(pix);
label->setAlignment( Qt::AlignTop | Qt::AlignRight );
label->setVisible(true);
} else {
QString str = variant.toString();
if( !str.isEmpty() ) {
label->setText( str );
label->setTextFormat( Qt::RichText );
label->setVisible(true);
label->setOpenExternalLinks(true);
}
}
}
// ======================================================================
OwncloudSetupPage::OwncloudSetupPage()
{
_ui.setupUi(this);
registerField( "OCUrl", _ui.leUrl );
registerField( "OCUser", _ui.leUsername );
registerField( "OCPasswd", _ui.lePassword);
registerField( "connectMyOC", _ui.cbConnectOC );
registerField( "PwdNoLocalStore", _ui.cbNoPasswordStore );
connect( _ui.lePassword, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
connect( _ui.cbNoPasswordStore, SIGNAL(stateChanged(int)), this, SLOT(slotPwdStoreChanged(int)));
connect( _ui.cbSecureConnect, SIGNAL(stateChanged(int)), this, SLOT(slotSecureConChanged(int)));
_ui.cbConnectOC->hide();
setupCustomization();
}
OwncloudSetupPage::~OwncloudSetupPage()
{
#if QT_VERSION >= 0x040700
_ui.leUsername->setPlaceholderText(QApplication::translate("OwncloudSetupPage", "john", 0, QApplication::UnicodeUTF8));
_ui.lePassword->setPlaceholderText(QApplication::translate("OwncloudSetupPage", "secret", 0, QApplication::UnicodeUTF8));
#endif
}
void OwncloudSetupPage::setOCUrl( const QString& newUrl )
{
QString url( newUrl );
if( url.isEmpty() ) {
_ui.leUrl->clear();
return;
}
if( url.startsWith( QLatin1String("https"))) {
_ui.cbSecureConnect->setChecked( true );
url.remove(0,5);
} else if( url.startsWith( QLatin1String("http"))) {
_ui.cbSecureConnect->setChecked( false );
url.remove(0,4);
}
if( url.startsWith( QLatin1String("://"))) url.remove(0,3);
_ui.leUrl->setText( url );
}
void OwncloudSetupPage::setupCustomization()
{
// set defaults for the customize labels.
_ui.sideLabel->setText( QString() );
_ui.sideLabel->setFixedWidth(160);
_ui.topLabel->hide();
_ui.bottomLabel->hide();
MirallConfigFile cfg;
QVariant variant = cfg.customMedia( MirallConfigFile::oCSetupTop );
setupCustomMedia( variant, _ui.topLabel );
variant = cfg.customMedia( MirallConfigFile::oCSetupSide );
setupCustomMedia( variant, _ui.sideLabel );
variant = cfg.customMedia( MirallConfigFile::oCSetupBottom );
setupCustomMedia( variant, _ui.bottomLabel );
QString fixUrl = cfg.customMedia( MirallConfigFile::oCSetupFixUrl ).toString();
if( !fixUrl.isEmpty() ) {
setOCUrl( fixUrl );
_ui.leUrl->setEnabled( false );
_ui.cbSecureConnect->hide();
_ui.leUrl->hide();
_ui.protocolLabel->hide();
_ui.serverAddressLabel->hide();
}
}
void OwncloudSetupPage::slotPwdStoreChanged( int state )
{
_ui.lePassword->setEnabled( state == Qt::Unchecked );
emit completeChanged();
}
void OwncloudSetupPage::slotSecureConChanged( int state )
{
if( state == Qt::Checked ) {
_ui.protocolLabel->setText(QLatin1String("https://"));
} else {
_ui.protocolLabel->setText(QLatin1String("http://"));
}
}
bool OwncloudSetupPage::isComplete() const
{
if( _ui.leUrl->text().isEmpty() ) return false;
if( _ui.cbNoPasswordStore->checkState() == Qt::Checked ) {
return !(_ui.leUsername->text().isEmpty());
}
return !(_ui.leUsername->text().isEmpty() || _ui.lePassword->text().isEmpty() );
}
void OwncloudSetupPage::initializePage()
{
QString user = qgetenv( "USER" );
_ui.leUsername->setText( user );
}
int OwncloudSetupPage::nextId() const
{
return OwncloudWizard::Page_Install;
}
// ======================================================================
OwncloudWizardSelectTypePage::OwncloudWizardSelectTypePage()
{
_ui.setupUi(this);
@ -235,6 +372,8 @@ OwncloudWizardResultPage::OwncloudWizardResultPage()
// no fields to register.
_ui.resultTextEdit->setAcceptRichText(true);
_ui.ocLinkLabel->setVisible( false );
setupCustomization();
}
OwncloudWizardResultPage::~OwncloudWizardResultPage()
@ -278,6 +417,18 @@ void OwncloudWizardResultPage::showOCUrlLabel( const QString& url, bool show )
}
}
void OwncloudWizardResultPage::setupCustomization()
{
// set defaults for the customize labels.
_ui.topLabel->setText( QString() );
_ui.topLabel->hide();
MirallConfigFile cfg;
QVariant variant = cfg.customMedia( MirallConfigFile::oCSetupResultTop );
setupCustomMedia( variant, _ui.topLabel );
}
// ======================================================================
/**
@ -287,15 +438,20 @@ void OwncloudWizardResultPage::showOCUrlLabel( const QString& url, bool show )
OwncloudWizard::OwncloudWizard(QWidget *parent)
: QWizard(parent)
{
#ifdef OWNCLOUD_CLIENT
setPage(Page_oCSetup, new OwncloudSetupPage() );
#else
setPage(Page_SelectType, new OwncloudWizardSelectTypePage() );
setPage(Page_OC_Credentials, new OwncloudCredentialsPage() );
#endif
setPage(Page_Create_OC, new CreateAnOwncloudPage() );
setPage(Page_FTP, new OwncloudFTPAccessPage() );
setPage(Page_OC_Credentials, new OwncloudCredentialsPage() );
setPage(Page_Install, new OwncloudWizardResultPage() );
#ifdef Q_WS_MAC
setWizardStyle( QWizard::ModernStyle );
#endif
setField("connectMyOC", true);
connect( this, SIGNAL(currentIdChanged(int)), SLOT(slotCurrentPageChanged(int)));
@ -354,8 +510,14 @@ void OwncloudWizard::appendToResultWidget( const QString& msg, LogType type )
void OwncloudWizard::setOCUrl( const QString& url )
{
_oCUrl = url;
#ifdef OWNCLOUD_CLIENT
OwncloudSetupPage *p = static_cast<OwncloudSetupPage*>(page(Page_oCSetup));
#else
OwncloudWizardSelectTypePage *p = static_cast<OwncloudWizardSelectTypePage*>(page( Page_SelectType ));
p->setOCUrl( url );
#endif
if( p )
p->setOCUrl( url );
}
} // end namespace

View file

@ -23,15 +23,41 @@
#include "ui_owncloudftpaccesspage.h"
#include "ui_owncloudwizardresultpage.h"
#include "ui_owncloudcredentialspage.h"
#include "ui_owncloudsetuppage.h"
class QLabel;
class QVariant;
namespace Mirall {
class OwncloudSetupPage: public QWizardPage
{
Q_OBJECT
public:
OwncloudSetupPage();
~OwncloudSetupPage();
virtual bool isComplete() const;
virtual void initializePage();
virtual int nextId() const;
void setOCUrl( const QString& );
protected slots:
void slotPwdStoreChanged( int );
void slotSecureConChanged( int );
void setupCustomization();
private:
Ui_OwncloudSetupPage _ui;
};
class OwncloudWizard: public QWizard
{
Q_OBJECT
public:
enum {
Page_oCSetup,
Page_SelectType,
Page_Create_OC,
Page_OC_Credentials,
@ -48,6 +74,8 @@ public:
void setOCUrl( const QString& );
void setupCustomMedia( QVariant, QLabel* );
public slots:
void appendToResultWidget( const QString& msg, LogType type = LogParagraph );
void slotCurrentPageChanged( int );
@ -159,6 +187,9 @@ public slots:
void appendResultText( const QString&, OwncloudWizard::LogType type = OwncloudWizard::LogParagraph );
void showOCUrlLabel( const QString&, bool );
protected:
void setupCustomization();
private:
Ui_OwncloudWizardResultPage _ui;

View file

@ -6,15 +6,29 @@
<rect>
<x>0</x>
<y>0</y>
<width>595</width>
<height>371</height>
<width>526</width>
<height>357</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<item row="3" column="0">
<widget class="QTextEdit" name="resultTextEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="ocLinkLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="label_3">
@ -45,7 +59,7 @@
</item>
</layout>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
@ -65,15 +79,8 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QTextEdit" name="resultTextEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="ocLinkLabel">
<item row="0" column="0">
<widget class="QLabel" name="topLabel">
<property name="text">
<string>TextLabel</string>
</property>