Commit a0ccf4fc authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Port to new connect() syntax where possible

parent b222e459
......@@ -103,12 +103,9 @@ GpgME::Error DefaultKeyGenerationJob::start(const QString &email, const QString
d->job = QGpgME::openpgp()->keyGenerationJob();
d->job->installEventFilter(this);
connect(d->job.data(), &QGpgME::KeyGenerationJob::result,
this, &DefaultKeyGenerationJob::result);
connect(d->job.data(), &QGpgME::KeyGenerationJob::done,
this, &DefaultKeyGenerationJob::done);
connect(d->job.data(), &QGpgME::KeyGenerationJob::done,
this, &QObject::deleteLater);
connect(d->job.data(), &QGpgME::KeyGenerationJob::result, this, &DefaultKeyGenerationJob::result);
connect(d->job.data(), &QGpgME::KeyGenerationJob::done, this, &DefaultKeyGenerationJob::done);
connect(d->job.data(), &QGpgME::KeyGenerationJob::done, this, &QObject::deleteLater);
return d->job->start(args);
}
......
......@@ -90,7 +90,7 @@ class KeyCache::Private
public:
explicit Private(KeyCache *qq) : q(qq), m_refreshInterval(1), m_initalized(false)
{
connect(&m_autoKeyListingTimer, SIGNAL(timeout()), q, SLOT(startKeyListing()));
connect(&m_autoKeyListingTimer, &QTimer::timeout, q, [this]() { q->startKeyListing(); });
updateAutoKeyListingTimer();
}
......@@ -255,7 +255,10 @@ void KeyCache::reload(GpgME::Protocol /*proto*/)
enableFileSystemWatcher(false);
d->m_refreshJob = new RefreshKeysJob(this);
connect(d->m_refreshJob, SIGNAL(done(GpgME::KeyListResult)), this, SLOT(refreshJobDone(GpgME::KeyListResult)));
connect(d->m_refreshJob, &RefreshKeysJob::done,
this, [this](const GpgME::KeyListResult &r) {
d->refreshJobDone(r);
});
d->m_refreshJob->start();
}
......@@ -273,10 +276,10 @@ void KeyCache::addFileSystemWatcher(const std::shared_ptr<FileSystemWatcher> &wa
return;
}
d->m_fsWatchers.push_back(watcher);
connect(watcher.get(), SIGNAL(directoryChanged(QString)),
this, SLOT(startKeyListing()));
connect(watcher.get(), SIGNAL(fileChanged(QString)),
this, SLOT(startKeyListing()));
connect(watcher.get(), &FileSystemWatcher::directoryChanged,
this, [this]() { startKeyListing(); });
connect(watcher.get(), &FileSystemWatcher::fileChanged,
this, [this]() { startKeyListing(); });
watcher->setEnabled(d->m_refreshJob == 0);
}
......@@ -1004,7 +1007,7 @@ KeyCache::RefreshKeysJob::~RefreshKeysJob() {}
void KeyCache::RefreshKeysJob::start()
{
QTimer::singleShot(0, this, SLOT(doStart()));
QTimer::singleShot(0, this, [this](){ d->doStart(); });
}
void KeyCache::RefreshKeysJob::cancel()
......@@ -1049,11 +1052,12 @@ Error KeyCache::RefreshKeysJob::Private::startKeyListing(GpgME::Protocol proto)
if (!job) {
return Error();
}
connect(job, SIGNAL(result(GpgME::KeyListResult,std::vector<GpgME::Key>)),
q, SLOT(listAllKeysJobDone(GpgME::KeyListResult,std::vector<GpgME::Key>)));
connect(job, &QGpgME::ListAllKeysJob::result,
q, [this](const GpgME::KeyListResult &res, const std::vector<GpgME::Key> &keys) {
listAllKeysJobDone(res, keys);
});
connect(q, &RefreshKeysJob::canceled,
job, &QGpgME::Job::slotCancel);
connect(q, &RefreshKeysJob::canceled, job, &QGpgME::Job::slotCancel);
const Error error = job->start(true);
......
......@@ -155,8 +155,6 @@ private:
class Private;
QScopedPointer<Private> const d;
Q_PRIVATE_SLOT(d, void refreshJobDone(GpgME::KeyListResult))
};
}
......
......@@ -62,9 +62,6 @@ private:
class Private;
friend class Private;
Private * const d;
Q_PRIVATE_SLOT(d, void listAllKeysJobDone(GpgME::KeyListResult, std::vector<GpgME::Key>))
Q_PRIVATE_SLOT(d, void doStart())
};
}
......
......@@ -964,12 +964,7 @@ void AbstractKeyListModel::useKeyCache(bool value, bool secretOnly)
} else {
setKeys(std::vector<Key>());
}
connect(KeyCache::instance().get(), &KeyCache::keysMayHaveChanged,
this, [this] {
if (d->m_useKeyCache) {
setKeys(d->m_secretOnly ? KeyCache::instance()->secretKeys() : KeyCache::instance()->keys());
}
});
connect(KeyCache::instance().get(), &KeyCache::keysMayHaveChanged, this, [this] { if (d->m_useKeyCache) { setKeys(d->m_secretOnly ? KeyCache::instance()->secretKeys() : KeyCache::instance()->keys()); } });
}
// static
......
......@@ -133,8 +133,7 @@ void KeyGenerator::slotStartKeyGeneration()
QGpgME::KeyGenerationJob *job = proto->keyGenerationJob();
Q_ASSERT(job);
connect(job, SIGNAL(result(GpgME::KeyGenerationResult,QByteArray)),
SLOT(slotResult(GpgME::KeyGenerationResult,QByteArray)));
connect(job, &QGpgME::KeyGenerationJob::result, this, &KeyGenerator::slotResult);
const GpgME::Error err = job->start(params);
if (err) {
......
......@@ -124,10 +124,8 @@ void CertListView::slotStart()
qDebug() << "CertListView::slotStart()";
QGpgME::KeyListJob *job = QGpgME::smime()->keyListJob(false);
Q_ASSERT(job);
QObject::connect(job, SIGNAL(nextKey(GpgME::Key)),
this, SLOT(slotAddKey(GpgME::Key)));
QObject::connect(job, SIGNAL(result(GpgME::KeyListResult)),
this, SLOT(slotResult(GpgME::KeyListResult)));
QObject::connect(job, &QGpgME::KeyListJob::nextKey, this, &CertListView::slotAddKey);
QObject::connect(job, &QGpgME::KeyListJob::result, this, &CertListView::slotResult);
#if 0
QStringList l;
l << "Marc";
......@@ -153,7 +151,7 @@ int main(int argc, char **argv)
CertListView *clv = new CertListView;
clv->show();
QTimer::singleShot(5000, clv, SLOT(slotStart()));
QTimer::singleShot(5000, clv, &CertListView::slotStart);
return app.exec();
}
......@@ -66,14 +66,8 @@ int main(int argc, char **argv)
combo.setKeyFilter(filter);
combo.prependCustomItem(QIcon(), i18n("No key"), QStringLiteral("no-key"));
QObject::connect(&combo, &Kleo::KeySelectionCombo::currentKeyChanged,
[](const GpgME::Key &key) {
qDebug() << "Current key changed:" << key.keyID();
});
QObject::connect(&combo, &Kleo::KeySelectionCombo::customItemSelected,
[](const QVariant &data) {
qDebug() << "Custom item selected:" << data.toString();
});
QObject::connect(&combo, &Kleo::KeySelectionCombo::currentKeyChanged, [](const GpgME::Key &key) { qDebug() << "Current key changed:" << key.keyID(); });
QObject::connect(&combo, &Kleo::KeySelectionCombo::customItemSelected, [](const QVariant &data) { qDebug() << "Custom item selected:" << data.toString(); });
window.show();
......
......@@ -561,7 +561,8 @@ Kleo::CryptoConfigEntryDebugLevel::CryptoConfigEntryDebugLevel(CryptoConfigModul
label->setEnabled(false);
mComboBox->setEnabled(false);
} else {
connect(mComboBox, SIGNAL(currentIndexChanged(int)), SLOT(slotChanged()));
connect(mComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &CryptoConfigEntryDebugLevel::slotChanged);
}
const int row = glay->rowCount();
......@@ -615,8 +616,7 @@ Kleo::CryptoConfigEntryPath::CryptoConfigEntryPath(
}
} else {
if (mFileNameRequester)
connect(mFileNameRequester, &FileNameRequester::fileNameChanged,
this, &CryptoConfigEntryPath::slotChanged);
connect(mFileNameRequester, &FileNameRequester::fileNameChanged, this, &CryptoConfigEntryPath::slotChanged);
}
}
......@@ -659,8 +659,7 @@ Kleo::CryptoConfigEntryDirPath::CryptoConfigEntryDirPath(
}
} else {
if (mFileNameRequester)
connect(mFileNameRequester, &FileNameRequester::fileNameChanged,
this, &CryptoConfigEntryDirPath::slotChanged);
connect(mFileNameRequester, &FileNameRequester::fileNameChanged, this, &CryptoConfigEntryDirPath::slotChanged);
}
}
......@@ -817,8 +816,7 @@ void prepareURLCfgDialog(QDialog *dialog, DirectoryServicesWidget *dirserv, bool
QPushButton *defaultsBtn = buttonBox->button(QDialogButtonBox::RestoreDefaults);
QObject::connect(defaultsBtn, &QPushButton::clicked, dirserv,
&DirectoryServicesWidget::clear);
QObject::connect(defaultsBtn, &QPushButton::clicked, dirserv, &DirectoryServicesWidget::clear);
QObject::connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
}
......
......@@ -471,12 +471,9 @@ public:
ui.treeView->setModel(&model);
ui.treeView->setItemDelegate(&delegate);
connect(&model, &QAbstractItemModel::dataChanged,
q, &DirectoryServicesWidget::changed);
connect(&model, &QAbstractItemModel::rowsInserted,
q, &DirectoryServicesWidget::changed);
connect(&model, &QAbstractItemModel::rowsRemoved,
q, &DirectoryServicesWidget::changed);
connect(&model, &QAbstractItemModel::dataChanged, q, &DirectoryServicesWidget::changed);
connect(&model, &QAbstractItemModel::rowsInserted, q, &DirectoryServicesWidget::changed);
connect(&model, &QAbstractItemModel::rowsRemoved, q, &DirectoryServicesWidget::changed);
connect(ui.treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
q, SLOT(slotSelectionChanged()));
......
......@@ -123,15 +123,15 @@ Kleo::DNAttributeOrderConfigWidget::DNAttributeOrderConfigWidget(DNAttributeMapp
const char *icon;
int row, col;
const char *tooltip;
const char *slot;
void(DNAttributeOrderConfigWidget::*slot)();
bool autorepeat;
} navButtons[] = {
{ "go-top", 0, 1, I18N_NOOP("Move to top"), SLOT(slotDoubleUpButtonClicked()), false },
{ "go-up", 1, 1, I18N_NOOP("Move one up"), SLOT(slotUpButtonClicked()), true },
{ "go-previous", 2, 0, I18N_NOOP("Remove from current attribute order"), SLOT(slotLeftButtonClicked()), false },
{ "go-next", 2, 2, I18N_NOOP("Add to current attribute order"), SLOT(slotRightButtonClicked()), false },
{ "go-down", 3, 1, I18N_NOOP("Move one down"), SLOT(slotDownButtonClicked()), true },
{ "go-bottom", 4, 1, I18N_NOOP("Move to bottom"), SLOT(slotDoubleDownButtonClicked()), false }
{ "go-top", 0, 1, I18N_NOOP("Move to top"), &DNAttributeOrderConfigWidget::slotDoubleUpButtonClicked, false },
{ "go-up", 1, 1, I18N_NOOP("Move one up"), &DNAttributeOrderConfigWidget::slotUpButtonClicked, true },
{ "go-previous", 2, 0, I18N_NOOP("Remove from current attribute order"), &DNAttributeOrderConfigWidget::slotLeftButtonClicked, false },
{ "go-next", 2, 2, I18N_NOOP("Add to current attribute order"), &DNAttributeOrderConfigWidget::slotRightButtonClicked, false },
{ "go-down", 3, 1, I18N_NOOP("Move one down"), &DNAttributeOrderConfigWidget::slotDownButtonClicked, true },
{ "go-bottom", 4, 1, I18N_NOOP("Move to bottom"), &DNAttributeOrderConfigWidget::slotDoubleDownButtonClicked, false }
};
for (unsigned int i = 0; i < sizeof navButtons / sizeof * navButtons; ++i) {
......@@ -141,7 +141,7 @@ Kleo::DNAttributeOrderConfigWidget::DNAttributeOrderConfigWidget(DNAttributeMapp
tb->setToolTip(i18n(navButtons[i].tooltip));
xlay->addWidget(tb, navButtons[i].row, navButtons[i].col);
tb->setAutoRepeat(navButtons[i].autorepeat);
connect(tb, SIGNAL(clicked()), navButtons[i].slot);
connect(tb, &QToolButton::clicked, this, navButtons[i].slot);
}
glay->addLayout(xlay, row, 1);
......
......@@ -170,6 +170,7 @@ public:
KeyListViewItem *itemByFingerprint(const QByteArray &) const;
public:
using QTreeWidget::selectionChanged; // for below, but moc doesn't like it to be in the Q_SIGNALS: section
Q_SIGNALS:
void doubleClicked(Kleo::KeyListViewItem *, int);
......
......@@ -254,16 +254,7 @@ KeySelectionCombo::KeySelectionCombo(QWidget* parent)
d->proxyModel->setSourceModel(d->sortFilterProxy);
setModel(d->proxyModel);
connect(this, static_cast<void(KeySelectionCombo::*)(int)>(&KeySelectionCombo::currentIndexChanged),
this, [this](int row) {
if (row >= 0 && row < d->proxyModel->rowCount()) {
if (d->proxyModel->isCustomItem(row)) {
Q_EMIT customItemSelected(d->proxyModel->index(row, 0).data(Qt::UserRole));
} else {
Q_EMIT currentKeyChanged(currentKey());
}
}
});
connect(this, static_cast<void(KeySelectionCombo::*)(int)>(&KeySelectionCombo::currentIndexChanged), this, [this](int row) { if (row >= 0 && row < d->proxyModel->rowCount()) { if (d->proxyModel->isCustomItem(row)) { Q_EMIT customItemSelected(d->proxyModel->index(row, 0).data(Qt::UserRole)); } else { Q_EMIT currentKeyChanged(currentKey()); } } });
d->cache = Kleo::KeyCache::mutableInstance();
......@@ -279,19 +270,16 @@ void KeySelectionCombo::init()
{
connect(d->cache.get(), &Kleo::KeyCache::keyListingDone,
this, [this]() {
qDebug() << "Key listing done";
// Set useKeyCache ensures that the cache is populated
// so this can be a blocking call if the cache is not initalized
d->model->useKeyCache(true, true);
d->proxyModel->removeCustomItem(QStringLiteral("-libkleo-loading-keys"));
setEnabled(d->wasEnabled);
Q_EMIT keyListingFinished();
// Set useKeyCache ensures that the cache is populated
// so this can be a blocking call if the cache is not initalized
qDebug() << "Key listing done";
d->model->useKeyCache(true, true);
d->proxyModel->removeCustomItem(QStringLiteral("-libkleo-loading-keys"));
setEnabled(d->wasEnabled);
Q_EMIT keyListingFinished();
});
connect(this, &KeySelectionCombo::keyListingFinished,
this, [this]() {
setCurrentKey(d->defaultKey);
});
connect(this, &KeySelectionCombo::keyListingFinished, this, [this]() { setCurrentKey(d->defaultKey); });
if (!d->cache->initialized()) {
refreshKeys();
......
......@@ -455,8 +455,7 @@ void Kleo::KeySelectionDialog::init(bool rememberChoice, bool extendedSelection,
QPushButton *const searchExternalPB =
new QPushButton(i18n("Search for &External Certificates"), page);
mTopLayout->addWidget(searchExternalPB, 0, Qt::AlignLeft);
connect(searchExternalPB, &QAbstractButton::clicked,
this, &KeySelectionDialog::slotStartSearchForExternalCertificates);
connect(searchExternalPB, &QAbstractButton::clicked, this, &KeySelectionDialog::slotStartSearchForExternalCertificates);
if (initialQuery.isEmpty()) {
searchExternalPB->hide();
}
......@@ -475,8 +474,8 @@ void Kleo::KeySelectionDialog::init(bool rememberChoice, bool extendedSelection,
hlay->addWidget(le, 1);
le->setFocus();
connect(le, SIGNAL(textChanged(QString)),
this, SLOT(slotSearch(QString)));
connect(le, &QLineEdit::textChanged,
this, static_cast<void(KeySelectionDialog::*)(const QString &)>(&KeySelectionDialog::slotSearch));
connect(mStartSearchTimer, &QTimer::timeout, this, &KeySelectionDialog::slotFilter);
mKeyListView = new KeyListView(new ColumnStrategy(mKeyUsage), 0, page);
......@@ -500,21 +499,17 @@ void Kleo::KeySelectionDialog::init(bool rememberChoice, bool extendedSelection,
"</p></qt>"));
}
connect(mCheckSelectionTimer, SIGNAL(timeout()),
SLOT(slotCheckSelection()));
connect(mCheckSelectionTimer, &QTimer::timeout,
this, static_cast<void(KeySelectionDialog::*)()>(&KeySelectionDialog::slotCheckSelection));
connectSignals();
connect(mKeyListView,
SIGNAL(doubleClicked(Kleo::KeyListViewItem*,int)),
SLOT(slotTryOk()));
connect(mKeyListView,
&KeyListView::contextMenu,
this, &KeySelectionDialog::slotRMB);
connect(mKeyListView, &Kleo::KeyListView::doubleClicked, this, &KeySelectionDialog::slotTryOk);
connect(mKeyListView, &KeyListView::contextMenu, this, &KeySelectionDialog::slotRMB);
user1Button->setText(i18n("&Reread Keys"));
user2Button->setText(i18n("&Start Certificate Manager"));
connect(user1Button, &QPushButton::clicked, this, &KeySelectionDialog::slotRereadKeys);
connect(user2Button, SIGNAL(clicked()), this, SLOT(slotStartCertificateManager()));
connect(user2Button, &QPushButton::clicked, this, [this]() { slotStartCertificateManager(); });
connect(mOkButton, &QPushButton::clicked, this, &KeySelectionDialog::slotOk);
connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &KeySelectionDialog::slotCancel);
slotRereadKeys();
......@@ -547,11 +542,10 @@ Kleo::KeySelectionDialog::~KeySelectionDialog()
void Kleo::KeySelectionDialog::connectSignals()
{
if (mKeyListView->isMultiSelection())
connect(mKeyListView, &QTreeWidget::itemSelectionChanged,
this, &KeySelectionDialog::slotSelectionChanged);
connect(mKeyListView, &QTreeWidget::itemSelectionChanged, this, &KeySelectionDialog::slotSelectionChanged);
else
connect(mKeyListView, SIGNAL(selectionChanged(Kleo::KeyListViewItem*)),
SLOT(slotCheckSelection(Kleo::KeyListViewItem*)));
connect(mKeyListView, static_cast<void(KeyListView::*)(KeyListViewItem*)>(&KeyListView::selectionChanged),
this, static_cast<void(KeySelectionDialog::*)(KeyListViewItem*)>(&KeySelectionDialog::slotCheckSelection));
}
void Kleo::KeySelectionDialog::disconnectSignals()
......@@ -560,8 +554,8 @@ void Kleo::KeySelectionDialog::disconnectSignals()
disconnect(mKeyListView, &QTreeWidget::itemSelectionChanged,
this, &KeySelectionDialog::slotSelectionChanged);
else
disconnect(mKeyListView, SIGNAL(selectionChanged(Kleo::KeyListViewItem*)),
this, SLOT(slotCheckSelection(Kleo::KeyListViewItem*)));
disconnect(mKeyListView, static_cast<void(KeyListView::*)(KeyListViewItem*)>(&KeyListView::selectionChanged),
this, static_cast<void(KeySelectionDialog::*)(KeyListViewItem*)>(&KeySelectionDialog::slotCheckSelection));
}
const GpgME::Key &Kleo::KeySelectionDialog::selectedKey() const
......@@ -687,14 +681,11 @@ void Kleo::KeySelectionDialog::startKeyListJobForBackend(const QGpgME::Protocol
return;
}
connect(job, &QGpgME::KeyListJob::result,
this, &KeySelectionDialog::slotKeyListResult);
connect(job, &QGpgME::KeyListJob::result, this, &KeySelectionDialog::slotKeyListResult);
if (validate)
connect(job, &QGpgME::KeyListJob::nextKey,
mKeyListView, &KeyListView::slotRefreshKey);
connect(job, &QGpgME::KeyListJob::nextKey, mKeyListView, &KeyListView::slotRefreshKey);
else
connect(job, &QGpgME::KeyListJob::nextKey,
mKeyListView, &KeyListView::slotAddKey);
connect(job, &QGpgME::KeyListJob::nextKey, mKeyListView, &KeyListView::slotAddKey);
QStringList fprs;
std::transform(keys.begin(), keys.end(), std::back_inserter(fprs), ExtractFingerprint());
......@@ -862,7 +853,7 @@ void Kleo::KeySelectionDialog::slotRMB(Kleo::KeyListViewItem *item, const QPoint
mCurrentContextMenuItem = item;
QMenu menu;
menu.addAction(i18n("Recheck Key"), this, SLOT(slotRecheckKey()));
menu.addAction(i18n("Recheck Key"), this, &KeySelectionDialog::slotRecheckKey);
menu.exec(p);
}
......
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