mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-01-08 11:11:51 +00:00
GUI: refuse to close the preferences if any of the actions to execute is invalid
This commit is contained in:
parent
9e00fac77a
commit
0fd771282b
@ -18,6 +18,7 @@
|
||||
#include "mkvtoolnix-gui/main_window/prefs_run_program_widget.h"
|
||||
#include "mkvtoolnix-gui/merge/additional_command_line_options_dialog.h"
|
||||
#include "mkvtoolnix-gui/util/file_dialog.h"
|
||||
#include "mkvtoolnix-gui/util/message_box.h"
|
||||
#include "mkvtoolnix-gui/util/model.h"
|
||||
#include "mkvtoolnix-gui/util/side_by_side_multi_select.h"
|
||||
#include "mkvtoolnix-gui/util/widget.h"
|
||||
@ -826,4 +827,31 @@ PreferencesDialog::showPage(Page page) {
|
||||
ui->pages->setCurrentIndex(pageIndex);
|
||||
}
|
||||
|
||||
void
|
||||
PreferencesDialog::accept() {
|
||||
for (auto tabIdx = 0, numTabs = ui->twJobsPrograms->count(); tabIdx < numTabs; ++tabIdx) {
|
||||
auto tab = qobject_cast<PrefsRunProgramWidget *>(ui->twJobsPrograms->widget(tabIdx));
|
||||
auto error = tab->validate();
|
||||
|
||||
if (error.isEmpty())
|
||||
continue;
|
||||
|
||||
showPage(Page::RunPrograms);
|
||||
ui->twJobsPrograms->setCurrentIndex(tabIdx);
|
||||
|
||||
Util::MessageBox::critical(this)
|
||||
->title(QY("Invalid settings"))
|
||||
.text(Q("<p>%1 %2</p>"
|
||||
"<p>%3</p>")
|
||||
.arg(QY("This configuration is currently invalid.").toHtmlEscaped())
|
||||
.arg(error.toHtmlEscaped())
|
||||
.arg(QY("Either fix the error or remove the configuration before closing the preferences dialog.").toHtmlEscaped()))
|
||||
.exec();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
}}
|
||||
|
@ -68,6 +68,8 @@ public slots:
|
||||
void enableOftendUsedCountriesOnly();
|
||||
void enableOftendUsedCharacterSetsOnly();
|
||||
|
||||
virtual void accept() override;
|
||||
|
||||
protected:
|
||||
void setupPageSelector(Page pageToShow);
|
||||
void setupToolTips();
|
||||
|
@ -436,4 +436,10 @@ PrefsRunProgramWidget::showPageForType(Util::Settings::RunProgramType type) {
|
||||
d->ui->gbTypeSpecificSettings->setVisible(d->pagesByType[type] != d->ui->emptyTypePage);
|
||||
}
|
||||
|
||||
QString
|
||||
PrefsRunProgramWidget::validate()
|
||||
const {
|
||||
return config()->validate();
|
||||
}
|
||||
|
||||
}}
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
|
||||
bool isValid() const;
|
||||
Util::Settings::RunProgramConfigPtr config() const;
|
||||
QString validate() const;
|
||||
|
||||
signals:
|
||||
void titleChanged();
|
||||
|
@ -37,12 +37,18 @@ defaultUiFont() {
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
Settings::RunProgramConfig::validate()
|
||||
const {
|
||||
return (m_type == RunProgramType::ExecuteProgram) && (m_commandLine.isEmpty() || m_commandLine.value(0).isEmpty()) ? QY("The program to execute hasn't been set yet.")
|
||||
: (m_type == RunProgramType::PlayAudioFile) && m_audioFile.isEmpty() ? QY("The audio file to play hasn't been set yet.")
|
||||
: QString{};
|
||||
}
|
||||
|
||||
bool
|
||||
Settings::RunProgramConfig::isValid()
|
||||
const {
|
||||
return m_type == RunProgramType::ExecuteProgram ? !m_commandLine.value(0).isEmpty()
|
||||
: m_type == RunProgramType::PlayAudioFile ? !m_audioFile.isEmpty()
|
||||
: true;
|
||||
return validate().isEmpty();
|
||||
}
|
||||
|
||||
QString
|
||||
|
@ -114,6 +114,7 @@ public:
|
||||
unsigned int m_volume{75};
|
||||
|
||||
bool isValid() const;
|
||||
QString validate() const;
|
||||
QString name() const;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user