1 /*
2     KSysGuard, the KDE System Guard
3 
4     Copyright (c) 1999, 2000 Chris Schlaeger <cs@kde.org>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License or (at your option) version 3 or any later version
10  accepted by the membership of KDE e.V. (or its successor approved
11  by the membership of KDE e.V.), which shall act as a proxy
12  defined in Section 14 of version 3 of the license.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #ifndef KSG_KSYSGUARD_H
24 #define KSG_KSYSGUARD_H
25 
26 #include <QEvent>
27 #include <QDBusMessage>
28 
29 #include <KXmlGuiWindow>
30 
31 #include <ksgrd/SensorClient.h>
32 
33 class QAction;
34 class QLabel;
35 class QSplitter;
36 
37 class ProcessController;
38 class SensorBrowserWidget;
39 class Workspace;
40 
41 class TopLevel : public KXmlGuiWindow, public KSGRD::SensorClient
42 {
43   Q_OBJECT
44   Q_CLASSINFO("D-Bus Interface", "org.kde.SystemMonitor")
45 
46   public:
47     TopLevel();
48 
49     void saveProperties( KConfigGroup& ) override;
50     void readProperties( const KConfigGroup& ) override;
51 
52     void answerReceived( int id, const QList<QByteArray> & ) override;
53 
54     void initStatusBar();
55     void setLocalProcessController(ProcessController * localProcessController);
localProcessController()56     ProcessController *localProcessController() const { return mLocalProcessController; }
57 
58   public Q_SLOTS:
59     Q_SCRIPTABLE Q_NOREPLY void showOnCurrentDesktop();
60     Q_SCRIPTABLE Q_NOREPLY void importWorkSheet( const QString &fileName );
61     Q_SCRIPTABLE Q_NOREPLY void removeWorkSheet( const QString &fileName );
62     Q_SCRIPTABLE Q_NOREPLY void getHotNewWorksheet();
63     Q_SCRIPTABLE QStringList listHosts();
64     Q_SCRIPTABLE QStringList listSensors( const QString &hostName );
65 
66 
67   protected:
68     bool event( QEvent* ) override;
69     void timerEvent( QTimerEvent* ) override;
70     bool queryClose() override;
71 
72   protected Q_SLOTS:
73     void connectHost();
74     void disconnectHost();
75     void updateStatusBar();
76     void currentTabChanged(int index);
77     void updateProcessCount();
78     void configureCurrentSheet();
79     void toggleShowMenuBar();
80 
81   private:
82     void setSwapInfo( qlonglong, qlonglong, const QString& );
83     void changeEvent( QEvent * event ) override;
84     void retranslateUi();
85 
86     QDBusMessage mDBusReply;
87 
88     QSplitter* mSplitter;
89     void startSensorBrowserWidget();  ///creates an mSensorBrowser if it doesn't exist
90 
91     SensorBrowserWidget* mSensorBrowser;
92     Workspace* mWorkSpace;
93 
94     int mTimerId;
95     QAction *mNewWorksheetAction;
96     QAction *mInsertWorksheetAction;
97     QAction *mTabExportAction;
98     QAction *mTabRemoveAction;
99     QAction *mMonitorRemoteAction;
100     QAction *mHotNewWorksheetAction;
101     QAction *mQuitAction;
102     QAction *mConfigureSheetAction;
103     QAction *mHotNewWorksheetUploadAction;
104     QAction *mRefreshTabAction;
105     QAction *mShowMenuBarAction;
106     QLabel *sbProcessCount;
107     QLabel *sbCpuStat;
108     QLabel *sbMemTotal;
109     QLabel *sbSwapTotal;
110     ProcessController *mLocalProcessController;
111 
112     QList<int> mSplitterSize;
113 };
114 
115 extern TopLevel* Toplevel;
116 
117 #endif
118