VirtualBox

Changeset 46413 in vbox for trunk


Ignore:
Timestamp:
Jun 6, 2013 1:57:01 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM settings: Display page: Overall cleanup (part 2): Comments update, coding style.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r46411 r46413  
    6464#endif /* VBOX_WITH_CRHGSMI */
    6565{
    66     /* Apply UI decorations */
    67     Ui::UIMachineSettingsDisplay::setupUi (this);
    68 
    69     /* Setup constants */
     66    /* Apply UI decorations: */
     67    Ui::UIMachineSettingsDisplay::setupUi(this);
     68
     69    /* Prepare variables: */
    7070    CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties();
    7171    m_iMinVRAM = sys.GetMinGuestVRAM();
    7272    m_iMaxVRAM = sys.GetMaxGuestVRAM();
    7373    m_iMaxVRAMVisible = m_iMaxVRAM;
    74     const uint cMinGuestScreens = 1;
    7574#if (QT_VERSION >= 0x040600)
    7675    const uint cHostScreens = QApplication::desktop()->screenCount();
     
    7877    const uint cHostScreens = QApplication::desktop()->numScreens();
    7978#endif /* !(QT_VERSION >= 0x040600) */
     79    const uint cMinGuestScreens = 1;
    8080    const uint cMaxGuestScreens = sys.GetMaxGuestMonitors();
    8181
    82     /* Setup validators */
    83     m_pEditorMemory->setValidator (new QIntValidator (m_iMinVRAM, m_iMaxVRAMVisible, this));
    84     m_pEditorScreens->setValidator (new QIntValidator (cMinGuestScreens, cMaxGuestScreens, this));
    85     m_pEditorRemoteDisplayPort->setValidator (new QRegExpValidator (QRegExp("(([0-9]{1,5}(\\-[0-9]{1,5}){0,1}),)*([0-9]{1,5}(\\-[0-9]{1,5}){0,1})"), this));
    86     m_pEditorRemoteDisplayTimeout->setValidator (new QIntValidator (this));
    87 
    88     /* Setup connections */
    89     connect (m_pSliderMemory, SIGNAL (valueChanged (int)), this, SLOT (sltValueChangedVRAM (int)));
    90     connect (m_pEditorMemory, SIGNAL (textChanged (const QString&)), this, SLOT (sltTextChangedVRAM (const QString&)));
    91     connect (m_pSliderScreeens, SIGNAL (valueChanged (int)), this, SLOT (sltValueChangedScreens (int)));
    92     connect (m_pEditorScreens, SIGNAL (textChanged (const QString&)), this, SLOT (sltTextChangedScreens (const QString&)));
    93 
    94     /* Setup initial values */
    95     m_pSliderMemory->setPageStep (calcPageStep (m_iMaxVRAMVisible));
    96     m_pSliderMemory->setSingleStep (m_pSliderMemory->pageStep() / 4);
    97     m_pSliderMemory->setTickInterval (m_pSliderMemory->pageStep());
    98     m_pSliderScreeens->setPageStep (1);
    99     m_pSliderScreeens->setSingleStep (1);
    100     m_pSliderScreeens->setTickInterval (1);
    101     /* Setup the scale so that ticks are at page step boundaries */
    102     m_pSliderMemory->setMinimum ((m_iMinVRAM / m_pSliderMemory->pageStep()) * m_pSliderMemory->pageStep());
    103     m_pSliderMemory->setMaximum (m_iMaxVRAMVisible);
    104     m_pSliderMemory->setSnappingEnabled (true);
    105     m_pSliderMemory->setErrorHint (0, 1);
    106     m_pSliderScreeens->setMinimum (cMinGuestScreens);
    107     m_pSliderScreeens->setMaximum (cMaxGuestScreens);
    108     m_pSliderScreeens->setErrorHint (0, cMinGuestScreens);
    109     m_pSliderScreeens->setOptimalHint (cMinGuestScreens, cHostScreens);
    110     m_pSliderScreeens->setWarningHint (cHostScreens, cMaxGuestScreens);
    111     /* Limit min/max. size of QLineEdit */
    112     m_pEditorMemory->setFixedWidthByText (QString().fill ('8', 4));
    113     m_pEditorScreens->setFixedWidthByText (QString().fill ('8', 4));
    114     /* Ensure value and validation is updated */
    115     sltValueChangedVRAM (m_pSliderMemory->value());
    116     sltValueChangedScreens (m_pSliderScreeens->value());
    117     /* Setup VRDE widget */
    118     m_pComboRemoteDisplayAuthMethod->insertItem (0, ""); /* KAuthType_Null */
    119     m_pComboRemoteDisplayAuthMethod->insertItem (1, ""); /* KAuthType_External */
    120     m_pComboRemoteDisplayAuthMethod->insertItem (2, ""); /* KAuthType_Guest */
    121 
     82    /* Setup validators: */
     83    m_pEditorMemory->setValidator(new QIntValidator(m_iMinVRAM, m_iMaxVRAMVisible, this));
     84    m_pEditorScreens->setValidator(new QIntValidator(cMinGuestScreens, cMaxGuestScreens, this));
     85    m_pEditorRemoteDisplayPort->setValidator(new QRegExpValidator(QRegExp("(([0-9]{1,5}(\\-[0-9]{1,5}){0,1}),)*([0-9]{1,5}(\\-[0-9]{1,5}){0,1})"), this));
     86    m_pEditorRemoteDisplayTimeout->setValidator(new QIntValidator(this));
     87
     88    /* Setup connections: */
     89    connect(m_pSliderMemory, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedVRAM(int)));
     90    connect(m_pEditorMemory, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedVRAM(const QString&)));
     91    connect(m_pSliderScreeens, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedScreens(int)));
     92    connect(m_pEditorScreens, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedScreens(const QString&)));
     93
     94    /* Setup widgets: */
     95    m_pSliderMemory->setPageStep(calcPageStep(m_iMaxVRAMVisible));
     96    m_pSliderMemory->setSingleStep(m_pSliderMemory->pageStep() / 4);
     97    m_pSliderMemory->setTickInterval(m_pSliderMemory->pageStep());
     98    m_pSliderScreeens->setPageStep(1);
     99    m_pSliderScreeens->setSingleStep(1);
     100    m_pSliderScreeens->setTickInterval(1);
     101    /* Setup the scale so that ticks are at page step boundaries: */
     102    m_pSliderMemory->setMinimum((m_iMinVRAM / m_pSliderMemory->pageStep()) * m_pSliderMemory->pageStep());
     103    m_pSliderMemory->setMaximum(m_iMaxVRAMVisible);
     104    m_pSliderMemory->setSnappingEnabled(true);
     105    m_pSliderMemory->setErrorHint(0, 1);
     106    m_pSliderScreeens->setMinimum(cMinGuestScreens);
     107    m_pSliderScreeens->setMaximum(cMaxGuestScreens);
     108    m_pSliderScreeens->setErrorHint(0, cMinGuestScreens);
     109    m_pSliderScreeens->setOptimalHint(cMinGuestScreens, cHostScreens);
     110    m_pSliderScreeens->setWarningHint(cHostScreens, cMaxGuestScreens);
     111    /* Limit min/max. size of QLineEdit: */
     112    m_pEditorMemory->setFixedWidthByText(QString().fill('8', 4));
     113    m_pEditorScreens->setFixedWidthByText(QString().fill('8', 4));
     114    /* Ensure value and validation is updated: */
     115    sltValueChangedVRAM(m_pSliderMemory->value());
     116    sltValueChangedScreens(m_pSliderScreeens->value());
    122117#ifndef VBOX_WITH_VIDEOHWACCEL
    123     mCb2DVideo->setVisible (false);
    124 #endif /* VBOX_WITH_VIDEOHWACCEL */
    125 
    126     /* Applying language settings */
     118    /* Hide check-box if not supported: */
     119    mCb2DVideo->setVisible(false);
     120#endif /* VBOX_WITH_VIDEOHWACCEL */
     121
     122    /* Prepare auth-method combo: */
     123    m_pComboRemoteDisplayAuthMethod->insertItem(0, ""); /* KAuthType_Null */
     124    m_pComboRemoteDisplayAuthMethod->insertItem(1, ""); /* KAuthType_External */
     125    m_pComboRemoteDisplayAuthMethod->insertItem(2, ""); /* KAuthType_Guest */
     126
     127    /* Translate finally: */
    127128    retranslateUi();
    128129}
     
    172173    UIDataSettingsMachineDisplay displayData;
    173174
    174     /* Gather display data: */
     175    /* Cache Video data: */
    175176    displayData.m_iCurrentVRAM = m_machine.GetVRAMSize();
    176177    displayData.m_cGuestScreenCount = m_machine.GetMonitorCount();
     
    179180    displayData.m_f2dAccelerationEnabled = m_machine.GetAccelerate2DVideoEnabled();
    180181#endif /* VBOX_WITH_VIDEOHWACCEL */
    181     /* Check if VRDE server is valid: */
     182
     183    /* Check if Remote Display server is valid: */
    182184    CVRDEServer remoteDisplayServer = m_machine.GetVRDEServer();
    183185    displayData.m_fRemoteDisplayServerSupported = !remoteDisplayServer.isNull();
    184186    if (!remoteDisplayServer.isNull())
    185187    {
     188        /* Cache Remote Display data: */
    186189        displayData.m_fRemoteDisplayServerEnabled = remoteDisplayServer.GetEnabled();
    187190        displayData.m_strRemoteDisplayPort = remoteDisplayServer.GetVRDEProperty("TCP/Ports");
     
    208211    const UIDataSettingsMachineDisplay &displayData = m_cache.base();
    209212
    210     /* Load display data to page: */
     213    /* Load Video data to page: */
    211214    m_pSliderScreeens->setValue(displayData.m_cGuestScreenCount);
    212215    mCb3D->setChecked(displayData.m_f3dAccelerationEnabled);
     
    216219    checkVRAMRequirements();
    217220    m_pSliderMemory->setValue(displayData.m_iCurrentVRAM);
     221
     222    /* If Remote Display server is supported: */
    218223    if (displayData.m_fRemoteDisplayServerSupported)
    219224    {
     225        /* Load Remote Display data to page: */
    220226        m_pCheckboxRemoteDisplay->setChecked(displayData.m_fRemoteDisplayServerEnabled);
    221227        m_pEditorRemoteDisplayPort->setText(displayData.m_strRemoteDisplayPort);
     
    240246    UIDataSettingsMachineDisplay displayData = m_cache.base();
    241247
    242     /* Gather display data: */
     248    /* Gather Video data from page: */
    243249    displayData.m_iCurrentVRAM = m_pSliderMemory->value();
    244250    displayData.m_cGuestScreenCount = m_pSliderScreeens->value();
     
    247253    displayData.m_f2dAccelerationEnabled = mCb2DVideo->isChecked();
    248254#endif /* VBOX_WITH_VIDEOHWACCEL */
     255
     256    /* If Remote Display server is supported: */
    249257    if (displayData.m_fRemoteDisplayServerSupported)
    250258    {
     259        /* Gather Remote Display data from page: */
    251260        displayData.m_fRemoteDisplayServerEnabled = m_pCheckboxRemoteDisplay->isChecked();
    252261        displayData.m_strRemoteDisplayPort = m_pEditorRemoteDisplayPort->text();
     
    273282        const UIDataSettingsMachineDisplay &displayData = m_cache.data();
    274283
    275         /* Store display data: */
     284        /* Store Video data: */
    276285        if (isMachineOffline())
    277286        {
     
    284293#endif /* VBOX_WITH_VIDEOHWACCEL */
    285294        }
    286         /* Check if VRDE server still valid: */
     295
     296        /* Check if Remote Display server still valid: */
    287297        CVRDEServer remoteDisplayServer = m_machine.GetVRDEServer();
    288298        if (!remoteDisplayServer.isNull())
    289299        {
    290             /* Store VRDE data: */
     300            /* Store Remote Display data: */
    291301            if (isMachineInValidMode())
    292302            {
     
    310320{
    311321    m_pValidator = pValidator;
    312     connect (mCb3D, SIGNAL (stateChanged (int)),
    313              m_pValidator, SLOT (revalidate()));
    314 #ifdef VBOX_WITH_VIDEOHWACCEL
    315     connect (mCb2DVideo, SIGNAL (stateChanged (int)),
    316              m_pValidator, SLOT (revalidate()));
    317 #endif /* VBOX_WITH_VIDEOHWACCEL */
    318     connect (m_pCheckboxRemoteDisplay, SIGNAL (toggled (bool)),
    319              m_pValidator, SLOT (revalidate()));
    320     connect (m_pEditorRemoteDisplayPort, SIGNAL (textChanged (const QString&)),
    321              m_pValidator, SLOT (revalidate()));
    322     connect (m_pEditorRemoteDisplayTimeout, SIGNAL (textChanged (const QString&)),
    323              m_pValidator, SLOT (revalidate()));
     322    connect(mCb3D, SIGNAL(stateChanged(int)), m_pValidator, SLOT(revalidate()));
     323#ifdef VBOX_WITH_VIDEOHWACCEL
     324    connect(mCb2DVideo, SIGNAL(stateChanged(int)), m_pValidator, SLOT(revalidate()));
     325#endif /* VBOX_WITH_VIDEOHWACCEL */
     326    connect(m_pCheckboxRemoteDisplay, SIGNAL(toggled(bool)), m_pValidator, SLOT(revalidate()));
     327    connect(m_pEditorRemoteDisplayPort, SIGNAL(textChanged(const QString&)), m_pValidator, SLOT(revalidate()));
     328    connect(m_pEditorRemoteDisplayTimeout, SIGNAL(textChanged(const QString&)), m_pValidator, SLOT(revalidate()));
    324329}
    325330
     
    399404}
    400405
    401 void UIMachineSettingsDisplay::setOrderAfter (QWidget *pWidget)
     406void UIMachineSettingsDisplay::setOrderAfter(QWidget *pWidget)
    402407{
    403408    /* Video tab-order */
    404     setTabOrder (pWidget, m_pTabWidget->focusProxy());
    405     setTabOrder (m_pTabWidget->focusProxy(), m_pSliderMemory);
    406     setTabOrder (m_pSliderMemory, m_pEditorMemory);
    407     setTabOrder (m_pEditorMemory, m_pSliderScreeens);
    408     setTabOrder (m_pSliderScreeens, m_pEditorScreens);
    409     setTabOrder (m_pEditorScreens, mCb3D);
    410 #ifdef VBOX_WITH_VIDEOHWACCEL
    411     setTabOrder (mCb3D, mCb2DVideo);
    412     setTabOrder (mCb2DVideo, m_pCheckboxRemoteDisplay);
     409    setTabOrder(pWidget, m_pTabWidget->focusProxy());
     410    setTabOrder(m_pTabWidget->focusProxy(), m_pSliderMemory);
     411    setTabOrder(m_pSliderMemory, m_pEditorMemory);
     412    setTabOrder(m_pEditorMemory, m_pSliderScreeens);
     413    setTabOrder(m_pSliderScreeens, m_pEditorScreens);
     414    setTabOrder(m_pEditorScreens, mCb3D);
     415#ifdef VBOX_WITH_VIDEOHWACCEL
     416    setTabOrder(mCb3D, mCb2DVideo);
     417    setTabOrder(mCb2DVideo, m_pCheckboxRemoteDisplay);
    413418#else /* VBOX_WITH_VIDEOHWACCEL */
    414     setTabOrder (mCb3D, m_pCheckboxRemoteDisplay);
     419    setTabOrder(mCb3D, m_pCheckboxRemoteDisplay);
    415420#endif /* !VBOX_WITH_VIDEOHWACCEL */
    416421
    417     /* Remote display tab-order */
    418     setTabOrder (m_pCheckboxRemoteDisplay, m_pEditorRemoteDisplayPort);
    419     setTabOrder (m_pEditorRemoteDisplayPort, m_pComboRemoteDisplayAuthMethod);
    420     setTabOrder (m_pComboRemoteDisplayAuthMethod, m_pEditorRemoteDisplayTimeout);
    421     setTabOrder (m_pEditorRemoteDisplayTimeout, m_pCheckboxMultipleConn);
     422    /* Remote Display tab-order: */
     423    setTabOrder(m_pCheckboxRemoteDisplay, m_pEditorRemoteDisplayPort);
     424    setTabOrder(m_pEditorRemoteDisplayPort, m_pComboRemoteDisplayAuthMethod);
     425    setTabOrder(m_pComboRemoteDisplayAuthMethod, m_pEditorRemoteDisplayTimeout);
     426    setTabOrder(m_pEditorRemoteDisplayTimeout, m_pCheckboxMultipleConn);
    422427}
    423428
     
    425430{
    426431    /* Translate uic generated strings */
    427     Ui::UIMachineSettingsDisplay::retranslateUi (this);
    428 
     432    Ui::UIMachineSettingsDisplay::retranslateUi(this);
     433
     434    /* Video stuff: */
    429435    CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties();
    430     m_pLabelMemoryMin->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (m_iMinVRAM));
    431     m_pLabelMemoryMin->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (m_iMaxVRAMVisible));
    432     m_pLabelScreensMin->setText (tr ("<qt>%1</qt>").arg (1));
    433     m_pLabelScreensMax->setText (tr ("<qt>%1</qt>").arg (sys.GetMaxGuestMonitors()));
    434 
    435     m_pComboRemoteDisplayAuthMethod->setItemText (0,
    436         gpConverter->toString (KAuthType_Null));
    437     m_pComboRemoteDisplayAuthMethod->setItemText (1,
    438         gpConverter->toString (KAuthType_External));
    439     m_pComboRemoteDisplayAuthMethod->setItemText (2,
    440         gpConverter->toString (KAuthType_Guest));
    441 }
    442 
    443 void UIMachineSettingsDisplay::sltValueChangedVRAM (int iValue)
    444 {
    445     m_pEditorMemory->setText (QString::number (iValue));
    446 }
    447 
    448 void UIMachineSettingsDisplay::sltTextChangedVRAM (const QString &strText)
    449 {
    450     m_pSliderMemory->setValue (strText.toInt());
    451 }
    452 
    453 void UIMachineSettingsDisplay::sltValueChangedScreens (int iValue)
    454 {
    455     m_pEditorScreens->setText (QString::number (iValue));
     436    m_pLabelMemoryMin->setText(tr("<qt>%1&nbsp;MB</qt>").arg(m_iMinVRAM));
     437    m_pLabelMemoryMin->setText(tr("<qt>%1&nbsp;MB</qt>").arg(m_iMaxVRAMVisible));
     438    m_pLabelScreensMin->setText(tr("<qt>%1</qt>").arg(1));
     439    m_pLabelScreensMax->setText(tr("<qt>%1</qt>").arg(sys.GetMaxGuestMonitors()));
     440
     441    /* Remote Display stuff: */
     442    m_pComboRemoteDisplayAuthMethod->setItemText(0, gpConverter->toString(KAuthType_Null));
     443    m_pComboRemoteDisplayAuthMethod->setItemText(1, gpConverter->toString(KAuthType_External));
     444    m_pComboRemoteDisplayAuthMethod->setItemText(2, gpConverter->toString(KAuthType_Guest));
     445}
     446
     447void UIMachineSettingsDisplay::sltValueChangedVRAM(int iValue)
     448{
     449    m_pEditorMemory->setText(QString::number(iValue));
     450}
     451
     452void UIMachineSettingsDisplay::sltTextChangedVRAM(const QString &strText)
     453{
     454    m_pSliderMemory->setValue(strText.toInt());
     455}
     456
     457void UIMachineSettingsDisplay::sltValueChangedScreens(int iValue)
     458{
     459    m_pEditorScreens->setText(QString::number(iValue));
    456460    checkVRAMRequirements();
    457461}
    458462
    459 void UIMachineSettingsDisplay::sltTextChangedScreens (const QString &strText)
    460 {
    461     m_pSliderScreeens->setValue (strText.toInt());
     463void UIMachineSettingsDisplay::sltTextChangedScreens(const QString &strText)
     464{
     465    m_pSliderScreeens->setValue(strText.toInt());
    462466}
    463467
    464468void UIMachineSettingsDisplay::checkVRAMRequirements()
    465469{
     470    /* Make sure guest OS type is set: */
    466471    if (m_guestOSType.isNull())
    467472        return;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r46411 r46413  
    3030struct UIDataSettingsMachineDisplay
    3131{
    32     /* Default constructor: */
     32    /* Constructor: */
    3333    UIDataSettingsMachineDisplay()
    3434        : m_iCurrentVRAM(0)
     
    4343        , m_remoteDisplayAuthType(KAuthType_Null)
    4444        , m_uRemoteDisplayTimeout(0)
    45         , m_fRemoteDisplayMultiConnAllowed(false) {}
     45        , m_fRemoteDisplayMultiConnAllowed(false)
     46    {}
     47
    4648    /* Functions: */
    4749    bool equal(const UIDataSettingsMachineDisplay &other) const
     
    6062               (m_fRemoteDisplayMultiConnAllowed == other.m_fRemoteDisplayMultiConnAllowed);
    6163    }
     64
    6265    /* Operators: */
    6366    bool operator==(const UIDataSettingsMachineDisplay &other) const { return equal(other); }
    6467    bool operator!=(const UIDataSettingsMachineDisplay &other) const { return !equal(other); }
    65     /* Variables: */
     68
     69    /* Variables: Video stuff: */
    6670    int m_iCurrentVRAM;
    6771    int m_cGuestScreenCount;
     
    7074    bool m_f2dAccelerationEnabled;
    7175#endif /* VBOX_WITH_VIDEOHWACCEL */
     76
     77    /* Variables: Remote Display stuff: */
    7278    bool m_fRemoteDisplayServerSupported;
    7379    bool m_fRemoteDisplayServerEnabled;
     
    8187/* Machine settings / Display page: */
    8288class UIMachineSettingsDisplay : public UISettingsPageMachine,
    83                               public Ui::UIMachineSettingsDisplay
     89                                 public Ui::UIMachineSettingsDisplay
    8490{
    8591    Q_OBJECT;
     
    8793public:
    8894
     95    /* Constructor: */
    8996    UIMachineSettingsDisplay();
    9097
     98    /* API: Guest OS type stuff: */
    9199    void setGuestOSType(CGuestOSType guestOSType);
    92100
     101    /* API: 2D video acceleration stuff: */
    93102#ifdef VBOX_WITH_VIDEOHWACCEL
    94103    bool isAcceleration2DVideoSelected() const;
     
    111120    void saveFromCacheTo(QVariant &data);
    112121
    113     /* Page changed: */
     122    /* API: Cache stuff: */
    114123    bool changed() const { return m_cache.wasChanged(); }
    115124
     125    /* API: Validation stuff: */
    116126    void setValidator(QIWidgetValidator *pValidator);
    117127    bool revalidate(QString &strWarning, QString &strTitle);
    118128
     129    /* API: Focus-order stuff: */
    119130    void setOrderAfter(QWidget *pWidget);
    120131
     132    /* Helper: Translate stuff: */
    121133    void retranslateUi();
    122134
    123135private slots:
    124136
     137    /* Handlers: Video stuff: */
    125138    void sltValueChangedVRAM(int iValue);
    126139    void sltTextChangedVRAM(const QString &strText);
     
    130143private:
    131144
     145    /* Helpers: Video stuff: */
    132146    void checkVRAMRequirements();
    133147    bool shouldWeWarnAboutLowVideoMemory();
    134148
     149    /* Helper: Polish stuff: */
    135150    void polishPage();
    136151
     152    /* Validation stuff: */
    137153    QIWidgetValidator *m_pValidator;
    138 
    139154    /* Guest OS type id: */
    140155    CGuestOSType m_guestOSType;
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