diff --git a/src/kiwixapp.cpp b/src/kiwixapp.cpp index 1e06755..bdf00d6 100644 --- a/src/kiwixapp.cpp +++ b/src/kiwixapp.cpp @@ -216,21 +216,17 @@ void KiwixApp::printPage() if(!webview) return; + const auto onPrintFinished = [=](bool success) { + if (!success) { + showMessage(gt("print-page-error"), gt("error-title"), QMessageBox::Critical); + } + delete printer; + }; #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - webview->page()->print(printer, [=](bool success) { - if (!success) { - showMessage(gt("print-page-error"), gt("error-title"), QMessageBox::Critical); - } - delete printer; - }); + webview->page()->print(printer, onPrintFinished); #else webview->print(printer); - connect(webview, &QWebEngineView::printFinished, this, [=](bool success) { - if (!success) { - showMessage(gt("print-page-error"), gt("error-title"), QMessageBox::Critical); - } - delete printer; - }); + connect(webview, &QWebEngineView::printFinished, this, onPrintFinished); #endif } } diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index 5681d2a..f83165b 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -150,15 +150,21 @@ void SettingsManager::initSettings() m_moveToTrash = m_settings.value("moveToTrash", true).toBool(); QString defaultLang = QLocale::languageToString(QLocale().language()) + '|' + QLocale().name().split("_").at(0); - QList defaultLangList; // Qt5 QList doesn't support supplying a constructor list, so use append() for Qt5+Qt6 compat + /* + * Qt5 & Qt6 have slightly different behaviors with regards to initializing QVariant. + * The below approach is specifically chosen to work with both versions. + * m_langList initialized with defaultLang should be of the form: + * + * (QVariant(QString, "English|en")) + * + * and not + * + * QList(QVariant(QChar, 'E'), QVariant(QChar, 'n'), QVariant(QChar, 'g'), ... + */ + QList defaultLangList; // Qt5 QList doesn't support supplying a constructor list defaultLangList.append(defaultLang); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QVariant defaultLangVariant(defaultLangList); // Qt5 requires explicit conversion from QList to QVariant + QVariant defaultLangVariant(defaultLangList); m_langList = m_settings.value("language", defaultLangVariant).toList(); -#else - m_langList = m_settings.value("language", defaultLangList).toList(); -#endif m_categoryList = m_settings.value("category", {}).toList(); m_contentTypeList = m_settings.value("contentType", {}).toList(); diff --git a/subprojects/QtSingleApplication/src/qtlockedfile.h b/subprojects/QtSingleApplication/src/qtlockedfile.h index 0f6b2bd..84c18e5 100644 --- a/subprojects/QtSingleApplication/src/qtlockedfile.h +++ b/subprojects/QtSingleApplication/src/qtlockedfile.h @@ -66,9 +66,6 @@ namespace QtLP_Private { class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile { - //Q_OBJECT - // TODO: Uncomment Q_OBJECT. Setting Q_OBJECT here causes this error: - // undefined reference to `vtable for QtLP_Private::QtLockedFile' public: enum LockMode { NoLock = 0, ReadLock, WriteLock };