Sketcher: filter list strings are updated at language change (include fix commits)
This commit is contained in:
@@ -492,33 +492,40 @@ ElementItem* ElementItemDelegate::getElementtItem(const QModelIndex& index) cons
|
||||
/* Filter element list widget ------------------------------------------------------ */
|
||||
ElementFilterList::ElementFilterList(QWidget* parent) : QListWidget(parent)
|
||||
{
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", "Normal"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", "Construction"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", "Internal"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", "External"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", "All types"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", " - Point"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", " - Line"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", " - Circle"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", " - Ellipse"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", " - Arc"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", " - Arc of ellipse"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", " - Arc of hyperbola"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", " - Arc of parabola"), this));
|
||||
addItem(new QListWidgetItem(QApplication::translate("ElementFilterList", " - B-Spline"), this));
|
||||
|
||||
for (int i = 0; i < count(); i++) {
|
||||
QListWidgetItem* it = item(i);
|
||||
|
||||
for (auto const &filterItem:filterItems) {
|
||||
Q_UNUSED(filterItem);
|
||||
auto it = new QListWidgetItem();
|
||||
it->setFlags(it->flags() | Qt::ItemIsUserCheckable);
|
||||
it->setCheckState(Qt::Checked);
|
||||
addItem(it);
|
||||
}
|
||||
languageChange();
|
||||
}
|
||||
|
||||
ElementFilterList::~ElementFilterList()
|
||||
{
|
||||
}
|
||||
|
||||
void ElementFilterList::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
languageChange();
|
||||
}
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
void ElementFilterList::languageChange()
|
||||
{
|
||||
assert(static_cast<int>(filterItems.size()) == count());
|
||||
int i=0;
|
||||
for (auto const &filterItem:filterItems) {
|
||||
auto text = QStringLiteral(" ").repeated(filterItem.second-1) +
|
||||
(filterItem.second > 0 ? QStringLiteral("- ") : QStringLiteral()) +
|
||||
tr(filterItem.first);
|
||||
item(i++)->setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* TRANSLATOR SketcherGui::TaskSketcherElements */
|
||||
|
||||
|
||||
@@ -185,6 +185,29 @@ public:
|
||||
explicit ElementFilterList(QWidget* parent = nullptr);
|
||||
~ElementFilterList() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent* e) override;
|
||||
virtual void languageChange();
|
||||
|
||||
private:
|
||||
using filterItemRepr = std::pair<const char *, const int>; // {filter item text, filter item level}
|
||||
inline static const std::vector<filterItemRepr> filterItems = {
|
||||
{QT_TR_NOOP("Normal"),0},
|
||||
{QT_TR_NOOP("Construction"),0},
|
||||
{QT_TR_NOOP("Internal"),0},
|
||||
{QT_TR_NOOP("External"),0},
|
||||
{QT_TR_NOOP("All types"),0},
|
||||
{QT_TR_NOOP("Point"),1},
|
||||
{QT_TR_NOOP("Line"),1},
|
||||
{QT_TR_NOOP("Circle"),1},
|
||||
{QT_TR_NOOP("Ellipse"),1},
|
||||
{QT_TR_NOOP("Arc of circle"),1},
|
||||
{QT_TR_NOOP("Arc of ellipse"),1},
|
||||
{QT_TR_NOOP("Arc of hyperbola"),1},
|
||||
{QT_TR_NOOP("Arc of parabola"),1},
|
||||
{QT_TR_NOOP("B-Spline"),1}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
class TaskSketcherElements : public Gui::TaskView::TaskBox, public Gui::SelectionObserver
|
||||
|
||||
Reference in New Issue
Block a user