VirtualBox

Changeset 72099 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 3, 2018 5:00:18 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Full and heavy cleanup for UISettingsPage and move it to VBoxGlobal library.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r72092 r72099  
    520520        src/selector/graphics/details/UIGDetailsElements.h \
    521521        src/selector/graphics/details/UIGMachinePreview.h \
    522         src/settings/UISettingsPage.h \
    523522        src/settings/UISettingsSelector.h \
    524523        src/settings/UISettingsSerializer.h \
     
    664663        src/settings/UISettingsDialog.h \
    665664        src/settings/UISettingsDialogSpecific.h \
     665        src/settings/UISettingsPage.h \
    666666        src/widgets/UIAddDiskEncryptionPasswordDialog.h \
    667667        src/widgets/UIBootTable.h \
     
    779779        src/settings/UISettingsDialog.h \
    780780        src/settings/UISettingsDialogSpecific.h \
     781        src/settings/UISettingsPage.h \
    781782        src/widgets/UIAddDiskEncryptionPasswordDialog.h \
    782783        src/widgets/UIBootTable.h \
     
    10361037        src/selector/graphics/details/UIGDetailsElements.cpp \
    10371038        src/selector/graphics/details/UIGMachinePreview.cpp \
    1038         src/settings/UISettingsPage.cpp \
    10391039        src/settings/UISettingsSelector.cpp \
    10401040        src/settings/UISettingsSerializer.cpp \
     
    12211221        src/settings/UISettingsDialog.cpp \
    12221222        src/settings/UISettingsDialogSpecific.cpp \
     1223        src/settings/UISettingsPage.cpp \
    12231224        src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \
    12241225        src/widgets/UIBootTable.cpp \
     
    13631364        src/settings/UISettingsDialog.cpp \
    13641365        src/settings/UISettingsDialogSpecific.cpp \
     1366        src/settings/UISettingsPage.cpp \
    13651367        src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \
    13661368        src/widgets/UIBootTable.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.cpp

    r71027 r72099  
    55
    66/*
    7  * Copyright (C) 2006-2017 Oracle Corporation
     7 * Copyright (C) 2006-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828
    2929
    30 /* Settings page constructor, hidden: */
    31 UISettingsPage::UISettingsPage(UISettingsPageType pageType)
    32     : m_pageType(pageType)
    33     , m_configurationAccessLevel(ConfigurationAccessLevel_Null)
     30/*********************************************************************************************************************************
     31*   Class UISettingsPage implementation.                                                                                         *
     32*********************************************************************************************************************************/
     33
     34UISettingsPage::UISettingsPage()
     35    : m_enmConfigurationAccessLevel(ConfigurationAccessLevel_Null)
    3436    , m_cId(-1)
    35     , m_fProcessed(false)
    36     , m_fFailed(false)
    3737    , m_pFirstWidget(0)
    3838    , m_pValidator(0)
    3939    , m_fIsValidatorBlocked(true)
     40    , m_fProcessed(false)
     41    , m_fFailed(false)
    4042{
    4143}
     
    6062}
    6163
     64void UISettingsPage::setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel)
     65{
     66    m_enmConfigurationAccessLevel = enmConfigurationAccessLevel;
     67    polishPage();
     68}
     69
    6270void UISettingsPage::revalidate()
    6371{
     
    6775}
    6876
    69 /* Global settings page constructor, hidden: */
     77
     78/*********************************************************************************************************************************
     79*   Class UISettingsPageGlobal implementation.                                                                                   *
     80*********************************************************************************************************************************/
     81
    7082UISettingsPageGlobal::UISettingsPageGlobal()
    71     : UISettingsPage(UISettingsPageType_Global)
    7283{
    7384}
     
    8899}
    89100
    90 /* Fetch data to m_properties: */
    91101void UISettingsPageGlobal::fetchData(const QVariant &data)
    92102{
     103    /* Fetch data to m_properties: */
    93104    m_properties = data.value<UISettingsDataGlobal>().m_properties;
    94105}
    95106
    96 /* Upload m_properties to data: */
    97107void UISettingsPageGlobal::uploadData(QVariant &data) const
    98108{
     109    /* Upload m_properties to data: */
    99110    data = QVariant::fromValue(UISettingsDataGlobal(m_properties));
    100111}
    101112
    102 /* Machine settings page constructor, hidden: */
     113
     114/*********************************************************************************************************************************
     115*   Class UISettingsPageMachine implementation.                                                                                  *
     116*********************************************************************************************************************************/
     117
    103118UISettingsPageMachine::UISettingsPageMachine()
    104     : UISettingsPage(UISettingsPageType_Machine)
    105119{
    106120}
     
    121135}
    122136
    123 /* Fetch data to m_machine & m_console: */
    124137void UISettingsPageMachine::fetchData(const QVariant &data)
    125138{
     139    /* Fetch data to m_machine & m_console: */
    126140    m_machine = data.value<UISettingsDataMachine>().m_machine;
    127141    m_console = data.value<UISettingsDataMachine>().m_console;
    128142}
    129143
    130 /* Upload m_machine & m_console to data: */
    131144void UISettingsPageMachine::uploadData(QVariant &data) const
    132145{
     146    /* Upload m_machine & m_console to data: */
    133147    data = QVariant::fromValue(UISettingsDataMachine(m_machine, m_console));
    134148}
    135 
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.h

    r71027 r72099  
    55
    66/*
    7  * Copyright (C) 2006-2017 Oracle Corporation
     7 * Copyright (C) 2006-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __UISettingsPage_h__
    19 #define __UISettingsPage_h__
     18#ifndef ___UISettingsPage_h___
     19#define ___UISettingsPage_h___
    2020
    2121/* Qt includes: */
     22#include <QVariant>
    2223#include <QWidget>
    23 #include <QVariant>
    2424
    2525/* GUI includes: */
    2626#include "QIWithRetranslateUI.h"
     27#include "UIExtraDataDefs.h"
    2728#include "UISettingsDefs.h"
    28 #include "UIExtraDataDefs.h"
    2929
    3030/* COM includes: */
    3131#include "COMEnums.h"
     32#include "CConsole.h"
    3233#include "CMachine.h"
    33 #include "CConsole.h"
    3434#include "CSystemProperties.h"
    3535
    3636/* Forward declarations: */
     37class QShowEvent;
     38class QString;
     39class QVariant;
     40class QWidget;
    3741class UIPageValidator;
    38 class QShowEvent;
    3942
    4043/* Using declarations: */
    4144using namespace UISettingsDefs;
    4245
    43 /* Settings page types: */
    44 enum UISettingsPageType
    45 {
    46     UISettingsPageType_Global,
    47     UISettingsPageType_Machine
    48 };
    49 
    50 /* Global settings data wrapper: */
     46
     47/** Global settings data wrapper. */
    5148struct UISettingsDataGlobal
    5249{
     50    /** Constructs NULL global settings data struct. */
    5351    UISettingsDataGlobal() {}
    54     UISettingsDataGlobal(const CSystemProperties &properties)
    55         : m_properties(properties) {}
     52    /** Constructs global settings data struct on the basis of @a comProperties. */
     53    UISettingsDataGlobal(const CSystemProperties &comProperties)
     54        : m_properties(comProperties) {}
     55    /** Holds the global VirtualBox properties. */
    5656    CSystemProperties m_properties;
    5757};
    5858Q_DECLARE_METATYPE(UISettingsDataGlobal);
    5959
    60 /* Machine settings data wrapper: */
     60
     61/** Machine settings data wrapper. */
    6162struct UISettingsDataMachine
    6263{
     64    /** Constructs NULL machine settings data struct. */
    6365    UISettingsDataMachine() {}
    64     UISettingsDataMachine(const CMachine &machine, const CConsole &console)
    65         : m_machine(machine), m_console(console) {}
     66    /** Constructs machine settings data struct on the basis of @a comMachine and @a comConsole. */
     67    UISettingsDataMachine(const CMachine &comMachine, const CConsole &comConsole)
     68        : m_machine(comMachine), m_console(comConsole) {}
     69    /** Holds the machine reference. */
    6670    CMachine m_machine;
     71    /** Holds the console reference. */
    6772    CConsole m_console;
    6873};
    6974Q_DECLARE_METATYPE(UISettingsDataMachine);
    7075
    71 /* Validation message type: */
     76
     77/** Validation message. */
    7278typedef QPair<QString, QStringList> UIValidationMessage;
    7379
    74 /* Settings page base class: */
    75 class UISettingsPage : public QIWithRetranslateUI<QWidget>
     80
     81/** QWidget subclass used as settings page interface. */
     82class SHARED_LIBRARY_STUFF UISettingsPage : public QIWithRetranslateUI<QWidget>
    7683{
    7784    Q_OBJECT;
     
    111118    void notifyOperationProgressError(const QString &strErrorInfo);
    112119
    113     /* Validation stuff: */
     120    /** Defines @a pValidator. */
    114121    void setValidator(UIPageValidator *pValidator);
     122    /** Defines whether @a fIsValidatorBlocked which means not used at all. */
    115123    void setValidatorBlocked(bool fIsValidatorBlocked) { m_fIsValidatorBlocked = fIsValidatorBlocked; }
    116     virtual bool validate(QList<UIValidationMessage>& /* messages */) { return true; }
    117 
    118     /* Navigation stuff: */
    119     QWidget* firstWidget() const { return m_pFirstWidget; }
     124    /** Performs page validation composing a list of @a messages. */
     125    virtual bool validate(QList<UIValidationMessage> &messages) { Q_UNUSED(messages); return true; }
     126
     127    /** Returns first navigation widget. */
     128    QWidget *firstWidget() const { return m_pFirstWidget; }
     129    /** Defines the first navigation widget for TAB-order. */
    120130    virtual void setOrderAfter(QWidget *pWidget) { m_pFirstWidget = pWidget; }
    121131
    122     /* Settings page type stuff: */
    123     UISettingsPageType pageType() const { return m_pageType; }
    124 
    125     /* Configuration access level stuff: */
    126     ConfigurationAccessLevel configurationAccessLevel() const { return m_configurationAccessLevel; }
    127     virtual void setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel) { m_configurationAccessLevel = newConfigurationAccessLevel; polishPage(); }
     132    /** Defines @a enmConfigurationAccessLevel. */
     133    virtual void setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel);
     134    /** Returns configuration access level. */
     135    ConfigurationAccessLevel configurationAccessLevel() const { return m_enmConfigurationAccessLevel; }
     136    /** Returns whether configuration access level is Full. */
    128137    bool isMachineOffline() const { return configurationAccessLevel() == ConfigurationAccessLevel_Full; }
     138    /** Returns whether configuration access level corresponds to machine in Powered Off state. */
    129139    bool isMachinePoweredOff() const { return configurationAccessLevel() == ConfigurationAccessLevel_Partial_PoweredOff; }
     140    /** Returns whether configuration access level corresponds to machine in Saved state. */
    130141    bool isMachineSaved() const { return configurationAccessLevel() == ConfigurationAccessLevel_Partial_Saved; }
     142    /** Returns whether configuration access level corresponds to machine in one of Running states. */
    131143    bool isMachineOnline() const { return configurationAccessLevel() == ConfigurationAccessLevel_Partial_Running; }
     144    /** Returns whether configuration access level corresponds to machine in one of allowed states. */
    132145    bool isMachineInValidMode() const { return isMachineOffline() || isMachinePoweredOff() || isMachineSaved() || isMachineOnline(); }
    133146
     
    135148    virtual bool changed() const = 0;
    136149
    137     /* Page 'ID' stuff: */
     150    /** Defines page @a cId. */
     151    void setId(int cId) { m_cId = cId; }
     152    /** Returns page ID. */
    138153    int id() const { return m_cId; }
    139     void setId(int cId) { m_cId = cId; }
    140 
    141     /* Page 'name' stuff: */
     154
     155    /** Returns page internal name. */
    142156    virtual QString internalName() const = 0;
    143157
    144     /* Page 'warning pixmap' stuff: */
     158    /** Returns page warning pixmap. */
    145159    virtual QPixmap warningPixmap() const = 0;
    146160
    147     /* Page 'processed' stuff: */
     161    /** Defines whether page is @a fProcessed. */
     162    void setProcessed(bool fProcessed) { m_fProcessed = fProcessed; }
     163    /** Returns whether page is processed. */
    148164    bool processed() const { return m_fProcessed; }
    149     void setProcessed(bool fProcessed) { m_fProcessed = fProcessed; }
    150 
    151     /* Page 'failed' stuff: */
     165
     166    /** Defines whether page processing is @a fFailed. */
     167    void setFailed(bool fFailed) { m_fFailed = fFailed; }
     168    /** Returns whether page processing is failed. */
    152169    bool failed() const { return m_fFailed; }
    153     void setFailed(bool fFailed) { m_fFailed = fFailed; }
    154 
    155     /* Virtual function to polish page content: */
     170
     171    /** Performs page polishing. */
    156172    virtual void polishPage() {}
    157173
    158174public slots:
    159175
    160     /* Handler: Validation stuff: */
     176    /** Performs validation. */
    161177    void revalidate();
    162178
    163179protected:
    164180
    165     /* Settings page constructor, hidden: */
    166     UISettingsPage(UISettingsPageType type);
     181    /** Constructs settings page. */
     182    UISettingsPage();
    167183
    168184private:
    169185
    170     /* Variables: */
    171     UISettingsPageType m_pageType;
    172     ConfigurationAccessLevel m_configurationAccessLevel;
    173     int m_cId;
    174     bool m_fProcessed;
    175     bool m_fFailed;
    176     QWidget *m_pFirstWidget;
     186    /** Holds the configuration access level. */
     187    ConfigurationAccessLevel  m_enmConfigurationAccessLevel;
     188
     189    /** Holds the page ID. */
     190    int  m_cId;
     191
     192    /** Holds the first TAB-orer widget reference. */
     193    QWidget         *m_pFirstWidget;
     194    /** Holds the page validator. */
    177195    UIPageValidator *m_pValidator;
    178     bool m_fIsValidatorBlocked;
    179 };
    180 
    181 /* Global settings page class: */
    182 class UISettingsPageGlobal : public UISettingsPage
     196
     197    /** Holds whether page validation is blocked. */
     198    bool  m_fIsValidatorBlocked : 1;
     199    /** Holds whether page is processed. */
     200    bool  m_fProcessed : 1;
     201    /** Holds whether page processing is failed. */
     202    bool  m_fFailed : 1;
     203};
     204
     205
     206/** UISettingsPage extension used as Global Preferences page interface. */
     207class SHARED_LIBRARY_STUFF UISettingsPageGlobal : public UISettingsPage
    183208{
    184209    Q_OBJECT;
     
    186211protected:
    187212
    188     /* Global settings page constructor, hidden: */
     213    /** Constructs global preferences page. */
    189214    UISettingsPageGlobal();
    190215
    191     /* Page 'ID' stuff: */
     216    /** Returns internal page ID. */
    192217    GlobalSettingsPageType internalID() const;
    193218
    194     /* Page 'name' stuff: */
    195     QString internalName() const;
    196 
    197     /* Page 'warning pixmap' stuff: */
    198     QPixmap warningPixmap() const;
    199 
    200     /* Fetch data to m_properties & m_settings: */
     219    /** Returns page internal name. */
     220    virtual QString internalName() const /* override */;
     221
     222    /** Returns page warning pixmap. */
     223    virtual QPixmap warningPixmap() const /* override */;
     224
     225    /** Returns whether the page content was changed. */
     226    virtual bool changed() const /* override */ { return false; }
     227
     228    /** Fetches data to m_properties & m_settings. */
    201229    void fetchData(const QVariant &data);
    202 
    203     /* Upload m_properties & m_settings to data: */
     230    /** Uploads m_properties & m_settings to data. */
    204231    void uploadData(QVariant &data) const;
    205232
    206     /** Returns whether the page content was changed. */
    207     bool changed() const { return false; }
    208 
    209     /* Global data source: */
     233    /** Holds the source of global preferences. */
    210234    CSystemProperties m_properties;
    211235};
    212236
    213 /* Machine settings page class: */
    214 class UISettingsPageMachine : public UISettingsPage
     237
     238/** UISettingsPage extension used as Machine Settings page interface. */
     239class SHARED_LIBRARY_STUFF UISettingsPageMachine : public UISettingsPage
    215240{
    216241    Q_OBJECT;
     
    218243protected:
    219244
    220     /* Machine settings page constructor, hidden: */
     245    /** Constructs machine settings page. */
    221246    UISettingsPageMachine();
    222247
    223     /* Page 'ID' stuff: */
     248    /** Returns internal page ID. */
    224249    MachineSettingsPageType internalID() const;
    225250
    226     /* Page 'name' stuff: */
    227     QString internalName() const;
    228 
    229     /* Page 'warning pixmap' stuff: */
    230     QPixmap warningPixmap() const;
    231 
    232     /* Fetch data to m_machine: */
     251    /** Returns page internal name. */
     252    virtual QString internalName() const /* override */;
     253
     254    /** Returns page warning pixmap. */
     255    virtual QPixmap warningPixmap() const /* override */;
     256
     257    /** Fetches data to m_machine & m_console. */
    233258    void fetchData(const QVariant &data);
    234 
    235     /* Upload m_machine to data: */
     259    /** Uploads m_machine & m_console to data. */
    236260    void uploadData(QVariant &data) const;
    237261
    238     /* Machine data source: */
     262    /** Holds the source of machine settings. */
    239263    CMachine m_machine;
     264    /** Holds the source of console settings. */
    240265    CConsole m_console;
    241266};
    242267
    243 #endif // __UISettingsPage_h__
    244 
     268
     269#endif /* !___UISettingsPage_h___ */
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