GUI: mux: temporarily ignore invalid destination file names

Before the GUI tried to make the destination file name valid after
each change. This worked badly with the user trying to change the
drive letter by adding the new one and removing the old one in two
steps.

Now the GUI will simply ignore an invalid destination file name for
the time being. The file name will still be verified when the job is
started or added to the queue.

Fixes #2527.
This commit is contained in:
Moritz Bunkus 2019-04-09 21:35:04 +02:00
parent 765f23e1c0
commit 4db66e2574
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
3 changed files with 20 additions and 7 deletions

View File

@ -11,6 +11,11 @@
stripped anymore during the process of ensuring the destination file name is
unique. Only those suffixes added automatically in prior attempts to make
the file name unique will be removed. Fixes #2521.
* MKVToolNix GUI: multiplexer: Windows: the GUI will let the user change the
drive letter part of the destination file name freely again and only verify
its validity right before starting to mux/adding to the job queue. Before it
tried to force that into something valid, often resulting in unintentional
paths (such as "C:\users\…\DC\files\…"). Fixes #2527.
# Version 32.0.0 "Astral Progressions" 2019-03-12

View File

@ -342,13 +342,12 @@ Tab::onTitleChanged(QString newValue) {
void
Tab::setDestination(QString const &newValue) {
QString prefix;
#if defined(SYS_WINDOWS)
if (newValue.startsWith(Q(":")))
prefix = Q(":");
if (!newValue.contains(QRegularExpression{Q("^[a-zA-Z]:[\\\\/]|^\\\\\\\\.+\\.+")}))
return;
#endif
m_config.m_destination = QDir::toNativeSeparators(prefix + Util::removeInvalidPathCharacters(newValue));
m_config.m_destination = QDir::toNativeSeparators(Util::removeInvalidPathCharacters(newValue));
if (!m_config.m_destination.isEmpty()) {
auto &settings = Util::Settings::get();
settings.m_lastOutputDir = QFileInfo{ newValue }.absoluteDir();
@ -359,7 +358,7 @@ Tab::setDestination(QString const &newValue) {
if (m_config.m_destination == newValue)
return;
auto newPosition = std::max(ui->output->cursorPosition(), 1) - 1;
auto newPosition = ui->output->cursorPosition();
ui->output->setText(m_config.m_destination);
ui->output->setCursorPosition(newPosition);
}

View File

@ -335,12 +335,21 @@ Tab::retranslateUi() {
bool
Tab::isReadyForMerging() {
if (m_config.m_destination.isEmpty()) {
auto destination = QDir::toNativeSeparators(ui->output->text());
if (destination.isEmpty()) {
Util::MessageBox::critical(this)->title(QY("Cannot start multiplexing")).text(QY("You have to set the destination file name before you can start multiplexing or add a job to the job queue.")).exec();
return false;
}
if (m_config.m_destination != Util::removeInvalidPathCharacters(m_config.m_destination)) {
auto destinationValid = destination == Util::removeInvalidPathCharacters(destination);
#if defined(SYS_WINDOWS)
if (destinationValid)
destinationValid = destination.contains(QRegularExpression{Q("^[a-zA-Z]:[\\\\/]|^\\\\\\\\.+\\.+")});
#endif // SYS_WINDOWS
if (!destinationValid) {
Util::MessageBox::critical(this)->title(QY("Cannot start multiplexing")).text(QY("The destination file name is invalid and must be fixed before you can start multiplexing or add a job to the job queue.")).exec();
return false;
}