VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.h@ 103551

Last change on this file since 103551 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/* $Id: UIWizardDiskEditors.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIWizardDiskEditors class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-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_wizards_editors_UIWizardDiskEditors_h
29#define FEQT_INCLUDED_SRC_wizards_editors_UIWizardDiskEditors_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QIcon>
36#include <QGroupBox>
37#include <QVector>
38
39/* Local includes: */
40#include "QIComboBox.h"
41#include "QIWithRetranslateUI.h"
42
43
44/* Forward declarations: */
45class CMediumFormat;
46class QButtonGroup;
47class QCheckBox;
48class QGridLayout;
49class QLabel;
50class QVBoxLayout;
51class QIRichTextLabel;
52class QILineEdit;
53class QIToolButton;
54class UIFilePathSelector;
55class UIHostnameDomainNameEditor;
56class UIPasswordLineEdit;
57class UIUserNamePasswordEditor;
58class UIMediumSizeEditor;
59
60/* Other VBox includes: */
61#include "COMEnums.h"
62#include "CMediumFormat.h"
63
64/** A set of static utility functions used by several wizard in the context of virtual media. */
65namespace UIWizardDiskEditors
66{
67 /** Makes sure that @strFileName is suffixed witht the @strExtension. */
68 SHARED_LIBRARY_STUFF QString appendExtension(const QString &strName, const QString &strExtension);
69 SHARED_LIBRARY_STUFF QString constructMediumFilePath(const QString &strFileName, const QString &strPath);
70 SHARED_LIBRARY_STUFF bool checkFATSizeLimitation(const qulonglong uVariant, const QString &strMediumPath, const qulonglong uSize);
71 SHARED_LIBRARY_STUFF QString openFileDialogForDiskFile(const QString &strInitialPath, const CMediumFormat &comMediumFormat,
72 KDeviceType enmDeviceType, QWidget *pParent);
73 /** Attempts to find a file extention for the device type @p enmDeviceType within the extensions
74 * returned by CMediumFormat::DescribeFileExtensions(..). */
75 SHARED_LIBRARY_STUFF QString defaultExtension(const CMediumFormat &mediumFormatRef, KDeviceType enmDeviceType);
76 /** Removes the file extension from @strFileName if @p formatExtensions contains it. */
77 SHARED_LIBRARY_STUFF QString stripFormatExtension(const QString &strFileName,
78 const QStringList &formatExtensions);
79};
80
81class SHARED_LIBRARY_STUFF UIDiskVariantWidget : public QIWithRetranslateUI<QWidget>
82{
83 Q_OBJECT;
84
85signals:
86
87 void sigMediumVariantChanged(qulonglong uVariant);
88
89public:
90
91 UIDiskVariantWidget(QWidget *pParent = 0);
92 /** Enable/disable medium variant radio button depending on the capabilities of the medium format. */
93 void updateMediumVariantWidgetsAfterFormatChange(const CMediumFormat &mediumFormat);
94 qulonglong mediumVariant() const;
95 void setMediumVariant(qulonglong uMediumVariant);
96 bool isComplete() const;
97
98 bool isCreateDynamicPossible() const;
99 bool isCreateFixedPossible() const;
100 bool isCreateSplitPossible() const;
101
102private slots:
103
104 void sltVariantChanged();
105
106private:
107
108 void prepare();
109 virtual void retranslateUi() /* override final */;
110
111 QCheckBox *m_pFixedCheckBox;
112 QCheckBox *m_pSplitBox;
113 bool m_fIsCreateDynamicPossible;
114 bool m_fIsCreateFixedPossible;
115 bool m_fIsCreateSplitPossible;
116};
117
118
119class SHARED_LIBRARY_STUFF UIMediumSizeAndPathGroupBox : public QIWithRetranslateUI<QGroupBox>
120{
121 Q_OBJECT;
122
123signals:
124
125 void sigMediumSizeChanged(qulonglong uSize);
126 void sigMediumPathChanged(const QString &strPath);
127 void sigMediumLocationButtonClicked();
128
129public:
130
131 UIMediumSizeAndPathGroupBox(bool fExpertMode, QWidget *pParent, qulonglong uMinimumMediumSize);
132 /** Returns name of the medium file without extension and path. */
133 QString mediumName() const;
134 /** Returns the file pat of the medium file including file name and extension. */
135 QString mediumFilePath() const;
136 void setMediumFilePath(const QString &strMediumPath);
137 /** Returns path of the medium file without the file name. */
138 QString mediumPath() const;
139 /** Checks if the file extension is correct. Fixs it if necessary. */
140 void updateMediumPath(const CMediumFormat &mediumFormat, const QStringList &formatExtensions, KDeviceType enmDeviceType);
141 qulonglong mediumSize() const;
142 void setMediumSize(qulonglong uSize);
143
144 bool isComplete() const;
145
146private:
147
148 void prepare(qulonglong uMinimumMediumSize);
149 virtual void retranslateUi() /* override final */;
150
151 QILineEdit *m_pLocationEditor;
152 QIToolButton *m_pLocationOpenButton;
153 UIMediumSizeEditor *m_pMediumSizeEditor;
154 QIRichTextLabel *m_pLocationLabel;
155 QIRichTextLabel *m_pSizeLabel;
156 bool m_fExpertMode;
157};
158
159/** Base class for the widgets used to select virtual medium format. It implements mutual functioanlity
160 * like finding name, extension etc for a CMediumFormat and device type. */
161class SHARED_LIBRARY_STUFF UIDiskFormatBase
162{
163public:
164
165 UIDiskFormatBase(KDeviceType enmDeviceType, bool fExpertMode);
166 virtual ~UIDiskFormatBase();
167 virtual CMediumFormat mediumFormat() const = 0;
168 virtual void setMediumFormat(const CMediumFormat &mediumFormat) = 0;
169
170 const CMediumFormat &VDIMediumFormat() const;
171 QStringList formatExtensions() const;
172
173protected:
174
175 struct Format
176 {
177 CMediumFormat m_comFormat;
178 QString m_strExtension;
179 bool m_fPreferred;
180 Format(const CMediumFormat &comFormat,
181 const QString &strExtension, bool fPreferred)
182 : m_comFormat(comFormat)
183 , m_strExtension(strExtension)
184 , m_fPreferred(fPreferred){}
185 Format(){}
186 };
187
188 void addFormat(CMediumFormat medFormat, bool fPreferred = false);
189 void populateFormats();
190 bool isExpertMode() const;
191 QVector<Format> m_formatList;
192
193private:
194
195 CMediumFormat m_comVDIMediumFormat;
196 KDeviceType m_enmDeviceType;
197 bool m_fExpertMode;
198};
199
200class SHARED_LIBRARY_STUFF UIDiskFormatsGroupBox : public QIWithRetranslateUI<QWidget>, public UIDiskFormatBase
201{
202 Q_OBJECT;
203
204signals:
205
206 void sigMediumFormatChanged();
207
208public:
209
210 UIDiskFormatsGroupBox(bool fExpertMode, KDeviceType enmDeviceType, QWidget *pParent = 0);
211 virtual CMediumFormat mediumFormat() const /* override final */;
212 virtual void setMediumFormat(const CMediumFormat &mediumFormat) /* override final */;
213
214private:
215
216 void prepare();
217 void createFormatWidgets();
218 virtual void retranslateUi() /* override final */;
219
220 QButtonGroup *m_pFormatButtonGroup;
221 QVBoxLayout *m_pMainLayout;
222};
223
224class SHARED_LIBRARY_STUFF UIDiskFormatsComboBox : public QIWithRetranslateUI<QIComboBox>, public UIDiskFormatBase
225{
226 Q_OBJECT;
227
228signals:
229
230 void sigMediumFormatChanged();
231
232public:
233
234 UIDiskFormatsComboBox(bool fExpertMode, KDeviceType enmDeviceType, QWidget *pParent = 0);
235 virtual CMediumFormat mediumFormat() const /* override final */;
236 virtual void setMediumFormat(const CMediumFormat &mediumFormat) /* override final */;
237
238private:
239
240 void prepare();
241 virtual void retranslateUi() /* override final */;
242};
243
244#endif /* !FEQT_INCLUDED_SRC_wizards_editors_UIWizardDiskEditors_h */
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