From 7206024d6aafd70fbc0504f9b9126fe080bd99ee Mon Sep 17 00:00:00 2001 From: Christian Hohnstaedt Date: Sun, 14 May 2023 10:15:33 +0200 Subject: [PATCH] Fix deprecation warnings The proposed "addAction()" with the KeySequence as 2nd argument is only available soince Qt6.3 and not compatible with QT5 Change the call in a compatible way and set the shortcut afterwards. --- lib/func.cpp | 2 +- lib/pki_evp.cpp | 10 +++++----- lib/pki_key.cpp | 4 ++-- lib/pki_temp.cpp | 12 ++++++------ widgets/MW_menu.cpp | 32 ++++++++++++++++++-------------- widgets/XcaTreeView.cpp | 14 +++++++------- 6 files changed, 39 insertions(+), 35 deletions(-) diff --git a/lib/func.cpp b/lib/func.cpp index d930e9b6..cbc63dc7 100644 --- a/lib/func.cpp +++ b/lib/func.cpp @@ -492,7 +492,7 @@ void *d2i_bytearray(void *(*d2i)(void *, unsigned char **, long), unsigned char *p, *p1; void *ret; p = p1 = (unsigned char *)ba.constData(); - ret = d2i(NULL, &p1, ba.count()); + ret = d2i(NULL, &p1, ba.size()); ba = ba.mid(p1-p); openssl_error(); return ret; diff --git a/lib/pki_evp.cpp b/lib/pki_evp.cpp index 98edb19e..76a3865e 100644 --- a/lib/pki_evp.cpp +++ b/lib/pki_evp.cpp @@ -349,7 +349,7 @@ EVP_PKEY *pki_evp::load_ssh_ed25519_privatekey(const QByteArray &ba, pub = ssh_key_next_chunk(&content); ssh_key_check_chunk(&pub, "ssh-ed25519"); pub = ssh_key_next_chunk(&pub); - if (pub.count() != ED25519_KEYLEN) + if (pub.size() != ED25519_KEYLEN) return NULL; // Followed by the private key @@ -364,7 +364,7 @@ EVP_PKEY *pki_evp::load_ssh_ed25519_privatekey(const QByteArray &ba, return NULL; priv = ssh_key_next_chunk(&priv); // The private key is concatenated by the public key in one chunk - if (priv.count() != 2 * ED25519_KEYLEN) + if (priv.size() != 2 * ED25519_KEYLEN) return NULL; // The last ED25519_KEYLEN bytes must match the public key if (pub != priv.mid(ED25519_KEYLEN)) @@ -487,8 +487,8 @@ EVP_PKEY *pki_evp::decryptKey() const } } QByteArray myencKey = getEncKey(); - qDebug() << "myencKey.count()"< 0 || !sqlItemId.isValid()) + if (encKey.size() > 0 || !sqlItemId.isValid()) return encKey; SQL_PREPARE(q, "SELECT private FROM private_keys WHERE item=?"); diff --git a/lib/pki_key.cpp b/lib/pki_key.cpp index 2ed8e469..e3c82ddc 100644 --- a/lib/pki_key.cpp +++ b/lib/pki_key.cpp @@ -73,7 +73,7 @@ void pki_key::d2i_old(QByteArray &ba, int type) { const unsigned char *p, *p1; p = p1 = (const unsigned char *)ba.constData(); - EVP_PKEY *k = d2i_PublicKey(type, NULL, &p1, ba.count()); + EVP_PKEY *k = d2i_PublicKey(type, NULL, &p1, ba.size()); pki_openssl_error(); @@ -661,7 +661,7 @@ EVP_PKEY *pki_key::load_ssh2_key(const QByteArray &b) ssh_key_check_chunk(&ba, "ssh-ed25519"); QByteArray pub = ssh_key_next_chunk(&ba); pk = EVP_PKEY_new_raw_public_key(EVP_PKEY_ED25519, NULL, - (const unsigned char *)pub.constData(), pub.count()); + (const unsigned char *)pub.constData(), pub.size()); pki_openssl_error(); #endif #endif diff --git a/lib/pki_temp.cpp b/lib/pki_temp.cpp index cf09a001..0f3950bd 100644 --- a/lib/pki_temp.cpp +++ b/lib/pki_temp.cpp @@ -27,7 +27,7 @@ namespace db { uint32_t intFromData(QByteArray &ba) { uint32_t ret; - if ((unsigned)(ba.count()) < sizeof(uint32_t)) { + if ((unsigned)(ba.size()) < sizeof(uint32_t)) { throw errorEx(QObject::tr("Out of data")); } memcpy(&ret, ba.constData(), sizeof(uint32_t)); @@ -37,7 +37,7 @@ namespace db { bool boolFromData(QByteArray &ba) { unsigned char c; - if (ba.count() < 1) + if (ba.size() < 1) throw errorEx(QObject::tr("Out of data")); c = ba.constData()[0]; @@ -307,7 +307,7 @@ static QString old_eKeyUse2QString(int old) { QStringList sl; - for (int i = 0; i < extkeyuse_nid.count(); i++) { + for (int i = 0; i < extkeyuse_nid.size(); i++) { if (old & (1< 0) { - my_error(tr("Wrong Size %1").arg(ba.count())); + if (ba.size() > 0) { + my_error(tr("Wrong Size %1").arg(ba.size())); } } @@ -418,7 +418,7 @@ QByteArray pki_temp::toExportData() const { QByteArray data, header; data = toData(); - header = db::intToData(data.count()); + header = db::intToData(data.size()); header += db::intToData(TMPL_VERSION); header += data; return header; diff --git a/widgets/MW_menu.cpp b/widgets/MW_menu.cpp index a6eac38f..79c3e97c 100644 --- a/widgets/MW_menu.cpp +++ b/widgets/MW_menu.cpp @@ -98,20 +98,24 @@ void MainWindow::init_menu() languageMenu->addAction(a); } file = menuBar()->addMenu(tr("&File")); - file->addAction(tr("New DataBase"), this, SLOT(new_database()), - QKeySequence::New) - ->setEnabled(OpenDb::hasSqLite()); - file->addAction(tr("Open DataBase"), this, SLOT(load_database()), - QKeySequence::Open) - ->setEnabled(OpenDb::hasSqLite()); + + a = file->addAction(tr("New DataBase"), this, SLOT(new_database())); + a->setShortcut(QKeySequence::New); + a->setEnabled(OpenDb::hasSqLite()); + + a = file->addAction(tr("Open DataBase"), this, SLOT(load_database())); + a->setShortcut(QKeySequence::Open); + a->setEnabled(OpenDb::hasSqLite()); + file->addAction(tr("Open Remote DataBase"), - this, SLOT(openRemoteSqlDB())) - ->setEnabled(OpenDb::hasRemoteDrivers()); + this, SLOT(openRemoteSqlDB()))-> + setEnabled(OpenDb::hasRemoteDrivers()); file->addMenu(historyMenu); file->addAction(tr("Set as default DataBase"), this, SLOT(default_database())); - acList += file->addAction(tr("Close DataBase"), this, - SLOT(close_database()), QKeySequence::Close); + a = file->addAction(tr("Close DataBase"), this, SLOT(close_database())); + a->setShortcut(QKeySequence::Close); + acList += a; a = new QAction(tr("Options"), this); connect(a, SIGNAL(triggered()), this, SLOT(setOptions())); @@ -137,8 +141,8 @@ void MainWindow::init_menu() import->addAction(tr("Template"), tempView, SLOT(load()) ); import->addAction(tr("Revocation list"), crlView, SLOT(load())); import->addAction(tr("PEM file"), this, SLOT(loadPem()) ); - import->addAction(tr("Paste PEM file"), this, SLOT(pastePem()), - QKeySequence::Paste); + import->addAction(tr("Paste PEM file"), this, SLOT(pastePem()))-> + setShortcut(QKeySequence::Paste); token = menuBar()->addMenu(tr("Token")); token->addAction(tr("&Manage Security token"), this, @@ -170,8 +174,8 @@ void MainWindow::init_menu() extra->addAction(tr("OID Resolver"), resolver, SLOT(show())); help = menuBar()->addMenu(tr("&Help") ); - help->addAction(tr("Content"), helpdlg, SLOT(content()), - QKeySequence::HelpContents); + help->addAction(tr("Content"), helpdlg, SLOT(content()))-> + setShortcut(QKeySequence::HelpContents); a = new QAction(tr("About"), this); connect(a, SIGNAL(triggered()), this, SLOT(about())); a->setMenuRole(QAction::AboutRole); diff --git a/widgets/XcaTreeView.cpp b/widgets/XcaTreeView.cpp index ad13c9d7..fda07292 100644 --- a/widgets/XcaTreeView.cpp +++ b/widgets/XcaTreeView.cpp @@ -498,21 +498,21 @@ void XcaTreeView::showContextMenu(QContextMenuEvent *e, index = idx.isValid() ? idx : currentIndex(); menu->addAction(tr("New"), this, SLOT(newItem())); menu->addAction(tr("Import"), this, SLOT(load())); - menu->addAction(tr("Paste PEM data"), mainwin, SLOT(pastePem()), - QKeySequence::Paste); + menu->addAction(tr("Paste PEM data"), mainwin, SLOT(pastePem()))-> + setShortcut(QKeySequence::Paste); if (indexes.size() == 1) { menu->addAction(tr("Rename"), this, SLOT(editIdx())); menu->addAction(tr("Properties"), this, SLOT(editComment())); } if (indexes.size() > 0) { - menu->addAction(tr("Delete"), this, SLOT(deleteItems()), - QKeySequence::Delete); + menu->addAction(tr("Delete"), this, SLOT(deleteItems()))-> + setShortcut(QKeySequence::Delete); subExport = menu->addMenu(tr("Export")); subExport->addAction(tr("Clipboard"), this, - SLOT(pem2clipboard()), QKeySequence::Copy); - subExport->addAction(tr("File"), this, SLOT(exportItems()), - QKeySequence::Save); + SLOT(pem2clipboard()))->setShortcut(QKeySequence::Copy); + subExport->addAction(tr("File"), this, SLOT(exportItems()))-> + setShortcut(QKeySequence::Save); } fillContextMenu(menu, subExport, index, indexes);