1 /* SPDX-License-Identifier: LGPL-2.0-or-later 2 3 SPDX-FileCopyrightText: 2001 Christoph Cullmann <cullmann@kde.org> 4 5 SPDX-License-Identifier: LGPL-2.0-or-later 6 */ 7 8 #ifndef _kateapp_adaptor_h_ 9 #define _kateapp_adaptor_h_ 10 11 #include <QDBusAbstractAdaptor> 12 13 class KateApp; 14 15 class KateAppAdaptor : public QDBusAbstractAdaptor 16 { 17 Q_OBJECT 18 Q_CLASSINFO("D-Bus Interface", "org.kde.Kate.Application") 19 Q_PROPERTY(QString activeSession READ activeSession) 20 public: 21 KateAppAdaptor(KateApp *app); 22 23 /** 24 * emit the exiting signal 25 */ 26 void emitExiting(); 27 void emitDocumentClosed(const QString &token); 28 29 public Q_SLOTS: 30 /** 31 * open a file with given url and encoding 32 * will get view created 33 * @param url url of the file 34 * @param encoding encoding name 35 * @return success 36 */ 37 bool openUrl(const QString &url, const QString &encoding); 38 39 /** 40 * checks if the Kate instance is in the specified activity 41 * @param activity activity to check 42 * @return true if it is in the specified activity, false otherwise 43 */ 44 bool isOnActivity(const QString &activity); 45 46 /** 47 * open a file with given url and encoding 48 * will get view created 49 * @param url url of the file 50 * @param encoding encoding name 51 * @return token or ERROR 52 */ 53 QString tokenOpenUrl(const QString &url, const QString &encoding); 54 55 /** 56 * Like the above, but adds an option to let the documentManager know 57 * if the file should be deleted when closed. 58 * @p isTempFile should be set to true with the --tempfile option set ONLY, 59 * files opened with this set to true will be deleted when closed. 60 */ 61 bool openUrl(const QString &url, const QString &encoding, bool isTempFile); 62 63 QString tokenOpenUrl(const QString &url, const QString &encoding, bool isTempFile); 64 65 QString tokenOpenUrlAt(const QString &url, int line, int column, const QString &encoding, bool isTempFile); 66 67 /** 68 * set cursor of active view in active main window 69 * will clear selection 70 * @param line line for cursor 71 * @param column column for cursor 72 * @return success 73 */ 74 bool setCursor(int line, int column); 75 76 /** 77 * helper to handle stdin input 78 * open a new document/view, fill it with the text given 79 * @param text text to fill in the new doc/view 80 * @param encoding encoding to set for the document, if any 81 * @return success 82 */ 83 bool openInput(const QString &text, const QString &encoding); 84 85 /** 86 * activate a given session 87 * @param session session name 88 * @return success 89 */ 90 bool activateSession(const QString &session); 91 92 int desktopNumber(); 93 94 /** 95 * activate this kate instance 96 */ 97 void activate(const QString &token = QString()); 98 99 Q_SIGNALS: 100 /** 101 * Notify the world that this kate instance is exiting. 102 * All apps should stop using the dbus interface of this instance after this signal got emitted. 103 */ 104 void exiting(); 105 void documentClosed(const QString &token); 106 107 public: 108 QString activeSession(); 109 110 private: 111 KateApp *m_app; 112 }; 113 114 #endif 115