mirror of
https://github.com/zealdocs/zeal.git
synced 2024-11-23 14:26:12 +03:00
feat(ui): use relative path in portable build if possible (fixes #956)
Applicable only to the subdirectories within path to the executable.
This commit is contained in:
parent
83a8bb75fe
commit
00f299345c
@ -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;
|
||||
}
|
||||
|
||||
ui->docsetStorageEdit->setText(QDir::toNativeSeparators(dir));
|
||||
#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(path));
|
||||
}
|
||||
|
||||
void SettingsDialog::loadSettings()
|
||||
|
Loading…
Reference in New Issue
Block a user