1 | /* $Id: UINetworkManagerIndicator.h 76581 2019-01-01 06:24:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UINetworkManagerIndicator stuff declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef FEQT_INCLUDED_SRC_net_UINetworkManagerIndicator_h
|
---|
19 | #define FEQT_INCLUDED_SRC_net_UINetworkManagerIndicator_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QVector>
|
---|
26 | #include <QUuid>
|
---|
27 |
|
---|
28 | /* GUI includes: */
|
---|
29 | #include "QIStatusBarIndicator.h"
|
---|
30 | #include "QIWithRetranslateUI.h"
|
---|
31 | #include "UILibraryDefs.h"
|
---|
32 |
|
---|
33 | /* Forward declarations: */
|
---|
34 | class UINetworkRequest;
|
---|
35 |
|
---|
36 |
|
---|
37 | /** Network-manager status-bar indicator states. */
|
---|
38 | enum UINetworkManagerIndicatorState
|
---|
39 | {
|
---|
40 | UINetworkManagerIndicatorState_Idle,
|
---|
41 | UINetworkManagerIndicatorState_Loading,
|
---|
42 | UINetworkManagerIndicatorState_Error
|
---|
43 | };
|
---|
44 |
|
---|
45 |
|
---|
46 | /** QIStateStatusBarIndicator extension for network-manager indicator. */
|
---|
47 | class SHARED_LIBRARY_STUFF UINetworkManagerIndicator : public QIWithRetranslateUI<QIStateStatusBarIndicator>
|
---|
48 | {
|
---|
49 | Q_OBJECT;
|
---|
50 |
|
---|
51 | public:
|
---|
52 |
|
---|
53 | /** Constructs network manager indicator. */
|
---|
54 | UINetworkManagerIndicator();
|
---|
55 |
|
---|
56 | /** Updates appearance. */
|
---|
57 | void updateAppearance();
|
---|
58 |
|
---|
59 | public slots:
|
---|
60 |
|
---|
61 | /** Adds @a pNetworkRequest to network-manager state-indicators. */
|
---|
62 | void sltAddNetworkManagerIndicatorDescription(UINetworkRequest *pNetworkRequest);
|
---|
63 | /** Removes network-request with @a uuid from network-manager state-indicators. */
|
---|
64 | void sldRemoveNetworkManagerIndicatorDescription(const QUuid &uuid);
|
---|
65 |
|
---|
66 | protected:
|
---|
67 |
|
---|
68 | /** Handles translation event. */
|
---|
69 | virtual void retranslateUi() /* override */;
|
---|
70 |
|
---|
71 | private slots:
|
---|
72 |
|
---|
73 | /** Sets particular network-request @a uuid progress to 'started'. */
|
---|
74 | void sltSetProgressToStarted(const QUuid &uuid);
|
---|
75 | /** Sets particular network-request @a uuid progress to 'canceled'. */
|
---|
76 | void sltSetProgressToCanceled(const QUuid &uuid);
|
---|
77 | /** Sets particular network-request @a uuid progress to 'failed'. */
|
---|
78 | void sltSetProgressToFailed(const QUuid &uuid, const QString &strError);
|
---|
79 | /** Sets particular network-request @a uuid progress to 'finished'. */
|
---|
80 | void sltSetProgressToFinished(const QUuid &uuid);
|
---|
81 | /** Updates particular network-request @a uuid progress for @a iReceived amount of bytes among @a iTotal. */
|
---|
82 | void sltSetProgress(const QUuid &uuid, qint64 iReceived, qint64 iTotal);
|
---|
83 |
|
---|
84 | private:
|
---|
85 |
|
---|
86 | /** Network request data. */
|
---|
87 | struct UINetworkRequestData
|
---|
88 | {
|
---|
89 | /** Constructs network request data. */
|
---|
90 | UINetworkRequestData()
|
---|
91 | : bytesReceived(0), bytesTotal(0), failed(false) {}
|
---|
92 | /** Constructs network request data with @a strDescription, @a iBytesReceived and @a iBytesTotal. */
|
---|
93 | UINetworkRequestData(const QString &strDescription, int iBytesReceived, int iBytesTotal)
|
---|
94 | : description(strDescription), bytesReceived(iBytesReceived), bytesTotal(iBytesTotal), failed(false) {}
|
---|
95 | /** Holds the description. */
|
---|
96 | QString description;
|
---|
97 | /** Holds the amount of bytes received. */
|
---|
98 | int bytesReceived;
|
---|
99 | /** Holds the amount of total bytes. */
|
---|
100 | int bytesTotal;
|
---|
101 | /** Holds whether request is failed. */
|
---|
102 | bool failed;
|
---|
103 | };
|
---|
104 |
|
---|
105 | /** Update stuff. */
|
---|
106 | void recalculateIndicatorState();
|
---|
107 |
|
---|
108 | /** Holds the vector of network request IDs. */
|
---|
109 | QVector<QUuid> m_ids;
|
---|
110 | /** Holds the vector of network request data. */
|
---|
111 | QVector<UINetworkRequestData> m_data;
|
---|
112 | };
|
---|
113 |
|
---|
114 |
|
---|
115 | #endif /* !FEQT_INCLUDED_SRC_net_UINetworkManagerIndicator_h */
|
---|
116 |
|
---|