VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.h@ 103988

Last change on this file since 103988 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1/* $Id: UIProgressDialog.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIProgressDialog class declaration.
4 */
5
6/*
7 * Copyright (C) 2009-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_widgets_UIProgressDialog_h
29#define FEQT_INCLUDED_SRC_widgets_UIProgressDialog_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* GUI includes: */
35#include "QIDialog.h"
36#include "QIWithRetranslateUI.h"
37#include "UILibraryDefs.h"
38
39/* Forward declarations: */
40class QLabel;
41class QProgressBar;
42class QILabel;
43class UIMiniCancelButton;
44class UIProgressEventHandler;
45class CProgress;
46
47/** QProgressDialog enhancement that allows to:
48 * 1) prevent closing the dialog when it has no cancel button;
49 * 2) effectively track the IProgress object completion (w/o using
50 * IProgress::waitForCompletion() and w/o blocking the UI thread in any other way for too long).
51 * @note The CProgress instance is passed as a non-const reference to the constructor (to memorize COM errors if they happen),
52 * and therefore must not be destroyed before the created UIProgressDialog instance is destroyed. */
53class SHARED_LIBRARY_STUFF UIProgressDialog : public QIWithRetranslateUI2<QIDialog>
54{
55 Q_OBJECT;
56
57signals:
58
59 /** Notifies listeners about wrapped CProgress change.
60 * @param iOperations Brings the number of operations CProgress have.
61 * @param strOperation Brings the description of the current CProgress operation.
62 * @param iOperation Brings the index of the current CProgress operation.
63 * @param iPercent Brings the percentage of the current CProgress operation. */
64 void sigProgressChange(ulong iOperations, QString strOperation,
65 ulong iOperation, ulong iPercent);
66
67public:
68
69 /** Constructs progress-dialog passing @a pParent to the base-class.
70 * @param comProgress Brings the progress reference.
71 * @param strTitle Brings the progress-dialog title.
72 * @param pImage Brings the progress-dialog image.
73 * @param cMinDuration Brings the minimum duration before the progress-dialog is shown. */
74 UIProgressDialog(CProgress &comProgress, const QString &strTitle,
75 QPixmap *pImage = 0, int cMinDuration = 2000, QWidget *pParent = 0);
76 /** Destructs progress-dialog. */
77 virtual ~UIProgressDialog() RT_OVERRIDE;
78
79 /** Executes the progress-dialog within its loop with passed @a iRefreshInterval. */
80 int run(int iRefreshInterval);
81
82public slots:
83
84 /** Shows progress-dialog if it's not yet shown. */
85 void show();
86
87protected:
88
89 /** Handles translation event. */
90 virtual void retranslateUi() RT_OVERRIDE;
91
92 /** Rejects dialog. */
93 virtual void reject() RT_OVERRIDE;
94
95 /** Handles timer @a pEvent. */
96 virtual void timerEvent(QTimerEvent *pEvent) RT_OVERRIDE;
97 /** Handles close @a pEvent. */
98 virtual void closeEvent(QCloseEvent *pEvent) RT_OVERRIDE;
99
100private slots:
101
102 /** Handles percentage changed event for progress with @a uProgressId to @a iPercent. */
103 void sltHandleProgressPercentageChange(const QUuid &uProgressId, const int iPercent);
104 /** Handles task completed event for progress with @a uProgressId. */
105 void sltHandleProgressTaskComplete(const QUuid &uProgressId);
106
107 /** Handles window stack changed signal. */
108 void sltHandleWindowStackChange();
109
110 /** Handles request to cancel operation. */
111 void sltCancelOperation();
112
113private:
114
115 /** Prepares all. */
116 void prepare();
117 /** Prepares event handler. */
118 void prepareEventHandler();
119 /** Prepares widgets. */
120 void prepareWidgets();
121 /** Cleanups widgets. */
122 void cleanupWidgets();
123 /** Cleanups event handler. */
124 void cleanupEventHandler();
125 /** Cleanups all. */
126 void cleanup();
127
128 /** Updates progress-dialog state. */
129 void updateProgressState();
130 /** Updates progress-dialog percentage. */
131 void updateProgressPercentage(int iPercent = -1);
132
133 /** Closes progress dialog (if possible). */
134 void closeProgressDialog();
135
136 /** Performes timer event handling. */
137 void handleTimerEvent();
138
139 /** Holds the progress reference. */
140 CProgress &m_comProgress;
141 /** Holds the progress-dialog title. */
142 QString m_strTitle;
143 /** Holds the dialog image. */
144 QPixmap *m_pImage;
145 /** Holds the minimum duration before the progress-dialog is shown. */
146 int m_cMinDuration;
147
148 /** Holds whether legacy handling is requested for this progress. */
149 bool m_fLegacyHandling;
150
151 /** Holds the image label instance. */
152 QLabel *m_pLabelImage;
153 /** Holds the description label instance. */
154 QILabel *m_pLabelDescription;
155 /** Holds the progress-bar instance. */
156 QProgressBar *m_pProgressBar;
157 /** Holds the cancel button instance. */
158 UIMiniCancelButton *m_pButtonCancel;
159 /** Holds the ETA label instance. */
160 QILabel *m_pLabelEta;
161
162 /** Holds the amount of operations. */
163 const ulong m_cOperations;
164 /** Holds the number of current operation. */
165 ulong m_uCurrentOperation;
166 /** Holds the weight of current operation. */
167 ulong m_uCurrentOperationWeight;
168 /** Holds whether progress cancel is enabled. */
169 bool m_fCancelEnabled;
170 /** Holds whether the progress has ended. */
171 bool m_fEnded;
172
173 /** Holds the progress event handler instance. */
174 UIProgressEventHandler *m_pEventHandler;
175
176 /** Holds the operation description template. */
177 static const char *m_spcszOpDescTpl;
178};
179
180#endif /* !FEQT_INCLUDED_SRC_widgets_UIProgressDialog_h */
181
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette