VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.h@ 85810

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

FE/Qt: bugref:9656: A bit of cleanup for UIScaleFactorEditor; This one related to proper slider label text and proper prepare cascade.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: UIScaleFactorEditor.h 85810 2020-08-18 09:09:21Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIScaleFactorEditor class declaration.
4 */
5
6/*
7 * Copyright (C) 2009-2020 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_UIScaleFactorEditor_h
19#define FEQT_INCLUDED_SRC_widgets_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: */
29class QComboBox;
30class QGridLayout;
31class QLabel;
32class QSpinBox;
33class QWidget;
34class 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. */
39class SHARED_LIBRARY_STUFF UIScaleFactorEditor : public QIWithRetranslateUI<QWidget>
40{
41 Q_OBJECT;
42
43public:
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
62protected:
63
64 /** Handles translation event. */
65 virtual void retranslateUi() /* override */;
66
67private 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
76private:
77
78 /** Prepares all. */
79 void prepare();
80 /** Prepare min/max values of related widgets wrt. device pixel ratio(s). */
81 void prepareScaleFactorMinMaxValues();
82
83 /** Defines whether scale factor is @a fGlobal one. */
84 void setIsGlobalScaleFactor(bool fGlobal);
85 /** Defines @a iScaleFactor for certain @a iMonitorIndex. */
86 void setScaleFactor(int iMonitorIndex, int iScaleFactor);
87 /** Defines slider's @a iValue. */
88 void setSliderValue(int iValue);
89 /** Defines spinbox's @a iValue. */
90 void setSpinBoxValue(int iValue);
91
92 /** Sets the spinbox and slider to scale factor of currently selected monitor. */
93 void updateValuesAfterMonitorChange();
94
95 /** @name Member widgets.
96 * @{ */
97 QGridLayout *m_pMainLayout;
98 QComboBox *m_pMonitorComboBox;
99 QIAdvancedSlider *m_pScaleSlider;
100 QSpinBox *m_pScaleSpinBox;
101 QLabel *m_pMinScaleLabel;
102 QLabel *m_pMaxScaleLabel;
103 /** @} */
104
105 /** Holds the per-monitor scale factors. The 0th item is for all monitors (global). */
106 QList<double> m_scaleFactors;
107 /** Holds the default scale factor. */
108 double m_dDefaultScaleFactor;
109};
110
111#endif /* !FEQT_INCLUDED_SRC_widgets_UIScaleFactorEditor_h */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette