2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Allow selecting export folder.

This commit is contained in:
John Preston
2018-06-20 19:12:47 +01:00
parent 154e5660de
commit 156c3d288c
7 changed files with 28 additions and 17 deletions

View File

@@ -76,8 +76,10 @@ QString filedialogDefaultName(
if (skipExistance) {
name = base + extension;
} else {
QDir dir(directoryPath);
QString nameBase = dir.absolutePath() + '/' + base;
QDir directory(directoryPath);
const auto dir = directory.absolutePath();
const auto nameBase = (dir.endsWith('/') ? dir : (dir + '/'))
+ base;
name = nameBase + extension;
for (int i = 0; QFileInfo(name).exists(); ++i) {
name = nameBase + qsl(" (%1)").arg(i + 2) + extension;
@@ -90,14 +92,16 @@ QString filedialogNextFilename(
const QString &name,
const QString &cur,
const QString &path) {
QDir dir(path.isEmpty() ? cDialogLastPath() : path);
QDir directory(path.isEmpty() ? cDialogLastPath() : path);
int32 extIndex = name.lastIndexOf('.');
QString prefix = name, extension;
if (extIndex >= 0) {
extension = name.mid(extIndex);
prefix = name.mid(0, extIndex);
}
QString nameBase = dir.absolutePath() + '/' + prefix, result = nameBase + extension;
const auto dir = directory.absolutePath();
const auto nameBase = (dir.endsWith('/') ? dir : (dir + '/')) + prefix;
auto result = nameBase + extension;
for (int i = 0; result.toLower() != cur.toLower() && QFileInfo(result).exists(); ++i) {
result = nameBase + qsl(" (%1)").arg(i + 2) + extension;
}

View File

@@ -151,7 +151,8 @@ void Launcher::prepareSettings() {
info = info.symLinkTarget();
}
if (info.exists()) {
gExeDir = info.absoluteDir().absolutePath() + '/';
const auto dir = info.absoluteDir().absolutePath();
gExeDir = (dir.endsWith('/') ? dir : (dir + '/'));
gExeName = info.fileName();
}
}