Skip to content

Commit

Permalink
feat(ui): use relative path in portable build if possible (fixes #956)
Browse files Browse the repository at this point in the history
Applicable only to the subdirectories within path to the executable.
  • Loading branch information
trollixx committed Sep 28, 2018
1 parent 83a8bb7 commit 00f2993
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/libs/ui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,21 @@ void SettingsDialog::chooseCustomCssFile()

void SettingsDialog::chooseDocsetStoragePath()
{
const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
ui->docsetStorageEdit->text());
if (dir.isEmpty())
QString path = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
ui->docsetStorageEdit->text());
if (path.isEmpty()) {
return;
}

#ifdef PORTABLE_BUILD
// Use relative path if selected directory is under the application binary path.
if (path.startsWith(QCoreApplication::applicationDirPath() + QLatin1String("/"))) {
const QDir appDirPath(QCoreApplication::applicationDirPath());
path = appDirPath.relativeFilePath(path);
}
#endif

ui->docsetStorageEdit->setText(QDir::toNativeSeparators(dir));
ui->docsetStorageEdit->setText(QDir::toNativeSeparators(path));
}

void SettingsDialog::loadSettings()
Expand Down

0 comments on commit 00f2993

Please sign in to comment.