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

Move setup of UI to member function of Private

This allows calling other member functions of Private from setUpUI()
resp. from lambdas connected in setUpUI().

GnuPG-bug-id: 5333
parent 272335da
......@@ -109,66 +109,60 @@ private:
SearchBar searchBar;
TabWidget tabWidget;
QDialogButtonBox buttonBox;
QVBoxLayout vlay;
explicit UI(CertificateSelectionDialog *q)
: label(q),
searchBar(q),
tabWidget(q),
buttonBox(q),
vlay(q)
{
KDAB_SET_OBJECT_NAME(label);
KDAB_SET_OBJECT_NAME(searchBar);
KDAB_SET_OBJECT_NAME(tabWidget);
KDAB_SET_OBJECT_NAME(buttonBox);
KDAB_SET_OBJECT_NAME(vlay);
vlay.addWidget(&label);
vlay.addWidget(&searchBar);
vlay.addWidget(&tabWidget, 1);
vlay.addWidget(&buttonBox);
QPushButton *const ok = buttonBox.addButton(QDialogButtonBox::Ok);
ok->setEnabled(false);
QPushButton *const cancel = buttonBox.addButton(QDialogButtonBox::Close);
Q_UNUSED(cancel)
QPushButton *const reload = buttonBox.addButton(i18n("Reload"), QDialogButtonBox::ActionRole);
QPushButton *const import = buttonBox.addButton(i18n("Import..."), QDialogButtonBox::ActionRole);
QPushButton *const lookup = buttonBox.addButton(i18n("Lookup..."), QDialogButtonBox::ActionRole);
QPushButton *const create = buttonBox.addButton(i18n("New..."), QDialogButtonBox::ActionRole);
import->setToolTip(i18nc("@info:tooltip", "Import certificate from file"));
lookup->setToolTip(i18nc("@info:tooltip", "Lookup certificates on server"));
reload->setToolTip(i18nc("@info:tooltip", "Refresh certificate list"));
create->setToolTip(i18nc("@info:tooltip", "Create a new certificate"));
connect(&buttonBox, &QDialogButtonBox::accepted, q, &CertificateSelectionDialog::accept);
connect(&buttonBox, &QDialogButtonBox::rejected, q, &CertificateSelectionDialog::reject);
connect(reload, SIGNAL(clicked()), q, SLOT(reload()));
connect(lookup, SIGNAL(clicked()), q, SLOT(lookup()));
connect(create, SIGNAL(clicked()), q, SLOT(create()));
connect(KeyCache::instance().get(), SIGNAL(keysMayHaveChanged()),
q, SLOT(slotKeysMayHaveChanged()));
connect(import, &QPushButton::clicked, q, [import, q] () {
import->setEnabled(false);
auto cmd = new Kleo::ImportCertificateFromFileCommand();
connect(cmd, &Kleo::ImportCertificateFromFileCommand::finished,
q, [import]() {
import->setEnabled(true);
});
cmd->setParentWidget(q);
cmd->start();
});
}
} ui;
void setUpUI(CertificateSelectionDialog *q)
{
KDAB_SET_OBJECT_NAME(ui.label);
KDAB_SET_OBJECT_NAME(ui.searchBar);
KDAB_SET_OBJECT_NAME(ui.tabWidget);
KDAB_SET_OBJECT_NAME(ui.buttonBox);
auto *vlay = new QVBoxLayout(q);
vlay->addWidget(&ui.label);
vlay->addWidget(&ui.searchBar);
vlay->addWidget(&ui.tabWidget, 1);
vlay->addWidget(&ui.buttonBox);
QPushButton *const ok = ui.buttonBox.addButton(QDialogButtonBox::Ok);
ok->setEnabled(false);
QPushButton *const cancel = ui.buttonBox.addButton(QDialogButtonBox::Close);
Q_UNUSED(cancel)
QPushButton *const reload = ui.buttonBox.addButton(i18n("Reload"), QDialogButtonBox::ActionRole);
QPushButton *const import = ui.buttonBox.addButton(i18n("Import..."), QDialogButtonBox::ActionRole);
QPushButton *const lookup = ui.buttonBox.addButton(i18n("Lookup..."), QDialogButtonBox::ActionRole);
QPushButton *const create = ui.buttonBox.addButton(i18n("New..."), QDialogButtonBox::ActionRole);
import->setToolTip(i18nc("@info:tooltip", "Import certificate from file"));
lookup->setToolTip(i18nc("@info:tooltip", "Lookup certificates on server"));
reload->setToolTip(i18nc("@info:tooltip", "Refresh certificate list"));
create->setToolTip(i18nc("@info:tooltip", "Create a new certificate"));
connect(&ui.buttonBox, &QDialogButtonBox::accepted, q, &CertificateSelectionDialog::accept);
connect(&ui.buttonBox, &QDialogButtonBox::rejected, q, &CertificateSelectionDialog::reject);
connect(reload, SIGNAL(clicked()), q, SLOT(reload()));
connect(lookup, SIGNAL(clicked()), q, SLOT(lookup()));
connect(create, SIGNAL(clicked()), q, SLOT(create()));
connect(KeyCache::instance().get(), SIGNAL(keysMayHaveChanged()),
q, SLOT(slotKeysMayHaveChanged()));
connect(import, &QPushButton::clicked, q, [import, q] () {
import->setEnabled(false);
auto cmd = new Kleo::ImportCertificateFromFileCommand();
connect(cmd, &Kleo::ImportCertificateFromFileCommand::finished,
q, [import]() {
import->setEnabled(true);
});
cmd->setParentWidget(q);
cmd->start();
});
}
};
CertificateSelectionDialog::Private::Private(CertificateSelectionDialog *qq)
: q(qq),
ui(q)
: q(qq)
{
setUpUI(q);
ui.tabWidget.setFlatModel(AbstractKeyListModel::createFlatKeyListModel(q));
ui.tabWidget.setHierarchicalModel(AbstractKeyListModel::createHierarchicalKeyListModel(q));
#ifdef GPGME_HAS_REMARKS
......
Markdown is supported
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