add back Qt5

This commit is contained in:
Le Tan 2023-09-27 23:23:36 +08:00
parent 2f6afb2f97
commit 853e9c08e0
8 changed files with 36 additions and 4 deletions

@ -1 +1 @@
Subproject commit 7fc093c14e8bc4b8f9203f81499ddd993b707906
Subproject commit 6fe9338d459b016877ebc2d65819e8171ab03659

View File

@ -2,9 +2,13 @@ lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5 and above")
equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 12): error("requires Qt 5.12 and above")
QT += core gui widgets webenginewidgets webchannel network svg printsupport core5compat
QT += core gui widgets webenginewidgets webchannel network svg printsupport
QT += sql
greaterThan(QT_MAJOR_VERSION, 5) {
QT += core5compat
}
CONFIG -= qtquickcompiler
unix:!mac:exists(/usr/bin/ld.gold) {

View File

@ -70,7 +70,12 @@ QChar Utils::keyToChar(int p_key, bool p_lowerCase)
QString Utils::pickAvailableFontFamily(const QStringList &p_families)
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
auto availableFonts = QFontDatabase().families();
#else
auto availableFonts = QFontDatabase::families();
#endif
for (const auto& f : p_families) {
auto family = f.trimmed();
if (family.isEmpty()) {

View File

@ -1,4 +1,8 @@
QT += widgets svg core5compat
QT += widgets svg
greaterThan(QT_MAJOR_VERSION, 5) {
QT += core5compat
}
SOURCES += \
$$PWD/asyncworker.cpp \

View File

@ -108,7 +108,12 @@ void MarkdownViewer::setPreviewHelper(PreviewHelper *p_previewHelper)
void MarkdownViewer::contextMenuEvent(QContextMenuEvent *p_event)
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QScopedPointer<QMenu> menu(page()->createStandardContextMenu());
#else
QScopedPointer<QMenu> menu(createStandardContextMenu());
#endif
const QList<QAction *> actions = menu->actions();
#if defined(Q_OS_WIN)

View File

@ -395,9 +395,11 @@ void MarkdownViewWindow::setupTextEditor()
connect(m_editor, &MarkdownEditor::applySnippetRequested,
this, QOverload<>::of(&MarkdownViewWindow::applySnippet));
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
connect(m_viewer, &MarkdownViewer::printFinished,
this, &MarkdownViewWindow::onPrintFinished);
#endif
}
QStackedWidget *MarkdownViewWindow::getMainStatusWidget() const
@ -1407,8 +1409,12 @@ void MarkdownViewWindow::print()
m_printer = PrintUtils::promptForPrint(m_viewer->hasSelection(), this);
if (m_printer)
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_viewer->page()->print(m_printer.data(), std::bind(&MarkdownViewWindow::onPrintFinished, this, std::placeholders::_1));
#else
m_printer->setOutputFormat(QPrinter::PdfFormat);
m_viewer->print(m_printer.get());
#endif
}
}

View File

@ -99,7 +99,11 @@ void TitleBar::setupActionButtons(TitleBar::Actions p_actionFlags)
}
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void TitleBar::enterEvent(QEvent *p_event)
#else
void TitleBar::enterEvent(QEnterEvent *p_event)
#endif
{
QFrame::enterEvent(p_event);
setActionButtonsVisible(true);

View File

@ -53,7 +53,11 @@ namespace vnotex
void setActionButtonsAlwaysShown(bool p_shown);
protected:
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEvent *p_event) Q_DECL_OVERRIDE;
#else
void enterEvent(QEnterEvent *p_event) Q_DECL_OVERRIDE;
#endif
void leaveEvent(QEvent *p_event) Q_DECL_OVERRIDE;