Skip to content

Commit

Permalink
fixed Save As default filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Feb 16, 2015
1 parent 394170b commit 840d5eb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Telegram/SourceFiles/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,9 @@ void VideoSaveLink::doSave(bool forceSavingAs) const {
psOpenFile(already, true);
}
} else {
QDir alreadyDir(already.isEmpty() ? QDir() : QFileInfo(already).dir());
QString name = already.isEmpty() ? QString(".mov") : already;
QFileInfo alreadyInfo(already);
QDir alreadyDir(already.isEmpty() ? QDir() : alreadyInfo.dir());
QString name = already.isEmpty() ? QString(".mov") : alreadyInfo.fileName();
QString filename = saveFileName(lang(lng_save_video), qsl("MOV Video (*.mov);;All files (*.*)"), qsl("video"), name, forceSavingAs, alreadyDir);
if (!filename.isEmpty()) {
if (forceSavingAs) {
Expand Down Expand Up @@ -587,9 +588,10 @@ void AudioSaveLink::doSave(bool forceSavingAs) const {
psOpenFile(already, true);
}
} else {
QDir alreadyDir(already.isEmpty() ? QDir() : QFileInfo(already).dir());
QFileInfo alreadyInfo(already);
QDir alreadyDir(already.isEmpty() ? QDir() : alreadyInfo.dir());
bool mp3 = (data->mime == QLatin1String("audio/mp3"));
QString name = already.isEmpty() ? (mp3 ? qsl(".mp3") : qsl(".ogg")) : already;
QString name = already.isEmpty() ? (mp3 ? qsl(".mp3") : qsl(".ogg")) : alreadyInfo.fileName();
QString filename = saveFileName(lang(lng_save_audio), mp3 ? qsl("MP3 Audio (*.mp3);;All files (*.*)") : qsl("OGG Opus Audio (*.ogg);;All files (*.*)"), qsl("audio"), name, forceSavingAs, alreadyDir);
if (!filename.isEmpty()) {
if (forceSavingAs) {
Expand Down Expand Up @@ -692,8 +694,9 @@ void DocumentSaveLink::doSave(bool forceSavingAs) const {
psOpenFile(already, true);
}
} else {
QDir alreadyDir(already.isEmpty() ? QDir() : QFileInfo(already).dir());
QString name = already.isEmpty() ? data->name : already, filter;
QFileInfo alreadyInfo(already);
QDir alreadyDir(already.isEmpty() ? QDir() : alreadyInfo.dir());
QString name = already.isEmpty() ? data->name : alreadyInfo.fileName(), filter;
MimeType mimeType = mimeTypeForName(data->mime);
QStringList p = mimeType.globPatterns();
QString pattern = p.isEmpty() ? QString() : p.front();
Expand Down

0 comments on commit 840d5eb

Please sign in to comment.