diff --git a/NEWS.md b/NEWS.md index 4198d4e56..fdf17e19c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,12 @@ # Version ? +## New features and enhancements + +* MKVToolNix GUI: chapter editor: removed the support for explicitly setting + the legacy country elements. Instead the legacy country elements are derived + from the region parts of the IETF BCP 47 languages. Part of the + implementation of #3193. + ## Bug fixes * mkvmerge: Matroska reader, TrueHD: mkvmerge will now probe much more TrueHD diff --git a/src/mkvtoolnix-gui/chapter_editor/chapter_model.cpp b/src/mkvtoolnix-gui/chapter_editor/chapter_model.cpp index 7363fd934..366cf6bd7 100644 --- a/src/mkvtoolnix-gui/chapter_editor/chapter_model.cpp +++ b/src/mkvtoolnix-gui/chapter_editor/chapter_model.cpp @@ -182,9 +182,9 @@ ChapterModel::chapterNameForLanguage(KaxChapterAtom &chapter, if (!kDisplay) continue; - auto lists = NameModel::effectiveLanguagesAndCountriesForDisplay(*kDisplay); - + auto lists = NameModel::effectiveLanguagesForDisplay(*kDisplay); auto actualLanguage = mtx::chapters::get_language_from_display(*kDisplay, "eng"s); + if ( language.empty() || (std::find_if(lists.languageCodes.begin(), lists.languageCodes.end(), [&language](auto const &actualLanguage) { return (language == actualLanguage.get_language()) diff --git a/src/mkvtoolnix-gui/chapter_editor/generate_sub_chapters_parameters_dialog.cpp b/src/mkvtoolnix-gui/chapter_editor/generate_sub_chapters_parameters_dialog.cpp index a446deb47..537a99b38 100644 --- a/src/mkvtoolnix-gui/chapter_editor/generate_sub_chapters_parameters_dialog.cpp +++ b/src/mkvtoolnix-gui/chapter_editor/generate_sub_chapters_parameters_dialog.cpp @@ -23,12 +23,11 @@ using namespace mtx::gui; GenerateSubChaptersParametersDialog::GenerateSubChaptersParametersDialog(QWidget *parent, int firstChapterNumber, uint64_t startTimestamp, - QStringList const &additionalLanguages, - QStringList const &additionalCountryCodes) + QStringList const &additionalLanguages) : QDialog{parent} , m_ui{new Ui::GenerateSubChaptersParametersDialog} { - setupUi(firstChapterNumber, startTimestamp, additionalLanguages, additionalCountryCodes); + setupUi(firstChapterNumber, startTimestamp, additionalLanguages); retranslateUi(); } @@ -38,8 +37,7 @@ GenerateSubChaptersParametersDialog::~GenerateSubChaptersParametersDialog() { void GenerateSubChaptersParametersDialog::setupUi(int firstChapterNumber, uint64_t startTimestamp, - QStringList const &additionalLanguages, - QStringList const &additionalCountryCodes) { + QStringList const &additionalLanguages) { auto &cfg = Util::Settings::get(); m_ui->setupUi(this); @@ -52,7 +50,6 @@ GenerateSubChaptersParametersDialog::setupUi(int firstChapterNumber, m_ui->ldwLanguage->setLanguage(cfg.m_defaultChapterLanguage); m_ui->ldwLanguage->enableClearingLanguage(true); m_ui->ldwLanguage->setClearTitle(QY("– Set to none –")); - m_ui->cbCountry->setAdditionalItems(additionalCountryCodes).setup(true, QY("– Set to none –")).setCurrentByData(cfg.m_defaultChapterCountry); m_ui->sbNumberOfEntries->setFocus(); @@ -110,13 +107,6 @@ GenerateSubChaptersParametersDialog::language() return m_ui->ldwLanguage->language(); } -OptQString -GenerateSubChaptersParametersDialog::country() - const { - auto countryStr = m_ui->cbCountry->currentData().toString(); - return countryStr.isEmpty() ? OptQString{} : OptQString{ countryStr }; -} - void GenerateSubChaptersParametersDialog::verifyStartTimestamp() { int64_t dummy = 0; diff --git a/src/mkvtoolnix-gui/chapter_editor/generate_sub_chapters_parameters_dialog.h b/src/mkvtoolnix-gui/chapter_editor/generate_sub_chapters_parameters_dialog.h index b6e0d3960..74b516ec4 100644 --- a/src/mkvtoolnix-gui/chapter_editor/generate_sub_chapters_parameters_dialog.h +++ b/src/mkvtoolnix-gui/chapter_editor/generate_sub_chapters_parameters_dialog.h @@ -22,7 +22,7 @@ private: std::unique_ptr m_ui; public: - explicit GenerateSubChaptersParametersDialog(QWidget *parent, int firstChapterNumber, uint64_t startTimestamp, QStringList const &additionalLanguages, QStringList const &additionalCountryCodes); + explicit GenerateSubChaptersParametersDialog(QWidget *parent, int firstChapterNumber, uint64_t startTimestamp, QStringList const &additionalLanguages); ~GenerateSubChaptersParametersDialog(); int numberOfEntries() const; @@ -31,13 +31,12 @@ public: uint64_t startTimestamp() const; QString nameTemplate() const; mtx::bcp47::language_c language() const; - OptQString country() const; public Q_SLOTS: void verifyStartTimestamp(); protected: - void setupUi(int firstChapterNumber, uint64_t startTimestamp, QStringList const &additionalLanguages, QStringList const &additionalCountryCodes); + void setupUi(int firstChapterNumber, uint64_t startTimestamp, QStringList const &additionalLanguages); void retranslateUi(); }; diff --git a/src/mkvtoolnix-gui/chapter_editor/mass_modification_dialog.cpp b/src/mkvtoolnix-gui/chapter_editor/mass_modification_dialog.cpp index 5ee830720..385b88640 100644 --- a/src/mkvtoolnix-gui/chapter_editor/mass_modification_dialog.cpp +++ b/src/mkvtoolnix-gui/chapter_editor/mass_modification_dialog.cpp @@ -20,13 +20,12 @@ using namespace mtx::gui; MassModificationDialog::MassModificationDialog(QWidget *parent, bool editionOrChapterSelected, - QStringList const &additionalLanguages, - QStringList const &additionalCountryCodes) + QStringList const &additionalLanguages) : QDialog{parent} , m_ui{new Ui::MassModificationDialog} , m_editionOrChapterSelected{editionOrChapterSelected} { - setupUi(additionalLanguages, additionalCountryCodes); + setupUi(additionalLanguages); retranslateUi(); } @@ -34,19 +33,16 @@ MassModificationDialog::~MassModificationDialog() { } void -MassModificationDialog::setupUi(QStringList const &additionalLanguages, - QStringList const &additionalCountryCodes) { +MassModificationDialog::setupUi(QStringList const &additionalLanguages) { m_ui->setupUi(this); m_ui->ldwLanguage->setAdditionalLanguages(additionalLanguages); - m_ui->cbCountry->setAdditionalItems(additionalCountryCodes).setup(true, QY("– Set to none –")); connect(m_ui->cbShift, &QCheckBox::toggled, this, &MassModificationDialog::verifyOptions); connect(m_ui->leShiftBy, &QLineEdit::textChanged, this, &MassModificationDialog::verifyOptions); connect(m_ui->cbMultiply, &QCheckBox::toggled, this, &MassModificationDialog::verifyOptions); connect(m_ui->dsbMultiplyBy, static_cast(&QDoubleSpinBox::valueChanged), this, &MassModificationDialog::verifyOptions); connect(m_ui->cbSetLanguage, &QCheckBox::toggled, m_ui->ldwLanguage, &QComboBox::setEnabled); - connect(m_ui->cbSetCountry, &QCheckBox::toggled, m_ui->cbCountry, &QComboBox::setEnabled); connect(m_ui->cbConstrictExpand, &QCheckBox::toggled, m_ui->rbConstrict, &QRadioButton::setEnabled); connect(m_ui->cbConstrictExpand, &QCheckBox::toggled, m_ui->rbExpand, &QRadioButton::setEnabled); connect(m_ui->cbSetEndTimestamps, &QCheckBox::toggled, m_ui->cbRemoveEndTimestamps, &QRadioButton::setDisabled); @@ -57,7 +53,6 @@ MassModificationDialog::setupUi(QStringList const &additionalLanguages, m_ui->leShiftBy->setEnabled(false); m_ui->dsbMultiplyBy->setEnabled(false); m_ui->ldwLanguage->setEnabled(false); - m_ui->cbCountry->setEnabled(false); m_ui->rbConstrict->setEnabled(false); m_ui->rbExpand->setEnabled(false); m_ui->rbConstrict->setChecked(true); @@ -97,7 +92,6 @@ MassModificationDialog::actions() if (m_ui->cbConstrictExpand->isChecked() && m_ui->rbConstrict->isChecked()) result |= Action::Constrict; if (m_ui->cbConstrictExpand->isChecked() && m_ui->rbExpand->isChecked()) result |= Action::Expand; if (m_ui->cbSetLanguage->isChecked()) result |= Action::SetLanguage; - if (m_ui->cbSetCountry->isChecked()) result |= Action::SetCountry; if (m_ui->cbMultiply->isChecked()) result |= Action::Multiply; if (m_ui->cbSetEndTimestamps->isEnabled() && m_ui->cbSetEndTimestamps->isChecked()) result |= Action::SetEndTimestamps; if (m_ui->cbRemoveEndTimestamps->isEnabled() && m_ui->cbRemoveEndTimestamps->isChecked()) result |= Action::RemoveEndTimestamps; @@ -126,12 +120,6 @@ MassModificationDialog::language() return m_ui->ldwLanguage->language(); } -QString -MassModificationDialog::country() - const { - return m_ui->cbCountry->currentData().toString(); -} - bool MassModificationDialog::isMultiplyByValid() const { diff --git a/src/mkvtoolnix-gui/chapter_editor/mass_modification_dialog.h b/src/mkvtoolnix-gui/chapter_editor/mass_modification_dialog.h index 3c598322a..6729ea87b 100644 --- a/src/mkvtoolnix-gui/chapter_editor/mass_modification_dialog.h +++ b/src/mkvtoolnix-gui/chapter_editor/mass_modification_dialog.h @@ -24,11 +24,10 @@ public: Constrict = 0x0004, Expand = 0x0008, SetLanguage = 0x0010, - SetCountry = 0x0020, - Multiply = 0x0040, - SetEndTimestamps = 0x0080, - RemoveEndTimestamps = 0x0100, - RemoveNames = 0x0200, + Multiply = 0x0020, + SetEndTimestamps = 0x0040, + RemoveEndTimestamps = 0x0080, + RemoveNames = 0x0100, }; Q_DECLARE_FLAGS(Actions, Action) @@ -37,16 +36,15 @@ private: bool m_editionOrChapterSelected; public: - explicit MassModificationDialog(QWidget *parent, bool editionOrChapterSelected, QStringList const &additionalLanguages, QStringList const &additionalCountryCodes); + explicit MassModificationDialog(QWidget *parent, bool editionOrChapterSelected, QStringList const &additionalLanguages); ~MassModificationDialog(); Actions actions() const; int64_t shiftBy() const; double multiplyBy() const; mtx::bcp47::language_c language() const; - QString country() const; - void setupUi(QStringList const &additionalLanguages, QStringList const &additionalCountryCodes); + void setupUi(QStringList const &additionalLanguages); void retranslateUi(); public Q_SLOTS: diff --git a/src/mkvtoolnix-gui/chapter_editor/name_model.cpp b/src/mkvtoolnix-gui/chapter_editor/name_model.cpp index 1e4dc1b29..00a2d3006 100644 --- a/src/mkvtoolnix-gui/chapter_editor/name_model.cpp +++ b/src/mkvtoolnix-gui/chapter_editor/name_model.cpp @@ -26,7 +26,6 @@ NameModel::retranslateUi() { Util::setDisplayableAndSymbolicColumnNames(*this, { { QY("Name"), Q("name") }, { QY("Languages"), Q("language") }, - { QY("Countries"), Q("country") }, }); } @@ -45,9 +44,9 @@ NameModel::displayFromIndex(QModelIndex const &idx) { return displayFromItem(itemFromIndex(idx)); } -LanguagesAndCountries -NameModel::effectiveLanguagesAndCountriesForDisplay(libmatroska::KaxChapterDisplay &display) { - LanguagesAndCountries lists; +Languages +NameModel::effectiveLanguagesForDisplay(libmatroska::KaxChapterDisplay &display) { + Languages lists; QList legacyLanguageCodes; QStringList legacyLanguageNames; @@ -62,10 +61,6 @@ NameModel::effectiveLanguagesAndCountriesForDisplay(libmatroska::KaxChapterDispl legacyLanguageCodes << language; legacyLanguageNames << Q(language.format_long()); - } else if (auto kCountry = dynamic_cast(child); kCountry) { - auto countryCode = Q(kCountry->GetValue()); - lists.countryCodes << countryCode; - lists.countryNames << App::descriptionForRegion(countryCode); } } @@ -86,20 +81,18 @@ NameModel::effectiveLanguagesAndCountriesForDisplay(libmatroska::KaxChapterDispl void NameModel::setRowText(QList const &rowItems) { auto &display = *displayFromItem(rowItems[0]); - auto lists = effectiveLanguagesAndCountriesForDisplay(display); + auto lists = effectiveLanguagesForDisplay(display); lists.languageNames.sort(); - lists.countryNames.sort(); rowItems[0]->setText(Q(GetChildValue(display))); rowItems[1]->setText(lists.languageNames.join(Q("; "))); - rowItems[2]->setText(lists.countryNames.join(Q("; "))); } QList NameModel::itemsForRow(int row) { auto rowItems = QList{}; - for (auto column = 0; 3 > column; ++column) + for (auto column = 0; 2 > column; ++column) rowItems << item(row, column); return rowItems; @@ -126,8 +119,6 @@ NameModel::addNew() { GetChild(display).SetValueUTF8(Y("")); mtx::chapters::set_languages_in_display(*display, cfg.m_defaultChapterLanguage); - if (!cfg.m_defaultChapterCountry.isEmpty()) - GetChild(display).SetValue(to_utf8(cfg.m_defaultChapterCountry)); m_chapter->PushElement(*display); append(*display); diff --git a/src/mkvtoolnix-gui/chapter_editor/name_model.h b/src/mkvtoolnix-gui/chapter_editor/name_model.h index d9303b248..63f91ea27 100644 --- a/src/mkvtoolnix-gui/chapter_editor/name_model.h +++ b/src/mkvtoolnix-gui/chapter_editor/name_model.h @@ -13,9 +13,9 @@ Q_DECLARE_METATYPE(libmatroska::KaxChapterDisplay *) namespace mtx::gui::ChapterEditor { -struct LanguagesAndCountries { +struct Languages { QList languageCodes; - QStringList languageNames, countryCodes, countryNames; + QStringList languageNames; }; class NameModel: public QStandardItemModel { @@ -49,7 +49,7 @@ public: virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; public: - static LanguagesAndCountries effectiveLanguagesAndCountriesForDisplay(libmatroska::KaxChapterDisplay &display); + static Languages effectiveLanguagesForDisplay(libmatroska::KaxChapterDisplay &display); protected: void setRowText(QList const &rowItems); diff --git a/src/mkvtoolnix-gui/chapter_editor/tab.cpp b/src/mkvtoolnix-gui/chapter_editor/tab.cpp index cb5e97d38..7326ae47a 100644 --- a/src/mkvtoolnix-gui/chapter_editor/tab.cpp +++ b/src/mkvtoolnix-gui/chapter_editor/tab.cpp @@ -61,8 +61,8 @@ namespace mtx::gui::ChapterEditor { namespace { bool -removeLanguageOrCountryControlRow(QVector> &controls, - QObject *sender) { +removeLanguageControlRow(QVector> &controls, + QObject *sender) { for (int idx = 0, numControls = controls.size(); idx < numControls; ++idx) { auto &[layout, widget, button] = controls[idx]; @@ -147,17 +147,9 @@ Tab::setupUi() { p->ui->elements->acceptDroppedFiles(true); - p->ui->cbChNameCountry1->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - p->ui->cbChNameCountry1->setWithAlphaCodesOnly(true); - p->ui->cbChNameCountry1->setup(true); - Util::fixComboBoxViewWidth(*p->ui->cbChNameCountry1); - p->languageControls.push_back({ nullptr, p->ui->ldwChNameLanguage1, p->ui->pbChNameLanguageAdd }); - p->countryControls .push_back({ nullptr, p->ui->cbChNameCountry1, p->ui->pbChNameCountryAdd }); - p->nameWidgets << p->ui->pbChRemoveName - << p->ui->lChName << p->ui->leChName - << p->ui->lChNameLanguage << p->ui->lChNameCountry; + p->nameWidgets << p->ui->pbChRemoveName << p->ui->lChName << p->ui->leChName; Util::fixScrollAreaBackground(p->ui->scrollArea); Util::HeaderViewManager::create(*p->ui->elements, "ChapterEditor::Elements") .setDefaultSizes({ { Q("editionChapter"), 200 }, { Q("start"), 130 }, { Q("end"), 130 } }); @@ -174,7 +166,6 @@ Tab::setupUi() { p->massModificationAction->setIcon(QIcon{Q(":/icons/16x16/tools-wizard.png")}); p->copyToOtherTabMenu->setIcon(QIcon{Q(":/icons/16x16/edit-copy.png")}); - auto mw = MainWindow::get(); auto tool = MainWindow::chapterEditorTool(); connect(p->ui->elements, &Util::BasicTreeView::customContextMenuRequested, this, &Tab::showChapterContextMenu); connect(p->ui->elements, &Util::BasicTreeView::deletePressed, this, &Tab::removeElement); @@ -184,12 +175,10 @@ Tab::setupUi() { connect(p->ui->tvChNames->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Tab::nameSelectionChanged); connect(p->ui->leChName, &QLineEdit::textEdited, this, &Tab::chapterNameEdited); connect(p->ui->ldwChNameLanguage1, &Util::LanguageDisplayWidget::languageChanged, this, &Tab::chapterNameLanguageChanged); - connect(p->ui->cbChNameCountry1, static_cast(&QComboBox::currentIndexChanged), this, &Tab::chapterNameCountryChanged); connect(p->ui->pbChAddName, &QPushButton::clicked, this, &Tab::addChapterName); connect(p->ui->pbChRemoveName, &QPushButton::clicked, this, &Tab::removeChapterName); connect(p->ui->pbBrowseSegmentUID, &QPushButton::clicked, this, &Tab::addSegmentUIDFromFile); connect(p->ui->pbChNameLanguageAdd, &QPushButton::clicked, this, &Tab::addChapterNameLanguage); - connect(p->ui->pbChNameCountryAdd, &QPushButton::clicked, this, &Tab::addChapterNameCountry); connect(p->expandAllAction, &QAction::triggered, this, &Tab::expandAll); connect(p->collapseAllAction, &QAction::triggered, this, &Tab::collapseAll); @@ -204,8 +193,6 @@ Tab::setupUi() { connect(p->generateSubChaptersAction, &QAction::triggered, this, &Tab::generateSubChapters); connect(p->renumberSubChaptersAction, &QAction::triggered, this, &Tab::renumberSubChapters); - connect(mw, &MainWindow::preferencesChanged, p->ui->cbChNameCountry1, &Util::ComboBoxBase::reInitialize); - for (auto &lineEdit : findChildren()) { lineEdit->acceptDroppedFiles(false).setTextToDroppedFileName(false); connect(lineEdit, &Util::BasicLineEdit::returnPressed, this, &Tab::focusOtherControlInNextChapterElement); @@ -685,8 +672,6 @@ void Tab::appendTheseChapters(ChaptersPtr const &chapters) { auto p = p_func(); - mtx::chapters::fix_country_codes(*chapters); - disconnect(p->chapterModel, &QStandardItemModel::rowsInserted, this, &Tab::expandInsertedElements); p->chapterModel->populate(*chapters, true); @@ -703,8 +688,6 @@ Tab::chaptersLoaded(ChaptersPtr const &chapters, bool canBeWritten) { auto p = p_func(); - mtx::chapters::fix_country_codes(*chapters); - if (!p->fileName.isEmpty()) p->fileModificationTime = QFileInfo{p->fileName}.lastModified(); @@ -1170,14 +1153,10 @@ Tab::setNameControlsFromStorage(QModelIndex const &idx) { p.ui->leChName->setText(Q(GetChildValue(display))); - auto lists = NameModel::effectiveLanguagesAndCountriesForDisplay(*display); + auto lists = NameModel::effectiveLanguagesForDisplay(*display); auto usedLanguageCodes = usedNameLanguages(); - auto usedCountryCodes = usedNameCountryCodes(); - - // qDebug() << lists.languageNames << usedCountryCodes; std::sort(lists.languageCodes.begin(), lists.languageCodes.end(), [](auto const &a, auto const &b) { return a.format_long() < b.format_long(); }); - lists.countryCodes.sort(); for (int languageIdx = 1, numLanguages = p.languageControls.size(); languageIdx < numLanguages; ++languageIdx) { auto &[layout, language, button] = p.languageControls[languageIdx]; @@ -1186,29 +1165,14 @@ Tab::setNameControlsFromStorage(QModelIndex const &idx) { delete button; } - for (int countryIdx = 1, numCountries = p.countryControls.size(); countryIdx < numCountries; ++countryIdx) { - auto &[layout, country, button] = p.countryControls[countryIdx]; - delete layout; - delete country; - delete button; - } - p.languageControls.remove(1, p.languageControls.size() - 1); - p.countryControls .remove(1, p.countryControls .size() - 1); p.ui->ldwChNameLanguage1->setAdditionalLanguages(usedLanguageCodes); p.ui->ldwChNameLanguage1->setLanguage(lists.languageCodes.isEmpty() ? mtx::bcp47::language_c{} : lists.languageCodes[0]); - p.ui->cbChNameCountry1->setAdditionalItems(usedCountryCodes) - .reInitializeIfNecessary() - .setCurrentByData(lists.countryCodes.isEmpty() ? QString{} : lists.countryCodes[0]); - for (int languageIdx = 1, numLanguages = lists.languageCodes.size(); languageIdx < numLanguages; ++languageIdx) addOneChapterNameLanguage(lists.languageCodes[languageIdx], usedLanguageCodes); - for (int countryIdx = 1, numCountries = lists.countryCodes.size(); countryIdx < numCountries; ++countryIdx) - addOneChapterNameCountry(lists.countryCodes[countryIdx], usedCountryCodes); - p.ignoreChapterNameChanges = false; // qDebug() << "setNameControlsFromStorage end"; @@ -1290,40 +1254,6 @@ Tab::chapterNameLanguageChanged() { // qDebug() << "chapterNameLanguageChanged end"; } -void -Tab::chapterNameCountryChanged() { - auto &p = *p_func(); - - // qDebug() << "chapterNameCountryChanged start"; - - if (p.ignoreChapterNameChanges) { - // qDebug() << "chapterNameCountryChanged ignoring"; - return; - } - - QSet uniqueCountryCodes; - - for (auto const &control : p.countryControls) { - auto countryCode = static_cast(std::get<1>(control))->currentData().toString(); - if (!countryCode.isEmpty()) - uniqueCountryCodes << countryCode; - } - - auto countryCodes = uniqueCountryCodes.values(); - countryCodes.sort(); - - withSelectedName([&p, &countryCodes](QModelIndex const &idx, KaxChapterDisplay &display) { - DeleteChildren(display); - - for (auto const &countryCode : countryCodes) - AddEmptyChild(display).SetValue(to_utf8(countryCode)); - - p.nameModel->updateRow(idx.row()); - }); - - // qDebug() << "chapterNameCountryChanged end"; -} - void Tab::addChapterName() { auto p = p_func(); @@ -1373,61 +1303,14 @@ Tab::addOneChapterNameLanguage(mtx::bcp47::language_c const &languageCode, p.languageControls.push_back({ layout, language, removeButton }); connect(language, &Util::LanguageDisplayWidget::languageChanged, this, &Tab::chapterNameLanguageChanged); - connect(removeButton, &QPushButton::clicked, this, &Tab::removeChapterNameLanguageOrCountry); } void -Tab::addChapterNameCountry() { - addOneChapterNameCountry({}, usedNameCountryCodes()); -} - -void -Tab::addOneChapterNameCountry(QString const &countryCode, - QStringList const &usedCountryCodes) { - auto &p = *p_func(); - - auto country = new mtx::gui::Util::CountryComboBox{p.ui->wChNameCountries}; - auto removeButton = new QPushButton{p.ui->wChNameCountries}; - auto layout = new QHBoxLayout; - - country->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - country->setWithAlphaCodesOnly(true); - country->setup(true); - Util::fixComboBoxViewWidth(*country); - - country->setAdditionalItems(usedCountryCodes) - .reInitializeIfNecessary() - .setCurrentByData(countryCode); - - QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - country->setSizePolicy(sizePolicy); - - QIcon removeIcon; - removeIcon.addFile(QString::fromUtf8(":/icons/16x16/list-remove.png"), QSize(), QIcon::Normal, QIcon::Off); - - removeButton->setIcon(removeIcon); - - layout->addWidget(country); - layout->addWidget(removeButton); - - static_cast(p.ui->wChNameCountries->layout())->addLayout(layout); - - p.countryControls.push_back({ layout, country, removeButton }); - - connect(country, static_cast(&QComboBox::currentIndexChanged), this, &Tab::chapterNameCountryChanged); - connect(removeButton, &QPushButton::clicked, this, &Tab::removeChapterNameLanguageOrCountry); - connect(MainWindow::get(), &MainWindow::preferencesChanged, country, &Util::ComboBoxBase::reInitialize); -} - -void -Tab::removeChapterNameLanguageOrCountry() { +Tab::removeChapterNameLanguage() { auto &p = *p_func(); - if (removeLanguageOrCountryControlRow(p.languageControls, sender())) + if (removeLanguageControlRow(p.languageControls, sender())) chapterNameLanguageChanged(); - - else if (removeLanguageOrCountryControlRow(p.countryControls, sender())) - chapterNameCountryChanged(); } void @@ -1439,9 +1322,6 @@ Tab::enableNameWidgets(bool enable) { for (auto const &widget : p->ui->wChNameLanguages->findChildren()) widget->setEnabled(enable); - - for (auto const &widget : p->ui->wChNameCountries->findChildren()) - widget->setEnabled(enable); } void @@ -1505,8 +1385,7 @@ ChapterPtr Tab::createEmptyChapter(int64_t startTime, int chapterNumber, std::optional const &nameTemplate, - mtx::bcp47::language_c const &language, - std::optional const &country) { + mtx::bcp47::language_c const &language) { auto &cfg = Util::Settings::get(); auto chapter = std::make_shared(); auto name = formatChapterName(nameTemplate ? *nameTemplate : cfg.m_chapterNameTemplate, chapterNumber, timestamp_c::ns(startTime)); @@ -1514,11 +1393,11 @@ Tab::createEmptyChapter(int64_t startTime, GetChild(*chapter).SetValue(0); GetChild(*chapter).SetValue(startTime); if (!name.isEmpty()) { - auto &display = GetChild(*chapter); + auto &display = GetChild(*chapter); + auto actual_language = language.is_valid() ? language : cfg.m_defaultChapterLanguage; + GetChild(display).SetValue(to_wide(name)); - mtx::chapters::set_languages_in_display(display, language.is_valid() ? language : cfg.m_defaultChapterLanguage); - if ((country && !country->isEmpty()) || !cfg.m_defaultChapterCountry.isEmpty()) - GetChild(display).SetValue(to_utf8((country && !country->isEmpty()) ? *country : cfg.m_defaultChapterCountry)); + mtx::chapters::set_languages_in_display(display, actual_language); } return chapter; @@ -1720,31 +1599,6 @@ Tab::setLanguages(QStandardItem *item, setLanguages(item->child(row), language); } -void -Tab::setCountries(QStandardItem *item, - QString const &country) { - auto p = p_func(); - - if (!item) - return; - - auto chapter = p->chapterModel->chapterFromItem(item); - if (chapter) - for (auto const &element : *chapter) { - auto kDisplay = dynamic_cast(element); - if (!kDisplay) - continue; - - if (country.isEmpty()) - DeleteChildren(*kDisplay); - else - GetChild(*kDisplay).SetValue(to_utf8(country)); - } - - for (auto row = 0, numRows = item->rowCount(); row < numRows; ++row) - setCountries(item->child(row), country); -} - void Tab::setEndTimestamps(QStandardItem *startItem) { auto p = p_func(); @@ -1831,7 +1685,7 @@ Tab::massModify() { auto selectedIdx = Util::selectedRowIdx(p->ui->elements); auto item = selectedIdx.isValid() ? p->chapterModel->itemFromIndex(selectedIdx) : p->chapterModel->invisibleRootItem(); - MassModificationDialog dlg{this, selectedIdx.isValid(), usedNameLanguages(), usedNameCountryCodes()}; + MassModificationDialog dlg{this, selectedIdx.isValid(), usedNameLanguages()}; if (!dlg.exec()) return; @@ -1852,9 +1706,6 @@ Tab::massModify() { if (actions & MassModificationDialog::SetLanguage) setLanguages(item, dlg.language()); - if (actions & MassModificationDialog::SetCountry) - setCountries(item, dlg.country()); - if (actions & MassModificationDialog::Sort) item->sortChildren(1); @@ -1931,7 +1782,7 @@ Tab::generateSubChapters() { maxEndTimestamp = std::max(maxEndTimestamp, std::max(FindChildValue(*chapter, 0ull), FindChildValue(*chapter, 0ull))); } - GenerateSubChaptersParametersDialog dlg{this, numRows + 1, maxEndTimestamp, usedNameLanguages(), usedNameCountryCodes()}; + GenerateSubChaptersParametersDialog dlg{this, numRows + 1, maxEndTimestamp, usedNameLanguages()}; if (!dlg.exec()) return; @@ -1941,10 +1792,9 @@ Tab::generateSubChapters() { auto duration = dlg.durationInNs(); auto nameTemplate = dlg.nameTemplate(); auto language = dlg.language(); - auto country = dlg.country(); while (toCreate > 0) { - auto chapter = createEmptyChapter(timestamp, chapterNumber, nameTemplate, language, country); + auto chapter = createEmptyChapter(timestamp, chapterNumber, nameTemplate, language); timestamp += duration; ++chapterNumber; @@ -1995,7 +1845,7 @@ Tab::changeChapterName(QModelIndex const &parentIdx, if (!kDisplay) continue; - auto lists = NameModel::effectiveLanguagesAndCountriesForDisplay(*kDisplay); + auto lists = NameModel::effectiveLanguagesForDisplay(*kDisplay); if ( (RenumberSubChaptersParametersDialog::NameMatch::All == nameMatchingMode) || (std::find_if(lists.languageCodes.begin(), lists.languageCodes.end(), [&languageOfNamesToReplace](auto const &actualLanguage) { @@ -2335,7 +2185,7 @@ Tab::usedNameLanguages(QStandardItem *rootItem) { if (!kDisplay) continue; - auto lists = NameModel::effectiveLanguagesAndCountriesForDisplay(*static_cast(kDisplay)); + auto lists = NameModel::effectiveLanguagesForDisplay(*static_cast(kDisplay)); for (auto const &languageCodeHere : lists.languageCodes) languages << Q(languageCodeHere.format()); } @@ -2349,40 +2199,6 @@ Tab::usedNameLanguages(QStandardItem *rootItem) { return languages.values(); } -QStringList -Tab::usedNameCountryCodes(QStandardItem *rootItem) { - auto p = p_func(); - - if (!rootItem) - rootItem = p->chapterModel->invisibleRootItem(); - - auto countryCodes = QSet{}; - - std::function collector = [p, &collector, &countryCodes](auto *currentItem) { - if (!currentItem) - return; - - auto chapter = p->chapterModel->chapterFromItem(currentItem); - if (chapter) - for (auto const &element : *chapter) { - auto kDisplay = dynamic_cast(element); - if (!kDisplay) - continue; - - auto lists = NameModel::effectiveLanguagesAndCountriesForDisplay(*static_cast(kDisplay)); - for (auto const &countryCodeHere : lists.countryCodes) - countryCodes << countryCodeHere; - } - - for (int row = 0, numRows = currentItem->rowCount(); row < numRows; ++row) - collector(currentItem->child(row)); - }; - - collector(rootItem); - - return countryCodes.values(); -} - QHash Tab::collectChapterAtomDataForEdition(QStandardItem *item) { auto p = p_func(); diff --git a/src/mkvtoolnix-gui/chapter_editor/tab.h b/src/mkvtoolnix-gui/chapter_editor/tab.h index c84844bce..0c2d5b6e1 100644 --- a/src/mkvtoolnix-gui/chapter_editor/tab.h +++ b/src/mkvtoolnix-gui/chapter_editor/tab.h @@ -28,10 +28,6 @@ namespace mtx::bluray::mpls { struct chapter_t; } -namespace mtx::gui::Util { -class CountryComboBox; -} - namespace mtx::gui::ChapterEditor { namespace Ui { @@ -124,12 +120,10 @@ public Q_SLOTS: virtual void nameSelectionChanged(QItemSelection const &selected, QItemSelection const &deselected); virtual void chapterNameEdited(QString const &text); virtual void chapterNameLanguageChanged(); - virtual void chapterNameCountryChanged(); virtual void addChapterName(); virtual void addChapterNameLanguage(); - virtual void addChapterNameCountry(); virtual void removeChapterName(); - virtual void removeChapterNameLanguageOrCountry(); + virtual void removeChapterNameLanguage(); virtual void showChapterContextMenu(QPoint const &pos); @@ -178,7 +172,7 @@ protected: QModelIndex addEdition(bool before); QModelIndex addChapter(bool before); - ChapterPtr createEmptyChapter(int64_t startTime, int chapterNumber, OptQString const &nameTemplate = OptQString{}, mtx::bcp47::language_c const &language = {}, OptQString const &country = OptQString{}); + ChapterPtr createEmptyChapter(int64_t startTime, int chapterNumber, std::optional const &nameTemplate = {}, mtx::bcp47::language_c const &language = {}); void saveAsImpl(bool requireNewFileName, std::function const &worker); void saveAsXmlImpl(bool requireNewFileName); @@ -191,7 +185,6 @@ protected: void constrictTimestamps(QStandardItem *item, std::optional const &constrictStart, std::optional const &constrictEnd); std::pair, std::optional> expandTimestamps(QStandardItem *item); void setLanguages(QStandardItem *item, mtx::bcp47::language_c const &language); - void setCountries(QStandardItem *item, QString const &country); void setEndTimestamps(QStandardItem *startItem); void removeEndTimestamps(QStandardItem *startItem); void removeNames(QStandardItem *startItem); @@ -205,7 +198,6 @@ protected: QString currentState() const; QStringList usedNameLanguages(QStandardItem *parentItem = nullptr); - QStringList usedNameCountryCodes(QStandardItem *parentItem = nullptr); ChaptersPtr mplsChaptersToMatroskaChapters(std::vector const &mplsChapters) const; QHash collectChapterAtomDataForEdition(QStandardItem *item); QString formatChapterName(QString const &nameTemplate, int chapterNumber, timestamp_c const &startTimestamp) const; @@ -217,7 +209,6 @@ protected: void focusNextChapterElement(bool keepSameControl); void addOneChapterNameLanguage(mtx::bcp47::language_c const &languageCode, QStringList const &usedLanguageCodes); - void addOneChapterNameCountry(QString const &countryCode, QStringList const &usedCountryCodes); static QString formatEbmlBinary(EbmlBinary *binary); }; diff --git a/src/mkvtoolnix-gui/chapter_editor/tab_p.h b/src/mkvtoolnix-gui/chapter_editor/tab_p.h index 44fc04fb0..dee2344d2 100644 --- a/src/mkvtoolnix-gui/chapter_editor/tab_p.h +++ b/src/mkvtoolnix-gui/chapter_editor/tab_p.h @@ -28,7 +28,7 @@ class TabPrivate { timestamp_c fileEndTimestamp; - QVector> languageControls, countryControls; + QVector> languageControls; explicit TabPrivate(Tab &tab, QString const &pFileName); }; diff --git a/src/mkvtoolnix-gui/forms/chapter_editor/generate_sub_chapters_parameters_dialog.ui b/src/mkvtoolnix-gui/forms/chapter_editor/generate_sub_chapters_parameters_dialog.ui index 287f032a7..391df2d2b 100644 --- a/src/mkvtoolnix-gui/forms/chapter_editor/generate_sub_chapters_parameters_dialog.ui +++ b/src/mkvtoolnix-gui/forms/chapter_editor/generate_sub_chapters_parameters_dialog.ui @@ -7,7 +7,7 @@ 0 0 453 - 344 + 274 @@ -30,36 +30,13 @@ - - + + - &Language: + Nu&mber of entries to create: - ldwLanguage - - - - - - - 1 - - - 9999 - - - 10 - - - - - - - 1 - - - 999999 + sbNumberOfEntries @@ -73,13 +50,63 @@ - - + + + + true + + + + + + + 1 + + + 999999 + + + + + - Nu&mber of entries to create: + &Language: - sbNumberOfEntries + ldwLanguage + + + + + + + &Start timestamp of first created entry: + + + leStartTimestamp + + + + + + + + + + true + + + + + + + 1 + + + 9999 + + + 10 @@ -109,13 +136,6 @@ - - - - true - - - @@ -126,39 +146,6 @@ - - - - true - - - - - - - &Start timestamp of first created entry: - - - leStartTimestamp - - - - - - - C&ountry: - - - cbCountry - - - - - - - - - @@ -189,13 +176,9 @@ mtx::gui::Util::LanguageDisplayWidget - QForm + QFrame
mkvtoolnix-gui/util/language_display_widget.h
-
- - mtx::gui::Util::CountryComboBox - QComboBox -
mkvtoolnix-gui/util/country_combo_box.h
+ 1
@@ -205,7 +188,6 @@ leStartTimestamp leNameTemplate ldwLanguage - cbCountry diff --git a/src/mkvtoolnix-gui/forms/chapter_editor/mass_modification_dialog.ui b/src/mkvtoolnix-gui/forms/chapter_editor/mass_modification_dialog.ui index c197c45d0..b31028ce8 100644 --- a/src/mkvtoolnix-gui/forms/chapter_editor/mass_modification_dialog.ui +++ b/src/mkvtoolnix-gui/forms/chapter_editor/mass_modification_dialog.ui @@ -7,7 +7,7 @@ 0 0 833 - 386 + 394 @@ -39,13 +39,6 @@
- - - - Set the chapter names' co&untries: - - - @@ -53,8 +46,24 @@ - - + + + + 9 + + + 9999.999998999999661 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + @@ -73,9 +82,6 @@ - - - @@ -83,22 +89,6 @@ - - - - 9 - - - 9999.999998999999661 - - - 0.100000000000000 - - - 1.000000000000000 - - - @@ -202,13 +192,9 @@ mtx::gui::Util::LanguageDisplayWidget - QForm + QFrame
mkvtoolnix-gui/util/language_display_widget.h
-
- - mtx::gui::Util::CountryComboBox - QComboBox -
mkvtoolnix-gui/util/country_combo_box.h
+ 1
@@ -218,8 +204,6 @@ dsbMultiplyBy cbSetLanguage ldwLanguage - cbSetCountry - cbCountry cbSort cbConstrictExpand rbConstrict diff --git a/src/mkvtoolnix-gui/forms/chapter_editor/tab.ui b/src/mkvtoolnix-gui/forms/chapter_editor/tab.ui index 807227999..c87d0a573 100644 --- a/src/mkvtoolnix-gui/forms/chapter_editor/tab.ui +++ b/src/mkvtoolnix-gui/forms/chapter_editor/tab.ui @@ -450,6 +450,9 @@
+ + + @@ -460,19 +463,6 @@ - - - - - - - Languages: - - - ldwChNameLanguage1 - - - @@ -516,59 +506,16 @@ - - + + - &Countries: + Languages: - cbChNameCountry1 + ldwChNameLanguage1 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - 0 - 0 - - - - - - - - - - - - :/icons/16x16/list-add.png:/icons/16x16/list-add.png - - - - - - - - @@ -601,11 +548,6 @@ QLabel
mkvtoolnix-gui/util/elide_label.h
- - mtx::gui::Util::CountryComboBox - QComboBox -
mkvtoolnix-gui/util/country_combo_box.h
-
mtx::gui::Util::LanguageDisplayWidget QWidget @@ -632,7 +574,6 @@ pbChRemoveName leChName ldwChNameLanguage1 - cbChNameCountry1 diff --git a/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui b/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui index 039ae15ab..d3c1c55df 100644 --- a/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui +++ b/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui @@ -1972,16 +1972,6 @@ Defaults for new chapter entries - - - - Na&me template: - - - leCENameTemplate - - - @@ -1989,10 +1979,13 @@ - - + + - Language: + Na&me template: + + + leCENameTemplate @@ -2006,23 +1999,10 @@ - - + + - C&ountry: - - - cbCEDefaultCountry - - - - - - - - 0 - 0 - + Language: @@ -2392,11 +2372,6 @@ QComboBox
mkvtoolnix-gui/util/character_set_combo_box.h
- - mtx::gui::Util::CountryComboBox - QComboBox -
mkvtoolnix-gui/util/country_combo_box.h
-
mtx::gui::Util::BasicTabWidget QTabWidget @@ -2514,7 +2489,6 @@ cbCEDropLastFromBlurayPlaylist cbCETextFileCharacterSet leCENameTemplate - cbCEDefaultCountry cbGuiSwitchToJobOutputAfterStarting cbGuiUseDefaultJobDescription cbGuiShowOutputOfAllJobs diff --git a/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp b/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp index b16cef28a..a38d6bf5f 100644 --- a/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp +++ b/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp @@ -130,7 +130,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, ui->cbCETextFileCharacterSet->setAdditionalItems(m_cfg.m_ceTextFileCharacterSet).setup(true, QY("Always ask the user")).setCurrentByData(m_cfg.m_ceTextFileCharacterSet); ui->leCENameTemplate->setText(m_cfg.m_chapterNameTemplate); ui->ldwCEDefaultLanguage->setLanguage(m_cfg.m_defaultChapterLanguage); - ui->cbCEDefaultCountry->setWithAlphaCodesOnly(true).setAdditionalItems(m_cfg.m_defaultChapterCountry).setup(true, QY("– No selection by default –")).setCurrentByData(m_cfg.m_defaultChapterCountry); // Header editor page setupHeaderEditorDroppedFilesPolicy(); @@ -310,7 +309,6 @@ PreferencesDialog::setupToolTips() { Util::setToolTip(ui->leCENameTemplate, ChapterEditor::Tool::chapterNameTemplateToolTip()); Util::setToolTip(ui->ldwCEDefaultLanguage, QY("This is the language that newly added chapter names get assigned automatically.")); - Util::setToolTip(ui->cbCEDefaultCountry, QY("This is the country that newly added chapter names get assigned automatically.")); Util::setToolTip(ui->cbCEDropLastFromBlurayPlaylist, Q("%1 %2") .arg(QY("Blu-ray discs often contain a chapter entry very close to the end of the movie.")) @@ -1047,7 +1045,6 @@ PreferencesDialog::save() { m_cfg.m_chapterNameTemplate = ui->leCENameTemplate->text(); m_cfg.m_ceTextFileCharacterSet = ui->cbCETextFileCharacterSet->currentData().toString(); m_cfg.m_defaultChapterLanguage = ui->ldwCEDefaultLanguage->language(); - m_cfg.m_defaultChapterCountry = ui->cbCEDefaultCountry->currentData().toString(); m_cfg.m_dropLastChapterFromBlurayPlaylist = ui->cbCEDropLastFromBlurayPlaylist->isChecked(); // Merge page: diff --git a/src/mkvtoolnix-gui/types.h b/src/mkvtoolnix-gui/types.h index 1d8830435..ee990790d 100644 --- a/src/mkvtoolnix-gui/types.h +++ b/src/mkvtoolnix-gui/types.h @@ -7,4 +7,3 @@ #include using ChaptersPtr = std::shared_ptr; -using OptQString = std::optional; diff --git a/src/mkvtoolnix-gui/util/settings.cpp b/src/mkvtoolnix-gui/util/settings.cpp index 69b6e2976..7633455c7 100644 --- a/src/mkvtoolnix-gui/util/settings.cpp +++ b/src/mkvtoolnix-gui/util/settings.cpp @@ -530,7 +530,6 @@ Settings::loadDefaults(QSettings ®) { m_defaultSubtitleTrackLanguage = mtx::bcp47::language_c::parse(to_utf8(reg.value(s_valDefaultSubtitleTrackLanguage, Q("und")).toString())); m_whenToSetDefaultLanguage = static_cast(reg.value(s_valWhenToSetDefaultLanguage, static_cast(SetDefaultLanguagePolicy::IfAbsentOrUndetermined)).toInt()); m_defaultChapterLanguage = mtx::bcp47::language_c::parse(to_utf8(reg.value(s_valDefaultChapterLanguage, Q("und")).toString())); - m_defaultChapterCountry = reg.value(s_valDefaultChapterCountry).toString(); m_defaultSubtitleCharset = reg.value(s_valDefaultSubtitleCharset).toString(); m_defaultAdditionalMergeOptions = reg.value(s_valDefaultAdditionalMergeOptions).toString(); reg.endGroup(); // defaults @@ -851,7 +850,6 @@ Settings::saveDefaults(QSettings ®) reg.setValue(s_valDefaultSubtitleTrackLanguage, Q(m_defaultSubtitleTrackLanguage.format())); reg.setValue(s_valWhenToSetDefaultLanguage, static_cast(m_whenToSetDefaultLanguage)); reg.setValue(s_valDefaultChapterLanguage, Q(m_defaultChapterLanguage.format())); - reg.setValue(s_valDefaultChapterCountry, m_defaultChapterCountry); reg.setValue(s_valDefaultSubtitleCharset, m_defaultSubtitleCharset); reg.setValue(s_valDefaultAdditionalMergeOptions, m_defaultAdditionalMergeOptions); reg.endGroup(); // defaults diff --git a/src/mkvtoolnix-gui/util/settings.h b/src/mkvtoolnix-gui/util/settings.h index e298d64c7..d89fa2b24 100644 --- a/src/mkvtoolnix-gui/util/settings.h +++ b/src/mkvtoolnix-gui/util/settings.h @@ -169,7 +169,7 @@ public: QString m_boundaryCharsForDerivingTrackLanguagesFromFileNames; QStringList m_recognizedTrackLanguagesInFileNames, m_mergePredefinedSplitSizes, m_mergePredefinedSplitDurations; QStringList m_mergePredefinedVideoTrackNames, m_mergePredefinedAudioTrackNames, m_mergePredefinedSubtitleTrackNames; - QString m_chapterNameTemplate, m_defaultChapterCountry, m_ceTextFileCharacterSet, m_defaultSubtitleCharset, m_defaultAdditionalMergeOptions; + QString m_chapterNameTemplate, m_ceTextFileCharacterSet, m_defaultSubtitleCharset, m_defaultAdditionalMergeOptions; QStringList m_oftenUsedLanguages, m_oftenUsedRegions, m_oftenUsedCharacterSets; bool m_oftenUsedLanguagesOnly, m_oftenUsedRegionsOnly, m_oftenUsedCharacterSetsOnly; bool m_useISO639_3Languages; diff --git a/src/mkvtoolnix-gui/util/settings_names.h b/src/mkvtoolnix-gui/util/settings_names.h index c3b59c2b5..363d38275 100644 --- a/src/mkvtoolnix-gui/util/settings_names.h +++ b/src/mkvtoolnix-gui/util/settings_names.h @@ -33,7 +33,6 @@ char const * const s_valColumnSizes = "columnSizes char const * const s_valCommandLine = "commandLine"; char const * const s_valDefaultAdditionalMergeOptions = "defaultAdditionalMergeOptions"; char const * const s_valDefaultAudioTrackLanguage = "defaultAudioTrackLanguage"; -char const * const s_valDefaultChapterCountry = "defaultChapterCountry"; char const * const s_valDefaultChapterLanguage = "defaultChapterLanguage"; char const * const s_valDefaultSubtitleCharset = "defaultSubtitleCharset"; char const * const s_valDefaultSubtitleTrackLanguage = "defaultSubtitleTrackLanguage";