KTextEditor

mainwindow.cpp
1 /*
2  SPDX-FileCopyrightText: 2013 Christoph Cullmann <[email protected]>
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 
12 namespace KTextEditor
13 {
15  : QObject(parent)
16  , d(nullptr)
17 {
18 }
19 
21 {
22 }
23 
25 {
26  // dispatch to parent
27  QWidget *window = nullptr;
28  QMetaObject::invokeMethod(parent(), "window", Qt::DirectConnection, Q_RETURN_ARG(QWidget *, window));
29  return window;
30 }
31 
33 {
34  // dispatch to parent
35  KXMLGUIFactory *guiFactory = nullptr;
36  QMetaObject::invokeMethod(parent(), "guiFactory", Qt::DirectConnection, Q_RETURN_ARG(KXMLGUIFactory *, guiFactory));
37  return guiFactory;
38 }
39 
41 {
42  // dispatch to parent
45  return views;
46 }
47 
49 {
50  // dispatch to parent
51  KTextEditor::View *view = nullptr;
52  QMetaObject::invokeMethod(parent(), "activeView", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::View *, view));
53  return view;
54 }
55 
57 {
58  // dispatch to parent
59  KTextEditor::View *view = nullptr;
61  "activateView",
63  Q_RETURN_ARG(KTextEditor::View *, view),
64  Q_ARG(KTextEditor::Document *, document));
65  return view;
66 }
67 
68 KTextEditor::View *MainWindow::openUrl(const QUrl &url, const QString &encoding)
69 {
70  // dispatch to parent
71  KTextEditor::View *view = nullptr;
72  QMetaObject::invokeMethod(parent(), "openUrl", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::View *, view), Q_ARG(QUrl, url), Q_ARG(QString, encoding));
73  return view;
74 }
75 
77 {
78  // dispatch to parent
79  bool success = false;
80  QMetaObject::invokeMethod(parent(), "closeView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::View *, view));
81  return success;
82 }
83 
85 {
86  // dispatch to parent
87  QMetaObject::invokeMethod(parent(), "splitView", Qt::DirectConnection, Q_ARG(Qt::Orientation, orientation));
88 }
89 
91 {
92  // dispatch to parent
93  bool success = false;
94  QMetaObject::invokeMethod(parent(), "closeSplitView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::View *, view));
95  return success;
96 }
97 
99 {
100  // dispatch to parent
101  bool success = false;
103  "viewsInSameSplitView",
105  Q_RETURN_ARG(bool, success),
106  Q_ARG(KTextEditor::View *, view1),
107  Q_ARG(KTextEditor::View *, view2));
108  return success;
109 }
110 
112 {
113  // dispatch to parent
114  QWidget *viewBar = nullptr;
115  QMetaObject::invokeMethod(parent(), "createViewBar", Qt::DirectConnection, Q_RETURN_ARG(QWidget *, viewBar), Q_ARG(KTextEditor::View *, view));
116  return viewBar;
117 }
118 
120 {
121  // dispatch to parent
122  QMetaObject::invokeMethod(parent(), "deleteViewBar", Qt::DirectConnection, Q_ARG(KTextEditor::View *, view));
123 }
124 
126 {
127  // dispatch to parent
128  QMetaObject::invokeMethod(parent(), "addWidgetToViewBar", Qt::DirectConnection, Q_ARG(KTextEditor::View *, view), Q_ARG(QWidget *, bar));
129 }
130 
132 {
133  // dispatch to parent
134  QMetaObject::invokeMethod(parent(), "showViewBar", Qt::DirectConnection, Q_ARG(KTextEditor::View *, view));
135 }
136 
138 {
139  // dispatch to parent
140  QMetaObject::invokeMethod(parent(), "hideViewBar", Qt::DirectConnection, Q_ARG(KTextEditor::View *, view));
141 }
142 
144  const QString &identifier,
146  const QIcon &icon,
147  const QString &text)
148 {
149  // dispatch to parent
150  QWidget *toolView = nullptr;
152  "createToolView",
154  Q_RETURN_ARG(QWidget *, toolView),
155  Q_ARG(KTextEditor::Plugin *, plugin),
156  Q_ARG(QString, identifier),
158  Q_ARG(QIcon, icon),
159  Q_ARG(QString, text));
160  return toolView;
161 }
162 
164 {
165  // dispatch to parent
166  bool success = false;
168  "moveToolView",
170  Q_RETURN_ARG(bool, success),
171  Q_ARG(QWidget *, widget),
173  return success;
174 }
175 
177 {
178  // dispatch to parent
179  bool success = false;
180  QMetaObject::invokeMethod(parent(), "showToolView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QWidget *, widget));
181  return success;
182 }
183 
185 {
186  // dispatch to parent
187  bool success = false;
188  QMetaObject::invokeMethod(parent(), "hideToolView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QWidget *, widget));
189  return success;
190 }
191 
193 {
194  // dispatch to parent
195  bool success = false;
197  "showPluginConfigPage",
199  Q_RETURN_ARG(bool, success),
200  Q_ARG(KTextEditor::Plugin *, plugin),
201  Q_ARG(int, page));
202  return success;
203 }
204 
206 {
207  // dispatch to parent
208  QObject *pluginView = nullptr;
209  QMetaObject::invokeMethod(parent(), "pluginView", Qt::DirectConnection, Q_RETURN_ARG(QObject *, pluginView), Q_ARG(QString, name));
210  return pluginView;
211 }
212 
213 } // namespace KTextEditor
void deleteViewBar(KTextEditor::View *view)
Delete the view bar for the given view.
Definition: mainwindow.cpp:119
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.
Definition: mainwindow.cpp:143
ToolViewPosition
Toolview position.
Definition: mainwindow.h:210
bool showPluginConfigPage(KTextEditor::Plugin *plugin, int page)
Shows the plugin&#39;s config page.
Definition: mainwindow.cpp:192
bool closeView(KTextEditor::View *view)
Close selected view.
Definition: mainwindow.cpp:76
KTextEditor::View * activeView()
Access the active view.
Definition: mainwindow.cpp:48
virtual ~MainWindow()
Virtual Destructor.
Definition: mainwindow.cpp:20
QList< KTextEditor::View * > views()
Get a list of all views for this main window.
Definition: mainwindow.cpp:40
QWidget * widget() override
bool showToolView(QWidget *widget)
Show the toolview widget.
Definition: mainwindow.cpp:176
A KParts derived class representing a text document.
Definition: document.h:185
KTextEditor::View * activateView(KTextEditor::Document *document)
Activate the view with the corresponding document.
Definition: mainwindow.cpp:56
KTextEditor::View * openUrl(const QUrl &url, const QString &encoding=QString())
Open the document url with the given encoding.
Definition: mainwindow.cpp:68
QWidget * createViewBar(KTextEditor::View *view)
Try to create a view bar for the given view.
Definition: mainwindow.cpp:111
KXMLGUIFactory * guiFactory()
Accessor to the XMLGUIFactory.
Definition: mainwindow.cpp:32
void hideViewBar(KTextEditor::View *view)
Hide the view bar for the given view.
Definition: mainwindow.cpp:137
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:21
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
void addWidgetToViewBar(KTextEditor::View *view, QWidget *bar)
Add a widget to the view bar.
Definition: mainwindow.cpp:125
KTextEditor Plugin interface.
Definition: plugin.h:78
void showViewBar(KTextEditor::View *view)
Show the view bar for the given view.
Definition: mainwindow.cpp:131
bool viewsInSameSplitView(KTextEditor::View *view1, KTextEditor::View *view2)
Definition: mainwindow.cpp:98
QWidget * window()
Get the toplevel widget.
Definition: mainwindow.cpp:24
Orientation
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:146
void splitView(Qt::Orientation orientation)
Split current view space according to orientation.
Definition: mainwindow.cpp:84
DirectConnection
QObject * parent() const const
bool moveToolView(QWidget *widget, KTextEditor::MainWindow::ToolViewPosition pos)
Move the toolview widget to position pos.
Definition: mainwindow.cpp:163
QObject * pluginView(const QString &name)
Get a plugin view for the plugin with with identifier name.
Definition: mainwindow.cpp:205
bool closeSplitView(KTextEditor::View *view)
Close the split view that contains the given view.
Definition: mainwindow.cpp:90
MainWindow(QObject *parent)
Construct an MainWindow wrapper object.
Definition: mainwindow.cpp:14
bool hideToolView(QWidget *widget)
Hide the toolview widget.
Definition: mainwindow.cpp:184
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 01:49:17 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.