KTextEditor

mainwindow.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/mainwindow.h>
8#include <ktexteditor/plugin.h>
9
10#include <KXMLGUIFactory>
11#include <QIcon>
12#include <QUrl>
13#include <QVariant>
14
15// clang-format off
16
17namespace KTextEditor
18{
20 : QObject(parent)
21 , d(nullptr)
22{
23}
24
28
30{
31 // dispatch to parent
32 QWidget *window = nullptr;
34 return window;
35}
36
38{
39 // dispatch to parent
40 KXMLGUIFactory *guiFactory = nullptr;
42 return guiFactory;
43}
44
52
54{
55 // dispatch to parent
56 KTextEditor::View *view = nullptr;
57 QMetaObject::invokeMethod(parent(), "activeView", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::View*, view));
58 return view;
59}
60
62{
63 // dispatch to parent
64 KTextEditor::View *view = nullptr;
66 "activateView",
68 Q_RETURN_ARG(KTextEditor::View*, view),
69 Q_ARG(KTextEditor::Document*, document));
70 return view;
71}
72
74{
75 // dispatch to parent
76 KTextEditor::View *view = nullptr;
77 QMetaObject::invokeMethod(parent(), "openUrl", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::View*, view), Q_ARG(QUrl, url), Q_ARG(QString, encoding));
78 return view;
79}
80
82{
83 // dispatch to parent
84 bool success = false;
85 QMetaObject::invokeMethod(parent(), "closeView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::View*, view));
86 return success;
87}
88
90{
91 // dispatch to parent
92 QMetaObject::invokeMethod(parent(), "splitView", Qt::DirectConnection, Q_ARG(Qt::Orientation, orientation));
93}
94
96{
97 // dispatch to parent
98 bool success = false;
99 QMetaObject::invokeMethod(parent(), "closeSplitView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::View*, view));
100 return success;
101}
102
104{
105 // dispatch to parent
106 bool success = false;
108 "viewsInSameSplitView",
110 Q_RETURN_ARG(bool, success),
111 Q_ARG(KTextEditor::View*, view1),
112 Q_ARG(KTextEditor::View*, view2));
113 return success;
114}
115
117{
118 // dispatch to parent
119 QWidget *viewBar = nullptr;
120 QMetaObject::invokeMethod(parent(), "createViewBar", Qt::DirectConnection, Q_RETURN_ARG(QWidget*, viewBar), Q_ARG(KTextEditor::View*, view));
121 return viewBar;
122}
123
125{
126 // dispatch to parent
128}
129
131{
132 // dispatch to parent
133 QMetaObject::invokeMethod(parent(), "addWidgetToViewBar", Qt::DirectConnection, Q_ARG(KTextEditor::View*, view), Q_ARG(QWidget*, bar));
134}
135
137{
138 // dispatch to parent
140}
141
143{
144 // dispatch to parent
146}
147
149 const QString &identifier,
151 const QIcon &icon,
152 const QString &text)
153{
154 // dispatch to parent
155 QWidget *toolView = nullptr;
157 "createToolView",
159 Q_RETURN_ARG(QWidget*, toolView),
160 Q_ARG(KTextEditor::Plugin*, plugin),
161 Q_ARG(QString, identifier),
163 Q_ARG(QIcon, icon),
164 Q_ARG(QString, text));
165 return toolView;
166}
167
169{
170 // dispatch to parent
171 bool success = false;
173 "moveToolView",
175 Q_RETURN_ARG(bool, success),
176 Q_ARG(QWidget*, widget),
178 return success;
179}
180
182{
183 // dispatch to parent
184 bool success = false;
185 QMetaObject::invokeMethod(parent(), "showToolView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QWidget*, widget));
186 return success;
187}
188
190{
191 // dispatch to parent
192 bool success = false;
193 QMetaObject::invokeMethod(parent(), "hideToolView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QWidget*, widget));
194 return success;
195}
196
198{
199 // dispatch to parent
200 bool success = false;
202 "showPluginConfigPage",
204 Q_RETURN_ARG(bool, success),
205 Q_ARG(KTextEditor::Plugin*, plugin),
206 Q_ARG(int, page));
207 return success;
208}
209
211{
212 // dispatch to parent
213 QObject *pluginView = nullptr;
214 QMetaObject::invokeMethod(parent(), "pluginView", Qt::DirectConnection, Q_RETURN_ARG(QObject*, pluginView), Q_ARG(QString, name));
215 return pluginView;
216}
217
219{
220 // dispatch to parent
221 bool success = false;
222 QMetaObject::invokeMethod(parent(), "addWidget", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QWidget*, widget));
223 return success;
224}
225
227{
228 // dispatch to parent
229 bool success = false;
230 QMetaObject::invokeMethod(parent(), "removeWidget", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QWidget*, widget));
231 return success;
232}
233
235{
236 // dispatch to parent
237 QWidgetList l;
238 QMetaObject::invokeMethod(parent(), "widgets", Qt::DirectConnection, Q_RETURN_ARG(QWidgetList, l));
239 return l;
240}
241
243{
244 // dispatch to parent
245 QWidget *w = nullptr;
246 QMetaObject::invokeMethod(parent(), "activeWidget", Qt::DirectConnection, Q_RETURN_ARG(QWidget*, w));
247 return w;
248}
249
251{
252 // dispatch to parent
253 QMetaObject::invokeMethod(parent(), "activateWidget", Qt::DirectConnection, Q_ARG(QWidget*, widget));
254}
255
256bool MainWindow::showMessage(const QVariantMap &message)
257{
258 // dispatch to parent
259 bool success = false;
260 QMetaObject::invokeMethod(parent(), "showMessage", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QVariantMap, message));
261 return success;
262}
263} // namespace KTextEditor
264
265// clang-format on
A KParts derived class representing a text document.
Definition document.h:284
bool showPluginConfigPage(KTextEditor::Plugin *plugin, int page)
Shows the plugin's config page.
bool hideToolView(QWidget *widget)
Hide the toolview widget.
KTextEditor::View * openUrl(const QUrl &url, const QString &encoding=QString())
Open the document url with the given encoding.
MainWindow(QObject *parent)
Construct an MainWindow wrapper object.
QList< KTextEditor::View * > views()
Get a list of all views for this main window.
KTextEditor::View * activeView()
Access the active view.
KXMLGUIFactory * guiFactory()
Accessor to the XMLGUIFactory.
~MainWindow() override
Virtual Destructor.
bool moveToolView(QWidget *widget, KTextEditor::MainWindow::ToolViewPosition pos)
Move the toolview widget to position pos.
bool closeView(KTextEditor::View *view)
Close selected view.
void activateWidget(QWidget *widget)
activate widget.
void addWidgetToViewBar(KTextEditor::View *view, QWidget *bar)
Add a widget to the view bar.
QWidget * createViewBar(KTextEditor::View *view)
Try to create a view bar for the given view.
void hideViewBar(KTextEditor::View *view)
Hide the view bar for the given view.
QWidget * activeWidget()
returns the currently active widget.
bool addWidget(QWidget *widget)
Add a widget to the main window.
bool closeSplitView(KTextEditor::View *view)
Close the split view that contains the given view.
KTextEditor::View * activateView(KTextEditor::Document *document)
Activate the view with the corresponding document.
bool showMessage(const QVariantMap &message)
Display a message to the user.
void splitView(Qt::Orientation orientation)
Split current view space according to orientation.
QWidget * createToolView(KTextEditor::Plugin *plugin, const QString &identifier, KTextEditor::MainWindow::ToolViewPosition pos, const QIcon &icon, const QString &text)
Create a new toolview with unique identifier at side pos with icon and caption text.
bool viewsInSameSplitView(KTextEditor::View *view1, KTextEditor::View *view2)
QWidget * window()
Get the toplevel widget.
QWidgetList widgets()
returns the list of non-KTextEditorView widgets in this main window.
void deleteViewBar(KTextEditor::View *view)
Delete the view bar for the given view.
bool removeWidget(QWidget *widget)
remove this widget from this mainwindow.
void showViewBar(KTextEditor::View *view)
Show the view bar for the given view.
QObject * pluginView(const QString &name)
Get a plugin view for the plugin with with identifier name.
ToolViewPosition
Toolview position.
Definition mainwindow.h:218
bool showToolView(QWidget *widget)
Show the toolview widget.
KTextEditor Plugin interface.
Definition plugin.h:79
A text widget with KXMLGUIClient that represents a Document.
Definition view.h:244
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
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:07:21 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.