VirtualBox

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

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

scm --update-copyright-year

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

© 2023 Oracle
ContactPrivacy policyTerms of Use