1 | /* $Id: UIScaleFactorEditor.h 76532 2018-12-30 06:08:06Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIScaleFactorEditor class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2018 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 ___UIScaleFactorEditor_h___
|
---|
19 | #define ___UIScaleFactorEditor_h___
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* GUI includes: */
|
---|
25 | #include "QIWithRetranslateUI.h"
|
---|
26 | #include "UILibraryDefs.h"
|
---|
27 |
|
---|
28 | /* Forward declarations: */
|
---|
29 | class QComboBox;
|
---|
30 | class QGridLayout;
|
---|
31 | class QLabel;
|
---|
32 | class QSpinBox;
|
---|
33 | class QWidget;
|
---|
34 | class QIAdvancedSlider;
|
---|
35 |
|
---|
36 | /** QWidget reimplementation providing GUI with monitor scale factor editing functionality.
|
---|
37 | * It includes a combo box to select a monitor, a slider, and a spinbox to display/modify values.
|
---|
38 | * The first item in the combo box is used to change the scale factor of all monitors. */
|
---|
39 | class SHARED_LIBRARY_STUFF UIScaleFactorEditor : public QIWithRetranslateUI<QWidget>
|
---|
40 | {
|
---|
41 | Q_OBJECT;
|
---|
42 |
|
---|
43 | public:
|
---|
44 |
|
---|
45 | /** Creates scale factor editor passing @a pParent to the base-class. */
|
---|
46 | UIScaleFactorEditor(QWidget *pParent);
|
---|
47 |
|
---|
48 | /** Defines @a iMonitorCount. */
|
---|
49 | void setMonitorCount(int iMonitorCount);
|
---|
50 | /** Defines a list of guest-screen @a scaleFactors. */
|
---|
51 | void setScaleFactors(const QList<double> &scaleFactors);
|
---|
52 |
|
---|
53 | /** Returns either a single global scale factor or a list of scale factor for each monitor. */
|
---|
54 | QList<double> scaleFactors() const;
|
---|
55 |
|
---|
56 | /** Defines @a dDefaultScaleFactor. */
|
---|
57 | void setDefaultScaleFactor(double dDefaultScaleFactor);
|
---|
58 |
|
---|
59 | /** Defines minimum width @a iHint for internal spin-box. */
|
---|
60 | void setSpinBoxWidthHint(int iHint);
|
---|
61 |
|
---|
62 | protected:
|
---|
63 |
|
---|
64 | /** Handles translation event. */
|
---|
65 | virtual void retranslateUi() /* override */;
|
---|
66 |
|
---|
67 | private slots:
|
---|
68 |
|
---|
69 | /** @name Internal slots handling respective widget's value update.
|
---|
70 | * @{ */
|
---|
71 | void sltScaleSpinBoxValueChanged(int iValue);
|
---|
72 | void sltScaleSliderValueChanged(int iValue);
|
---|
73 | void sltMonitorComboIndexChanged(int iIndex);
|
---|
74 | /** @} */
|
---|
75 |
|
---|
76 | private:
|
---|
77 |
|
---|
78 | /** Prepares all. */
|
---|
79 | void prepare();
|
---|
80 |
|
---|
81 | /** Defines whether scale factor is @a fGlobal one. */
|
---|
82 | void setIsGlobalScaleFactor(bool fGlobal);
|
---|
83 | /** Defines @a iScaleFactor for certain @a iMonitorIndex. */
|
---|
84 | void setScaleFactor(int iMonitorIndex, int iScaleFactor);
|
---|
85 | /** Defines slider's @a iValue. */
|
---|
86 | void setSliderValue(int iValue);
|
---|
87 | /** Defines spinbox's @a iValue. */
|
---|
88 | void setSpinBoxValue(int iValue);
|
---|
89 |
|
---|
90 | /** Sets the spinbox and slider to scale factor of currently selected monitor. */
|
---|
91 | void updateValuesAfterMonitorChange();
|
---|
92 | /** Sets the min/max values of related widgets wrt. device pixel ratio(s) */
|
---|
93 | void configureScaleFactorMinMaxValues();
|
---|
94 | /** @name Member widgets.
|
---|
95 | * @{ */
|
---|
96 | QSpinBox *m_pScaleSpinBox;
|
---|
97 | QGridLayout *m_pMainLayout;
|
---|
98 | QComboBox *m_pMonitorComboBox;
|
---|
99 | QIAdvancedSlider *m_pScaleSlider;
|
---|
100 | QLabel *m_pMaxScaleLabel;
|
---|
101 | QLabel *m_pMinScaleLabel;
|
---|
102 | /** @} */
|
---|
103 |
|
---|
104 | /** Holds the per-monitor scale factors. The 0th item is for all monitors (global). */
|
---|
105 | QList<double> m_scaleFactors;
|
---|
106 | /** Holds the default scale factor. */
|
---|
107 | double m_dDefaultScaleFactor;
|
---|
108 | };
|
---|
109 |
|
---|
110 | #endif /* !___UIScaleFactorEditor_h___ */
|
---|