1 /*
2     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 // KDE includes
10 #include <KConfig>
11 #include <kxmlguiwindow.h>
12 
13 #include "logModeAction.h"
14 
15 class LogManager;
16 class LogMode;
17 
18 class View;
19 
20 class TabLogViewsWidget;
21 class QPrinter;
22 class DetailDialog;
23 class LoggerDialog;
24 class ConfigurationDialog;
25 namespace KSystemLog
26 {
27 class StatusBar;
28 /**
29  * This class serves as the main window for ksystemlog.  It handles the
30  * menus, toolbars, and status bars.
31  */
32 class MainWindow : public KXmlGuiWindow
33 {
34     Q_OBJECT
35 
36 public:
37     /**
38      * Default Constructor
39      */
40     MainWindow();
41 
42     /**
43      * Default Destructor
44      */
45     ~MainWindow() override;
46 
47     TabLogViewsWidget *tabs();
48 
49 protected:
50     /**
51      * This function is called when it is time for the app to save its
52      * properties for session management purposes.
53      */
54     void saveProperties(KConfigGroup &configuration) override;
55 
56     /**
57      * This function is called when this app is restored.  The KConfig
58      * object points to the session management config file that was saved
59      * with @ref saveProperties
60      */
61     void readProperties(const KConfigGroup &configuration) override;
62 
63     /**
64      * Reimplemented to save configuration when closing.
65      */
66     void closeEvent(QCloseEvent *event) override;
67 
68 public Q_SLOTS:
69     void changeStatusBar(const QString &text);
70     void changeWindowTitle(const QString &text);
71 
72     void updateStatusBar();
73 
74     void prepareCreatedLogManager(LogManager *logManager);
75 
76 private Q_SLOTS:
77     void fileOpen();
78 
79     void showConfigurationDialog();
80     void showDetailsDialog();
81     void showLogMessageDialog();
82 
83     // Transmits signals to active LogManager
84     void showSearchBar();
85     void findNext();
86     void findPrevious();
87 
88     void updateSelection();
89     void updateReloading();
90 
91     void toggleFilterBar();
92 
93     void toggleItemTooltip(bool enabled);
94     void toggleNewLinesDisplaying(bool displayed);
95     void toggleResumePauseParsing(bool paused);
96 
97     void changeCurrentTab();
98 
99     void changeResumePauseAction(bool paused);
100     void selectLogModeAction(bool);
101     void recreateActions();
102 
103 private:
104     void loadLogModePlugins();
105 
106     void setupStatusBar();
107 
108     void setupTabLogViews();
109 
110     void setupActions();
111     void setupLogModeMenu();
112     void setupLogActions();
113 
114     void updateDetailDialog();
115 
116     QAction *mSaveAction = nullptr;
117     QAction *mCopyAction = nullptr;
118 
119     QAction *mReloadAction = nullptr;
120 
121     QAction *mSendMailAction = nullptr;
122     QAction *mLogMessageAction = nullptr;
123 
124     QAction *mFilterBarAction = nullptr;
125 
126     QAction *mSelectAllAction = nullptr;
127 
128     QAction *mExpandAllAction = nullptr;
129     QAction *mCollapseAllAction = nullptr;
130 
131     QAction *mResumePauseAction = nullptr;
132     QAction *mDetailAction = nullptr;
133     QAction *mPrintAction = nullptr;
134     QAction *mPrintPreviewAction = nullptr;
135 
136     QAction *mFindAction = nullptr;
137     QAction *mFindNextAction = nullptr;
138     QAction *mFindPreviousAction = nullptr;
139 
140     QAction *mTooltipEnabledAction = nullptr;
141     QAction *mNewLinesDisplayedAction = nullptr;
142 
143     /**
144      * Action groups which stores all Log Mode Actions
145      */
146     QActionGroup *mLogModesActionGroup = nullptr;
147 
148     QPrinter *mPrinter = nullptr;
149 
150     /**
151      * Detail dialog
152      */
153     DetailDialog *mDetailDialog = nullptr;
154 
155     /**
156      * Logged Dialog
157      */
158     LoggerDialog *mLoggedDialog = nullptr;
159 
160     ConfigurationDialog *mConfigurationDialog = nullptr;
161 
162     /**
163      * Tab widget managing different views
164      */
165     TabLogViewsWidget *mTabs = nullptr;
166 
167     KSystemLog::StatusBar *mStatusBar = nullptr;
168 };
169 }
170 
171