Commit 458e7832 authored by Daan De Meyer's avatar Daan De Meyer

Refactor config.h handling.

- Use separate config.h files for kate and kwrite.
- Add `KWRITE_VERSION` for use in kwrite source code.
- Use the more widely used .in suffix for config.h templates instead of
the .cmake suffix which is primarily used by CMake script files.
- Rename `KActivities_FOUND` define to `KF5Activities_FOUND` so that
cmakedefine in config.h.in automatically picks it up when
`KF5Activities_FOUND` is set during CMake's configure stage.
- Remove config.h include from source files that don't need it.
parent f99afa4e
......@@ -59,16 +59,6 @@ find_package(KF5 "${KF5_DEP_VERSION}" COMPONENTS
DocTools
)
if (KF5Activities_FOUND)
add_definitions(-DKActivities_FOUND)
endif ()
# config.h
configure_file(config.h.cmake config.h)
# let our config.h be found first in any case
include_directories (BEFORE ${CMAKE_CURRENT_BINARY_DIR})
# Allow adding Qt resource files with `add_executable` or `target_sources` instead of
# `qt5_add_resources`. See https://cmake.org/cmake/help/v3.0/manual/cmake-qt.7.html#autorcc.
set(CMAKE_AUTORCC ON)
......
......@@ -6,6 +6,11 @@ project(kate)
# Load the frameworks we need
find_package(KF5 REQUIRED COMPONENTS DBusAddons GuiAddons)
configure_file(config.h.in config.h) # config.h
# Let our config.h be found first.
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
# includes
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
......
......@@ -5,6 +5,6 @@
#define KATE_VERSION "${KDE_APPLICATIONS_VERSION}"
#cmakedefine KActivities_FOUND 1
#cmakedefine KF5Activities_FOUND
#endif
......@@ -18,8 +18,6 @@
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "katepluginmanager.h"
#include "kateapp.h"
......
......@@ -21,6 +21,7 @@
//BEGIN Includes
#include "kateviewmanager.h"
#include "config.h"
#include "kateapp.h"
#include "katemainwindow.h"
#include "kateviewspace.h"
......@@ -39,9 +40,7 @@
#include <KLocalizedString>
#include <KXMLGUIFactory>
#include <config.h>
#ifdef KActivities_FOUND
#ifdef KF5Activities_FOUND
#include <KActivities/ResourceInstance>
#endif
......@@ -457,7 +456,7 @@ KTextEditor::View *KateViewManager::createView(KTextEditor::Document *doc, KateV
m_views[view].active = false;
m_views[view].lruAge = m_minAge--;
#ifdef KActivities_FOUND
#ifdef KF5Activities_FOUND
m_views[view].activityResource = new KActivities::ResourceInstance(view->window()->winId(), view);
m_views[view].activityResource->setUri(doc->url());
#endif
......@@ -649,7 +648,7 @@ void KateViewManager::activateView(KTextEditor::View *view)
emit viewChanged(view);
#ifdef KActivities_FOUND
#ifdef KF5Activities_FOUND
// inform activity manager
m_views[view].activityResource->setUri(view->document()->url());
m_views[view].activityResource->notifyFocusedIn();
......
......@@ -28,8 +28,6 @@
#include <QSplitter>
#include <QMap>
#include <config.h>
namespace KActivities
{
class ResourceInstance;
......
......@@ -18,8 +18,6 @@
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "katesessionmanager.h"
#include "katesessionmanagedialog.h"
......
......@@ -4,6 +4,11 @@ project (kwrite)
# Load the frameworks we need
find_package(KF5 REQUIRED COMPONENTS DBusAddons)
configure_file(config.h.in config.h)
# Let our config.h be found first.
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
# collect icons
set(KWRITE_ICONS_PNG
${CMAKE_CURRENT_SOURCE_DIR}/icons/16-apps-kwrite.png
......
#ifndef KWRITE_CONFIG_H
#define KWRITE_CONFIG_H
/* config.h. Generated by cmake from config.h.cmake */
#define KWRITE_VERSION "${KDE_APPLICATIONS_VERSION}"
#cmakedefine KF5Activities_FOUND
#endif
......@@ -20,6 +20,9 @@
#include "kwrite.h"
#include "kwriteapplication.h"
#include "config.h"
#include <ktexteditor/document.h>
#include <ktexteditor/view.h>
#include <ktexteditor/modificationinterface.h>
......@@ -40,9 +43,7 @@
#include <KConfig>
#include <KConfigGui>
#include <config.h>
#ifdef KActivities_FOUND
#ifdef KF5Activities_FOUND
#include <KActivities/ResourceInstance>
#endif
......@@ -57,8 +58,6 @@
#include <QFileDialog>
#include <QFileOpenEvent>
#include "kwriteapplication.h"
KWrite::KWrite(KTextEditor::Document *doc, KWriteApplication *app)
: m_view(nullptr)
, m_recentFiles(nullptr)
......@@ -201,7 +200,7 @@ void KWrite::loadURL(const QUrl &url)
{
m_view->document()->openUrl(url);
#ifdef KActivities_FOUND
#ifdef KF5Activities_FOUND
if (!m_activityResource) {
m_activityResource = new KActivities::ResourceInstance(winId(), this);
}
......
......@@ -29,8 +29,6 @@
#include <KConfigGroup>
#include <KSharedConfig>
#include <config.h>
class QLabel;
namespace KActivities
......
......@@ -18,6 +18,8 @@
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "kwrite.h"
#include "kwriteapplication.h"
......@@ -92,7 +94,7 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv)
*/
KAboutData aboutData(QStringLiteral("kwrite"),
i18n("KWrite"),
QStringLiteral(KATE_VERSION),
QStringLiteral(KWRITE_VERSION),
i18n("KWrite - Text Editor"), KAboutLicense::LGPL_V2,
i18n("(c) 2000-2019 The Kate Authors"), QString(), QStringLiteral("https://kate-editor.org"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment