1 | /* |
2 | This file is part of the KDE project |
3 | SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org> |
4 | SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #ifndef __MAINWINDOW_H |
10 | #define __MAINWINDOW_H |
11 | |
12 | #include <kparts/part.h> |
13 | |
14 | #include <KXmlGuiWindow> |
15 | #include <memory> |
16 | |
17 | class QString; |
18 | |
19 | namespace KParts |
20 | { |
21 | class MainWindowPrivate; |
22 | |
23 | /** |
24 | * @class MainWindow mainwindow.h <KParts/MainWindow> |
25 | * |
26 | * @short A KPart-aware main window, whose user interface is described in XML. |
27 | * |
28 | * It implements all internal interfaces in the case of a |
29 | * KMainWindow as host: the builder and servant interface (for menu |
30 | * merging). |
31 | * |
32 | * Inherit your main window from this class |
33 | * and make sure to call @c setXMLFile() and @c setupGUI() before you |
34 | * call @c createGUI() on the KPart. |
35 | * |
36 | * For example: |
37 | * \code |
38 | * setCentralWidget(m_part->widget()); |
39 | * setXMLFile(QStringLiteral("appui.rc")); |
40 | * setupGUI(ToolBar | Keys | StatusBar | Save); // Never Create flag here |
41 | * createGUI(m_part); |
42 | * \endcode |
43 | * |
44 | * @warning You should not pass the @c Default flag set to @c setupGUI(), |
45 | * since it contains the @c Create flag, which is not supposed to be used |
46 | * from this class. |
47 | * @see KXmlGuiWindow::Create, @see setupGUI, @see createGUI |
48 | * |
49 | */ |
50 | class KPARTS_EXPORT MainWindow : public KXmlGuiWindow, virtual public PartBase |
51 | { |
52 | Q_OBJECT |
53 | public: |
54 | /** |
55 | * Constructor, same signature as KMainWindow. |
56 | */ |
57 | explicit MainWindow(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); |
58 | /** |
59 | * Destructor. |
60 | */ |
61 | ~MainWindow() override; |
62 | |
63 | public Q_SLOTS: |
64 | void configureToolbars() override; |
65 | |
66 | protected Q_SLOTS: |
67 | |
68 | /** |
69 | * Create the GUI (by merging the host's and the active part's) |
70 | * You _must_ call this in order to see any GUI being created. |
71 | * |
72 | * In a main window with multiple parts being shown (e.g. as in Konqueror) |
73 | * you need to connect this slot to the |
74 | * KPartManager::activePartChanged() signal |
75 | * |
76 | * @param part The active part (set to 0L if no part). |
77 | */ |
78 | void createGUI(KParts::Part *part); |
79 | |
80 | /** |
81 | * Enable or disable the automatic setting of window titles by the part's document title. |
82 | * By default, a part always changes the window title when the document changes. |
83 | * @note This value must be set before calling createGUI(). |
84 | * |
85 | * @param enabled boolean to enable or disable the window title handling |
86 | * @since 5.24 |
87 | */ |
88 | void setWindowTitleHandling(bool enabled); |
89 | |
90 | /** |
91 | * Called when the active part wants to change the statusbar message |
92 | * Reimplement if your mainwindow has a complex statusbar |
93 | * (with several items) |
94 | */ |
95 | virtual void slotSetStatusBarText(const QString &); |
96 | |
97 | /** |
98 | * Rebuilds the GUI after KEditToolBar changed the toolbar layout. |
99 | * @see configureToolbars() |
100 | */ |
101 | void saveNewToolbarConfig() override; |
102 | |
103 | protected: |
104 | virtual void createShellGUI(bool create = true); |
105 | |
106 | private: |
107 | std::unique_ptr<MainWindowPrivate> const d; |
108 | }; |
109 | |
110 | } |
111 | |
112 | #endif |
113 | |