diff --git a/kate/CMakeLists.txt b/kate/CMakeLists.txt index 574413b54..8beed2992 100644 --- a/kate/CMakeLists.txt +++ b/kate/CMakeLists.txt @@ -1,155 +1,155 @@ # # The Kate Application # project(kate) # Load the frameworks we need find_package(KF5 REQUIRED COMPONENTS DBusAddons GuiAddons) # includes include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/session ${CMAKE_CURRENT_SOURCE_DIR}/qtsingleapplication ) # collect the needed source files set (KATE_LIBRARY_SRCS kateappadaptor.cpp kateapp.cpp kateconfigdialog.cpp kateconfigplugindialogpage.cpp katedocmanager.cpp katefileactions.cpp katemainwindow.cpp katepluginmanager.cpp kateviewmanager.cpp kateviewspace.cpp katesavemodifieddialog.cpp katemwmodonhddialog.cpp katecolorschemechooser.cpp katequickopenmodel.cpp katetabbutton.cpp katetabbar.cpp # session session/katesessionsaction.cpp session/katesessionmanager.cpp session/katesessionmanagedialog.cpp session/katesession.cpp katemdi.cpp katerunninginstanceinfo.cpp katequickopen.cpp katewaiter.h katewaiter.cpp ) ki18n_wrap_ui(KATE_LIBRARY_SRCS ui/sessionconfigwidget.ui session/katesessionmanagedialog.ui ) qt5_add_resources( KATE_LIBRARY_SRCS data/kate.qrc ) add_library(kdeinit_kate STATIC ${KATE_LIBRARY_SRCS}) target_link_libraries(kdeinit_kate PUBLIC KF5::TextEditor KF5::I18n KF5::IconThemes KF5::WindowSystem KF5::GuiAddons KF5::DBusAddons KF5::Crash) if(KF5Activities_FOUND) target_link_libraries(kdeinit_kate PUBLIC KF5::Activities) endif() generate_export_header(kdeinit_kate - EXPORT_FILE_NAME kateprivate_export.h + EXPORT_FILE_NAME katetests_export.h EXPORT_MACRO_NAME KATE_TESTS_EXPORT ) # collect icons set(KATE_ICONS_PNG ${CMAKE_CURRENT_SOURCE_DIR}/icons/16-apps-kate.png ${CMAKE_CURRENT_SOURCE_DIR}/icons/22-apps-kate.png ${CMAKE_CURRENT_SOURCE_DIR}/icons/32-apps-kate.png ${CMAKE_CURRENT_SOURCE_DIR}/icons/48-apps-kate.png ${CMAKE_CURRENT_SOURCE_DIR}/icons/64-apps-kate.png ${CMAKE_CURRENT_SOURCE_DIR}/icons/128-apps-kate.png ) set(KATE_ICONS_SVG ${CMAKE_CURRENT_SOURCE_DIR}/icons/sc-apps-kate.svgz ) # application only sources set (KATE_APP_SRCS main.cpp ) # use single application instead of dbus on mac + windows if (APPLE OR WIN32) set(singleapp_SRCS qtsingleapplication/qtlocalpeer.cpp qtsingleapplication/qtsingleapplication.cpp qtsingleapplication/qtlockedfile.cpp ) if(WIN32) set(singleapp_SRCS ${singleapp_SRCS} qtsingleapplication/qtlockedfile_win.cpp) else() set(singleapp_SRCS ${singleapp_SRCS} qtsingleapplication/qtlockedfile_unix.cpp) endif() add_definitions("-DUSE_QT_SINGLE_APP") set(KATE_APP_SRCS ${KATE_APP_SRCS} ${singleapp_SRCS}) endif() # add icons to application sources, to have them bundled ecm_add_app_icon(KATE_APP_SRCS ICONS ${KATE_ICONS_PNG}) # create executable add_executable(kate ${KATE_APP_SRCS}) target_link_libraries(kate kdeinit_kate) # own plist magic for mac os if(APPLE) # own plist template set_target_properties (kate PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/data/MacOSXBundleInfo.plist.in) # the MacOSX bundle display name property (CFBundleDisplayName) is not currently supported by cmake, # so has to be set for all targets in this cmake file set(MACOSX_BUNDLE_DISPLAY_NAME Kate) set_target_properties(kate PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.Kate") set_target_properties(kate PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Kate") set_target_properties(kate PROPERTIES MACOSX_BUNDLE_DISPLAY_NAME "Kate") set_target_properties(kate PROPERTIES MACOSX_BUNDLE_INFO_STRING "Kate - Advanced Text Editor") set_target_properties(kate PROPERTIES MACOSX_BUNDLE_LONG_VERSION_STRING "Kate ${KDE_APPLICATIONS_VERSION}") set_target_properties(kate PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}") set_target_properties(kate PROPERTIES MACOSX_BUNDLE_BUNDLE_VERSION "${KDE_APPLICATIONS_VERSION}") set_target_properties(kate PROPERTIES MACOSX_BUNDLE_COPYRIGHT "2000-2016 The Kate Authors") endif() # install executable install(TARGETS kate ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) # desktop file install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/data/org.kde.kate.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) # appdata install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/org.kde.kate.appdata.xml DESTINATION ${CMAKE_INSTALL_METAINFODIR}) # install icons ecm_install_icons(ICONS ${KATE_ICONS_PNG} ${KATE_ICONS_SVG} DESTINATION ${ICON_INSTALL_DIR} THEME hicolor) # automatic unit tests if (BUILD_TESTING) add_subdirectory(autotests) endif() diff --git a/kate/kateapp.h b/kate/kateapp.h index f30ec7b52..29ddee44d 100644 --- a/kate/kateapp.h +++ b/kate/kateapp.h @@ -1,376 +1,376 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2002 Joseph Wenninger This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __KATE_APP_H__ #define __KATE_APP_H__ #include -#include "kateprivate_export.h" +#include "katetests_export.h" #include "katemainwindow.h" #include "katedocmanager.h" #include "katepluginmanager.h" #include "katesessionmanager.h" #include "kateappadaptor.h" #include #include class KateSessionManager; class KateMainWindow; class KatePluginManager; class KateDocManager; class KateAppCommands; class KateAppAdaptor; class QCommandLineParser; /** * Kate Application * This class represents the core kate application object */ class KATE_TESTS_EXPORT KateApp : public QObject { Q_OBJECT /** * constructors & accessor to app object + plugin interface for it */ public: /** * application constructor */ KateApp(const QCommandLineParser &args); /** * get kate inited * @return false, if application should exit */ bool init(); /** * application destructor */ ~KateApp() override; /** * static accessor to avoid casting ;) * @return app instance */ static KateApp *self(); /** * KTextEditor::Application wrapper * @return KTextEditor::Application wrapper. */ KTextEditor::Application *wrapper() { return &m_wrapper; } /** * kate init */ private: /** * restore a old kate session */ void restoreKate(); /** * try to start kate * @return success, if false, kate should exit */ bool startupKate(); /** * kate shutdown */ public: /** * shutdown kate application * @param win mainwindow which is used for dialogs */ void shutdownKate(KateMainWindow *win); /** * other accessors for global unique instances */ public: /** * accessor to plugin manager * @return plugin manager instance */ KatePluginManager *pluginManager(); /** * accessor to document manager * @return document manager instance */ KateDocManager *documentManager(); /** * accessor to session manager * @return session manager instance */ KateSessionManager *sessionManager(); /** * window management */ public: /** * create a new main window, use given config if any for restore * @param sconfig session config object * @param sgroup session group for this window * @return new constructed main window */ KateMainWindow *newMainWindow(KConfig *sconfig = nullptr, const QString &sgroup = QString()); /** * add the mainwindow given * should be called in mainwindow constructor * @param mainWindow window to remove */ void addMainWindow(KateMainWindow *mainWindow); /** * removes the mainwindow given, DOES NOT DELETE IT * should be called in mainwindow destructor * @param mainWindow window to remove */ void removeMainWindow(KateMainWindow *mainWindow); /** * give back current active main window * can only be 0 at app start or exit * @return current active main window */ KateMainWindow *activeKateMainWindow(); /** * give back number of existing main windows * @return number of main windows */ int mainWindowsCount() const; /** * give back the window you want * @param n window index * @return requested main window */ KateMainWindow *mainWindow(int n); int mainWindowID(KateMainWindow *window); /** * some stuff for the dcop API */ public: /** * open url with given encoding * used by kate if --use given * @param url filename * @param encoding encoding name * @param isTempFile whether the file is temporary * @return success */ bool openUrl(const QUrl &url, const QString &encoding, bool isTempFile); /** * checks if the current instance is in a given activity * @param activity activity to check * @return true if the window is in the given activity, false otherwise */ bool isOnActivity(const QString &activity); KTextEditor::Document *openDocUrl(const QUrl &url, const QString &encoding, bool isTempFile); void emitDocumentClosed(const QString &token); /** * position cursor in current active view * will clear selection * @param line line to set * @param column column to set * @return success */ bool setCursor(int line, int column); /** * helper to handle stdin input * open a new document/view, fill it with the text given * @param text text to fill in the new doc/view * @param encoding encoding to set for the document, if any * @return success */ bool openInput(const QString &text, const QString &encoding); // // KTextEditor::Application interface, called by wrappers via invokeMethod // public Q_SLOTS: /** * Get a list of all main windows. * @return all main windows */ QList mainWindows() { // assemble right list QList windows; windows.reserve(m_mainWindows.size()); for (const auto mainWindow : qAsConst(m_mainWindows)) { windows.push_back(mainWindow->wrapper()); } return windows; } /** * Accessor to the active main window. * \return a pointer to the active mainwindow */ KTextEditor::MainWindow *activeMainWindow() { // either return wrapper or nullptr if (KateMainWindow *a = activeKateMainWindow()) { return a->wrapper(); } return nullptr; } /** * Get a list of all documents that are managed by the application. * This might contain less documents than the editor has in his documents () list. * @return all documents the application manages */ QList documents() { return m_docManager.documentList(); } /** * Get the document with the URL \p url. * if multiple documents match the searched url, return the first found one... * \param url the document's URL * \return the document with the given \p url or NULL, if none found */ KTextEditor::Document *findUrl(const QUrl &url) { return m_docManager.findDocument(url); } /** * Open the document \p url with the given \p encoding. * if the url is empty, a new empty document will be created * \param url the document's url * \param encoding the preferred encoding. If encoding is QString() the * encoding will be guessed or the default encoding will be used. * \return a pointer to the created document */ KTextEditor::Document *openUrl(const QUrl &url, const QString &encoding = QString()) { return m_docManager.openUrl(url, encoding); } /** * Close the given \p document. If the document is modified, user will be asked if he wants that. * \param document the document to be closed * \return \e true on success, otherwise \e false */ bool closeDocument(KTextEditor::Document *document) { return m_docManager.closeDocument(document); } /** * Close a list of documents. If any of them are modified, user will be asked if he wants that. * Use this, if you want to close multiple documents at once, as the application might * be able to group the "do you really want that" dialogs into one. * \param documents list of documents to be closed * \return \e true on success, otherwise \e false */ bool closeDocuments(const QList &documents) { return m_docManager.closeDocumentList(documents); } /** * Get a plugin for the plugin with with identifier \p name. * \param name the plugin's name * \return pointer to the plugin if a plugin with \p name is loaded, otherwise nullptr */ KTextEditor::Plugin *plugin(const QString &name); /** * Ask app to quit. The app might interact with the user and decide that * quitting is not possible and return false. * * \return true if the app could quit */ bool quit() { shutdownKate(activeKateMainWindow()); return true; } /** * A message is received from an external instance, if we use QtSingleApplication * * \p message is a serialized message (at the moment just the file list separated by ';') * \p socket is the QLocalSocket used for the communication */ void remoteMessageReceived(const QString &message, QObject *socket); protected: /** * Event filter for QApplication to handle mac os like file open */ bool eventFilter(QObject *obj, QEvent *event) override; private: /** * kate's command line args */ const QCommandLineParser &m_args; /** * known main windows */ QList m_mainWindows; /** * Wrapper of application for KTextEditor */ KTextEditor::Application m_wrapper; /** * document manager */ KateDocManager m_docManager; /** * dbus interface */ KateAppAdaptor m_adaptor; /** * plugin manager */ KatePluginManager m_pluginManager; /** * session manager */ KateSessionManager m_sessionManager; }; #endif diff --git a/kate/session/katesession.h b/kate/session/katesession.h index 80f13ebc3..c568afd18 100644 --- a/kate/session/katesession.h +++ b/kate/session/katesession.h @@ -1,136 +1,137 @@ /* This file is part of the KDE project * * Copyright (C) 2005 Christoph Cullmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef __KATE_SESSION_H__ #define __KATE_SESSION_H__ +#include "katetests_export.h" + #include #include #include -#include "kateprivate_export.h" class KConfig; class KATE_TESTS_EXPORT KateSession : public QSharedData { public: /** * Define a Shared-Pointer type */ typedef QExplicitlySharedDataPointer Ptr; public: ~KateSession(); /** * session name * @return name for this session */ const QString &name() const { return m_name; } /** * session config * on first access, will create the config object, delete will be done automagic * return 0 if we have no file to read config from atm * @return correct KConfig, never null * @note never delete configRead(), because the return value might be * KSharedConfig::openConfig(). Only delete the member variables directly. */ KConfig *config(); /** * count of documents in this session * @return documents count */ unsigned int documents() const { return m_documents; } /** * update \p number of opened documents in session */ void setDocuments(const unsigned int number); /** * @return true if this is anonymous/new session */ bool isAnonymous() const { return m_anonymous; } /** * @return path to session file */ const QString &file() const; /** * returns last save time of this session */ const QDateTime ×tamp() const { return m_timestamp; } /** * Factories */ public: static KateSession::Ptr create(const QString &file, const QString &name); static KateSession::Ptr createFrom(const KateSession::Ptr &session, const QString &file, const QString &name); static KateSession::Ptr createAnonymous(const QString &file); static KateSession::Ptr createAnonymousFrom(const KateSession::Ptr &session, const QString &file); static bool compareByName(const KateSession::Ptr &s1, const KateSession::Ptr &s2); static bool compareByTimeDesc(const KateSession::Ptr &s1, const KateSession::Ptr &s2); private: friend class KateSessionManager; friend class KateSessionTest; /** * set session name */ void setName(const QString &name); /** * set's new session file to @filename */ void setFile(const QString &filename); /** * create a session from given @file * @param file configuration file * @param name name of this session * @param anonymous anonymous flag * @param config if specified, the session will copy configuration from the KConfig instead of opening the file */ KateSession(const QString &file, const QString &name, const bool anonymous, const KConfig *config = nullptr); private: QString m_name; QString m_file; bool m_anonymous; unsigned int m_documents; KConfig *m_config; QDateTime m_timestamp; }; #endif diff --git a/kate/session/katesessionsaction.h b/kate/session/katesessionsaction.h index aaa449ec9..03f01e87d 100644 --- a/kate/session/katesessionsaction.h +++ b/kate/session/katesessionsaction.h @@ -1,50 +1,50 @@ /* This file is part of the KDE project * * Copyright (C) 2005 Christoph Cullmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef __KATE_SESSIONS_ACTION_H__ #define __KATE_SESSIONS_ACTION_H__ -#include "kateprivate_export.h" +#include "katetests_export.h" #include class KateSessionManager; class KATE_TESTS_EXPORT KateSessionsAction : public KActionMenu { Q_OBJECT public: KateSessionsAction(const QString &text, QObject *parent, KateSessionManager *manager = nullptr); ~KateSessionsAction() override { } public Q_SLOTS: void slotAboutToShow(); void openSession(QAction *action); void slotSessionChanged(); private: friend class KateSessionsActionTest; // tfuj QActionGroup *sessionsGroup; KateSessionManager *m_manager; }; #endif