knotes: fix build
This commit is contained in:
parent
543e31c80b
commit
d768d4951b
@ -0,0 +1,186 @@
|
||||
From 1a6190def780440587084811c35c1f7cae3b4eff Mon Sep 17 00:00:00 2001
|
||||
From: Laurent Montel <montel@kde.org>
|
||||
Date: Sun, 23 Apr 2023 15:36:08 +0200
|
||||
Subject: [PATCH] Adapt to build against last textaddons
|
||||
|
||||
---
|
||||
CMakeLists.txt | 11 +++++++-
|
||||
noteshared/src/CMakeLists.txt | 7 ++++-
|
||||
noteshared/src/config-noshared.h.in | 7 +++++
|
||||
.../widget/richtexteditwithautocorrection.cpp | 26 +++++++++++++++++++
|
||||
.../widget/richtexteditwithautocorrection.h | 11 ++++++++
|
||||
5 files changed, 60 insertions(+), 2 deletions(-)
|
||||
create mode 100644 noteshared/src/config-noshared.h.in
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 5e0cd817..e89e0781 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -115,7 +115,16 @@ find_package(KPim${KF_MAJOR_VERSION}PimCommonAkonadi ${PIMCOMMON_LIB_VERSION} CO
|
||||
find_package(KPim${KF_MAJOR_VERSION}TextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED)
|
||||
find_package(KPim${KF_MAJOR_VERSION}GrantleeTheme ${GRANTLEETHEME_LIB_VERSION} CONFIG REQUIRED)
|
||||
|
||||
-find_package(KF${KF_MAJOR_VERSION}TextAutoCorrection ${KTEXTADDONS_MIN_VERSION} CONFIG REQUIRED)
|
||||
+find_package(KF${KF_MAJOR_VERSION}TextAutoCorrectionWidgets ${KTEXTADDONS_MIN_VERSION} CONFIG)
|
||||
+set_package_properties(KF${KF_MAJOR_VERSION}TextAutoCorrectionWidgets PROPERTIES DESCRIPTION
|
||||
+ "Add support for text auto correction"
|
||||
+ TYPE OPTIONAL
|
||||
+)
|
||||
+if (TARGET KF${KF_MAJOR_VERSION}::TextAutoCorrectionWidgets)
|
||||
+ set(HAVE_TEXT_AUTOCORRECTION_WIDGETS TRUE)
|
||||
+else()
|
||||
+ find_package(KF${KF_MAJOR_VERSION}TextAutoCorrection ${KTEXTADDONS_MIN_VERSION} CONFIG REQUIRED)
|
||||
+endif()
|
||||
|
||||
find_package(KPim${KF_MAJOR_VERSION}AkonadiSearch ${AKONADI_SEARCH_VERSION} CONFIG REQUIRED)
|
||||
set_package_properties(KPim${KF_MAJOR_VERSION}AkonadiSearch PROPERTIES DESCRIPTION "The Akonadi Search libraries" URL "https://invent.kde.org/pim/akonadi-search" TYPE REQUIRED PURPOSE "Provides search capabilities in pim apps and Akonadi")
|
||||
diff --git a/noteshared/src/CMakeLists.txt b/noteshared/src/CMakeLists.txt
|
||||
index c3bd6dc4..49ec63be 100644
|
||||
--- a/noteshared/src/CMakeLists.txt
|
||||
+++ b/noteshared/src/CMakeLists.txt
|
||||
@@ -2,6 +2,7 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
add_definitions(-DTRANSLATION_DOMAIN=\"libnoteshared\")
|
||||
+configure_file(config-noshared.h.in ${CMAKE_CURRENT_BINARY_DIR}/config-noshared.h)
|
||||
|
||||
|
||||
set(libnoteshared_SRCS
|
||||
@@ -99,7 +100,11 @@ target_link_libraries(notesharedprivate
|
||||
if (TARGET Qt::Core5Compat)
|
||||
target_link_libraries(notesharedprivate PRIVATE Qt::Core5Compat)
|
||||
endif()
|
||||
- target_link_libraries(notesharedprivate PRIVATE KF${KF_MAJOR_VERSION}::TextAutoCorrection)
|
||||
+ if (TARGET KF${KF_MAJOR_VERSION}::TextAutoCorrectionWidgets)
|
||||
+ target_link_libraries(notesharedprivate PRIVATE KF${KF_MAJOR_VERSION}::TextAutoCorrectionWidgets)
|
||||
+ else()
|
||||
+ target_link_libraries(notesharedprivate PRIVATE KF${KF_MAJOR_VERSION}::TextAutoCorrection)
|
||||
+ endif()
|
||||
|
||||
set_target_properties(notesharedprivate
|
||||
PROPERTIES VERSION ${KDEPIM_LIB_VERSION} SOVERSION ${KDEPIM_LIB_SOVERSION}
|
||||
diff --git a/noteshared/src/config-noshared.h.in b/noteshared/src/config-noshared.h.in
|
||||
new file mode 100644
|
||||
index 00000000..2f9f3f8e
|
||||
--- /dev/null
|
||||
+++ b/noteshared/src/config-noshared.h.in
|
||||
@@ -0,0 +1,7 @@
|
||||
+/*
|
||||
+SPDX-License-Identifier: CC0-1.0
|
||||
+SPDX-FileCopyrightText: none
|
||||
+*/
|
||||
+#pragma once
|
||||
+
|
||||
+#cmakedefine01 HAVE_TEXT_AUTOCORRECTION_WIDGETS
|
||||
diff --git a/noteshared/src/widget/richtexteditwithautocorrection.cpp b/noteshared/src/widget/richtexteditwithautocorrection.cpp
|
||||
index 8d42e2fd..2e51782f 100644
|
||||
--- a/noteshared/src/widget/richtexteditwithautocorrection.cpp
|
||||
+++ b/noteshared/src/widget/richtexteditwithautocorrection.cpp
|
||||
@@ -5,7 +5,12 @@
|
||||
*/
|
||||
|
||||
#include "richtexteditwithautocorrection.h"
|
||||
+
|
||||
+#ifdef HAVE_TEXT_AUTOCORRECTION_WIDGETS
|
||||
+#include <TextAutoCorrectionCore/AutoCorrection>
|
||||
+#else
|
||||
#include <TextAutoCorrection/AutoCorrection>
|
||||
+#endif
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
@@ -15,7 +20,11 @@ class NoteShared::RichTextEditWithAutoCorrectionPrivate
|
||||
{
|
||||
public:
|
||||
RichTextEditWithAutoCorrectionPrivate()
|
||||
+#ifdef HAVE_TEXT_AUTOCORRECTION_WIDGETS
|
||||
+ : mAutoCorrection(new TextAutoCorrectionCore::AutoCorrection())
|
||||
+#else
|
||||
: mAutoCorrection(new TextAutoCorrection::AutoCorrection())
|
||||
+#endif
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,7 +34,11 @@ class NoteShared::RichTextEditWithAutoCorrectionPrivate
|
||||
delete mAutoCorrection;
|
||||
}
|
||||
}
|
||||
+#ifdef HAVE_TEXT_AUTOCORRECTION_WIDGETS
|
||||
+ TextAutoCorrectionCore::AutoCorrection *mAutoCorrection = nullptr;
|
||||
+#else
|
||||
TextAutoCorrection::AutoCorrection *mAutoCorrection = nullptr;
|
||||
+#endif
|
||||
bool mNeedToDelete = true;
|
||||
};
|
||||
|
||||
@@ -36,21 +49,34 @@ RichTextEditWithAutoCorrection::RichTextEditWithAutoCorrection(QWidget *parent)
|
||||
}
|
||||
|
||||
RichTextEditWithAutoCorrection::~RichTextEditWithAutoCorrection() = default;
|
||||
+
|
||||
+#ifdef HAVE_TEXT_AUTOCORRECTION_WIDGETS
|
||||
+void RichTextEditWithAutoCorrection::setAutocorrection(TextAutoCorrectionCore::AutoCorrection *autocorrect)
|
||||
+#else
|
||||
void RichTextEditWithAutoCorrection::setAutocorrection(TextAutoCorrection::AutoCorrection *autocorrect)
|
||||
+#endif
|
||||
{
|
||||
d->mNeedToDelete = false;
|
||||
delete d->mAutoCorrection;
|
||||
d->mAutoCorrection = autocorrect;
|
||||
}
|
||||
|
||||
+#ifdef HAVE_TEXT_AUTOCORRECTION_WIDGETS
|
||||
+TextAutoCorrectionCore::AutoCorrection *RichTextEditWithAutoCorrection::autocorrection() const
|
||||
+#else
|
||||
TextAutoCorrection::AutoCorrection *RichTextEditWithAutoCorrection::autocorrection() const
|
||||
+#endif
|
||||
{
|
||||
return d->mAutoCorrection;
|
||||
}
|
||||
|
||||
void RichTextEditWithAutoCorrection::setAutocorrectionLanguage(const QString &language)
|
||||
{
|
||||
+#ifdef HAVE_TEXT_AUTOCORRECTION_WIDGETS
|
||||
+ TextAutoCorrectionCore::AutoCorrectionSettings *settings = d->mAutoCorrection->autoCorrectionSettings();
|
||||
+#else
|
||||
TextAutoCorrection::AutoCorrectionSettings *settings = d->mAutoCorrection->autoCorrectionSettings();
|
||||
+#endif
|
||||
settings->setLanguage(language);
|
||||
d->mAutoCorrection->setAutoCorrectionSettings(settings);
|
||||
}
|
||||
diff --git a/noteshared/src/widget/richtexteditwithautocorrection.h b/noteshared/src/widget/richtexteditwithautocorrection.h
|
||||
index 9ad9ec4e..787350d8 100644
|
||||
--- a/noteshared/src/widget/richtexteditwithautocorrection.h
|
||||
+++ b/noteshared/src/widget/richtexteditwithautocorrection.h
|
||||
@@ -6,11 +6,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
+#include "config-noshared.h"
|
||||
#include <KPIMTextEdit/RichTextEditor>
|
||||
+#ifdef HAVE_TEXT_AUTOCORRECTION_WIDGETS
|
||||
+namespace TextAutoCorrectionCore
|
||||
+#else
|
||||
namespace TextAutoCorrection
|
||||
+#endif
|
||||
{
|
||||
class AutoCorrection;
|
||||
}
|
||||
+
|
||||
namespace NoteShared
|
||||
{
|
||||
class RichTextEditWithAutoCorrectionPrivate;
|
||||
@@ -25,8 +31,13 @@ class RichTextEditWithAutoCorrection : public KPIMTextEdit::RichTextEditor
|
||||
explicit RichTextEditWithAutoCorrection(QWidget *parent = nullptr);
|
||||
~RichTextEditWithAutoCorrection() override;
|
||||
|
||||
+#ifdef HAVE_TEXT_AUTOCORRECTION_WIDGETS
|
||||
+ Q_REQUIRED_RESULT TextAutoCorrectionCore::AutoCorrection *autocorrection() const;
|
||||
+ void setAutocorrection(TextAutoCorrectionCore::AutoCorrection *autocorrect);
|
||||
+#else
|
||||
Q_REQUIRED_RESULT TextAutoCorrection::AutoCorrection *autocorrection() const;
|
||||
void setAutocorrection(TextAutoCorrection::AutoCorrection *autocorrect);
|
||||
+#endif
|
||||
|
||||
void setAutocorrectionLanguage(const QString &language);
|
||||
|
Loading…
Reference in New Issue
Block a user