25 #include <QVBoxLayout>
26 #include <QHBoxLayout>
27 #include <QPushButton>
33 static std::array<QString, 3> STATE_NAME = {
35 QStringLiteral(
"green"),
36 QStringLiteral(
"red"),
41 QVBoxLayout* layout =
new QVBoxLayout();
42 QHBoxLayout* layoutNavigation =
new QHBoxLayout();
43 QHBoxLayout* layoutMessage =
new QHBoxLayout();
44 QSpacerItem *lSpacer =
new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Ignored);
45 QSpacerItem *rSpacer =
new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Ignored);
51 messageLabel->setProperty(
"state", QStringLiteral(
"red"));
53 messageLabel->setText(tr(
"The text could not be found."));
63 layoutNavigation->setMargin(0);
67 layoutNavigation->addWidget(
upButton);
71 layout->addLayout(layoutNavigation);
74 layoutMessage->addSpacerItem(lSpacer);
76 layoutMessage->addSpacerItem(rSpacer);
77 layout->addLayout(layoutMessage);
137 QWidget::showEvent(event);
143 QPushButton* btn =
new QPushButton();
144 btn->setAttribute(Qt::WA_LayoutUsesWidgetRect);
145 btn->setObjectName(name);
146 btn->setProperty(
"state", state);
171 const auto index =
static_cast<unsigned long>(state);
172 btn->setProperty(
"state", STATE_NAME[index]);
174 btn->setEnabled(index != 0);
193 QString l = text.right(1);
194 if (!l.isEmpty() && l !=
" " && l[0].isSpace()) {
317 int key =
event->key();
319 if ((key == Qt::Key_Enter || key == Qt::Key_Return)) {
320 if ((event->modifiers() & Qt::ShiftModifier)) {
325 }
else if (key == Qt::Key_Escape) {
329 QLineEdit::keyPressEvent(event);