From 241284e1eefb6d4c404b38a210eb63ff6aa22db1 Mon Sep 17 00:00:00 2001
From: Lukas Holecek <hluk@email.cz>
Date: Sat, 10 Apr 2021 14:09:38 +0200
Subject: [PATCH] Fix build on Ubuntu 18.04 (gcc 7.5, Qt 5.9.5)
---
plugins/itemfakevim/fakevim/fakevimhandler.cpp | 16 ++++++++++++++++
plugins/itemfakevim/fakevim/utils/optional.h | 2 +-
src/gui/theme.cpp | 4 ++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/plugins/itemfakevim/fakevim/fakevimhandler.cpp b/plugins/itemfakevim/fakevim/fakevimhandler.cpp
index 9d0cecc3b..218c3c2dc 100644
--- a/plugins/itemfakevim/fakevim/fakevimhandler.cpp
+++ b/plugins/itemfakevim/fakevim/fakevimhandler.cpp
@@ -104,6 +104,10 @@
# define UNDO_DEBUG(s)
#endif
+#if QT_VERSION < QT_VERSION_CHECK(5,10,0)
+using QStringView = QStringRef;
+#endif
+
namespace FakeVim {
namespace Internal {
@@ -1510,7 +1514,11 @@ public:
m_buffer = s; m_pos = m_userPos = pos; m_anchor = anchor >= 0 ? anchor : pos;
}
+#if QT_VERSION < QT_VERSION_CHECK(5,10,0)
+ QStringRef userContents() const { return QStringRef(&m_buffer).left(m_userPos); }
+#else
QStringView userContents() const { return QStringView{m_buffer}.left(m_userPos); }
+#endif
const QChar &prompt() const { return m_prompt; }
const QString &contents() const { return m_buffer; }
bool isEmpty() const { return m_buffer.isEmpty(); }
@@ -2833,9 +2841,17 @@ void FakeVimHandler::Private::updateEditor()
void FakeVimHandler::Private::setTabSize(int tabSize)
{
+#if QT_VERSION >= QT_VERSION_CHECK(5,11,0)
const int charWidth = QFontMetrics(EDITOR(font())).horizontalAdvance(' ');
+#else
+ const int charWidth = QFontMetrics(EDITOR(font())).width(' ');
+#endif
const int width = charWidth * tabSize;
+#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
EDITOR(setTabStopDistance(width));
+#else
+ EDITOR(setTabStopWidth(width));
+#endif
}
void FakeVimHandler::Private::restoreWidget(int tabSize)
diff --git a/plugins/itemfakevim/fakevim/utils/optional.h b/plugins/itemfakevim/fakevim/utils/optional.h
index 9450b308e..a89e6cec8 100644
--- a/plugins/itemfakevim/fakevim/utils/optional.h
+++ b/plugins/itemfakevim/fakevim/utils/optional.h
@@ -35,7 +35,7 @@
// std::optional from Apple's Clang supports methods that throw std::bad_optional_access only
// with deployment target >= macOS 10.14
// TODO: Use std::optional everywhere when we can require macOS 10.14
-#if !defined(__apple_build_version__)
+#if !defined(__apple_build_version__) && __cpp_lib_optional >= 201603
#include <optional>
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 0d84cb057..740b695c9 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -63,7 +63,11 @@ QPalette::ColorRole defaultColorVarToRole(const QString &varName)
static QHash<QString, QPalette::ColorRole> map = {
{defaultColorVarBase, QPalette::Base},
{defaultColorVarText, QPalette::Text},
+#if QT_VERSION >= QT_VERSION_CHECK(5,12,0)
{defaultColorVarPlaceholderText, QPalette::PlaceholderText},
+#else
+ {defaultColorVarPlaceholderText, QPalette::AlternateBase},
+#endif
{defaultColorVarAlternateBase, QPalette::AlternateBase},
{defaultColorVarHighlight, QPalette::Highlight},
{defaultColorVarHighlightText, QPalette::HighlightedText},
--
GitLab