mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-01-09 03:31:41 +00:00
GUI: headers: re-translate tree view items on interface language change
This commit is contained in:
parent
62dcf96cea
commit
786b15c509
@ -1,3 +1,8 @@
|
||||
2015-10-18 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* MKVToolNix GUI: header editor bug fix: the tree items weren't
|
||||
re-translated when the GUI language was changed.
|
||||
|
||||
2015-10-17 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* MKVToolNix GUI: bug fix (Linux): the function "open folder" was
|
||||
|
@ -71,4 +71,10 @@ PageBase::title()
|
||||
return Q(m_title.get_translated());
|
||||
}
|
||||
|
||||
void
|
||||
PageBase::setItems(QList<QStandardItem *> const &items)
|
||||
const {
|
||||
items.at(0)->setText(title());
|
||||
}
|
||||
|
||||
}}}
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
virtual bool validateThis() const = 0;
|
||||
virtual void retranslateUi() = 0;
|
||||
virtual QString title() const;
|
||||
virtual void setItems(QList<QStandardItem *> const &items) const;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
@ -32,14 +32,17 @@ PageModel::appendPage(PageBase *page,
|
||||
page->retranslateUi();
|
||||
|
||||
auto parentItem = parentIdx.isValid() ? itemFromIndex(parentIdx) : invisibleRootItem();
|
||||
auto newItem = new QStandardItem{};
|
||||
auto newItems = QList<QStandardItem *>{};
|
||||
|
||||
newItem->setData(static_cast<unsigned int>(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<unsigned int>(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<QStandardItem *>
|
||||
PageModel::itemsForIndex(QModelIndex const &idx) {
|
||||
auto items = QList<QStandardItem *>{};
|
||||
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));
|
||||
});
|
||||
}
|
||||
|
||||
}}}
|
||||
|
@ -31,6 +31,10 @@ public:
|
||||
void reset();
|
||||
|
||||
QModelIndex validate() const;
|
||||
|
||||
void retranslateUi();
|
||||
|
||||
QList<QStandardItem *> itemsForIndex(QModelIndex const &idx);
|
||||
};
|
||||
|
||||
}}}
|
||||
|
@ -212,6 +212,8 @@ Tab::retranslateUi() {
|
||||
auto &pages = m_model->pages();
|
||||
for (auto const &page : pages)
|
||||
page->retranslateUi();
|
||||
|
||||
m_model->retranslateUi();
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user