Receptacle
 All Classes Files Functions Variables Pages
host_controller.h
1 /*
2 
3 Copyright 2014 William Wedler
4 
5 This file is part of Receptacle
6 
7 Receptacle is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Receptacle is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Receptacle. If not, see <http://www.gnu.org/licenses/>.
19 
20 */
21 
22 
23 
24 #ifndef HOST_CONTROLLER_H
25 #define HOST_CONTROLLER_H
26 
27 #include <QObject>
28 #include <QDebug>
29 #include <QThreadPool>
30 #include <QSystemTrayIcon>
31 #include "util_interface.h"
32 #include "util_collection.h"
33 #include "util_runner.h"
34 #include "util_collection.h"
35 #include "widgets/select_launcher.h"
36 #include "log_emitter.h"
37 #include "signal_counter.h"
38 
39 class HostController : public QObject
40 {
41  Q_OBJECT
42 public:
43  HostController(UtilCollection* u_collection, LogEmitter* log_emitter);
44  ~HostController();
45  void run_job(QString command);
46  void kill_job();
47  void notify_block();
48 
49 signals:
53  void setup_complete();
54 
60  void end_job(const QString &cmd);
61 
66  void util_result(int result);
67 
68 public slots:
74  void selected(QString cmd);
75 
76  void prompt_job_selection();
77 
78 protected:
79  UtilCollection* utils;
80  LogEmitter* logger;
81  SelectLauncher* main_window;
82  UtilRunner* bg_worker;
83  SignalCounter err_flag;
84  SignalCounter fatal_flag;
85  SignalCounter warn_flag;
86 
87 
89  QAction *minimizeAction;
90  QAction *maximizeAction;
91  QAction *restoreAction;
92  QAction *quitAction;
93  QAction *closeAction;
94  QAction *selectJobAction;
95 
96  QSystemTrayIcon *tray_icon;
97  QMenu * tray_icon_menu;
98 
99 
100  void create_tray_icon();
101  void create_tray_actions();
102  void connect_tray_actions(SelectLauncher* window);
103  void update_tray_menu();
104 
105 
106 protected slots:
107  void exec_plugin(QString command);
108  void cancel_handler();
109  void job_cleanup();
110  void job_complete_handler(int result);
111  void plugin_setup();
112 
113  void icon_activated(QSystemTrayIcon::ActivationReason reason);
114 };
115 
116 #endif // HOST_CONTROLLER_H
Definition: host_controller.h:39
void util_result(int result)
Publish the worker result after the worker ends execution.
The SignalCounter class is a simplified version of QSignalSpy.
Definition: signal_counter.h:33
void create_tray_icon()
SelectLauncher::create_tray_icon.
Definition: host_controller.cpp:342
Definition: log_emitter.h:41
void setup_complete()
Indicate that the post worker init setup steps performed by this HostController are done...
Definition: util_collection.h:34
QAction * minimizeAction
Tray actions.
Definition: host_controller.h:89
void end_job(const QString &cmd)
Indicate that the job is complete and HostController is cleaned up.
void selected(QString cmd)
Handler to load and execute the plugin specified by the given command.
Definition: host_controller.cpp:111
Definition: util_runner.h:36
Definition: select_launcher.h:43