mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-08-03 20:56:49 -04:00
Clean up print duplication and conditional compilation
This commit is contained in:
parent
d842a288f7
commit
e543bbc446
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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<QString> 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<QString> 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();
|
||||
|
@ -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 };
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user