VirtualBox

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

Last change on this file was 104358, checked in by vboxsync, 4 weeks ago

FE/Qt. bugref:10622. More refactoring around the retranslation functionality.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/* $Id: UIMediumSizeEditor.h 104358 2024-04-18 05:33:40Z 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 "UILibraryDefs.h"
40
41/* Forward declarations: */
42class QLabel;
43class QSlider;
44class QString;
45class QWidget;
46class QILineEdit;
47
48/** Medium size editor widget. */
49class SHARED_LIBRARY_STUFF UIMediumSizeEditor : public QWidget
50{
51 Q_OBJECT;
52
53signals:
54
55 /** Notifies listeners about medium size changed. */
56 void sigSizeChanged(qulonglong uSize);
57
58public:
59
60 /** Constructs medium size editor passing @a pParent to the base-class. */
61 UIMediumSizeEditor(QWidget *pParent = 0, qulonglong uMinimumSize = _4M);
62
63 /** Returns the medium size. */
64 qulonglong mediumSize() const { return m_uSize; }
65 /** Sets the initial medium size as the widget is created. */
66 void setMediumSize(qulonglong uSize);
67
68private slots:
69
70 /** Handles translation event. */
71 void sltRetranslateUI();
72 /** Handles size slider change. */
73 void sltSizeSliderChanged(int iValue);
74 /** Handles size editor text edit finished signal. */
75 void sltSizeEditorTextChanged();
76
77private:
78
79 /** Prepares all. */
80 void prepare();
81
82 /** Calculates slider scale according to passed @a uMaximumMediumSize. */
83 static int calculateSliderScale(qulonglong uMaximumMediumSize);
84 /** Returns log2 for passed @a uValue. */
85 static int log2i(qulonglong uValue);
86 /** Converts passed bytes @a uValue to slides scaled value using @a iSliderScale. */
87 static int sizeMBToSlider(qulonglong uValue, int iSliderScale);
88 /** Converts passed slider @a uValue to bytes unscaled value using @a iSliderScale. */
89 static qulonglong sliderToSizeMB(int uValue, int iSliderScale);
90 /** Updates slider/editor tool-tips. */
91 void updateSizeToolTips(qulonglong uSize);
92 /** Checks if the uSize is divisible by m_uSectorSize */
93 qulonglong checkSectorSizeAlignment(qulonglong uSize);
94 QString ensureSizeSuffix(const QString &strSizeString);
95
96 /* Holds the block size. We force m_uSize to be multiple of this number. */
97 static const qulonglong m_uSectorSize;
98 /** Holds the minimum medium size. */
99 const qulonglong m_uSizeMin;
100 /** Holds the maximum medium size. */
101 const qulonglong m_uSizeMax;
102 /** Holds the slider scale. */
103 const int m_iSliderScale;
104 /** Holds the current medium size. */
105 qulonglong m_uSize;
106 /** Holds the size suffix. */
107 QString m_strSizeSuffix;
108
109 /** Holds the size slider. */
110 QSlider *m_pSlider;
111 /** Holds the minimum size label. */
112 QLabel *m_pLabelMinSize;
113 /** Holds the maximum size label. */
114 QLabel *m_pLabelMaxSize;
115 /** Holds the size editor. */
116 QILineEdit *m_pEditor;
117
118 /* A regular expression used to remove any character from a QString which is neither a digit nor decimal separator. */
119 QRegularExpression m_regExNonDigitOrSeparator;
120};
121
122#endif /* !FEQT_INCLUDED_SRC_widgets_UIMediumSizeEditor_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use