mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-01-12 21:21:05 +00:00
GUI: mux: unique file names: only remove trailing number on directory changes
The caller of the function `generateUniqueOutputFileName` knows whether or not the base name given to the function is the base name of the first added file or the current content of the destination file name control. Only in the latter case is the suffix added for uniqueness present and has to be removed.
This commit is contained in:
parent
22ec2f9ac4
commit
07b412ae6b
9
NEWS.md
9
NEWS.md
@ -6,6 +6,15 @@
|
||||
Wikipedia's "List of languages by native speakers" by default. Also by
|
||||
default only those languages will be shown in the language drop-down boxes.
|
||||
|
||||
## Bug fixes
|
||||
|
||||
* MKVToolNix GUI: multiplexer: fixed a bug in the "make destination file names
|
||||
unique" logic that caused an existing number-in-parenthesis at the end of
|
||||
the file base name to be removed in certain situations (e.g. when the first
|
||||
added file was named `m (3).mkv` and both `m (3) (1).mkv` and `m (3)
|
||||
(2).mkv` existed already, the GUI was suddenly use `m.mkv` instead of `m (3)
|
||||
(3).mkv`).
|
||||
|
||||
|
||||
# Version 36.0.0 "Is That Jazz?" 2019-08-10
|
||||
|
||||
|
@ -1562,13 +1562,19 @@ Tab::setOutputFileNameMaybe(bool force) {
|
||||
|
||||
QString
|
||||
Tab::generateUniqueOutputFileName(QString const &baseName,
|
||||
QDir const &outputDir) {
|
||||
QDir const &outputDir,
|
||||
bool removeUniquenessSuffix) {
|
||||
auto &settings = Util::Settings::get();
|
||||
auto cleanedBaseName = baseName;
|
||||
auto suffix = suggestOutputFileNameExtension();
|
||||
auto needToRemove = removeUniquenessSuffix
|
||||
&& !m_config.m_destinationUniquenessSuffix.isEmpty()
|
||||
&& cleanedBaseName.endsWith(m_config.m_destinationUniquenessSuffix);
|
||||
|
||||
if ( !m_config.m_destinationUniquenessSuffix.isEmpty()
|
||||
&& cleanedBaseName.endsWith(m_config.m_destinationUniquenessSuffix))
|
||||
qDebug() << "generateUniqueOutputFileName: baseName" << baseName << "suffix" << suffix << "destinationUniquenessSuffix" << m_config.m_destinationUniquenessSuffix
|
||||
<< "removeUniquenessSuffix" << removeUniquenessSuffix << "needToRemove" << needToRemove;
|
||||
|
||||
if (needToRemove)
|
||||
cleanedBaseName.remove(cleanedBaseName.length() - m_config.m_destinationUniquenessSuffix.length(), m_config.m_destinationUniquenessSuffix.length());
|
||||
|
||||
auto idx = 0;
|
||||
|
@ -720,7 +720,7 @@ Tab::changeOutputDirectoryTo(QString const &directory) {
|
||||
auto makeUnique = Util::Settings::get().m_uniqueOutputFileNames;
|
||||
auto oldFileName = QFileInfo{ m_config.m_destination }.fileName();
|
||||
auto newFileName = !oldFileName.isEmpty() ? oldFileName : Q("%1.%2").arg(QY("unnamed")).arg(suggestOutputFileNameExtension());
|
||||
auto newFilePath = makeUnique ? generateUniqueOutputFileName(QFileInfo{newFileName}.completeBaseName(), QDir{directory}) : Q("%1/%2").arg(directory).arg(newFileName);
|
||||
auto newFilePath = makeUnique ? generateUniqueOutputFileName(QFileInfo{newFileName}.completeBaseName(), QDir{directory}, true) : Q("%1/%2").arg(directory).arg(newFileName);
|
||||
|
||||
ui->output->setText(QDir::toNativeSeparators(newFilePath));
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ protected:
|
||||
|
||||
virtual void setOutputFileNameMaybe(bool force = false);
|
||||
virtual QString suggestOutputFileNameExtension() const;
|
||||
virtual QString generateUniqueOutputFileName(QString const &baseName, QDir const &outputDir);
|
||||
virtual QString generateUniqueOutputFileName(QString const &baseName, QDir const &outputDir, bool removeUniquenessSuffix = false);
|
||||
|
||||
virtual void enableDisableAllTracks(bool enable);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user