Receptacle
 All Classes Files Functions Variables Pages
util_runner.h
Go to the documentation of this file.
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 
27 #ifndef UTIL_RUNNER_H
28 #define UTIL_RUNNER_H
29 
30 #include <QRunnable>
31 #include <QObject>
32 #include "signal_counter.h"
33 #include "util_worker.h"
34 #include "log_emitter.h"
35 
36 class UtilRunner : public QObject, public QRunnable
37 {
38  Q_OBJECT
39 public:
49  UtilRunner(QString cmd, UtilWorker* util_worker, LogEmitter* err_emitter);
50 
55  QString command();
56 
62  bool is_hidden();
63 
64  QWidget* worker_widget();
65  bool has_widget();
66 
72  QString worker_widget_type();
73 
74 public slots:
75 
79  void request_cancel();
80 
81 protected:
82 
86  void run();
87 
88 signals:
89 
93  void init_complete();
94 
95 
101  void result(int ret_val);
102 
103 protected:
104  QString command_str;
105  UtilWorker* worker;
106  SignalCounter err_flag;
107  SignalCounter warn_flag;
108  int result_code;
109 };
110 
111 #endif // UTIL_RUNNER_H
The SignalCounter class is a simplified version of QSignalSpy.
Definition: signal_counter.h:33
Definition: log_emitter.h:41
void result(int ret_val)
Notify when the worker execution has finished.
bool is_hidden()
Determine if the utility shall be hidden or shown based on current state.
Definition: util_runner.cpp:62
QString command()
Accessor method for the command associated with this worker.
Definition: util_runner.cpp:58
void run()
Perform time-consuming task in a background thread when the thread pool queues it.
Definition: util_runner.cpp:36
void init_complete()
Publish that the worker has finished its initialization.
Definition: util_worker.h:41
UtilRunner(QString cmd, UtilWorker *util_worker, LogEmitter *err_emitter)
Constructor.
Definition: util_runner.cpp:29
void request_cancel()
request_cancel send a cancel request to the worker to exit early
Definition: util_runner.cpp:71
Definition: util_runner.h:36
QString worker_widget_type()
worker_widget_type gets the type of widget from the plugin
Definition: util_runner.cpp:85