From 57e326ee412ce5316a76fe0bf06ea8c36a7ae1c0 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 4 Oct 2015 20:10:18 +0200 Subject: [PATCH] GUI: merge: preview buttons for subtitle & chapter character sets --- ChangeLog | 6 +++ share/icons/16x16/character-set.png | Bin 0 -> 494 bytes share/icons/32x32/character-set.png | Bin 0 -> 992 bytes share/icons/48x48/character-set.png | Bin 0 -> 1362 bytes src/mkvtoolnix-gui/forms/merge/tab.ui | 41 ++++++++++++++++-- .../select_character_set_dialog.cpp | 18 ++++++++ .../main_window/select_character_set_dialog.h | 4 ++ src/mkvtoolnix-gui/merge/input.cpp | 40 +++++++++++++++++ src/mkvtoolnix-gui/merge/output.cpp | 32 +++++++++++--- src/mkvtoolnix-gui/merge/source_file.cpp | 7 +++ src/mkvtoolnix-gui/merge/source_file.h | 1 + src/mkvtoolnix-gui/merge/tab.h | 4 ++ src/mkvtoolnix-gui/qt_resources.qrc | 3 ++ 13 files changed, 147 insertions(+), 9 deletions(-) create mode 100644 share/icons/16x16/character-set.png create mode 100644 share/icons/32x32/character-set.png create mode 100644 share/icons/48x48/character-set.png diff --git a/ChangeLog b/ChangeLog index 735f6bf25..cfc138cbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2015-10-04 Moritz Bunkus + * MKVToolNix GUI: merge tool enhancement: added buttons for + previewing the character sets for text subtitles read from SRT and + SSA/ASS files as well as for chapter files. They're located next + to the drop down boxes for the character sets on the input and + output tabs. + * MKVToolNix GUI: merge tool enhancement: added buttons next to the 'segment UID', 'previous segment UID' and 'next segment UID' controls that enable the user to select a Matroska file. The GUI diff --git a/share/icons/16x16/character-set.png b/share/icons/16x16/character-set.png new file mode 100644 index 0000000000000000000000000000000000000000..9be1a10b0980ddcca5ab4bdb61533d75d7ccf1cf GIT binary patch literal 494 zcmVI0z3gy)Gl_dXyIyk0%&c9T)1$>C>vV2+e*iK>vs+vF4TPL)%Wc8Yv13W&XIIo zw>1;H@gPZ36nR`i`*R0&&_FIQ4h>gg+(a@+!i`;=)W?-?y&RBHgB{ka;s$e25wh+; zLqX8$V^(AvI+Dg%)0b#=mlb6Ux)8ChZkJ^h>nPwIkJvZw!0B?u#Th%0K-QS^sH&Iw z9FIO6V*@qFjU%+QwR`wc!X~;ffxv6&xoRW6R)31JjN!MJa-M2N5v$KoJUBonmN1F5 zm>;FwK0Vy$e|?dhPFEZi3?YCIB)*R4R^jdL=~aF-=pPsivO*MP%wrZsXw3P=4$cuo z%-TTV#uvm+R<3i|QyU3|BQeSm7O|x`9Bb4Oq?ntc9-<1l{>M0qID?T4DoDUa<2y

nzcDod5s;07*qoM6N<$f@a>(Pyhe` literal 0 HcmV?d00001 diff --git a/share/icons/32x32/character-set.png b/share/icons/32x32/character-set.png new file mode 100644 index 0000000000000000000000000000000000000000..ceeb10aed922f37d8436cee905a08529f98e112d GIT binary patch literal 992 zcmV<610Vc}P)<*`{&Y=oTT&6hlu`&qA|W9j zyqKt^Gyx7?ym7+>(wG4be+4%Aqkv5RFX?l?77{kTxw<`e)0G z-)Vks-mL9%0E379C7=A>ym|BHH*aQNTAL(^d6?l)FQ8sPy?{(uYmcCWL3I7+6|fIf z5Um(T8{WqGwEun)XHZ5LwrKlodQO&D5s&!?_=*l<7fxdaW7=mHtF{l_rxfBOGlTd{LaFy@?3)SHW4WUcSh^Ak1Z4(Hv4lNiDzu3F~?@Q#E7MWWrL6-Z#w zi=)Vdw{CWHKKrqD}48geIf}JQ}3PU&#gWi9=Q*lPmxhGbxeAjxpAUWSs^*Y~x z!GPYp_D3izKMcN}7$2J>f2qeiRuu|QRj+_V3zkzvUlhrE6XWB@jmD~`LL+0Ig~4~G zMhHxyd5vYFJ=*t`uE+(_O*C0+_mV$^v36Uu`pIaswI+?(*qRq^jgJ0U^(}1(9&Y5G z1yJR7rY>sVrZp{V`_knjZlMVa1yG1@ZfX7ABvGf1of*Ae%G_M%yAd3=V#!$8h+5j# zy-)ja=0vuUpy=YeW3i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w)N+fcAvv)HNV`iT7Z&hWMj~s=lYX}s( z-1PhcQP&YNH3u?ZiJS&7SYM4VakaqgB;KqV99g*=2h>*Gq@bY{tM0=ABPCiJUb%9k ztre5Y{!xU{hz2adBGls60304|sMnzgT6Dt%l1L+qWmtjL zSc4o!u@?7ZJs!j(*oaNosE=8vPM`LV>iinrZ-wrkMH)#Y(2f>F(1<#CQ9aicsL`}O z_|26Fq6y8qVVk)UN%UhW1~H7~YFO7YNF#+FB+y}A^$0=;pkB}GhZi1H=Re=S0c{!( Uv1yXIMF0Q*07*qoM6N<$f}O>0mH+?% literal 0 HcmV?d00001 diff --git a/src/mkvtoolnix-gui/forms/merge/tab.ui b/src/mkvtoolnix-gui/forms/merge/tab.ui index 2d578c790..edd443576 100644 --- a/src/mkvtoolnix-gui/forms/merge/tab.ui +++ b/src/mkvtoolnix-gui/forms/merge/tab.ui @@ -852,6 +852,17 @@ + + + + + + + + :/icons/16x16/character-set.png:/icons/16x16/character-set.png + + + @@ -1160,7 +1171,7 @@ File/Segment linking - + @@ -1169,7 +1180,7 @@ - + @@ -1250,7 +1261,7 @@ Chapters - + @@ -1294,7 +1305,29 @@ - + + + + + + 0 + 0 + + + + + + + + + + + + :/icons/16x16/character-set.png:/icons/16x16/character-set.png + + + + diff --git a/src/mkvtoolnix-gui/main_window/select_character_set_dialog.cpp b/src/mkvtoolnix-gui/main_window/select_character_set_dialog.cpp index 4eb2b19b7..eb7e7a8d3 100644 --- a/src/mkvtoolnix-gui/main_window/select_character_set_dialog.cpp +++ b/src/mkvtoolnix-gui/main_window/select_character_set_dialog.cpp @@ -1,5 +1,7 @@ #include "common/common_pch.h" +#include + #include "common/locale.h" #include "common/qt.h" #include "mkvtoolnix-gui/forms/main_window/select_character_set_dialog.h" @@ -14,6 +16,7 @@ class SelectCharacterSetDialogPrivate { std::unique_ptr m_ui{new Ui::SelectCharacterSetDialog}; QByteArray m_content; + QVariant m_userData; }; SelectCharacterSetDialog::SelectCharacterSetDialog(QWidget *parent, @@ -87,4 +90,19 @@ SelectCharacterSetDialog::selectedCharacterSet() return d->m_ui->characterSet->currentData().toString(); } +void +SelectCharacterSetDialog::setUserData(QVariant const &data) { + Q_D(SelectCharacterSetDialog); + + d->m_userData = data; +} + +QVariant const & +SelectCharacterSetDialog::userData() + const { + Q_D(const SelectCharacterSetDialog); + + return d->m_userData; +} + }} diff --git a/src/mkvtoolnix-gui/main_window/select_character_set_dialog.h b/src/mkvtoolnix-gui/main_window/select_character_set_dialog.h index 89b91f71f..a3ee321d6 100644 --- a/src/mkvtoolnix-gui/main_window/select_character_set_dialog.h +++ b/src/mkvtoolnix-gui/main_window/select_character_set_dialog.h @@ -8,6 +8,7 @@ #include "mkvtoolnix-gui/util/settings.h" class QListWidget; +class QVariant; namespace mtx { namespace gui { @@ -22,6 +23,9 @@ public: explicit SelectCharacterSetDialog(QWidget *parent, QString const &fileName, QString const &initialCharacterSet = QString{}); virtual ~SelectCharacterSetDialog(); + void setUserData(QVariant const &data); + QVariant const &userData() const; + signals: void characterSetSelected(QString const &characterSet); diff --git a/src/mkvtoolnix-gui/merge/input.cpp b/src/mkvtoolnix-gui/merge/input.cpp index a3ae01be1..be161ced5 100644 --- a/src/mkvtoolnix-gui/merge/input.cpp +++ b/src/mkvtoolnix-gui/merge/input.cpp @@ -22,6 +22,7 @@ #include "mkvtoolnix-gui/app.h" #include "mkvtoolnix-gui/forms/merge/tab.h" #include "mkvtoolnix-gui/main_window/main_window.h" +#include "mkvtoolnix-gui/main_window/select_character_set_dialog.h" #include "mkvtoolnix-gui/merge/adding_appending_files_dialog.h" #include "mkvtoolnix-gui/merge/executable_location_dialog.h" #include "mkvtoolnix-gui/merge/tab.h" @@ -252,6 +253,7 @@ Tab::setupInputControls() { connect(ui->moveFilesDown, &QPushButton::clicked, this, &Tab::onMoveFilesDown); connect(ui->moveTracksUp, &QPushButton::clicked, this, &Tab::onMoveTracksUp); connect(ui->moveTracksDown, &QPushButton::clicked, this, &Tab::onMoveTracksDown); + connect(ui->subtitleCharacterSetPreview, &QPushButton::clicked, this, &Tab::onPreviewSubtitleCharacterSet); connect(m_addFilesAction, &QAction::triggered, this, &Tab::onAddFiles); connect(m_appendFilesAction, &QAction::triggered, this, &Tab::onAppendFiles); @@ -411,6 +413,7 @@ Tab::onTrackSelectionChanged() { Util::enableWidgets(m_allInputControls, false); ui->moveTracksUp->setEnabled(false); ui->moveTracksDown->setEnabled(false); + ui->subtitleCharacterSetPreview->setEnabled(false); auto selection = ui->tracks->selectionModel()->selection(); auto numRows = Util::numSelectedRows(selection); @@ -449,6 +452,9 @@ Tab::onTrackSelectionChanged() { if (track->m_file->m_type == FILE_TYPE_MATROSKA) Util::enableWidgets(QList{} << ui->characterSetLabel << ui->subtitleCharacterSet, false); + else if (track->m_file->isTextSubtitleContainer()) + ui->subtitleCharacterSetPreview->setEnabled(true); + } else if (track->isChapters()) Util::enableWidgets(m_chapterControls, true); @@ -1599,4 +1605,38 @@ Tab::openFilesInMediaInfo(QStringList const &fileNames) { QProcess::startDetached(exe, fileNames); } +void +Tab::onPreviewSubtitleCharacterSet() { + auto selection = selectedTracks(); + auto track = selection.count() ? selection[0] : nullptr; + + if ((selection.count() != 1) || !track->m_file->isTextSubtitleContainer()) + return; + + auto dlg = new SelectCharacterSetDialog{this, track->m_file->m_fileName, track->m_characterSet}; + dlg->setUserData(reinterpret_cast(track)); + + connect(dlg, &SelectCharacterSetDialog::characterSetSelected, this, &Tab::setSubtitleCharacterSet); + + dlg->show(); +} + +void +Tab::setSubtitleCharacterSet(QString const &characterSet) { + auto dlg = qobject_cast(QObject::sender()); + if (!dlg) + return; + + auto track = reinterpret_cast(dlg->userData().toULongLong()); + + if (!m_config.m_tracks.contains(track)) + return; + + track->m_characterSet = characterSet; + auto selection = selectedTracks(); + + if ((selection.count() == 1) && (selection[0] == track)) + Util::setComboBoxTextByData(ui->subtitleCharacterSet, characterSet); +} + }}} diff --git a/src/mkvtoolnix-gui/merge/output.cpp b/src/mkvtoolnix-gui/merge/output.cpp index 2f1cc4524..d8cde40a4 100644 --- a/src/mkvtoolnix-gui/merge/output.cpp +++ b/src/mkvtoolnix-gui/merge/output.cpp @@ -5,6 +5,7 @@ #include "common/qt.h" #include "mkvtoolnix-gui/forms/merge/tab.h" #include "mkvtoolnix-gui/main_window/main_window.h" +#include "mkvtoolnix-gui/main_window/select_character_set_dialog.h" #include "mkvtoolnix-gui/merge/additional_command_line_options_dialog.h" #include "mkvtoolnix-gui/merge/tab.h" #include "mkvtoolnix-gui/util/message_box.h" @@ -23,6 +24,8 @@ Tab::setupOutputControls() { setupOutputFileControls(); + ui->chapterCharacterSetPreview->setEnabled(false); + m_splitControls << ui->splitOptions << ui->splitOptionsLabel << ui->splitMaxFilesLabel << ui->splitMaxFiles << ui->linkFiles; auto comboBoxControls = QList{} << ui->splitMode << ui->chapterLanguage << ui->chapterCharacterSet; @@ -33,10 +36,11 @@ Tab::setupOutputControls() { onSplitModeChanged(MuxConfig::DoNotSplit); - connect(MainWindow::get(), &MainWindow::preferencesChanged, this, &Tab::setupOutputFileControls); - connect(ui->browseSegmentUID, &QPushButton::clicked, this, &Tab::onBrowseSegmentUID); - connect(ui->browsePreviousSegmentUID, &QPushButton::clicked, this, &Tab::onBrowsePreviousSegmentUID); - connect(ui->browseNextSegmentUID, &QPushButton::clicked, this, &Tab::onBrowseNextSegmentUID); + connect(MainWindow::get(), &MainWindow::preferencesChanged, this, &Tab::setupOutputFileControls); + connect(ui->browseSegmentUID, &QPushButton::clicked, this, &Tab::onBrowseSegmentUID); + connect(ui->browsePreviousSegmentUID, &QPushButton::clicked, this, &Tab::onBrowsePreviousSegmentUID); + connect(ui->browseNextSegmentUID, &QPushButton::clicked, this, &Tab::onBrowseNextSegmentUID); + connect(ui->chapterCharacterSetPreview, &QPushButton::clicked, this, &Tab::onPreviewChapterCharacterSet); } void @@ -393,6 +397,7 @@ Tab::onNextSegmentUIDChanged(QString newValue) { void Tab::onChaptersChanged(QString newValue) { m_config.m_chapters = newValue; + ui->chapterCharacterSetPreview->setEnabled(!newValue.isEmpty()); } void @@ -405,7 +410,7 @@ Tab::onBrowseChapters() { InitialDirMode::ContentFirstInputFileLastOpenDir); if (!fileName.isEmpty()) - m_config.m_chapters = fileName; + onChaptersChanged(fileName); } void @@ -518,4 +523,21 @@ Tab::addSegmentUIDFromFile(QLineEdit &lineEdit, } } +void +Tab::onPreviewChapterCharacterSet() { + if (m_config.m_chapters.isEmpty()) + return; + + auto dlg = new SelectCharacterSetDialog{this, m_config.m_chapters, ui->chapterCharacterSet->currentData().toString()}; + connect(dlg, &SelectCharacterSetDialog::characterSetSelected, this, &Tab::setChapterCharacterSet); + + dlg->show(); +} + +void +Tab::setChapterCharacterSet(QString const &characterSet) { + Util::setComboBoxTextByData(ui->chapterCharacterSet, characterSet); + onChapterCharacterSetChanged(characterSet); +} + }}} diff --git a/src/mkvtoolnix-gui/merge/source_file.cpp b/src/mkvtoolnix-gui/merge/source_file.cpp index 570f70317..6fca71ab5 100644 --- a/src/mkvtoolnix-gui/merge/source_file.cpp +++ b/src/mkvtoolnix-gui/merge/source_file.cpp @@ -1,5 +1,6 @@ #include "common/common_pch.h" +#include "common/list_utils.h" #include "common/qt.h" #include "mkvtoolnix-gui/merge/mkvmerge_option_builder.h" #include "mkvtoolnix-gui/merge/mux_config.h" @@ -132,6 +133,12 @@ SourceFile::container() return Q(file_type_t::get_name(m_type).get_translated()); } +bool +SourceFile::isTextSubtitleContainer() + const { + return mtx::included_in(m_type, FILE_TYPE_SRT, FILE_TYPE_SSA); +} + void SourceFile::saveSettings(Util::ConfigFile &settings) const { diff --git a/src/mkvtoolnix-gui/merge/source_file.h b/src/mkvtoolnix-gui/merge/source_file.h index 2586f36a5..fce9d18e1 100644 --- a/src/mkvtoolnix-gui/merge/source_file.h +++ b/src/mkvtoolnix-gui/merge/source_file.h @@ -40,6 +40,7 @@ public: SourceFile &operator =(SourceFile const &other); virtual QString container() const; + virtual bool isTextSubtitleContainer() const; virtual bool isValid() const; virtual bool isRegular() const; virtual bool isAppended() const; diff --git a/src/mkvtoolnix-gui/merge/tab.h b/src/mkvtoolnix-gui/merge/tab.h index 457e55057..26cf1d1ea 100644 --- a/src/mkvtoolnix-gui/merge/tab.h +++ b/src/mkvtoolnix-gui/merge/tab.h @@ -141,6 +141,8 @@ public slots: virtual void onSubtitleCharacterSetChanged(int newValue); virtual void onCuesChanged(int newValue); virtual void onAdditionalTrackOptionsChanged(QString newValue); + virtual void onPreviewChapterCharacterSet(); + virtual void setChapterCharacterSet(QString const &characterSet); virtual void resizeFilesColumnsToContents() const; virtual void resizeTracksColumnsToContents() const; @@ -188,6 +190,8 @@ public slots: virtual void onWebmClicked(bool newValue); virtual void onAdditionalOptionsChanged(QString newValue); virtual void onEditAdditionalOptions(); + virtual void onPreviewSubtitleCharacterSet(); + virtual void setSubtitleCharacterSet(QString const &characterSet); // Attachments tab: virtual void onAttachmentSelectionChanged(); diff --git a/src/mkvtoolnix-gui/qt_resources.qrc b/src/mkvtoolnix-gui/qt_resources.qrc index 0d49ba7ae..64bb57ef4 100644 --- a/src/mkvtoolnix-gui/qt_resources.qrc +++ b/src/mkvtoolnix-gui/qt_resources.qrc @@ -158,5 +158,8 @@ ../../share/icons/32x32/arrow-down.png ../../share/icons/48x48/arrow-up.png ../../share/icons/48x48/arrow-down.png + ../../share/icons/16x16/character-set.png + ../../share/icons/32x32/character-set.png + ../../share/icons/48x48/character-set.png \ No newline at end of file