From: Olivier Goffart Date: Mon, 17 Aug 2015 09:54:01 +0000 (+0200) Subject: Folder Wizard: always make an alias that does not conflict with anything X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1408^2~211 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=64bd6b204be6b9cf8f99c9a8ffa951b40798fb73;p=nextcloud-desktop.git Folder Wizard: always make an alias that does not conflict with anything --- diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index e7a445844..cd39c6c38 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -69,7 +69,15 @@ FolderWizardLocalPath::FolderWizardLocalPath() _ui.localFolderLineEdit->setToolTip(tr("Enter the path to the local folder.")); registerField(QLatin1String("alias*"), _ui.aliasLineEdit); - _ui.aliasLineEdit->setText( Theme::instance()->appNameGUI() ); + + QString newAlias = Theme::instance()->appName(); + int count = 0; + while (FolderMan::instance()->folder(newAlias)) { + // There is already a folder configured with this name and folder names need to be unique + newAlias = Theme::instance()->appName() + QString::number(++count); + } + _ui.aliasLineEdit->setText( newAlias ); + _ui.aliasLineEdit->setToolTip(tr("The directory alias is a descriptive name for this sync connection.")); _ui.warnLabel->setTextFormat(Qt::RichText); _ui.warnLabel->hide(); @@ -157,6 +165,11 @@ void FolderWizardLocalPath::slotChooseLocalFolder() QDir pickedDir(dir); QString newAlias = pickedDir.dirName(); + int count = 0; + while (FolderMan::instance()->folder(newAlias)) { + // There is already a folder configured with this name and folder names need to be unique + newAlias = pickedDir.dirName() + QString::number(++count); + } if( !newAlias.isEmpty() ) { _ui.aliasLineEdit->setText(newAlias); }