VirtualBox

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

Last change on this file since 82781 was 80859, checked in by vboxsync, 5 years ago

FE/Qt: bugref:9335: Connecting to text change rather than text edited.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use