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)
|
if(!webview)
|
||||||
return;
|
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)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
webview->page()->print(printer, [=](bool success) {
|
webview->page()->print(printer, onPrintFinished);
|
||||||
if (!success) {
|
|
||||||
showMessage(gt("print-page-error"), gt("error-title"), QMessageBox::Critical);
|
|
||||||
}
|
|
||||||
delete printer;
|
|
||||||
});
|
|
||||||
#else
|
#else
|
||||||
webview->print(printer);
|
webview->print(printer);
|
||||||
connect(webview, &QWebEngineView::printFinished, this, [=](bool success) {
|
connect(webview, &QWebEngineView::printFinished, this, onPrintFinished);
|
||||||
if (!success) {
|
|
||||||
showMessage(gt("print-page-error"), gt("error-title"), QMessageBox::Critical);
|
|
||||||
}
|
|
||||||
delete printer;
|
|
||||||
});
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,15 +150,21 @@ void SettingsManager::initSettings()
|
|||||||
m_moveToTrash = m_settings.value("moveToTrash", true).toBool();
|
m_moveToTrash = m_settings.value("moveToTrash", true).toBool();
|
||||||
QString defaultLang = QLocale::languageToString(QLocale().language()) + '|' + QLocale().name().split("_").at(0);
|
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);
|
defaultLangList.append(defaultLang);
|
||||||
|
QVariant defaultLangVariant(defaultLangList);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
QVariant defaultLangVariant(defaultLangList); // Qt5 requires explicit conversion from QList to QVariant
|
|
||||||
m_langList = m_settings.value("language", defaultLangVariant).toList();
|
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_categoryList = m_settings.value("category", {}).toList();
|
||||||
m_contentTypeList = m_settings.value("contentType", {}).toList();
|
m_contentTypeList = m_settings.value("contentType", {}).toList();
|
||||||
|
@ -66,9 +66,6 @@ namespace QtLP_Private {
|
|||||||
|
|
||||||
class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile
|
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:
|
public:
|
||||||
enum LockMode { NoLock = 0, ReadLock, WriteLock };
|
enum LockMode { NoLock = 0, ReadLock, WriteLock };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user