VirtualBox

Ignore:
Timestamp:
Oct 10, 2018 9:20:33 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9255. Some polishing on scale factor editor widget

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.cpp

    r74722 r74732  
    2121
    2222/* Qt includes: */
    23 #include <QComboBox>
    24 #include <QGridLayout>
    25 #include <QSpinBox>
     23# include <QComboBox>
     24# include <QGridLayout>
     25# include <QLabel>
     26# include <QSpacerItem>
     27# include <QSpinBox>
    2628# include <QWidget>
    2729
    2830/* GUI includes: */
    29 #include "QIAdvancedSlider.h"
    30 #include "UIScaleFactorEditor.h"
     31# include "QIAdvancedSlider.h"
     32# include "UIScaleFactorEditor.h"
    3133
    3234#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    3840    , m_pMainLayout(0)
    3941    , m_pMonitorComboBox(0)
     42    , m_pScaleSlider(0)
     43    , m_pMaxScaleLabel(0)
     44    , m_pMinScaleLabel(0)
    4045{
    4146    /* Prepare: */
     
    7176        int currentMonitorIndex = m_pMonitorComboBox->currentIndex();
    7277        if (m_scaleFactors.size() > currentMonitorIndex && m_pScaleSpinBox)
    73             m_pScaleSpinBox->setValue(100 * m_scaleFactors.at(currentMonitorIndex));
     78            setSpinBoxValue(100 * m_scaleFactors.at(currentMonitorIndex));
    7479    }
    7580}
     
    8287void UIScaleFactorEditor::retranslateUi()
    8388{
     89    if (m_pMaxScaleLabel)
     90    {
     91        m_pMaxScaleLabel->setText(tr("Max"));
     92    }
     93
     94    if (m_pMinScaleLabel)
     95    {
     96        m_pMinScaleLabel->setText(tr("Min"));
     97    }
    8498}
    8599
     
    104118
    105119    /* Update the slider and spinbox values without emitting signals: */
    106     int scaleFactor = 100 *m_scaleFactors[index];
     120    int scaleFactor = 100 * m_scaleFactors[index];
    107121    setSliderValue(scaleFactor);
    108122    setSpinBoxValue(scaleFactor);
     
    114128    if (!m_pMainLayout)
    115129        return;
     130    QMargins margins = m_pMainLayout->contentsMargins();
     131    m_pMainLayout->setContentsMargins(0, margins.top(), 0, margins.bottom());
    116132    m_pMonitorComboBox = new QComboBox;
    117133    if (m_pMonitorComboBox)
     
    121137                this, &UIScaleFactorEditor::sltMonitorComboIndexChanged);
    122138    }
    123     m_pScaleSpinBox = new QSpinBox;
    124     if (m_pScaleSpinBox)
    125     {
    126         m_pMainLayout->addWidget(m_pScaleSpinBox, 0, 2);
    127         m_pScaleSpinBox->setMinimum(100);
    128         m_pScaleSpinBox->setMaximum(200);
    129         connect(m_pScaleSpinBox ,static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
    130                 this, &UIScaleFactorEditor::sltScaleSpinBoxValueChanged);
    131     }
    132 
     139
     140    QGridLayout *pSliderLayout = new QGridLayout;
     141    pSliderLayout->setSpacing(0);
    133142    m_pScaleSlider = new QIAdvancedSlider;
    134143    {
    135         m_pMainLayout->addWidget(m_pScaleSlider, 0, 1);
     144        pSliderLayout->addWidget(m_pScaleSlider, 0, 0, 1, 3);
    136145        m_pScaleSlider->setMinimum(100);
    137146        m_pScaleSlider->setMaximum(200);
     
    143152                this, &UIScaleFactorEditor::sltScaleSliderValueChanged);
    144153    }
     154
     155    m_pMinScaleLabel = new QLabel;
     156    if (m_pMinScaleLabel)
     157        pSliderLayout->addWidget(m_pMinScaleLabel, 1, 0);
     158
     159    QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
     160    if (pSpacer)
     161        pSliderLayout->addItem(pSpacer, 1, 1);
     162
     163    m_pMaxScaleLabel = new QLabel;
     164    if (m_pMaxScaleLabel)
     165        pSliderLayout->addWidget(m_pMaxScaleLabel, 1, 2);
     166
     167    m_pMainLayout->addLayout(pSliderLayout, 0, 1, 2, 1);
     168
     169    m_pScaleSpinBox = new QSpinBox;
     170    if (m_pScaleSpinBox)
     171    {
     172        m_pMainLayout->addWidget(m_pScaleSpinBox, 0, 3);
     173        m_pScaleSpinBox->setMinimum(100);
     174        m_pScaleSpinBox->setMaximum(200);
     175        connect(m_pScaleSpinBox ,static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
     176                this, &UIScaleFactorEditor::sltScaleSpinBoxValueChanged);
     177    }
     178
     179
    145180    setLayout(m_pMainLayout);
     181    retranslateUi();
    146182}
    147183
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.h

    r74722 r74732  
    3030class QComboBox;
    3131class QGridLayout;
     32class QLabel;
    3233class QSpinBox;
    3334class QWidget;
     
    4041    Q_OBJECT;
    4142
    42 signals:
    43 
    4443public:
    4544
     
    5150
    5251protected:
     52
    5353    virtual void retranslateUi() /* override */;
    5454
    5555private slots:
     56
    5657    void sltScaleSpinBoxValueChanged(int value);
    5758    void sltScaleSliderValueChanged(int value);
     
    5960
    6061private:
     62
    6163    void prepare();
    6264    void setScaleFactor(int iMonitorIndex, int iScaleFactor);
     65    /* Blocks slider's signals before settting the value. */
    6366    void setSliderValue(int iValue);
     67    /* Blocks slider's signals before settting the value. */
    6468    void setSpinBoxValue(int iValue);
    6569    QSpinBox          *m_pScaleSpinBox;
     
    6771    QComboBox         *m_pMonitorComboBox;
    6872    QIAdvancedSlider  *m_pScaleSlider;
     73    QLabel            *m_pMaxScaleLabel;
     74    QLabel            *m_pMinScaleLabel;
    6975    /* Stores the per-monitor scale factors in range [.., 1, ..] */
    7076    QList<double>      m_scaleFactors;
Note: See TracChangeset for help on using the changeset viewer.

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