diff --git a/ChangeLog b/ChangeLog index a9eb48033..fd64d26ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-10-18 Moritz Bunkus + + * MKVToolNix GUI: header editor bug fix: the tree items weren't + re-translated when the GUI language was changed. + 2015-10-17 Moritz Bunkus * MKVToolNix GUI: bug fix (Linux): the function "open folder" was diff --git a/src/mkvtoolnix-gui/header_editor/page_base.cpp b/src/mkvtoolnix-gui/header_editor/page_base.cpp index 2a6fbd45e..2a3d1ba80 100644 --- a/src/mkvtoolnix-gui/header_editor/page_base.cpp +++ b/src/mkvtoolnix-gui/header_editor/page_base.cpp @@ -71,4 +71,10 @@ PageBase::title() return Q(m_title.get_translated()); } +void +PageBase::setItems(QList const &items) + const { + items.at(0)->setText(title()); +} + }}} diff --git a/src/mkvtoolnix-gui/header_editor/page_base.h b/src/mkvtoolnix-gui/header_editor/page_base.h index 4d9264053..10108b584 100644 --- a/src/mkvtoolnix-gui/header_editor/page_base.h +++ b/src/mkvtoolnix-gui/header_editor/page_base.h @@ -38,6 +38,7 @@ public: virtual bool validateThis() const = 0; virtual void retranslateUi() = 0; virtual QString title() const; + virtual void setItems(QList const &items) const; }; }}} diff --git a/src/mkvtoolnix-gui/header_editor/page_model.cpp b/src/mkvtoolnix-gui/header_editor/page_model.cpp index bf78244d5..63df912b7 100644 --- a/src/mkvtoolnix-gui/header_editor/page_model.cpp +++ b/src/mkvtoolnix-gui/header_editor/page_model.cpp @@ -32,14 +32,17 @@ PageModel::appendPage(PageBase *page, page->retranslateUi(); auto parentItem = parentIdx.isValid() ? itemFromIndex(parentIdx) : invisibleRootItem(); - auto newItem = new QStandardItem{}; + auto newItems = QList{}; - newItem->setData(static_cast(m_pages.count()), Util::HeaderEditorPageIdRole); - newItem->setText(page->title()); + for (auto idx = columnCount(); idx > 0; --idx) + newItems << new QStandardItem{}; - parentItem->appendRow(newItem); + newItems[0]->setData(static_cast(m_pages.count()), Util::HeaderEditorPageIdRole); - page->m_pageIdx = indexFromItem(newItem); + parentItem->appendRow(newItems); + + page->m_pageIdx = indexFromItem(newItems[0]); + page->setItems(newItems); m_pages << page; if (!parentIdx.isValid()) @@ -83,4 +86,28 @@ PageModel::validate() return QModelIndex{}; } +QList +PageModel::itemsForIndex(QModelIndex const &idx) { + auto items = QList{}; + for (auto column = 0, numColumns = columnCount(); column < numColumns; ++column) + items << itemFromIndex(idx.sibling(idx.row(), column)); + + return items; +} + +void +PageModel::retranslateUi() { + Util::setDisplayableAndSymbolicColumnNames(*this, { + { QY("Type"), Q("type") }, + }); + + // horizontalHeaderItem(4)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); + + Util::walkTree(*this, QModelIndex{}, [=](QModelIndex const ¤tIdx) { + auto page = selectedPage(currentIdx); + if (page) + page->setItems(itemsForIndex(currentIdx)); + }); +} + }}} diff --git a/src/mkvtoolnix-gui/header_editor/page_model.h b/src/mkvtoolnix-gui/header_editor/page_model.h index 1ec175699..5e7e17456 100644 --- a/src/mkvtoolnix-gui/header_editor/page_model.h +++ b/src/mkvtoolnix-gui/header_editor/page_model.h @@ -31,6 +31,10 @@ public: void reset(); QModelIndex validate() const; + + void retranslateUi(); + + QList itemsForIndex(QModelIndex const &idx); }; }}} diff --git a/src/mkvtoolnix-gui/header_editor/tab.cpp b/src/mkvtoolnix-gui/header_editor/tab.cpp index 2b6bf716e..1ef510879 100644 --- a/src/mkvtoolnix-gui/header_editor/tab.cpp +++ b/src/mkvtoolnix-gui/header_editor/tab.cpp @@ -212,6 +212,8 @@ Tab::retranslateUi() { auto &pages = m_model->pages(); for (auto const &page : pages) page->retranslateUi(); + + m_model->retranslateUi(); } void