Commit b9b2b9e4 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Use a scroll area in the Add User ID dialog

The scroll area allows the widgets to grow larger than the screen, e.g.
if one enters a lot of text into the input fields than the result label
grows very large.

GnuPG-bug-id: 5969
parent 3b1995f6
......@@ -14,6 +14,7 @@
#include "adduseriddialog.h"
#include "utils/accessibility.h"
#include "utils/scrollarea.h"
#include "view/errorlabel.h"
#include "view/formtextinput.h"
#include "view/htmllabel.h"
......@@ -57,6 +58,7 @@ class AddUserIDDialog::Private
AddUserIDDialog *const q;
struct {
ScrollArea *scrollArea;
std::unique_ptr<FormTextInput<QLineEdit>> nameInput;
std::unique_ptr<FormTextInput<QLineEdit>> emailInput;
HtmlLabel *resultLabel;
......@@ -78,13 +80,25 @@ public:
auto mainLayout = new QVBoxLayout{q};
const auto infoText = nameIsRequired || emailIsRequired
? i18n("Enter a name and an email address to use for the user ID.")
: i18n("Enter a name and/or an email address to use for the user ID.");
mainLayout->addWidget(new QLabel{infoText, q});
{
const auto infoText = nameIsRequired || emailIsRequired
? i18n("Enter a name and an email address to use for the user ID.")
: i18n("Enter a name and/or an email address to use for the user ID.");
auto label = new QLabel{infoText, q};
mainLayout->addWidget(label);
}
mainLayout->addWidget(new KSeparator{Qt::Horizontal, q});
ui.scrollArea = new ScrollArea{q};
ui.scrollArea->setFocusPolicy(Qt::NoFocus);
ui.scrollArea->setFrameStyle(QFrame::NoFrame);
ui.scrollArea->setBackgroundRole(q->backgroundRole());
ui.scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui.scrollArea->setSizeAdjustPolicy(QScrollArea::AdjustToContents);
auto scrollAreaLayout = qobject_cast<QBoxLayout *>(ui.scrollArea->widget()->layout());
scrollAreaLayout->setContentsMargins(0, 0, 0, 0);
{
ui.nameInput = FormTextInput<QLineEdit>::create(q);
ui.nameInput->setLabelText(i18nc("@label", "Name"));
......@@ -115,10 +129,10 @@ public:
"it must not include less-than sign, greater-than sign, and at sign."));
}
mainLayout->addWidget(ui.nameInput->label());
mainLayout->addWidget(ui.nameInput->hintLabel());
mainLayout->addWidget(ui.nameInput->errorLabel());
mainLayout->addWidget(ui.nameInput->widget());
scrollAreaLayout->addWidget(ui.nameInput->label());
scrollAreaLayout->addWidget(ui.nameInput->hintLabel());
scrollAreaLayout->addWidget(ui.nameInput->errorLabel());
scrollAreaLayout->addWidget(ui.nameInput->widget());
}
connect(ui.nameInput->widget(), &QLineEdit::textChanged,
q, [this]() { updateResultLabel(); });
......@@ -141,26 +155,28 @@ public:
"Enter an email address in the correct format required by your organization."));
}
mainLayout->addWidget(ui.emailInput->label());
mainLayout->addWidget(ui.emailInput->hintLabel());
mainLayout->addWidget(ui.emailInput->errorLabel());
mainLayout->addWidget(ui.emailInput->widget());
scrollAreaLayout->addWidget(ui.emailInput->label());
scrollAreaLayout->addWidget(ui.emailInput->hintLabel());
scrollAreaLayout->addWidget(ui.emailInput->errorLabel());
scrollAreaLayout->addWidget(ui.emailInput->widget());
}
connect(ui.emailInput->widget(), &QLineEdit::textChanged,
q, [this]() { updateResultLabel(); });
mainLayout->addWidget(new KSeparator{Qt::Horizontal, q});
scrollAreaLayout->addWidget(new KSeparator{Qt::Horizontal, q});
{
ui.resultLabel = new HtmlLabel{q};
ui.resultLabel->setFocusPolicy(Qt::ClickFocus);
labelHelper.addLabel(ui.resultLabel);
mainLayout->addWidget(ui.resultLabel);
scrollAreaLayout->addWidget(ui.resultLabel);
}
mainLayout->addWidget(new KSeparator{Qt::Horizontal, q});
scrollAreaLayout->addStretch(1);
mainLayout->addWidget(ui.scrollArea);
mainLayout->addStretch(1);
mainLayout->addWidget(new KSeparator{Qt::Horizontal, q});
ui.buttonBox = new QDialogButtonBox{QDialogButtonBox::Ok | QDialogButtonBox::Cancel, q};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment