Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split menu to two rows and workaround character truncation #297

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ui/dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ color: #003168;
border: 0px;
max-height: 22px;
padding-left: 7px;
padding-right: 7px;
padding-right: 6px;
font-size: 14px;
text-align: left;
}
Expand Down
14 changes: 9 additions & 5 deletions src/ui/webeiddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ WebEidDialog::WebEidDialog(QWidget* parent) : WebEidUI(parent), ui(new Private)
{QStringLiteral("cs"), QStringLiteral("Čeština")},
{QStringLiteral("sk"), QStringLiteral("Slovenština")}};
ui->langButton->setText(tr("EN", "Active language"));
if (auto i = std::find_if(
LANG_LIST.cbegin(), LANG_LIST.cend(),
[&](const auto& elem) { return elem.first == ui->langButton->text().toLower(); });
if (auto i = std::find_if(LANG_LIST.cbegin(), LANG_LIST.cend(),
[lang = ui->langButton->text().toLower()](const auto& elem) {
return elem.first == lang;
});
i != LANG_LIST.cend()) {
ui->langButton->setAccessibleName(i->second);
}
Expand All @@ -115,20 +116,23 @@ WebEidDialog::WebEidDialog(QWidget* parent) : WebEidUI(parent), ui(new Private)
}
auto* menu = new QWidget(this);
menu->setObjectName("langMenu");
auto* layout = new QVBoxLayout(menu);
auto* layout = new QGridLayout(menu);
layout->setContentsMargins(1, 1, 1, 1);
layout->setSpacing(1);
auto* langGroup = new QButtonGroup(menu);
langGroup->setExclusive(true);
int i {};
for (const auto& [lang, title] : LANG_LIST) {
auto* action = new QPushButton(menu);
action->setText(title);
action->setProperty("lang", lang);
action->setAutoDefault(false);
layout->addWidget(action);
layout->addWidget(action, i / 2, i % 2);
langGroup->addButton(action);
action->setCheckable(true);
action->setChecked(lang == ui->langButton->text().toLower());
action->setMinimumSize(action->sizeHint() + QSize(1, 0));
++i;
}
menu->show();
menu->adjustSize();
Expand Down
Loading