From 958f1e7fdca18da499dc8c72ffbe1fba9ed4878a Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Tue, 26 Jan 2016 18:40:59 +0100 Subject: [PATCH 3/3] Make KTextWidgets optional The textedit is only used in the bugreport widget. For a standalone application the added Features in there come at the cost of a dependency to KService. If it is optional a user of this library can decide if they want this. --- CMakeLists.txt | 9 ++++++++- src/CMakeLists.txt | 4 +++- src/config-xmlgui.h.cmake | 3 +++ src/kbugreport.cpp | 21 ++++++++++++++++++--- tests/CMakeLists.txt | 4 +++- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acb6037..dcaecc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,6 @@ find_package(KF5Config ${KF5_DEP_VERSION} REQUIRED) find_package(KF5ConfigWidgets ${KF5_DEP_VERSION} REQUIRED) find_package(KF5I18n ${KF5_DEP_VERSION} REQUIRED) find_package(KF5IconThemes ${KF5_DEP_VERSION} REQUIRED) -find_package(KF5TextWidgets ${KF5_DEP_VERSION} REQUIRED) find_package(KF5WidgetsAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5WindowSystem ${KF5_DEP_VERSION} REQUIRED) @@ -68,6 +67,14 @@ set_package_properties(KF5GlobalAccel PROPERTIES DESCRIPTION "A KDE Frameworks L ) set (HAVE_GLOBALACCEL ${KF5GlobalAccel_FOUND}) +find_package(KF5TextWidgets ${KF5_DEP_VERSION}) +set_package_properties(KF5TextWidgets PROPERTIES DESCRIPTION "Library for KDE integrated text editor widgets" + PURPOSE "KDE integration (e.g. Spell Checking) in bug report editor" + URL "https://projects.kde.org/projects/frameworks/ktextwidgets" + TYPE OPTIONAL + ) +set (HAVE_TEXTWIDGETS ${KF5TextWidgets_FOUND}) + # Subdirectories add_definitions(-DTRANSLATION_DOMAIN=\"kxmlgui5\") if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e849ab7..a4e9dd0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,6 +10,9 @@ if (HAVE_QDBUS) set (XMLGUI_QDBUS_LIBS Qt5::DBus) set (XMLGUI_DBUS_PRI_NAME "dbus") endif () +if (HAVE_TEXTWIDGETS) + set (XMLGUI_EXTRA_LIBS ${XMLGUI_EXTRA_LIBS} KF5::TextWidgets) # KTextEdit in kbugreport +endif() if(WIN32) set (XMLGUI_EXTRA_LIBS ${XMLGUI_EXTRA_LIBS} secur32) # GetUserNameEx() endif() @@ -99,7 +102,6 @@ PRIVATE KF5::ItemViews #KWidgetItemDelegate in KAboutApplicationPersonListDelegate KF5::I18n #i18n and i18nc in many places KF5::IconThemes #KIconLoader and KIconThemes in KToolBar - KF5::TextWidgets #KTextEdit in kbugreport KF5::WindowSystem #KKeyServer in kkeysequencewidget ${XMLGUI_EXTRA_LIBS} ) diff --git a/src/config-xmlgui.h.cmake b/src/config-xmlgui.h.cmake index 35c9477..0873a95 100644 --- a/src/config-xmlgui.h.cmake +++ b/src/config-xmlgui.h.cmake @@ -10,3 +10,6 @@ /* Qt5DBus available */ #cmakedefine01 HAVE_QDBUS + +/* KF5TextWidgets available */ +#cmakedefine01 HAVE_TEXTWIDGETS diff --git a/src/kbugreport.cpp b/src/kbugreport.cpp index f418dde..766b326 100644 --- a/src/kbugreport.cpp +++ b/src/kbugreport.cpp @@ -17,6 +17,8 @@ Boston, MA 02110-1301, USA. */ +#include "config-xmlgui.h" + #include "kbugreport.h" #include @@ -43,9 +45,14 @@ #include #include #include -#include #include +#if HAVE_TEXTWIDGETS +# include +#else +# include +#endif + #include "kdepackages.h" #include "../kxmlgui_version.h" #include "systeminformation_p.h" @@ -65,7 +72,11 @@ public: QProcess *m_process; KAboutData m_aboutData; +#if HAVE_TEXTWIDGETS KTextEdit *m_lineedit; +#else + QTextEdit *m_lineedit; +#endif QLineEdit *m_subject; QLabel *m_from; QLabel *m_version; @@ -263,12 +274,16 @@ KBugReport::KBugReport(const KAboutData &aboutData, QWidget *_parent) lay->addWidget(label); // The multiline-edit +#if HAVE_TEXTWIDGETS d->m_lineedit = new KTextEdit(this); + d->m_lineedit->setCheckSpellingEnabled(true); + d->m_lineedit->setSpellCheckingLanguage(QStringLiteral("en")); +#else + d->m_lineedit = new QTextEdit(this); +#endif d->m_lineedit->setMinimumHeight(180); // make it big d->m_lineedit->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); d->m_lineedit->setLineWrapMode(QTextEdit::WidgetWidth); - d->m_lineedit->setCheckSpellingEnabled(true); - d->m_lineedit->setSpellCheckingLanguage(QStringLiteral("en")); lay->addWidget(d->m_lineedit, 10 /*stretch*/); d->_k_slotSetFrom(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3a5a42f..9cc2e32 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,4 +22,6 @@ xmlgui_executable_tests( kwindowtest ) -add_subdirectory(krichtexteditor) +if (HAVE_TEXTWIDGETS) + add_subdirectory(krichtexteditor) +endif() -- 2.1.4