[network/ruqola] /: Prepare to use TextAddonsWidgets::TextAddonsWidgetFlowLayout

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 01ebefa7e37854f57c681245c05bfb1a962d8185 by Laurent Montel.
Committed on 17/07/2026 at 19:31.
Pushed by mlaurent into branch 'master'.

Prepare to use TextAddonsWidgets::TextAddonsWidgetFlowLayout

M  +3    -0    CMakeLists.txt
M  +1    -0    config-ruqola.h.in
M  +12   -1    src/widgets/common/flowlayout.cpp
M  +14   -0    src/widgets/common/flowlayout.h

https://invent.kde.org/network/ruqola/-/commit/01ebefa7e37854f57c681245c05bfb1a962d8185

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c455254a25..8a10defe83 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -322,6 +322,9 @@ set_package_properties(
         TYPE
             REQUIRED
 )
+if(${KF6TextAddonsWidgets_VERSION} VERSION_GREATER_EQUAL 2.1.41)
+    set(HAVE_TEXTADDONSWIDGETS_FLOWLAYOUT TRUE)
+endif()
 
 # shall we use DBus?
 # enabled per default on Linux & BSD systems
diff --git a/config-ruqola.h.in b/config-ruqola.h.in
index e19dc85575..df51e07dcf 100644
--- a/config-ruqola.h.in
+++ b/config-ruqola.h.in
@@ -22,3 +22,4 @@
 #cmakedefine01 RUQOLA_STABLE_VERSION
 #cmakedefine01 HAVE_TEXT_AUTOGENERATE_TEXT
 #cmakedefine01 ADD_OFFLINE_SUPPORT
+#cmakedefine01 HAVE_TEXTADDONSWIDGETS_FLOWLAYOUT
diff --git a/src/widgets/common/flowlayout.cpp b/src/widgets/common/flowlayout.cpp
index ff511931f7..b60a72391a 100644
--- a/src/widgets/common/flowlayout.cpp
+++ b/src/widgets/common/flowlayout.cpp
@@ -9,6 +9,17 @@
 #include <QStyle>
 #include <QWidget>
 
+#if HAVE_TEXTADDONSWIDGETS_FLOWLAYOUT
+FlowLayout::FlowLayout(QWidget *parent)
+    : TextAddonsWidgets::TextAddonsWidgetFlowLayout(parent)
+{
+}
+
+FlowLayout::~FlowLayout()
+{
+    clearAndDeleteWidgets();
+}
+#else
 static int smartSpacing(QObject *parent, QStyle::PixelMetric pm)
 {
     if (!parent) {
@@ -196,5 +207,5 @@ int FlowLayout::doFlow(QRect rect, bool effective) const
 
     return y + highest - rect.y() + margins.bottom();
 }
-
+#endif
 #include "moc_flowlayout.cpp"
diff --git a/src/widgets/common/flowlayout.h b/src/widgets/common/flowlayout.h
index d67552ae59..e6fe37ca6a 100644
--- a/src/widgets/common/flowlayout.h
+++ b/src/widgets/common/flowlayout.h
@@ -4,10 +4,23 @@
    SPDX-License-Identifier: LGPL-2.0-or-later
 */
 #pragma once
+#include "config-ruqola.h"
 #include "libruqolawidgets_export.h"
 #include <QLayout>
 #include <QList>
+// TODO remove when we depend against ktextaddons 2.1.2
+#if HAVE_TEXTADDONSWIDGETS_FLOWLAYOUT
+#include <TextAddonsWidgets/TextAddonsWidgetFlowLayout>
+class LIBRUQOLAWIDGETS_EXPORT FlowLayout : public TextAddonsWidgets::TextAddonsWidgetFlowLayout
+{
+    Q_OBJECT
+
+public:
+    explicit FlowLayout(QWidget *parent = nullptr);
+    ~FlowLayout() override;
+};
 
+#else
 class LIBRUQOLAWIDGETS_EXPORT FlowLayout : public QLayout
 {
     Q_OBJECT
@@ -45,3 +58,4 @@ private:
     int mHorizontalSpacing = -1;
     int mVerticalSpacing = -1;
 };
+#endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.