GUI: merge: more options for »always do XYZ« when dropping files

Now the three actions »add to current settings«, »add all to new
settings« and »add each file its own new settings« can be set to be
always performed without asking the user.

Implements #1388.
This commit is contained in:
Moritz Bunkus 2015-09-18 18:09:30 +02:00
parent 740c19c7f3
commit 42719778e3
10 changed files with 159 additions and 101 deletions

View File

@ -1,5 +1,13 @@
2015-09-18 Moritz Bunkus <moritz@bunkus.org>
* 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

View File

@ -417,13 +417,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbMAlwaysAddDroppedFiles">
<property name="text">
<string>Always add files dropped from e&amp;xternal applications</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbMAlwaysShowOutputFileControls">
<property name="text">
@ -433,7 +426,7 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="1">
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLineEdit" name="leMDefaultAdditionalCommandLineOptions"/>
@ -451,10 +444,10 @@
</item>
</layout>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QComboBox" name="cbMProcessPriority"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Default track &amp;language to set:</string>
@ -464,7 +457,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Process &amp;priority:</string>
@ -474,7 +467,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Default &amp;subtitle charset to set:</string>
@ -484,7 +477,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Default add&amp;itional command line options:</string>
@ -497,21 +490,8 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="mtx::gui::Util::LanguageComboBox" name="cbMDefaultTrackLanguage"/>
</item>
<item row="2" column="1">
<widget class="mtx::gui::Util::CharacterSetComboBox" name="cbMDefaultSubtitleCharset"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>&amp;Clearing settings automatically:</string>
</property>
<property name="buddy">
<cstring>cbMClearMergeSettings</cstring>
</property>
</widget>
<widget class="mtx::gui::Util::LanguageComboBox" name="cbMDefaultTrackLanguage"/>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cbMClearMergeSettings">
@ -532,6 +512,30 @@
</item>
</widget>
</item>
<item row="3" column="1">
<widget class="mtx::gui::Util::CharacterSetComboBox" name="cbMDefaultSubtitleCharset"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>&amp;Clearing settings automatically:</string>
</property>
<property name="buddy">
<cstring>cbMClearMergeSettings</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>When dropping files:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cbMAddingAppendingFilesPolicy">
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -49,9 +49,16 @@
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbAlwaysAdd">
<widget class="QRadioButton" name="rbAddToNew">
<property name="text">
<string>Alwa&amp;ys add as new input files and don't ask again</string>
<string>Create new &amp;merge settings and add to those</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbAddEachToNew">
<property name="text">
<string>Create new merge settings for &amp;each file</string>
</property>
</widget>
</item>
@ -69,20 +76,6 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbAddToNew">
<property name="text">
<string>Create new &amp;merge settings and add to those</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbAddEachToNew">
<property name="text">
<string>Create new merge settings for &amp;each file</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
@ -96,6 +89,13 @@
<item>
<widget class="QComboBox" name="cbFileName"/>
</item>
<item>
<widget class="QCheckBox" name="cbAlwaysUseThisDecision">
<property name="text">
<string>Alwa&amp;ys use the action selected above and don't ask again</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@ -137,11 +137,12 @@
</widget>
<tabstops>
<tabstop>rbAdd</tabstop>
<tabstop>rbAlwaysAdd</tabstop>
<tabstop>rbAddToNew</tabstop>
<tabstop>rbAddEachToNew</tabstop>
<tabstop>rbAppend</tabstop>
<tabstop>rbAddAdditionalParts</tabstop>
<tabstop>rbAddToNew</tabstop>
<tabstop>cbFileName</tabstop>
<tabstop>cbAlwaysUseThisDecision</tabstop>
</tabstops>
<resources/>
<connections>
@ -200,8 +201,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>261</x>
<y>283</y>
<x>544</x>
<y>307</y>
</hint>
<hint type="destinationlabel">
<x>215</x>
@ -232,8 +233,8 @@
<slot>selectionChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>179</x>
<y>184</y>
<x>185</x>
<y>102</y>
</hint>
<hint type="destinationlabel">
<x>147</x>
@ -242,18 +243,18 @@
</hints>
</connection>
<connection>
<sender>rbAlwaysAdd</sender>
<sender>rbAddEachToNew</sender>
<signal>clicked()</signal>
<receiver>mtx::gui::Merge::AddingAppendingFilesDialog</receiver>
<slot>selectionChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>203</x>
<y>93</y>
<x>87</x>
<y>122</y>
</hint>
<hint type="destinationlabel">
<x>173</x>
<y>285</y>
<x>80</x>
<y>299</y>
</hint>
</hints>
</connection>

View File

@ -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<int>(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("<p>%1 %2</p><p>%3</p>")
.arg(QY("Certain file formats have a 'language' property for their tracks."))
@ -356,6 +361,20 @@ PreferencesDialog::setupEnableMuxingTracksByLanguage() {
ui->tbMEnableMuxingTracksByLanguage->setItems(QList<Util::SideBySideMultiSelect::Item>::fromVector(QVector<Util::SideBySideMultiSelect::Item>::fromStdVector(allLanguages)), m_cfg.m_enableMuxingTracksByTheseLanguages);
}
void
PreferencesDialog::setupAddingAppendingFilesPolicy() {
ui->cbMAddingAppendingFilesPolicy->addItem(QY("ask the user"), static_cast<int>(Util::Settings::AddingAppendingFilesPolicy::Ask));
ui->cbMAddingAppendingFilesPolicy->addItem(QY("add all files to the current merge settings"), static_cast<int>(Util::Settings::AddingAppendingFilesPolicy::Add));
ui->cbMAddingAppendingFilesPolicy->addItem(QY("create one new merge settings tab and add all files there"), static_cast<int>(Util::Settings::AddingAppendingFilesPolicy::AddToNew));
ui->cbMAddingAppendingFilesPolicy->addItem(QY("create one new merge settings tab for each file"), static_cast<int>(Util::Settings::AddingAppendingFilesPolicy::AddEachToNew));
Util::setComboBoxIndexIf(ui->cbMAddingAppendingFilesPolicy, [this](QString const &, QVariant const &data) {
return data.isValid() && (static_cast<Util::Settings::AddingAppendingFilesPolicy>(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<Util::Settings::AddingAppendingFilesPolicy>(ui->cbMAddingAppendingFilesPolicy->currentData().toInt());
m_cfg.m_mergeAlwaysShowOutputFileControls = ui->cbMAlwaysShowOutputFileControls->isChecked();
m_cfg.m_clearMergeSettings = static_cast<Util::Settings::ClearMergeSettingsAction>(ui->cbMClearMergeSettings->currentIndex());
m_cfg.m_defaultTrackLanguage = ui->cbMDefaultTrackLanguage->currentData().toString();

View File

@ -51,6 +51,7 @@ protected:
void setupPlaylistScanningPolicy();
void setupOutputFileNamePolicy();
void setupEnableMuxingTracksByLanguage();
void setupAddingAppendingFilesPolicy();
};
}}

View File

@ -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();
}
}}}

View File

@ -6,6 +6,7 @@
#include <QDialog>
#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::AddingAppendingFilesDialog> ui;
@ -32,8 +23,9 @@ public:
explicit AddingAppendingFilesDialog(QWidget *parent, QList<SourceFilePtr> const &files);
~AddingAppendingFilesDialog();
Decision decision() const;
Util::Settings::AddingAppendingFilesPolicy decision() const;
int fileIndex() const;
bool alwaysUseThisDecision() const;
public slots:
void selectionChanged();

View File

@ -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

View File

@ -90,8 +90,25 @@ Settings::registry() {
return std::make_unique<QSettings>(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<int>(AddingAppendingFilesPolicy::Add));
reg->remove("mergeAlwaysAddDroppedFiles");
reg->endGroup();
}
void
Settings::load() {
convertOldSettings();
auto regPtr = registry();
auto &reg = *regPtr;
@ -118,8 +135,8 @@ Settings::load() {
m_clearMergeSettings = static_cast<ClearMergeSettingsAction>(reg.value("clearMergeSettings", static_cast<int>(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<AddingAppendingFilesPolicy>(reg.value("mergeAddingAppendingFilesPolicy", static_cast<int>(AddingAppendingFilesPolicy::Ask)).toInt());
m_uniqueOutputFileNames = reg.value("uniqueOutputFileNames", true).toBool();
m_outputFileNamePolicy = static_cast<OutputFileNamePolicy>(reg.value("outputFileNamePolicy", static_cast<int>(ToSameAsFirstInputFile)).toInt());
@ -229,8 +246,8 @@ Settings::save()
reg.setValue("clearMergeSettings", static_cast<int>(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<int>(m_mergeAddingAppendingFilesPolicy));
reg.setValue("outputFileNamePolicy", static_cast<int>(m_outputFileNamePolicy));
reg.setValue("relativeOutputDir", m_relativeOutputDir.path());

View File

@ -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();