VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIDialogContainer.cpp@ 98103

Last change on this file since 98103 was 98103, checked in by vboxsync, 17 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: 3.9 KB
Line 
1/* $Id: QIDialogContainer.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QIDialogContainer class implementation.
4 */
5
6/*
7 * Copyright (C) 2019-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/* Qt includes: */
29#include <QGridLayout>
30#include <QLabel>
31#include <QProgressBar>
32#include <QPushButton>
33
34/* GUI includes: */
35#include "QIDialogButtonBox.h"
36#include "QIDialogContainer.h"
37
38/* Other VBox includes: */
39#include "iprt/assert.h"
40
41
42QIDialogContainer::QIDialogContainer(QWidget *pParent /* = 0 */, Qt::WindowFlags enmFlags /* = Qt::WindowFlags() */)
43 : QIWithRetranslateUI2<QDialog>(pParent, enmFlags)
44 , m_pLayout(0)
45 , m_pWidget(0)
46 , m_pProgressLabel(0)
47 , m_pProgressBar(0)
48 , m_pButtonBox(0)
49{
50 prepare();
51}
52
53void QIDialogContainer::setWidget(QWidget *pWidget)
54{
55 delete m_pWidget;
56 m_pWidget = pWidget;
57 if (m_pWidget)
58 m_pLayout->addWidget(m_pWidget, 0, 0);
59}
60
61void QIDialogContainer::setProgressBarHidden(bool fHidden)
62{
63 AssertPtrReturnVoid(m_pProgressLabel);
64 AssertPtrReturnVoid(m_pProgressBar);
65 m_pProgressLabel->setHidden(fHidden);
66 m_pProgressBar->setHidden(fHidden);
67}
68
69void QIDialogContainer::setOkButtonEnabled(bool fEnabled)
70{
71 AssertPtrReturnVoid(m_pButtonBox);
72 AssertPtrReturnVoid(m_pButtonBox->button(QDialogButtonBox::Ok));
73 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(fEnabled);
74}
75
76void QIDialogContainer::retranslateUi()
77{
78 m_pProgressLabel->setText(tr("Loading"));
79}
80
81void QIDialogContainer::prepare()
82{
83 /* Prepare layout: */
84 m_pLayout = new QGridLayout(this);
85 if (m_pLayout)
86 {
87 /* Prepare dialog button-box: */
88 m_pButtonBox = new QIDialogButtonBox(this);
89 if (m_pButtonBox)
90 {
91 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok);
92 connect(m_pButtonBox, &QIDialogButtonBox::accepted,
93 this, &QDialog::accept);
94 connect(m_pButtonBox, &QIDialogButtonBox::rejected,
95 this, &QDialog::reject);
96
97 /* Prepare progress-layout: */
98 QHBoxLayout *pHLayout = new QHBoxLayout;
99 if (pHLayout)
100 {
101 pHLayout->setContentsMargins(0, 0, 0, 0);
102
103 /* Prepare progress-label: */
104 m_pProgressLabel = new QLabel(this);
105 if (m_pProgressLabel)
106 {
107 m_pProgressLabel->setHidden(true);
108
109 /* Add into layout: */
110 pHLayout->addWidget(m_pProgressLabel);
111 }
112 /* Prepare progress-bar: */
113 m_pProgressBar = new QProgressBar(this);
114 if (m_pProgressBar)
115 {
116 m_pProgressBar->setHidden(true);
117 m_pProgressBar->setTextVisible(false);
118 m_pProgressBar->setMinimum(0);
119 m_pProgressBar->setMaximum(0);
120
121 /* Add into layout: */
122 pHLayout->addWidget(m_pProgressBar);
123 }
124
125 /* Add into button-box: */
126 m_pButtonBox->addExtraLayout(pHLayout);
127 }
128
129 /* Add into layout: */
130 m_pLayout->addWidget(m_pButtonBox, 1, 0);
131 }
132 }
133
134 /* Apply language settings: */
135 retranslateUi();
136}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use