VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediumSizeEditor.h@ 100347

Last change on this file since 100347 was 98103, checked in by vboxsync, 22 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: 4.0 KB
Line 
1/* $Id: UIMediumSizeEditor.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMediumSizeEditor 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_widgets_UIMediumSizeEditor_h
29#define FEQT_INCLUDED_SRC_widgets_UIMediumSizeEditor_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QRegularExpression>
36#include <QWidget>
37
38/* GUI includes: */
39#include "QIWithRetranslateUI.h"
40#include "UIDefs.h"
41#include "UILibraryDefs.h"
42
43/* Forward declarations: */
44class QLabel;
45class QSlider;
46class QString;
47class QWidget;
48class QILineEdit;
49
50/** Medium size editor widget. */
51class SHARED_LIBRARY_STUFF UIMediumSizeEditor : public QIWithRetranslateUI<QWidget>
52{
53 Q_OBJECT;
54
55signals:
56
57 /** Notifies listeners about medium size changed. */
58 void sigSizeChanged(qulonglong uSize);
59
60public:
61
62 /** Constructs medium size editor passing @a pParent to the base-class. */
63 UIMediumSizeEditor(QWidget *pParent = 0, qulonglong uMinimumSize = _4M);
64
65 /** Returns the medium size. */
66 qulonglong mediumSize() const { return m_uSize; }
67 /** Sets the initial medium size as the widget is created. */
68 void setMediumSize(qulonglong uSize);
69
70protected:
71
72 /** Handles translation event. */
73 virtual void retranslateUi() RT_OVERRIDE;
74
75private slots:
76
77 /** Handles size slider change. */
78 void sltSizeSliderChanged(int iValue);
79 /** Handles size editor text edit finished signal. */
80 void sltSizeEditorTextChanged();
81
82private:
83
84 /** Prepares all. */
85 void prepare();
86
87 /** Calculates slider scale according to passed @a uMaximumMediumSize. */
88 static int calculateSliderScale(qulonglong uMaximumMediumSize);
89 /** Returns log2 for passed @a uValue. */
90 static int log2i(qulonglong uValue);
91 /** Converts passed bytes @a uValue to slides scaled value using @a iSliderScale. */
92 static int sizeMBToSlider(qulonglong uValue, int iSliderScale);
93 /** Converts passed slider @a uValue to bytes unscaled value using @a iSliderScale. */
94 static qulonglong sliderToSizeMB(int uValue, int iSliderScale);
95 /** Updates slider/editor tool-tips. */
96 void updateSizeToolTips(qulonglong uSize);
97 /** Checks if the uSize is divisible by m_uSectorSize */
98 qulonglong checkSectorSizeAlignment(qulonglong uSize);
99 QString ensureSizeSuffix(const QString &strSizeString);
100
101 /* Holds the block size. We force m_uSize to be multiple of this number. */
102 static const qulonglong m_uSectorSize;
103 /** Holds the minimum medium size. */
104 const qulonglong m_uSizeMin;
105 /** Holds the maximum medium size. */
106 const qulonglong m_uSizeMax;
107 /** Holds the slider scale. */
108 const int m_iSliderScale;
109 /** Holds the current medium size. */
110 qulonglong m_uSize;
111 SizeSuffix m_enmSizeSuffix;
112
113 /** Holds the size slider. */
114 QSlider *m_pSlider;
115 /** Holds the minimum size label. */
116 QLabel *m_pLabelMinSize;
117 /** Holds the maximum size label. */
118 QLabel *m_pLabelMaxSize;
119 /** Holds the size editor. */
120 QILineEdit *m_pEditor;
121
122 /* A regular expression used to remove any character from a QString which is neither a digit nor decimal separator. */
123 QRegularExpression m_regExNonDigitOrSeparator;
124};
125
126#endif /* !FEQT_INCLUDED_SRC_widgets_UIMediumSizeEditor_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