1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * UIDownloaderAdditions class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2010 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef __UIDownloaderAdditions_h__
|
---|
20 | #define __UIDownloaderAdditions_h__
|
---|
21 |
|
---|
22 | /* Local includes */
|
---|
23 | #include "QIWithRetranslateUI.h"
|
---|
24 | #include "UIDownloader.h"
|
---|
25 |
|
---|
26 | /* Global includes */
|
---|
27 | #include <QPointer>
|
---|
28 |
|
---|
29 | class UIMiniProcessWidgetAdditions : public QIWithRetranslateUI<UIMiniProcessWidget>
|
---|
30 | {
|
---|
31 | Q_OBJECT;
|
---|
32 |
|
---|
33 | public:
|
---|
34 |
|
---|
35 | UIMiniProcessWidgetAdditions(const QString &strSource, QWidget *pParent = 0)
|
---|
36 | : QIWithRetranslateUI<UIMiniProcessWidget>(pParent)
|
---|
37 | {
|
---|
38 | setSource(strSource);
|
---|
39 | retranslateUi();
|
---|
40 | }
|
---|
41 |
|
---|
42 | protected:
|
---|
43 |
|
---|
44 | void retranslateUi()
|
---|
45 | {
|
---|
46 | setCancelButtonText(tr("Cancel"));
|
---|
47 | setCancelButtonToolTip(tr("Cancel the VirtualBox Guest "
|
---|
48 | "Additions CD image download"));
|
---|
49 | setProgressBarToolTip((tr("Downloading the VirtualBox Guest Additions "
|
---|
50 | "CD image from <nobr><b>%1</b>...</nobr>")
|
---|
51 | .arg(source())));
|
---|
52 | }
|
---|
53 | };
|
---|
54 |
|
---|
55 | class UIDownloaderAdditions : public UIDownloader
|
---|
56 | {
|
---|
57 | Q_OBJECT;
|
---|
58 |
|
---|
59 | public:
|
---|
60 | static UIDownloaderAdditions* create();
|
---|
61 | static UIDownloaderAdditions* current();
|
---|
62 | static void destroy();
|
---|
63 |
|
---|
64 | void setAction(QAction *pAction);
|
---|
65 | QAction *action() const;
|
---|
66 |
|
---|
67 | void setParentWidget(QWidget *pParent);
|
---|
68 | QWidget *parentWidget() const;
|
---|
69 |
|
---|
70 | UIMiniProcessWidgetAdditions* processWidget(QWidget *pParent = 0) const;
|
---|
71 | void startDownload();
|
---|
72 |
|
---|
73 | signals:
|
---|
74 | void downloadFinished(const QString &strFile);
|
---|
75 |
|
---|
76 | private slots:
|
---|
77 |
|
---|
78 | void downloadFinished(bool fError);
|
---|
79 | void suicide();
|
---|
80 |
|
---|
81 | private:
|
---|
82 |
|
---|
83 | UIDownloaderAdditions();
|
---|
84 |
|
---|
85 | bool confirmDownload();
|
---|
86 | void warnAboutError(const QString &strError);
|
---|
87 |
|
---|
88 | /* Private member vars */
|
---|
89 | static UIDownloaderAdditions *m_pInstance;
|
---|
90 |
|
---|
91 | /* We use QPointer here, cause these items could be deleted in the life of
|
---|
92 | * this object. QPointer guarantees that the ptr itself is zero in that
|
---|
93 | * case. */
|
---|
94 | QPointer<QAction> m_pAction;
|
---|
95 | QPointer<QWidget> m_pParent;
|
---|
96 | };
|
---|
97 |
|
---|
98 | #endif // __UIDownloaderAdditions_h__
|
---|
99 |
|
---|