KTextEditor

application.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Christoph Cullmann <cullmann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include <ktexteditor/application.h>
8#include <ktexteditor/mainwindow.h>
9#include <ktexteditor/plugin.h>
10
11#include "kateglobal.h"
12
13namespace KTextEditor
14{
16 : QObject(parent)
17 , d(nullptr)
18{
19}
20
22
24{
25 // dispatch to parent
26 bool success = false;
27 QMetaObject::invokeMethod(parent(), "quit", Qt::DirectConnection, Q_RETURN_ARG(bool, success));
28
29 return success;
30}
31
33{
34 // dispatch to parent
37 return mainWindow;
38}
39
41{
42 // dispatch to parent
43 KTextEditor::MainWindow *window = nullptr;
44 QMetaObject::invokeMethod(parent(), "activeMainWindow", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::MainWindow *, window));
45
46 // always return some kind of window to not need to check for valid pointer
47 return window ? window : KTextEditor::EditorPrivate::self()->dummyMainWindow();
48}
49
57
59{
60 // dispatch to parent
61 KTextEditor::Document *document = nullptr;
62 QMetaObject::invokeMethod(parent(), "findUrl", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::Document *, document), Q_ARG(QUrl, url));
63 return document;
64}
65
67{
68 // dispatch to parent
69 KTextEditor::Document *document = nullptr;
71 "openUrl",
73 Q_RETURN_ARG(KTextEditor::Document *, document),
74 Q_ARG(QUrl, url),
75 Q_ARG(QString, encoding));
76 return document;
77}
78
80{
81 // dispatch to parent
82 bool success = false;
83 QMetaObject::invokeMethod(parent(), "closeDocument", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::Document *, document));
84 return success;
85}
86
88{
89 // dispatch to parent
90 bool success = false;
91 QMetaObject::invokeMethod(parent(), "closeDocuments", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QList<KTextEditor::Document *>, documents));
92 return success;
93}
94
96{
97 // dispatch to parent
98 Plugin *plugin = nullptr;
99 QMetaObject::invokeMethod(parent(), "plugin", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::Plugin *, plugin), Q_ARG(QString, name));
100 return plugin;
101}
102
103} // namespace KTextEditor
QList< KTextEditor::MainWindow * > mainWindows()
Get a list of all main windows.
KTextEditor::Document * openUrl(const QUrl &url, const QString &encoding=QString())
Open the document url with the given encoding.
bool closeDocuments(const QList< KTextEditor::Document * > &documents)
Close a list of documents.
KTextEditor::Plugin * plugin(const QString &name)
Get a plugin for the plugin with with identifier name.
KTextEditor::Document * findUrl(const QUrl &url)
Get the document with the URL url.
Application(QObject *parent)
Construct an Application wrapper object.
bool closeDocument(KTextEditor::Document *document)
Close the given document.
KTextEditor::MainWindow * activeMainWindow()
Accessor to the active main window.
bool quit()
Ask app to quit.
QList< KTextEditor::Document * > documents()
Get a list of all documents that are managed by the application.
~Application() override
Virtual Destructor.
A KParts derived class representing a text document.
Definition document.h:284
KTextEditor::MainWindow * dummyMainWindow()
Dummy main window to be null safe.
Definition kateglobal.h:374
static KTextEditor::EditorPrivate * self()
Kate Part Internal stuff ;)
This class allows the application that embeds the KTextEditor component to allow it to access parts o...
Definition mainwindow.h:47
KTextEditor Plugin interface.
Definition plugin.h:79
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
bool invokeMethod(QObject *context, Functor &&function, FunctorReturnType *ret)
QObject * parent() const const
DirectConnection
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.