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