From dc1816f023f955f858b3b6aaba030d0dd02ca41d Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 9 Jul 2026 11:26:10 +0200 Subject: [PATCH] gui: fix Qt5/KF5 compatibility - Remove placeholderText from QML palette block (not available in Qt5) - Use theme.placeholderTextColor directly instead of palette.placeholderText - Add Qt version guards for QFontDatabase static vs instance API - Add Qt version guard for QVariant::typeId vs QVariant::type - Link KF5::ConfigCore for ollie-gui KF5 build --- CMakeLists.txt | 1 + gui/main-kf5.qml | 3 +-- gui/main.cpp | 4 ++++ gui/thememanager.cpp | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9095a67..9338bc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,7 @@ if(OLLIE_KF5) Qt5::Quick Qt5::Qml Qt5::QuickControls2 + KF5::ConfigCore ) # --- Install --- diff --git a/gui/main-kf5.qml b/gui/main-kf5.qml index ea075df..44bbd6b 100644 --- a/gui/main-kf5.qml +++ b/gui/main-kf5.qml @@ -29,7 +29,6 @@ ApplicationWindow { dark: theme.darkColor light: theme.lightColor shadow: theme.shadowColor - placeholderText: theme.placeholderTextColor } // --- Settings Dialog --- @@ -371,7 +370,7 @@ ApplicationWindow { ? "(waiting for output...)" : "Select or create a session") font.family: "monospace" - color: dbus.chatText ? palette.text : palette.placeholderText + color: dbus.chatText ? palette.text : theme.placeholderTextColor background: null onTextChanged: { diff --git a/gui/main.cpp b/gui/main.cpp index 4f0fdab..287cb50 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -19,7 +19,11 @@ static QIcon makeBrainIcon() // Fallback: render FA6 brain glyph from installed font QFont fa("Font Awesome 6 Free Solid"); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (!QFontDatabase::hasFamily("Font Awesome 6 Free Solid")) { +#else + if (!QFontDatabase().families().contains("Font Awesome 6 Free Solid")) { +#endif fa = QFont("Font Awesome 6 Free"); fa.setWeight(QFont::Black); } diff --git a/gui/thememanager.cpp b/gui/thememanager.cpp index fc82719..bffaa7d 100644 --- a/gui/thememanager.cpp +++ b/gui/thememanager.cpp @@ -242,7 +242,11 @@ QPalette ThemeManager::paletteFromScheme(const QString &path) const QColor ThemeManager::parseColor(const QVariant &value) const { QStringList parts; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (value.typeId() == QMetaType::QStringList) { +#else + if (value.type() == QVariant::StringList) { +#endif parts = value.toStringList(); } else { parts = value.toString().split(','); @@ -329,7 +333,11 @@ void ThemeManager::setFontStyle(const QString &style) QStringList ThemeManager::availableFamilies() const { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return QFontDatabase::families(); +#else + return QFontDatabase().families(); +#endif } QStringList ThemeManager::availableStyles() const @@ -337,7 +345,11 @@ QStringList ThemeManager::availableStyles() const QString family = m_fontFamily.isEmpty() ? QGuiApplication::font().family() : m_fontFamily; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return QFontDatabase::styles(family); +#else + return QFontDatabase().styles(family); +#endif } void ThemeManager::resetFont() @@ -372,8 +384,13 @@ void ThemeManager::applyFont() if (!m_fontStyle.isEmpty()) { // Use QFontDatabase to resolve style string to weight + italic QString family = m_fontFamily.isEmpty() ? font.family() : m_fontFamily; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QFont styled = QFontDatabase::font(family, m_fontStyle, m_fontSize > 0 ? m_fontSize : font.pointSize()); +#else + QFont styled = QFontDatabase().font(family, m_fontStyle, + m_fontSize > 0 ? m_fontSize : font.pointSize()); +#endif font.setWeight(styled.weight()); font.setItalic(styled.italic()); }