Changeset View
Changeset View
Standalone View
Standalone View
kwrite/kwrite.h
Show All 17 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #ifndef KWRITE_MAIN_H | 21 | #ifndef KWRITE_MAIN_H | ||
22 | #define KWRITE_MAIN_H | 22 | #define KWRITE_MAIN_H | ||
23 | 23 | | |||
24 | #include <ktexteditor/view.h> | 24 | #include <ktexteditor/view.h> | ||
25 | #include <ktexteditor/document.h> | 25 | #include <ktexteditor/document.h> | ||
26 | #include <ktexteditor/mainwindow.h> | ||||
26 | 27 | | |||
27 | #include <KParts/MainWindow> | 28 | #include <KParts/MainWindow> | ||
28 | #include <KConfigGroup> | 29 | #include <KConfigGroup> | ||
29 | #include <KSharedConfig> | 30 | #include <KSharedConfig> | ||
30 | 31 | | |||
31 | #include <config.h> | 32 | #include <config.h> | ||
32 | 33 | | |||
33 | class QLabel; | 34 | class QLabel; | ||
34 | 35 | | |||
35 | namespace KActivities | 36 | namespace KActivities | ||
36 | { | 37 | { | ||
37 | class ResourceInstance; | 38 | class ResourceInstance; | ||
38 | } | 39 | } | ||
39 | 40 | | |||
40 | class KToggleAction; | 41 | class KToggleAction; | ||
41 | class KRecentFilesAction; | 42 | class KRecentFilesAction; | ||
42 | class KSqueezedTextLabel; | 43 | class KSqueezedTextLabel; | ||
44 | class KWriteApplication; | ||||
43 | 45 | | |||
44 | class KWrite : public KParts::MainWindow | 46 | class KWrite : public KParts::MainWindow | ||
45 | { | 47 | { | ||
46 | Q_OBJECT | 48 | Q_OBJECT | ||
47 | 49 | | |||
48 | public: | 50 | public: | ||
49 | KWrite(KTextEditor::Document * = nullptr); | 51 | KWrite(KTextEditor::Document * = nullptr, KWriteApplication *app = nullptr); | ||
50 | ~KWrite() override; | 52 | ~KWrite() override; | ||
51 | 53 | | |||
52 | void loadURL(const QUrl &url); | 54 | void loadURL(const QUrl &url); | ||
53 | 55 | | |||
54 | KTextEditor::View *view() const { | | |||
55 | return m_view; | | |||
56 | } | | |||
57 | | ||||
58 | static bool noWindows() { | | |||
59 | return winList.isEmpty(); | | |||
60 | } | | |||
61 | | ||||
62 | private: | 56 | private: | ||
63 | void setupActions(); | 57 | void setupActions(); | ||
64 | 58 | | |||
65 | void addMenuBarActionToContextMenu(); | 59 | void addMenuBarActionToContextMenu(); | ||
66 | void removeMenuBarActionFromContextMenu(); | 60 | void removeMenuBarActionFromContextMenu(); | ||
67 | 61 | | |||
68 | bool queryClose() override; | 62 | bool queryClose() override; | ||
69 | 63 | | |||
Show All 38 Lines | 100 | public: | |||
108 | void writeConfig(KSharedConfigPtr); | 102 | void writeConfig(KSharedConfigPtr); | ||
109 | 103 | | |||
110 | void readConfig(); | 104 | void readConfig(); | ||
111 | void writeConfig(); | 105 | void writeConfig(); | ||
112 | 106 | | |||
113 | //session management | 107 | //session management | ||
114 | public: | 108 | public: | ||
115 | void restore(KConfig *, int); | 109 | void restore(KConfig *, int); | ||
116 | static void restore(); | 110 | | ||
111 | public: | ||||
112 | KTextEditor::MainWindow *mainWindow() { return &m_mainWindow; } | ||||
113 | | ||||
114 | public Q_SLOTS: | ||||
115 | QWidget *window() { return this; } | ||||
116 | QList<KTextEditor::View *> views(); | ||||
117 | KTextEditor::View *activeView() { return m_view; } | ||||
118 | KTextEditor::View *activateView(KTextEditor::Document *document); | ||||
117 | 119 | | |||
118 | private: | 120 | private: | ||
119 | void readProperties(const KConfigGroup &) override; | 121 | void readProperties(const KConfigGroup &) override; | ||
120 | void saveProperties(KConfigGroup &) override; | 122 | void saveProperties(KConfigGroup &) override; | ||
121 | void saveGlobalProperties(KConfig *) override; | 123 | void saveGlobalProperties(KConfig *) override; | ||
122 | 124 | | |||
123 | private: | 125 | private: | ||
124 | KTextEditor::View *m_view; | 126 | KTextEditor::View *m_view; | ||
125 | 127 | | |||
126 | KRecentFilesAction *m_recentFiles; | 128 | KRecentFilesAction *m_recentFiles; | ||
127 | KToggleAction *m_paShowPath; | 129 | KToggleAction *m_paShowPath; | ||
128 | KToggleAction *m_paShowMenuBar; | 130 | KToggleAction *m_paShowMenuBar; | ||
129 | KToggleAction *m_paShowStatusBar; | 131 | KToggleAction *m_paShowStatusBar; | ||
130 | QAction *m_closeAction; | 132 | QAction *m_closeAction; | ||
131 | KActivities::ResourceInstance *m_activityResource; | 133 | KActivities::ResourceInstance *m_activityResource; | ||
132 | 134 | KWriteApplication *m_app; | |||
133 | static QList<KTextEditor::Document *> docList; | 135 | KTextEditor::MainWindow m_mainWindow; | ||
134 | static QList<KWrite *> winList; | | |||
135 | 136 | | |||
136 | public Q_SLOTS: | 137 | public Q_SLOTS: | ||
137 | void documentNameChanged(); | 138 | void documentNameChanged(); | ||
138 | 139 | | |||
139 | protected: | 140 | protected: | ||
140 | /** | 141 | /** | ||
141 | * Event filter for QApplication to handle mac os like file open | 142 | * Event filter for QApplication to handle mac os like file open | ||
142 | */ | 143 | */ | ||
143 | bool eventFilter(QObject *obj, QEvent *event) override; | 144 | bool eventFilter(QObject *obj, QEvent *event) override; | ||
144 | }; | 145 | }; | ||
145 | 146 | | |||
146 | #endif | 147 | #endif | ||
147 | |