File indexing completed on 2024-04-28 15:29:21
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org> 0004 SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef __MAINWINDOW_H 0010 #define __MAINWINDOW_H 0011 0012 #include <kparts/part.h> 0013 0014 #include <KXmlGuiWindow> 0015 #include <memory> 0016 0017 class QString; 0018 0019 namespace KParts 0020 { 0021 class MainWindowPrivate; 0022 0023 /** 0024 * @class MainWindow mainwindow.h <KParts/MainWindow> 0025 * 0026 * @short A KPart-aware main window, whose user interface is described in XML. 0027 * 0028 * It implements all internal interfaces in the case of a 0029 * KMainWindow as host: the builder and servant interface (for menu 0030 * merging). 0031 * 0032 * Inherit your main window from this class 0033 * and make sure to call @c setXMLFile() and @c setupGUI() before you 0034 * call @c createGUI() on the KPart. 0035 * 0036 * For example: 0037 * \code 0038 * setCentralWidget(m_part->widget()); 0039 * setXMLFile(QStringLiteral("appui.rc")); 0040 * setupGUI(ToolBar | Keys | StatusBar | Save); // Never Create flag here 0041 * createGUI(m_part); 0042 * \endcode 0043 * 0044 * @warning You should not pass the @c Default flag set to @c setupGUI(), 0045 * since it contains the @c Create flag, which is not supposed to be used 0046 * from this class. 0047 * @see KXmlGuiWindow::Create, @see setupGUI, @see createGUI 0048 * 0049 */ 0050 class KPARTS_EXPORT MainWindow : public KXmlGuiWindow, virtual public PartBase 0051 { 0052 Q_OBJECT 0053 public: 0054 /** 0055 * Constructor, same signature as KMainWindow. 0056 */ 0057 explicit MainWindow(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); 0058 /** 0059 * Destructor. 0060 */ 0061 ~MainWindow() override; 0062 0063 public Q_SLOTS: 0064 void configureToolbars() override; 0065 0066 protected Q_SLOTS: 0067 0068 /** 0069 * Create the GUI (by merging the host's and the active part's) 0070 * You _must_ call this in order to see any GUI being created. 0071 * 0072 * In a main window with multiple parts being shown (e.g. as in Konqueror) 0073 * you need to connect this slot to the 0074 * KPartManager::activePartChanged() signal 0075 * 0076 * @param part The active part (set to 0L if no part). 0077 */ 0078 void createGUI(KParts::Part *part); 0079 0080 /** 0081 * Enable or disable the automatic setting of window titles by the part's document title. 0082 * By default, a part always changes the window title when the document changes. 0083 * @note This value must be set before calling createGUI(). 0084 * 0085 * @param enabled boolean to enable or disable the window title handling 0086 * @since 5.24 0087 */ 0088 void setWindowTitleHandling(bool enabled); 0089 0090 /** 0091 * Called when the active part wants to change the statusbar message 0092 * Reimplement if your mainwindow has a complex statusbar 0093 * (with several items) 0094 */ 0095 virtual void slotSetStatusBarText(const QString &); 0096 0097 /** 0098 * Rebuilds the GUI after KEditToolBar changed the toolbar layout. 0099 * @see configureToolbars() 0100 */ 0101 void saveNewToolbarConfig() override; 0102 0103 protected: 0104 virtual void createShellGUI(bool create = true); 0105 0106 private: 0107 std::unique_ptr<MainWindowPrivate> const d; 0108 }; 0109 0110 } 0111 0112 #endif