diff --git a/ChangeLog b/ChangeLog index f27680593..7f99668e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2015-09-18 Moritz Bunkus + * MKVToolNix GUI: new merge tool feature: when dragging & dropping + files onto merge settings already containing a file the user can + set more options to be always done instead of asking (before: only + adding files to the current merge settings could be thus marked; + now: adding to current, adding to new settings and adding each + file to new settings can be set to perform without + asking). Implements #1388. + * MKVToolNix GUI: merge tool enhancement: when dragging & dropping files onto merge settings already containing a file the dialog asking the user what to do has received a new option for creating diff --git a/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui b/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui index d81b69e03..405c1a31a 100644 --- a/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui +++ b/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui @@ -417,13 +417,6 @@ - - - - Always add files dropped from e&xternal applications - - - @@ -433,7 +426,7 @@ - + @@ -451,10 +444,10 @@ - + - + Default track &language to set: @@ -464,7 +457,7 @@ - + Process &priority: @@ -474,7 +467,7 @@ - + Default &subtitle charset to set: @@ -484,7 +477,7 @@ - + Default add&itional command line options: @@ -497,21 +490,8 @@ - - - - - - - - - &Clearing settings automatically: - - - cbMClearMergeSettings - - + @@ -532,6 +512,30 @@ + + + + + + + &Clearing settings automatically: + + + cbMClearMergeSettings + + + + + + + When dropping files: + + + + + + + diff --git a/src/mkvtoolnix-gui/forms/merge/adding_appending_files_dialog.ui b/src/mkvtoolnix-gui/forms/merge/adding_appending_files_dialog.ui index 583412bec..d5cc5f248 100644 --- a/src/mkvtoolnix-gui/forms/merge/adding_appending_files_dialog.ui +++ b/src/mkvtoolnix-gui/forms/merge/adding_appending_files_dialog.ui @@ -49,9 +49,16 @@ - + - Alwa&ys add as new input files and don't ask again + Create new &merge settings and add to those + + + + + + + Create new merge settings for &each file @@ -69,20 +76,6 @@ - - - - Create new &merge settings and add to those - - - - - - - Create new merge settings for &each file - - - @@ -96,6 +89,13 @@ + + + + Alwa&ys use the action selected above and don't ask again + + + @@ -137,11 +137,12 @@ rbAdd - rbAlwaysAdd + rbAddToNew + rbAddEachToNew rbAppend rbAddAdditionalParts - rbAddToNew cbFileName + cbAlwaysUseThisDecision @@ -200,8 +201,8 @@ accept() - 261 - 283 + 544 + 307 215 @@ -232,8 +233,8 @@ selectionChanged() - 179 - 184 + 185 + 102 147 @@ -242,18 +243,18 @@ - rbAlwaysAdd + rbAddEachToNew clicked() mtx::gui::Merge::AddingAppendingFilesDialog selectionChanged() - 203 - 93 + 87 + 122 - 173 - 285 + 80 + 299 diff --git a/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp b/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp index 77ea61d86..4a349fdb5 100644 --- a/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp +++ b/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp @@ -52,7 +52,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) ui->cbMSetAudioDelayFromFileName->setChecked(m_cfg.m_setAudioDelayFromFileName); ui->cbMDisableCompressionForAllTrackTypes->setChecked(m_cfg.m_disableCompressionForAllTrackTypes); ui->cbMDisableDefaultTrackForSubtitles->setChecked(m_cfg.m_disableDefaultTrackForSubtitles); - ui->cbMAlwaysAddDroppedFiles->setChecked(m_cfg.m_mergeAlwaysAddDroppedFiles); ui->cbMAlwaysShowOutputFileControls->setChecked(m_cfg.m_mergeAlwaysShowOutputFileControls); ui->cbMClearMergeSettings->setCurrentIndex(static_cast(m_cfg.m_clearMergeSettings)); ui->cbMDefaultTrackLanguage->setup().setCurrentByData(m_cfg.m_defaultTrackLanguage); @@ -63,6 +62,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) setupPlaylistScanningPolicy(); setupOutputFileNamePolicy(); setupEnableMuxingTracksByLanguage(); + setupAddingAppendingFilesPolicy(); // Chapter editor page ui->leCENameTemplate->setText(m_cfg.m_chapterNameTemplate); @@ -154,7 +154,6 @@ PreferencesDialog::setupToolTips() { .arg(QY("Normally mkvmerge will apply additional lossless compression for subtitle tracks for certain codecs.")) .arg(QY("Checking this option causes the GUI to set that compression to »none« by default for all track types when adding files."))); - Util::setToolTip(ui->cbMAlwaysAddDroppedFiles, QY("If disabled the GUI will ask whether you want to add the dropped files, append them or add them as additional parts.")); Util::setToolTip(ui->cbMAlwaysShowOutputFileControls, Q("%1 %2") .arg(QY("If enabled the output file name controls will always be visible no matter which tab is currently shown.")) @@ -168,6 +167,12 @@ PreferencesDialog::setupToolTips() { .arg(QY("With »remove input files« all input files will be removed.")) .arg(QY("Most of the other settings on the output tab will be kept intact, though."))); + Util::setToolTip(ui->cbMAddingAppendingFilesPolicy, + Q("%1 %2 %3") + .arg(QY("When the user drags & drops files from an external application onto the merge tool the GUI can take different actions.")) + .arg(QY("The default is to always add all the files to the current merge settings.")) + .arg(QY("The GUI can also ask the user what to do each time, e.g. appending them instead of adding them, or creating new merge settings and adding them to those."))); + Util::setToolTip(ui->cbMDefaultTrackLanguage, Q("

%1 %2

%3

") .arg(QY("Certain file formats have a 'language' property for their tracks.")) @@ -356,6 +361,20 @@ PreferencesDialog::setupEnableMuxingTracksByLanguage() { ui->tbMEnableMuxingTracksByLanguage->setItems(QList::fromVector(QVector::fromStdVector(allLanguages)), m_cfg.m_enableMuxingTracksByTheseLanguages); } +void +PreferencesDialog::setupAddingAppendingFilesPolicy() { + ui->cbMAddingAppendingFilesPolicy->addItem(QY("ask the user"), static_cast(Util::Settings::AddingAppendingFilesPolicy::Ask)); + ui->cbMAddingAppendingFilesPolicy->addItem(QY("add all files to the current merge settings"), static_cast(Util::Settings::AddingAppendingFilesPolicy::Add)); + ui->cbMAddingAppendingFilesPolicy->addItem(QY("create one new merge settings tab and add all files there"), static_cast(Util::Settings::AddingAppendingFilesPolicy::AddToNew)); + ui->cbMAddingAppendingFilesPolicy->addItem(QY("create one new merge settings tab for each file"), static_cast(Util::Settings::AddingAppendingFilesPolicy::AddEachToNew)); + + Util::setComboBoxIndexIf(ui->cbMAddingAppendingFilesPolicy, [this](QString const &, QVariant const &data) { + return data.isValid() && (static_cast(data.toInt()) == m_cfg.m_mergeAddingAppendingFilesPolicy); + }); + + Util::fixComboBoxViewWidth(*ui->cbMAddingAppendingFilesPolicy); +} + void PreferencesDialog::setupTabPositions() { ui->cbGuiTabPositions->clear(); @@ -396,7 +415,7 @@ PreferencesDialog::save() { m_cfg.m_setAudioDelayFromFileName = ui->cbMSetAudioDelayFromFileName->isChecked(); m_cfg.m_disableCompressionForAllTrackTypes = ui->cbMDisableCompressionForAllTrackTypes->isChecked(); m_cfg.m_disableDefaultTrackForSubtitles = ui->cbMDisableDefaultTrackForSubtitles->isChecked(); - m_cfg.m_mergeAlwaysAddDroppedFiles = ui->cbMAlwaysAddDroppedFiles->isChecked(); + m_cfg.m_mergeAddingAppendingFilesPolicy = static_cast(ui->cbMAddingAppendingFilesPolicy->currentData().toInt()); m_cfg.m_mergeAlwaysShowOutputFileControls = ui->cbMAlwaysShowOutputFileControls->isChecked(); m_cfg.m_clearMergeSettings = static_cast(ui->cbMClearMergeSettings->currentIndex()); m_cfg.m_defaultTrackLanguage = ui->cbMDefaultTrackLanguage->currentData().toString(); diff --git a/src/mkvtoolnix-gui/main_window/preferences_dialog.h b/src/mkvtoolnix-gui/main_window/preferences_dialog.h index 3c70893b3..e0e90107c 100644 --- a/src/mkvtoolnix-gui/main_window/preferences_dialog.h +++ b/src/mkvtoolnix-gui/main_window/preferences_dialog.h @@ -51,6 +51,7 @@ protected: void setupPlaylistScanningPolicy(); void setupOutputFileNamePolicy(); void setupEnableMuxingTracksByLanguage(); + void setupAddingAppendingFilesPolicy(); }; }} diff --git a/src/mkvtoolnix-gui/merge/adding_appending_files_dialog.cpp b/src/mkvtoolnix-gui/merge/adding_appending_files_dialog.cpp index 29149a3d5..c879521c1 100644 --- a/src/mkvtoolnix-gui/merge/adding_appending_files_dialog.cpp +++ b/src/mkvtoolnix-gui/merge/adding_appending_files_dialog.cpp @@ -32,15 +32,14 @@ AddingAppendingFilesDialog::AddingAppendingFilesDialog(QWidget *parent, AddingAppendingFilesDialog::~AddingAppendingFilesDialog() { } -AddingAppendingFilesDialog::Decision +Util::Settings::AddingAppendingFilesPolicy AddingAppendingFilesDialog::decision() const { - return ui->rbAdd->isChecked() ? Decision::Add - : ui->rbAlwaysAdd->isChecked() ? Decision::AlwaysAdd - : ui->rbAppend->isChecked() ? Decision::Append - : ui->rbAddToNew->isChecked() ? Decision::AddToNew - : ui->rbAddEachToNew->isChecked() ? Decision::AddEachToNew - : Decision::AddAdditionalParts; + return ui->rbAdd->isChecked() ? Util::Settings::AddingAppendingFilesPolicy::Add + : ui->rbAppend->isChecked() ? Util::Settings::AddingAppendingFilesPolicy::Append + : ui->rbAddToNew->isChecked() ? Util::Settings::AddingAppendingFilesPolicy::AddToNew + : ui->rbAddEachToNew->isChecked() ? Util::Settings::AddingAppendingFilesPolicy::AddEachToNew + : Util::Settings::AddingAppendingFilesPolicy::AddAdditionalParts; } int @@ -52,6 +51,13 @@ AddingAppendingFilesDialog::fileIndex() void AddingAppendingFilesDialog::selectionChanged() { ui->cbFileName->setEnabled(ui->rbAppend->isChecked() || ui->rbAddAdditionalParts->isChecked()); + ui->cbAlwaysUseThisDecision->setEnabled(ui->rbAdd->isChecked() || ui->rbAddToNew->isChecked() || ui->rbAddEachToNew->isChecked()); +} + +bool +AddingAppendingFilesDialog::alwaysUseThisDecision() + const { + return ui->cbAlwaysUseThisDecision->isEnabled() && ui->cbAlwaysUseThisDecision->isChecked(); } }}} diff --git a/src/mkvtoolnix-gui/merge/adding_appending_files_dialog.h b/src/mkvtoolnix-gui/merge/adding_appending_files_dialog.h index 40fedbcbf..6ca4762b5 100644 --- a/src/mkvtoolnix-gui/merge/adding_appending_files_dialog.h +++ b/src/mkvtoolnix-gui/merge/adding_appending_files_dialog.h @@ -6,6 +6,7 @@ #include #include "mkvtoolnix-gui/merge/source_file.h" +#include "mkvtoolnix-gui/util/settings.h" namespace mtx { namespace gui { namespace Merge { @@ -15,16 +16,6 @@ class AddingAppendingFilesDialog; class AddingAppendingFilesDialog : public QDialog { Q_OBJECT; -public: - enum class Decision { - Add, - AlwaysAdd, - Append, - AddAdditionalParts, - AddToNew, - AddEachToNew, - }; - protected: std::unique_ptr ui; @@ -32,8 +23,9 @@ public: explicit AddingAppendingFilesDialog(QWidget *parent, QList const &files); ~AddingAppendingFilesDialog(); - Decision decision() const; + Util::Settings::AddingAppendingFilesPolicy decision() const; int fileIndex() const; + bool alwaysUseThisDecision() const; public slots: void selectionChanged(); diff --git a/src/mkvtoolnix-gui/merge/input.cpp b/src/mkvtoolnix-gui/merge/input.cpp index f39327148..7efa851d0 100644 --- a/src/mkvtoolnix-gui/merge/input.cpp +++ b/src/mkvtoolnix-gui/merge/input.cpp @@ -1129,35 +1129,34 @@ void Tab::addOrAppendDroppedFiles(QStringList const &fileNames) { auto &settings = Util::Settings::get(); - if (m_config.m_files.isEmpty() || settings.m_mergeAlwaysAddDroppedFiles) { - addOrAppendFiles(false, fileNames, {}); - return; - } + auto decision = settings.m_mergeAddingAppendingFilesPolicy; + auto fileIdx = QModelIndex{}; - AddingAppendingFilesDialog dlg{this, m_config.m_files}; - if (!dlg.exec()) - return; + if (Util::Settings::AddingAppendingFilesPolicy::Ask == decision) { + AddingAppendingFilesDialog dlg{this, m_config.m_files}; + if (!dlg.exec()) + return; - auto decision = dlg.decision(); - auto fileIdx = m_filesModel->index(dlg.fileIndex(), 0); + decision = dlg.decision(); + fileIdx = m_filesModel->index(dlg.fileIndex(), 0); - if (AddingAppendingFilesDialog::Decision::AddAdditionalParts == decision) - m_filesModel->addAdditionalParts(fileIdx, fileNames); - - else if (AddingAppendingFilesDialog::Decision::AddToNew == decision) - MainWindow::mergeTool()->addMultipleFilesToNewSettings(fileNames, false); - - else if (AddingAppendingFilesDialog::Decision::AddEachToNew == decision) - MainWindow::mergeTool()->addMultipleFilesToNewSettings(fileNames, true); - - else { - if (AddingAppendingFilesDialog::Decision::AlwaysAdd == decision) { - settings.m_mergeAlwaysAddDroppedFiles = true; + if (dlg.alwaysUseThisDecision()) { + settings.m_mergeAddingAppendingFilesPolicy = decision; settings.save(); } - - addOrAppendFiles(AddingAppendingFilesDialog::Decision::Append == decision, fileNames, fileIdx); } + + if (Util::Settings::AddingAppendingFilesPolicy::AddAdditionalParts == decision) + m_filesModel->addAdditionalParts(fileIdx, fileNames); + + else if (Util::Settings::AddingAppendingFilesPolicy::AddToNew == decision) + MainWindow::mergeTool()->addMultipleFilesToNewSettings(fileNames, false); + + else if (Util::Settings::AddingAppendingFilesPolicy::AddEachToNew == decision) + MainWindow::mergeTool()->addMultipleFilesToNewSettings(fileNames, true); + + else + addOrAppendFiles(Util::Settings::AddingAppendingFilesPolicy::Append == decision, fileNames, fileIdx); } void diff --git a/src/mkvtoolnix-gui/util/settings.cpp b/src/mkvtoolnix-gui/util/settings.cpp index 753d20330..38e95a1d1 100644 --- a/src/mkvtoolnix-gui/util/settings.cpp +++ b/src/mkvtoolnix-gui/util/settings.cpp @@ -90,8 +90,25 @@ Settings::registry() { return std::make_unique(iniFileName(), QSettings::IniFormat); } +void +Settings::convertOldSettings() { + auto reg = registry(); + + // mergeAlwaysAddDroppedFiles → + reg->beginGroup("settings"); + auto mergeAlwaysAddDroppedFiles = reg->value("mergeAlwaysAddDroppedFiles"); + + if (mergeAlwaysAddDroppedFiles.isValid()) + reg->setValue("mergeAddingAppendingFilesPolicy", static_cast(AddingAppendingFilesPolicy::Add)); + + reg->remove("mergeAlwaysAddDroppedFiles"); + reg->endGroup(); +} + void Settings::load() { + convertOldSettings(); + auto regPtr = registry(); auto ® = *regPtr; @@ -118,8 +135,8 @@ Settings::load() { m_clearMergeSettings = static_cast(reg.value("clearMergeSettings", static_cast(ClearMergeSettingsAction::None)).toInt()); m_disableCompressionForAllTrackTypes = reg.value("disableCompressionForAllTrackTypes", false).toBool(); m_disableDefaultTrackForSubtitles = reg.value("disableDefaultTrackForSubtitles", false).toBool(); - m_mergeAlwaysAddDroppedFiles = reg.value("mergeAlwaysAddDroppedFiles", false).toBool(); m_mergeAlwaysShowOutputFileControls = reg.value("mergeAlwaysShowOutputFileControls", true).toBool(); + m_mergeAddingAppendingFilesPolicy = static_cast(reg.value("mergeAddingAppendingFilesPolicy", static_cast(AddingAppendingFilesPolicy::Ask)).toInt()); m_uniqueOutputFileNames = reg.value("uniqueOutputFileNames", true).toBool(); m_outputFileNamePolicy = static_cast(reg.value("outputFileNamePolicy", static_cast(ToSameAsFirstInputFile)).toInt()); @@ -229,8 +246,8 @@ Settings::save() reg.setValue("clearMergeSettings", static_cast(m_clearMergeSettings)); reg.setValue("disableCompressionForAllTrackTypes", m_disableCompressionForAllTrackTypes); reg.setValue("disableDefaultTrackForSubtitles", m_disableDefaultTrackForSubtitles); - reg.setValue("mergeAlwaysAddDroppedFiles", m_mergeAlwaysAddDroppedFiles); reg.setValue("mergeAlwaysShowOutputFileControls", m_mergeAlwaysShowOutputFileControls); + reg.setValue("mergeAddingAppendingFilesPolicy", static_cast(m_mergeAddingAppendingFilesPolicy)); reg.setValue("outputFileNamePolicy", static_cast(m_outputFileNamePolicy)); reg.setValue("relativeOutputDir", m_relativeOutputDir.path()); diff --git a/src/mkvtoolnix-gui/util/settings.h b/src/mkvtoolnix-gui/util/settings.h index 09a434327..bd19261ec 100644 --- a/src/mkvtoolnix-gui/util/settings.h +++ b/src/mkvtoolnix-gui/util/settings.h @@ -53,13 +53,23 @@ public: RemoveInputFiles, }; + enum class AddingAppendingFilesPolicy { + Ask, + Add, + AddToNew, + AddEachToNew, + Append, + AddAdditionalParts, + }; + QString m_defaultTrackLanguage, m_chapterNameTemplate, m_defaultChapterLanguage, m_defaultChapterCountry, m_defaultSubtitleCharset, m_defaultAdditionalMergeOptions; QStringList m_oftenUsedLanguages, m_oftenUsedCountries, m_oftenUsedCharacterSets; ProcessPriority m_priority; QTabWidget::TabPosition m_tabPosition; QDir m_lastOpenDir, m_lastOutputDir, m_lastConfigDir; - bool m_setAudioDelayFromFileName, m_autoSetFileTitle, m_disableCompressionForAllTrackTypes, m_disableDefaultTrackForSubtitles, m_mergeAlwaysAddDroppedFiles, m_mergeAlwaysShowOutputFileControls, m_dropLastChapterFromBlurayPlaylist; + bool m_setAudioDelayFromFileName, m_autoSetFileTitle, m_disableCompressionForAllTrackTypes, m_disableDefaultTrackForSubtitles, m_mergeAlwaysShowOutputFileControls, m_dropLastChapterFromBlurayPlaylist; ClearMergeSettingsAction m_clearMergeSettings; + AddingAppendingFilesPolicy m_mergeAddingAppendingFilesPolicy; OutputFileNamePolicy m_outputFileNamePolicy; QDir m_relativeOutputDir, m_fixedOutputDir; @@ -112,6 +122,7 @@ public: static QString exeWithPath(QString const &exe); static void migrateFromRegistry(); + static void convertOldSettings(); static QString iniFileLocation(); static QString iniFileName();