File indexing completed on 2024-04-28 05:49:27

0001 /*
0002     SPDX-FileCopyrightText: 2001 Christoph Cullmann <cullmann@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QDBusAbstractAdaptor>
0010 
0011 class KateApp;
0012 
0013 class KateAppAdaptor : public QDBusAbstractAdaptor
0014 {
0015     Q_OBJECT
0016     Q_CLASSINFO("D-Bus Interface", "org.kde.Kate.Application")
0017     Q_PROPERTY(QString activeSession READ activeSession)
0018     Q_PROPERTY(qint64 lastActivationChange READ lastActivationChange)
0019 public:
0020     explicit KateAppAdaptor(KateApp *app);
0021 
0022     /**
0023      * emit the exiting signal
0024      */
0025     void emitExiting();
0026     void emitDocumentClosed(const QString &token);
0027 
0028 public Q_SLOTS:
0029     /**
0030      * open a file with given url and encoding
0031      * will get view created
0032      * @param url url of the file
0033      * @param encoding encoding name
0034      * @return success
0035      */
0036     bool openUrl(const QString &url, const QString &encoding);
0037 
0038     /**
0039      * open a file with given url and encoding
0040      * will get view created
0041      * @param url url of the file
0042      * @param encoding encoding name
0043      * @return token or ERROR
0044      */
0045     QString tokenOpenUrl(const QString &url, const QString &encoding);
0046 
0047     /**
0048      * Like the above, but adds an option to let the documentManager know
0049      * if the file should be deleted when closed.
0050      * @p isTempFile should be set to true with the --tempfile option set ONLY,
0051      * files opened with this set to true will be deleted when closed.
0052      */
0053     bool openUrl(const QString &url, const QString &encoding, bool isTempFile);
0054 
0055     QString tokenOpenUrl(const QString &url, const QString &encoding, bool isTempFile);
0056 
0057     QString tokenOpenUrlAt(const QString &url, int line, int column, const QString &encoding, bool isTempFile);
0058 
0059     /**
0060      * set cursor of active view in active main window
0061      * will clear selection
0062      * @param line line for cursor
0063      * @param column column for cursor
0064      * @return success
0065      */
0066     bool setCursor(int line, int column);
0067 
0068     /**
0069      * helper to handle stdin input
0070      * open a new document/view, fill it with the text given
0071      * @param text text to fill in the new doc/view
0072      * @param encoding encoding to set for the document, if any
0073      * @return success
0074      */
0075     bool openInput(const QString &text, const QString &encoding);
0076 
0077     /**
0078      * activate a given session
0079      * @param session session name
0080      * @return success
0081      */
0082     bool activateSession(const QString &session);
0083 
0084     /**
0085      * activate this kate instance
0086      */
0087     void activate(const QString &token = QString());
0088 
0089 Q_SIGNALS:
0090     /**
0091      * Notify the world that this kate instance is exiting.
0092      * All apps should stop using the dbus interface of this instance after this signal got emitted.
0093      */
0094     void exiting();
0095     void documentClosed(const QString &token);
0096 
0097 public:
0098     QString activeSession() const;
0099 
0100     /**
0101      * last time some QEvent::ActivationChange occured
0102      * used to determine which instance to reuse, if we have multiple
0103      */
0104     qint64 lastActivationChange() const;
0105 
0106 private:
0107     KateApp *m_app;
0108 };