1 | /* $Id: UISettingsPage.cpp 76606 2019-01-02 05:40:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISettingsPage class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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 | /* GUI includes: */
|
---|
19 | #include "UIConverter.h"
|
---|
20 | #include "UISettingsPage.h"
|
---|
21 | #include "QIWidgetValidator.h"
|
---|
22 |
|
---|
23 |
|
---|
24 | /*********************************************************************************************************************************
|
---|
25 | * Class UISettingsPage implementation. *
|
---|
26 | *********************************************************************************************************************************/
|
---|
27 |
|
---|
28 | UISettingsPage::UISettingsPage()
|
---|
29 | : m_enmConfigurationAccessLevel(ConfigurationAccessLevel_Null)
|
---|
30 | , m_cId(-1)
|
---|
31 | , m_pFirstWidget(0)
|
---|
32 | , m_pValidator(0)
|
---|
33 | , m_fIsValidatorBlocked(true)
|
---|
34 | , m_fProcessed(false)
|
---|
35 | , m_fFailed(false)
|
---|
36 | {
|
---|
37 | }
|
---|
38 |
|
---|
39 | void UISettingsPage::notifyOperationProgressError(const QString &strErrorInfo)
|
---|
40 | {
|
---|
41 | QMetaObject::invokeMethod(this,
|
---|
42 | "sigOperationProgressError",
|
---|
43 | Qt::BlockingQueuedConnection,
|
---|
44 | Q_ARG(QString, strErrorInfo));
|
---|
45 | }
|
---|
46 |
|
---|
47 | void UISettingsPage::setValidator(UIPageValidator *pValidator)
|
---|
48 | {
|
---|
49 | /* Make sure validator is not yet assigned: */
|
---|
50 | AssertMsg(!m_pValidator, ("Validator already assigned!\n"));
|
---|
51 | if (m_pValidator)
|
---|
52 | return;
|
---|
53 |
|
---|
54 | /* Assign validator: */
|
---|
55 | m_pValidator = pValidator;
|
---|
56 | }
|
---|
57 |
|
---|
58 | void UISettingsPage::setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel)
|
---|
59 | {
|
---|
60 | m_enmConfigurationAccessLevel = enmConfigurationAccessLevel;
|
---|
61 | polishPage();
|
---|
62 | }
|
---|
63 |
|
---|
64 | void UISettingsPage::revalidate()
|
---|
65 | {
|
---|
66 | /* Revalidate if possible: */
|
---|
67 | if (m_pValidator && !m_fIsValidatorBlocked)
|
---|
68 | m_pValidator->revalidate();
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | /*********************************************************************************************************************************
|
---|
73 | * Class UISettingsPageGlobal implementation. *
|
---|
74 | *********************************************************************************************************************************/
|
---|
75 |
|
---|
76 | UISettingsPageGlobal::UISettingsPageGlobal()
|
---|
77 | {
|
---|
78 | }
|
---|
79 |
|
---|
80 | GlobalSettingsPageType UISettingsPageGlobal::internalID() const
|
---|
81 | {
|
---|
82 | return static_cast<GlobalSettingsPageType>(id());
|
---|
83 | }
|
---|
84 |
|
---|
85 | QString UISettingsPageGlobal::internalName() const
|
---|
86 | {
|
---|
87 | return gpConverter->toInternalString(internalID());
|
---|
88 | }
|
---|
89 |
|
---|
90 | QPixmap UISettingsPageGlobal::warningPixmap() const
|
---|
91 | {
|
---|
92 | return gpConverter->toWarningPixmap(internalID());
|
---|
93 | }
|
---|
94 |
|
---|
95 | void UISettingsPageGlobal::fetchData(const QVariant &data)
|
---|
96 | {
|
---|
97 | /* Fetch data to m_properties: */
|
---|
98 | m_properties = data.value<UISettingsDataGlobal>().m_properties;
|
---|
99 | }
|
---|
100 |
|
---|
101 | void UISettingsPageGlobal::uploadData(QVariant &data) const
|
---|
102 | {
|
---|
103 | /* Upload m_properties to data: */
|
---|
104 | data = QVariant::fromValue(UISettingsDataGlobal(m_properties));
|
---|
105 | }
|
---|
106 |
|
---|
107 |
|
---|
108 | /*********************************************************************************************************************************
|
---|
109 | * Class UISettingsPageMachine implementation. *
|
---|
110 | *********************************************************************************************************************************/
|
---|
111 |
|
---|
112 | UISettingsPageMachine::UISettingsPageMachine()
|
---|
113 | {
|
---|
114 | }
|
---|
115 |
|
---|
116 | MachineSettingsPageType UISettingsPageMachine::internalID() const
|
---|
117 | {
|
---|
118 | return static_cast<MachineSettingsPageType>(id());
|
---|
119 | }
|
---|
120 |
|
---|
121 | QString UISettingsPageMachine::internalName() const
|
---|
122 | {
|
---|
123 | return gpConverter->toInternalString(internalID());
|
---|
124 | }
|
---|
125 |
|
---|
126 | QPixmap UISettingsPageMachine::warningPixmap() const
|
---|
127 | {
|
---|
128 | return gpConverter->toWarningPixmap(internalID());
|
---|
129 | }
|
---|
130 |
|
---|
131 | void UISettingsPageMachine::fetchData(const QVariant &data)
|
---|
132 | {
|
---|
133 | /* Fetch data to m_machine & m_console: */
|
---|
134 | m_machine = data.value<UISettingsDataMachine>().m_machine;
|
---|
135 | m_console = data.value<UISettingsDataMachine>().m_console;
|
---|
136 | }
|
---|
137 |
|
---|
138 | void UISettingsPageMachine::uploadData(QVariant &data) const
|
---|
139 | {
|
---|
140 | /* Upload m_machine & m_console to data: */
|
---|
141 | data = QVariant::fromValue(UISettingsDataMachine(m_machine, m_console));
|
---|
142 | }
|
---|