1 | /* $Id: UITask.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UITask class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_globals_UITask_h
|
---|
29 | #define FEQT_INCLUDED_SRC_globals_UITask_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QObject>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "UILibraryDefs.h"
|
---|
39 |
|
---|
40 | /** QObject extension used as worker-thread task interface.
|
---|
41 | * Describes task to be handled by the UIThreadPool object. */
|
---|
42 | class SHARED_LIBRARY_STUFF UITask : public QObject
|
---|
43 | {
|
---|
44 | Q_OBJECT;
|
---|
45 |
|
---|
46 | signals:
|
---|
47 |
|
---|
48 | /** Notifies listeners about @a pTask complete. */
|
---|
49 | void sigComplete(UITask *pTask);
|
---|
50 |
|
---|
51 | public:
|
---|
52 |
|
---|
53 | /** Task types. */
|
---|
54 | enum Type
|
---|
55 | {
|
---|
56 | Type_MediumEnumeration = 1,
|
---|
57 | Type_DetailsPopulation = 2,
|
---|
58 | Type_CloudListMachines = 3,
|
---|
59 | Type_CloudRefreshMachineInfo = 4,
|
---|
60 | Type_CloudGetSettingsForm = 5,
|
---|
61 | };
|
---|
62 |
|
---|
63 | /** Constructs the task of passed @a enmType. */
|
---|
64 | UITask(UITask::Type enmType) : m_enmType(enmType) {}
|
---|
65 |
|
---|
66 | /** Returns the type of the task. */
|
---|
67 | UITask::Type type() const { return m_enmType; }
|
---|
68 |
|
---|
69 | /** Starts the task. */
|
---|
70 | void start();
|
---|
71 |
|
---|
72 | protected:
|
---|
73 |
|
---|
74 | /** Contains the abstract task body. */
|
---|
75 | virtual void run() = 0;
|
---|
76 |
|
---|
77 | private:
|
---|
78 |
|
---|
79 | /** Holds the type of the task. */
|
---|
80 | const UITask::Type m_enmType;
|
---|
81 | };
|
---|
82 |
|
---|
83 | #endif /* !FEQT_INCLUDED_SRC_globals_UITask_h */
|
---|