diff --git a/libs/vtextedit b/libs/vtextedit index 7fc093c1..6fe9338d 160000 --- a/libs/vtextedit +++ b/libs/vtextedit @@ -1 +1 @@ -Subproject commit 7fc093c14e8bc4b8f9203f81499ddd993b707906 +Subproject commit 6fe9338d459b016877ebc2d65819e8171ab03659 diff --git a/src/src.pro b/src/src.pro index e3e1dd1f..24548eb1 100644 --- a/src/src.pro +++ b/src/src.pro @@ -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) { diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index c93e5ded..97a875ed 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -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()) { diff --git a/src/utils/utils.pri b/src/utils/utils.pri index b53ebf30..e0081702 100644 --- a/src/utils/utils.pri +++ b/src/utils/utils.pri @@ -1,4 +1,8 @@ -QT += widgets svg core5compat +QT += widgets svg + +greaterThan(QT_MAJOR_VERSION, 5) { + QT += core5compat +} SOURCES += \ $$PWD/asyncworker.cpp \ diff --git a/src/widgets/editors/markdownviewer.cpp b/src/widgets/editors/markdownviewer.cpp index 0208e3a3..aca4c2e8 100644 --- a/src/widgets/editors/markdownviewer.cpp +++ b/src/widgets/editors/markdownviewer.cpp @@ -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 menu(page()->createStandardContextMenu()); +#else QScopedPointer menu(createStandardContextMenu()); +#endif + const QList actions = menu->actions(); #if defined(Q_OS_WIN) diff --git a/src/widgets/markdownviewwindow.cpp b/src/widgets/markdownviewwindow.cpp index 0c352c9d..7f53ae9b 100644 --- a/src/widgets/markdownviewwindow.cpp +++ b/src/widgets/markdownviewwindow.cpp @@ -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 } } diff --git a/src/widgets/titlebar.cpp b/src/widgets/titlebar.cpp index 124e7ff0..90813717 100644 --- a/src/widgets/titlebar.cpp +++ b/src/widgets/titlebar.cpp @@ -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); diff --git a/src/widgets/titlebar.h b/src/widgets/titlebar.h index 258f6baf..fd6ff83b 100644 --- a/src/widgets/titlebar.h +++ b/src/widgets/titlebar.h @@ -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;