KTextEditor

mainwindow.cpp
1 /* SPDX-License-Identifier: LGPL-2.0-or-later
2 
3  Copyright (C) 2013 Christoph Cullmann <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include <ktexteditor/mainwindow.h>
22 #include <ktexteditor/plugin.h>
23 
24 #include <KXMLGUIFactory>
25 
26 namespace KTextEditor
27 {
29  : QObject(parent)
30  , d(nullptr)
31 {
32 }
33 
35 {
36 }
37 
39 {
43  QWidget *window = nullptr;
44  QMetaObject::invokeMethod(parent(), "window", Qt::DirectConnection, Q_RETURN_ARG(QWidget *, window));
45  return window;
46 }
47 
49 {
53  KXMLGUIFactory *guiFactory = nullptr;
54  QMetaObject::invokeMethod(parent(), "guiFactory", Qt::DirectConnection, Q_RETURN_ARG(KXMLGUIFactory *, guiFactory));
55  return guiFactory;
56 }
57 
59 {
64  QMetaObject::invokeMethod(parent(), "views", Qt::DirectConnection, Q_RETURN_ARG(QList<KTextEditor::View *>, views));
65  return views;
66 }
67 
69 {
73  KTextEditor::View *view = nullptr;
74  QMetaObject::invokeMethod(parent(), "activeView", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::View *, view));
75  return view;
76 }
77 
79 {
83  KTextEditor::View *view = nullptr;
84  QMetaObject::invokeMethod(parent(), "activateView", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::View *, view), Q_ARG(KTextEditor::Document *, document));
85  return view;
86 }
87 
88 KTextEditor::View *MainWindow::openUrl(const QUrl &url, const QString &encoding)
89 {
93  KTextEditor::View *view = nullptr;
94  QMetaObject::invokeMethod(parent(), "openUrl", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::View *, view), Q_ARG(QUrl, url), Q_ARG(QString, encoding));
95  return view;
96 }
97 
99 {
103  bool success = false;
104  QMetaObject::invokeMethod(parent(), "closeView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::View *, view));
105  return success;
106 }
107 
108 void MainWindow::splitView(Qt::Orientation orientation)
109 {
113  QMetaObject::invokeMethod(parent(), "splitView", Qt::DirectConnection, Q_ARG(Qt::Orientation, orientation));
114 }
115 
117 {
121  bool success = false;
122  QMetaObject::invokeMethod(parent(), "closeSplitView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::View *, view));
123  return success;
124 }
125 
127 {
131  bool success = false;
132  QMetaObject::invokeMethod(parent(), "viewsInSameSplitView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::View *, view1), Q_ARG(KTextEditor::View *, view2));
133  return success;
134 }
135 
137 {
141  QWidget *viewBar = nullptr;
142  QMetaObject::invokeMethod(parent(), "createViewBar", Qt::DirectConnection, Q_RETURN_ARG(QWidget *, viewBar), Q_ARG(KTextEditor::View *, view));
143  return viewBar;
144 }
145 
147 {
151  QMetaObject::invokeMethod(parent(), "deleteViewBar", Qt::DirectConnection, Q_ARG(KTextEditor::View *, view));
152 }
153 
155 {
159  QMetaObject::invokeMethod(parent(), "addWidgetToViewBar", Qt::DirectConnection, Q_ARG(KTextEditor::View *, view), Q_ARG(QWidget *, bar));
160 }
161 
163 {
167  QMetaObject::invokeMethod(parent(), "showViewBar", Qt::DirectConnection, Q_ARG(KTextEditor::View *, view));
168 }
169 
171 {
175  QMetaObject::invokeMethod(parent(), "hideViewBar", Qt::DirectConnection, Q_ARG(KTextEditor::View *, view));
176 }
177 
179 {
183  QWidget *toolView = nullptr;
185  "createToolView",
186  Qt::DirectConnection,
187  Q_RETURN_ARG(QWidget *, toolView),
188  Q_ARG(KTextEditor::Plugin *, plugin),
189  Q_ARG(QString, identifier),
191  Q_ARG(QIcon, icon),
192  Q_ARG(QString, text));
193  return toolView;
194 }
195 
197 {
201  bool success = false;
202  QMetaObject::invokeMethod(parent(), "moveToolView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QWidget *, widget), Q_ARG(KTextEditor::MainWindow::ToolViewPosition, pos));
203  return success;
204 }
205 
207 {
211  bool success = false;
212  QMetaObject::invokeMethod(parent(), "showToolView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QWidget *, widget));
213  return success;
214 }
215 
217 {
221  bool success = false;
222  QMetaObject::invokeMethod(parent(), "hideToolView", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QWidget *, widget));
223  return success;
224 }
225 
227 {
231  bool success = false;
232  QMetaObject::invokeMethod(parent(), "showPluginConfigPage", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::Plugin *, plugin), Q_ARG(int, page));
233  return success;
234 }
235 
237 {
241  QObject *pluginView = nullptr;
242  QMetaObject::invokeMethod(parent(), "pluginView", Qt::DirectConnection, Q_RETURN_ARG(QObject *, pluginView), Q_ARG(QString, name));
243  return pluginView;
244 }
245 
246 } // namespace KTextEditor
void deleteViewBar(KTextEditor::View *view)
Delete the view bar for the given view.
Definition: mainwindow.cpp:146
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:178
ToolViewPosition
Toolview position.
Definition: mainwindow.h:222
bool showPluginConfigPage(KTextEditor::Plugin *plugin, int page)
Shows the plugin&#39;s config page.
Definition: mainwindow.cpp:226
bool closeView(KTextEditor::View *view)
Close selected view.
Definition: mainwindow.cpp:98
KTextEditor::View * activeView()
Access the active view.
Definition: mainwindow.cpp:68
virtual ~MainWindow()
Virtual Destructor.
Definition: mainwindow.cpp:34
QList< KTextEditor::View * > views()
Get a list of all views for this main window.
Definition: mainwindow.cpp:58
QWidget * widget() override
bool showToolView(QWidget *widget)
Show the toolview widget.
Definition: mainwindow.cpp:206
A KParts derived class representing a text document.
Definition: document.h:197
KTextEditor::View * activateView(KTextEditor::Document *document)
Activate the view with the corresponding document.
Definition: mainwindow.cpp:78
KTextEditor::View * openUrl(const QUrl &url, const QString &encoding=QString())
Open the document url with the given encoding.
Definition: mainwindow.cpp:88
QWidget * createViewBar(KTextEditor::View *view)
Try to create a view bar for the given view.
Definition: mainwindow.cpp:136
KXMLGUIFactory * guiFactory()
Accessor to the XMLGUIFactory.
Definition: mainwindow.cpp:48
void hideViewBar(KTextEditor::View *view)
Hide the view bar for the given view.
Definition: mainwindow.cpp:170
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
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:154
KTextEditor Plugin interface.
Definition: plugin.h:90
void showViewBar(KTextEditor::View *view)
Show the view bar for the given view.
Definition: mainwindow.cpp:162
bool viewsInSameSplitView(KTextEditor::View *view1, KTextEditor::View *view2)
Definition: mainwindow.cpp:126
QWidget * window()
Get the toplevel widget.
Definition: mainwindow.cpp:38
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:153
void splitView(Qt::Orientation orientation)
Split current view space according to .
Definition: mainwindow.cpp:108
QObject * parent() const const
bool moveToolView(QWidget *widget, KTextEditor::MainWindow::ToolViewPosition pos)
Move the toolview widget to position pos.
Definition: mainwindow.cpp:196
QObject * pluginView(const QString &name)
Get a plugin view for the plugin with with identifier name.
Definition: mainwindow.cpp:236
bool closeSplitView(KTextEditor::View *view)
Close the split view that contains the given view.
Definition: mainwindow.cpp:116
MainWindow(QObject *parent)
Construct an MainWindow wrapper object.
Definition: mainwindow.cpp:28
bool hideToolView(QWidget *widget)
Hide the toolview widget.
Definition: mainwindow.cpp:216
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun May 24 2020 23:10:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.