mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Make setting custom folders work again
Also, ensure that opening the local directory from the wizard will work on Windows.
This commit is contained in:
parent
dbc085d4d4
commit
0683c26d41
@ -74,13 +74,14 @@ void OwncloudSetupWizard::startWizard()
|
||||
_remoteFolder = Theme::instance()->defaultServerFolder();
|
||||
// remoteFolder may be empty, which means /
|
||||
|
||||
_localFolder = Theme::instance()->defaultClientFolder();
|
||||
QString localFolder = Theme::instance()->defaultClientFolder();
|
||||
|
||||
// if its a relative path, prepend with users home dir, otherwise use as absolute path
|
||||
if( !_localFolder.startsWith(QLatin1Char('/')) ) {
|
||||
_localFolder = QDir::homePath() + QDir::separator() + Theme::instance()->defaultClientFolder();
|
||||
if( !localFolder.startsWith(QLatin1Char('/')) ) {
|
||||
localFolder = QDir::homePath() + QDir::separator() + Theme::instance()->defaultClientFolder();
|
||||
}
|
||||
_ocWizard->setFolderNames(_localFolder, _remoteFolder);
|
||||
_ocWizard->setProperty("localFolder", localFolder);
|
||||
_ocWizard->setRemoteFolder(_remoteFolder);
|
||||
|
||||
_ocWizard->setStartId(OwncloudWizard::Page_oCSetup);
|
||||
|
||||
@ -114,11 +115,12 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
|
||||
cfg.acceptCustomConfig();
|
||||
|
||||
// Now write the resulting folder definition if folder names are set.
|
||||
if( !( _localFolder.isEmpty() || _remoteFolder.isEmpty() ) ) { // both variables are set.
|
||||
const QString localFolder = _ocWizard->property("localFolder").toString();
|
||||
if( !( localFolder.isEmpty() || _remoteFolder.isEmpty() ) ) { // both variables are set.
|
||||
if( _folderMan ) {
|
||||
_folderMan->addFolderDefinition( QLatin1String("owncloud"), Theme::instance()->appName(),
|
||||
_localFolder, _remoteFolder, false );
|
||||
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(_localFolder));
|
||||
localFolder, _remoteFolder, false );
|
||||
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
|
||||
} else {
|
||||
qDebug() << "WRN: Folderman is zero in Setup Wizzard.";
|
||||
}
|
||||
@ -251,26 +253,27 @@ void OwncloudSetupWizard::setupLocalSyncFolder()
|
||||
{
|
||||
if( ! _folderMan ) return;
|
||||
|
||||
qDebug() << "Setup local sync folder for new oC connection " << _localFolder;
|
||||
QDir fi( _localFolder );
|
||||
const QString localFolder = _ocWizard->property("localFolder").toString();
|
||||
qDebug() << "Setup local sync folder for new oC connection " << localFolder;
|
||||
QDir fi( localFolder );
|
||||
// FIXME: Show problems with local folder properly.
|
||||
|
||||
bool localFolderOk = true;
|
||||
if( fi.exists() ) {
|
||||
// there is an existing local folder. If its non empty, it can only be synced if the
|
||||
// ownCloud is newly created.
|
||||
_ocWizard->appendToConfigurationLog( tr("Local sync folder %1 already exists, setting it up for sync.<br/><br/>").arg(_localFolder));
|
||||
_ocWizard->appendToConfigurationLog( tr("Local sync folder %1 already exists, setting it up for sync.<br/><br/>").arg(localFolder));
|
||||
} else {
|
||||
QString res = tr("Creating local sync folder %1... ").arg(_localFolder);
|
||||
if( fi.mkpath( _localFolder ) ) {
|
||||
Utility::setupFavLink( _localFolder );
|
||||
QString res = tr("Creating local sync folder %1... ").arg(localFolder);
|
||||
if( fi.mkpath( localFolder ) ) {
|
||||
Utility::setupFavLink( localFolder );
|
||||
// FIXME: Create a local sync folder.
|
||||
res += tr("ok");
|
||||
} else {
|
||||
res += tr("failed.");
|
||||
qDebug() << "Failed to create " << fi.path();
|
||||
localFolderOk = false;
|
||||
_ocWizard->displayError(tr("Could not create local folder %1").arg(_localFolder));
|
||||
_ocWizard->displayError(tr("Could not create local folder %1").arg(localFolder));
|
||||
}
|
||||
_ocWizard->appendToConfigurationLog( res );
|
||||
}
|
||||
@ -328,7 +331,7 @@ void OwncloudSetupWizard::slotAuthCheckReply( const QString&, QNetworkReply *rep
|
||||
if( !ok ) {
|
||||
_ocWizard->displayError(error);
|
||||
} else {
|
||||
_ocWizard->setFolderNames( _localFolder, _remoteFolder );
|
||||
_ocWizard->setRemoteFolder( _remoteFolder );
|
||||
}
|
||||
|
||||
finalizeSetup( ok );
|
||||
@ -369,13 +372,11 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished( QNetworkReply::Network
|
||||
"<br/>Please go back and check your credentials.</p>"));
|
||||
_ocWizard->appendToConfigurationLog( tr("<p><font color=\"red\">Remote folder creation failed probably because the provided credentials are wrong.</font>"
|
||||
"<br/>Please go back and check your credentials.</p>"));
|
||||
_localFolder.clear();
|
||||
_remoteFolder.clear();
|
||||
success = false;
|
||||
} else {
|
||||
_ocWizard->appendToConfigurationLog( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error));
|
||||
_ocWizard->displayError( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error) );
|
||||
_localFolder.clear();
|
||||
_remoteFolder.clear();
|
||||
success = false;
|
||||
}
|
||||
@ -388,10 +389,11 @@ void OwncloudSetupWizard::finalizeSetup( bool success )
|
||||
// enable/disable the finish button.
|
||||
_ocWizard->enableFinishOnResultWidget(success);
|
||||
|
||||
const QString localFolder = _ocWizard->property("localFolder").toString();
|
||||
if( success ) {
|
||||
if( !(_localFolder.isEmpty() || _remoteFolder.isEmpty() )) {
|
||||
if( !(localFolder.isEmpty() || _remoteFolder.isEmpty() )) {
|
||||
_ocWizard->appendToConfigurationLog( tr("A sync connection from %1 to remote directory %2 was set up.")
|
||||
.arg(_localFolder).arg(_remoteFolder));
|
||||
.arg(localFolder).arg(_remoteFolder));
|
||||
}
|
||||
_ocWizard->appendToConfigurationLog( QLatin1String(" "));
|
||||
_ocWizard->appendToConfigurationLog( QLatin1String("<p><font color=\"green\"><b>")
|
||||
|
||||
@ -95,7 +95,6 @@ private:
|
||||
FolderMan *_folderMan;
|
||||
|
||||
QString _configHandle;
|
||||
QString _localFolder;
|
||||
QString _remoteFolder;
|
||||
};
|
||||
|
||||
|
||||
@ -196,6 +196,21 @@ void OwncloudSetupPage::initializePage()
|
||||
{
|
||||
_connected = false;
|
||||
_checking = false;
|
||||
updateFoldersInfo();
|
||||
}
|
||||
|
||||
void OwncloudSetupPage::updateFoldersInfo()
|
||||
{
|
||||
const QString localFolder = wizard()->property("localFolder").toString();
|
||||
_ui.pbSelectLocalFolder->setText(localFolder);
|
||||
QString t;
|
||||
if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) {
|
||||
t = tr("Your entire account will be synced to the local folder '%1'").arg(localFolder);
|
||||
} else {
|
||||
t = tr("ownCloud folder '%1' is synced to local folder '%2'").arg(_remoteFolder).arg(localFolder);
|
||||
}
|
||||
|
||||
_ui.syncModeLabel->setText(t);
|
||||
}
|
||||
|
||||
int OwncloudSetupPage::nextId() const
|
||||
@ -268,25 +283,12 @@ OwncloudSetupPage::SyncMode OwncloudSetupPage::syncMode()
|
||||
return BoxMode;
|
||||
}
|
||||
|
||||
void OwncloudSetupPage::setFolderNames( const QString& localFolder, const QString& remoteFolder )
|
||||
void OwncloudSetupPage::setRemoteFolder( const QString& remoteFolder )
|
||||
{
|
||||
_ui.pbSelectLocalFolder->setText(localFolder);
|
||||
if( !remoteFolder.isEmpty() )
|
||||
if( !remoteFolder.isEmpty() ) {
|
||||
_remoteFolder = remoteFolder;
|
||||
|
||||
QString t;
|
||||
if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) {
|
||||
t = tr("Your entire account will be synced to the local folder '%1'").arg(localFolder);
|
||||
} else {
|
||||
t = tr("ownCloud folder '%1' is synced to local folder '%2'").arg(_remoteFolder).arg(localFolder);
|
||||
updateFoldersInfo();
|
||||
}
|
||||
|
||||
_ui.syncModeLabel->setText(t);
|
||||
}
|
||||
|
||||
QString OwncloudSetupPage::selectedLocalFolder() const
|
||||
{
|
||||
return _ui.pbSelectLocalFolder->text();
|
||||
}
|
||||
|
||||
void OwncloudSetupPage::slotSelectFolder()
|
||||
@ -294,7 +296,8 @@ void OwncloudSetupPage::slotSelectFolder()
|
||||
|
||||
QString dir = QFileDialog::getExistingDirectory(0, tr("Local Sync Folder"), QDir::homePath());
|
||||
if( !dir.isEmpty() ) {
|
||||
setFolderNames(dir);
|
||||
wizard()->setProperty("localFolder", dir);
|
||||
updateFoldersInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,19 +354,23 @@ bool OwncloudWizardResultPage::isComplete() const
|
||||
return _complete;
|
||||
}
|
||||
|
||||
void OwncloudWizardResultPage::setFolderNames( const QString& localFolder, const QString& remoteFolder )
|
||||
void OwncloudWizardResultPage::initializePage()
|
||||
{
|
||||
_localFolder = localFolder;
|
||||
const QString localFolder = wizard()->property("localFolder").toString();
|
||||
QString text;
|
||||
if( remoteFolder == QLatin1String("/") ||
|
||||
remoteFolder.isEmpty() ) {
|
||||
if( _remoteFolder == QLatin1String("/") || _remoteFolder.isEmpty() ) {
|
||||
text = tr("Your entire account is synced to the local folder <i>%1</i>").arg(localFolder);
|
||||
} else {
|
||||
text = tr("ownCloud folder <i>%1</i> is synced to local folder <i>%2</i>").arg(remoteFolder).arg(localFolder);
|
||||
text = tr("ownCloud folder <i>%1</i> is synced to local folder <i>%2</i>").arg(_remoteFolder).arg(localFolder);
|
||||
}
|
||||
_ui.localFolderLabel->setText( text );
|
||||
|
||||
}
|
||||
|
||||
void OwncloudWizardResultPage::setRemoteFolder(const QString &remoteFolder)
|
||||
{
|
||||
_remoteFolder = remoteFolder;
|
||||
}
|
||||
|
||||
void OwncloudWizardResultPage::setupCustomization()
|
||||
{
|
||||
@ -420,10 +427,10 @@ void OwncloudWizard::enableFinishOnResultWidget(bool enable)
|
||||
_resultPage->setComplete(enable);
|
||||
}
|
||||
|
||||
void OwncloudWizard::setFolderNames( const QString& localFolder, const QString& remoteFolder )
|
||||
void OwncloudWizard::setRemoteFolder( const QString& remoteFolder )
|
||||
{
|
||||
_setupPage->setFolderNames( localFolder, remoteFolder );
|
||||
_resultPage->setFolderNames( localFolder, remoteFolder );
|
||||
_setupPage->setRemoteFolder( remoteFolder );
|
||||
_resultPage->setRemoteFolder( remoteFolder );
|
||||
}
|
||||
|
||||
void OwncloudWizard::showConnectInfo( const QString& msg )
|
||||
@ -483,7 +490,8 @@ void OwncloudWizard::setOCUser( const QString& user )
|
||||
|
||||
void OwncloudWizardResultPage::slotOpenLocal()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(_localFolder));
|
||||
const QString localFolder = wizard()->property("localFolder").toString();
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(localFolder));
|
||||
}
|
||||
|
||||
void OwncloudWizardResultPage::slotOpenServer()
|
||||
|
||||
@ -51,8 +51,7 @@ public:
|
||||
bool validatePage();
|
||||
QString url() const;
|
||||
void setConnected(bool complete);
|
||||
QString selectedLocalFolder() const;
|
||||
void setFolderNames( const QString&, const QString& remoteFolder = QString::null);
|
||||
void setRemoteFolder( const QString& remoteFolder);
|
||||
|
||||
SyncMode syncMode();
|
||||
|
||||
@ -70,6 +69,9 @@ protected slots:
|
||||
signals:
|
||||
void connectToOCUrl( const QString& );
|
||||
|
||||
protected:
|
||||
void updateFoldersInfo();
|
||||
|
||||
private:
|
||||
Ui_OwncloudSetupPage _ui;
|
||||
QString _oCUrl;
|
||||
@ -109,7 +111,7 @@ public:
|
||||
OwncloudSetupPage::SyncMode syncMode();
|
||||
|
||||
public slots:
|
||||
void setFolderNames( const QString&, const QString& );
|
||||
void setRemoteFolder( const QString& );
|
||||
void appendToConfigurationLog( const QString& msg, LogType type = LogParagraph );
|
||||
void slotCurrentPageChanged( int );
|
||||
|
||||
@ -146,10 +148,11 @@ public:
|
||||
~OwncloudWizardResultPage();
|
||||
|
||||
bool isComplete() const;
|
||||
void initializePage();
|
||||
void setRemoteFolder( const QString& remoteFolder);
|
||||
|
||||
public slots:
|
||||
void setComplete(bool complete);
|
||||
void setFolderNames( const QString&, const QString& );
|
||||
|
||||
protected slots:
|
||||
void slotOpenLocal();
|
||||
@ -160,6 +163,7 @@ protected:
|
||||
|
||||
private:
|
||||
QString _localFolder;
|
||||
QString _remoteFolder;
|
||||
bool _complete;
|
||||
|
||||
Ui_OwncloudWizardResultPage _ui;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user