VirtualBox

Changeset 72105 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 4, 2018 8:57:19 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Small cleanup for UISettingsSerializer classes and move them to VBoxGlobal library.

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

Legend:

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

    r72102 r72105  
    520520        src/selector/graphics/details/UIGDetailsElements.h \
    521521        src/selector/graphics/details/UIGMachinePreview.h \
    522         src/settings/UISettingsSerializer.h \
    523522        src/settings/global/UIGlobalSettingsExtension.h \
    524523        src/settings/global/UIGlobalSettingsGeneral.h \
     
    664663        src/settings/UISettingsPage.h \
    665664        src/settings/UISettingsSelector.h \
     665        src/settings/UISettingsSerializer.h \
    666666        src/widgets/UIAddDiskEncryptionPasswordDialog.h \
    667667        src/widgets/UIBootTable.h \
     
    781781        src/settings/UISettingsPage.h \
    782782        src/settings/UISettingsSelector.h \
     783        src/settings/UISettingsSerializer.h \
    783784        src/widgets/UIAddDiskEncryptionPasswordDialog.h \
    784785        src/widgets/UIBootTable.h \
     
    10381039        src/selector/graphics/details/UIGDetailsElements.cpp \
    10391040        src/selector/graphics/details/UIGMachinePreview.cpp \
    1040         src/settings/UISettingsSerializer.cpp \
    10411041        src/settings/global/UIGlobalSettingsExtension.cpp \
    10421042        src/settings/global/UIGlobalSettingsGeneral.cpp \
     
    12231223        src/settings/UISettingsPage.cpp \
    12241224        src/settings/UISettingsSelector.cpp \
     1225        src/settings/UISettingsSerializer.cpp \
    12251226        src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \
    12261227        src/widgets/UIBootTable.cpp \
     
    13671368        src/settings/UISettingsPage.cpp \
    13681369        src/settings/UISettingsSelector.cpp \
     1370        src/settings/UISettingsSerializer.cpp \
    13691371        src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \
    13701372        src/widgets/UIBootTable.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.cpp

    r71027 r72105  
    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
     
    3333#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    3434
    35 UISettingsSerializer::UISettingsSerializer(QObject *pParent, SerializationDirection direction,
     35
     36/*********************************************************************************************************************************
     37*   Class UISettingsSerializer implementation.                                                                                   *
     38*********************************************************************************************************************************/
     39
     40UISettingsSerializer::UISettingsSerializer(QObject *pParent, SerializationDirection enmDirection,
    3641                                           const QVariant &data, const UISettingsPageList &pages)
    3742    : QThread(pParent)
    38     , m_direction(direction)
     43    , m_enmDirection(enmDirection)
    3944    , m_data(data)
    40     , m_fSavingComplete(m_direction == Load)
     45    , m_fSavingComplete(m_enmDirection == Load)
    4146    , m_iIdOfHighPriorityPage(-1)
    4247{
     
    7681
    7782    /* If serializer saves settings: */
    78     if (m_direction == Save)
     83    if (m_enmDirection == Save)
    7984    {
    8085        /* We should update internal page cache first: */
     
    96101
    97102    /* If serializer loads settings: */
    98     if (m_direction == Load)
     103    if (m_enmDirection == Load)
    99104    {
    100105        /* We should fetch internal page cache: */
     
    115120{
    116121    /* If serializer saves settings: */
    117     if (m_direction == Save)
     122    if (m_enmDirection == Save)
    118123    {
    119124        /* We should flag GUI thread to unlock itself: */
     
    159164        if (pPage->isEnabled())
    160165        {
    161             if (m_direction == Load)
     166            if (m_enmDirection == Load)
    162167                pPage->loadToCacheFrom(m_data);
    163             if (m_direction == Save)
     168            if (m_enmDirection == Save)
    164169                pPage->saveFromCacheTo(m_data);
    165170        }
     
    175180        emit sigNotifyAboutPageProcessed(pPage->id());
    176181        /* If serializer saves settings => wake up GUI thread: */
    177         if (m_direction == Save)
     182        if (m_enmDirection == Save)
    178183            m_condition.wakeAll();
    179184        /* Break further processing if page had failed: */
     
    184189    emit sigNotifyAboutPagesProcessed();
    185190    /* If serializer saves settings => wake up GUI thread: */
    186     if (m_direction == Save)
     191    if (m_enmDirection == Save)
    187192        m_condition.wakeAll();
    188193
     
    191196}
    192197
    193 QString UISettingsSerializerProgress::m_strProgressDescriptionTemplate = QString("<compact elipsis=\"middle\">%1 (%2/%3)</compact>");
    194 
    195 UISettingsSerializerProgress::UISettingsSerializerProgress(QWidget *pParent, UISettingsSerializer::SerializationDirection direction,
     198
     199/*********************************************************************************************************************************
     200*   Class UISettingsSerializerProgress implementation.                                                                           *
     201*********************************************************************************************************************************/
     202
     203QString UISettingsSerializerProgress::s_strProgressDescriptionTemplate = QString("<compact elipsis=\"middle\">%1 (%2/%3)</compact>");
     204
     205UISettingsSerializerProgress::UISettingsSerializerProgress(QWidget *pParent, UISettingsSerializer::SerializationDirection enmDirection,
    196206                                                           const QVariant &data, const UISettingsPageList &pages)
    197207    : QIWithRetranslateUI<QIDialog>(pParent)
    198     , m_direction(direction)
     208    , m_enmDirection(enmDirection)
    199209    , m_data(data)
    200210    , m_pages(pages)
     
    221231}
    222232
    223 QVariant& UISettingsSerializerProgress::data()
     233QVariant &UISettingsSerializerProgress::data()
    224234{
    225235    AssertPtrReturn(m_pSerializer, m_data);
     
    236246
    237247    /* Create serializer: */
    238     m_pSerializer = new UISettingsSerializer(this, m_direction, m_data, m_pages);
     248    m_pSerializer = new UISettingsSerializer(this, m_enmDirection, m_data, m_pages);
    239249    AssertPtrReturnVoid(m_pSerializer);
    240250    {
     
    378388    m_pLabelSubOperationProgress->show();
    379389    m_pBarSubOperationProgress->show();
    380     m_pLabelSubOperationProgress->setText(m_strProgressDescriptionTemplate.arg(strOperation).arg(iOperation).arg(iOperations));
     390    m_pLabelSubOperationProgress->setText(s_strProgressDescriptionTemplate.arg(strOperation).arg(iOperation).arg(iOperations));
    381391    m_pBarSubOperationProgress->setValue(iPercent);
    382392}
     
    390400    msgCenter().cannotSaveSettings(strErrorInfo, this);
    391401}
    392 
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.h

    r71027 r72105  
    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
     
    2020
    2121/* Qt includes: */
     22#include <QList>
     23#include <QMap>
     24#include <QMutex>
    2225#include <QThread>
    2326#include <QVariant>
    2427#include <QWaitCondition>
    25 #include <QMutex>
    26 #include <QList>
    27 #include <QMap>
    2828
    2929/* GUI includes: */
     30#include "QIDialog.h"
    3031#include "QIWithRetranslateUI.h"
    31 #include "QIDialog.h"
    3232
    3333/* Forward declarations: */
     34class QCloseEvent;
     35class QLabel;
     36class QMutex;
     37class QObject;
     38class QString;
     39class QThread;
     40class QProgressBar;
     41class QVariant;
     42class QWaitCondition;
     43class QWidget;
     44class QILabel;
    3445class UISettingsPage;
    35 class QProgressBar;
    36 class QILabel;
    37 class QLabel;
    3846
    3947/* Type definitions: */
     
    4149typedef QMap<int, UISettingsPage*> UISettingsPageMap;
    4250
     51
    4352/** QThread reimplementation used for
    4453  * loading/saving settings in async mode. */
    45 class UISettingsSerializer : public QThread
     54class SHARED_LIBRARY_STUFF UISettingsSerializer : public QThread
    4655{
    4756    Q_OBJECT;
     
    6271
    6372    /** Notifies listeners about particular operation progress change.
    64       * @param iOperations  holds the number of operations CProgress have,
    65       * @param strOperation holds the description of the current CProgress operation,
    66       * @param iOperation   holds the index of the current CProgress operation,
    67       * @param iPercent     holds the percentage of the current CProgress operation. */
     73      * @param  iOperations   Brings the number of operations CProgress have.
     74      * @param  strOperation  Brings the description of the current CProgress operation.
     75      * @param  iOperation    Brings the index of the current CProgress operation.
     76      * @param  iPercent      Brings the percentage of the current CProgress operation. */
    6877    void sigOperationProgressChange(ulong iOperations, QString strOperation,
    6978                                    ulong iOperation, ulong iPercent);
    7079
    7180    /** Notifies listeners about particular COM error.
    72       * @param strErrorInfo holds the details of the error happened. */
     81      * @param  strErrorInfo  Brings the details of the error happened. */
    7382    void sigOperationProgressError(QString strErrorInfo);
    7483
     
    7887    enum SerializationDirection { Load, Save };
    7988
    80     /** Constructor.
    81       * @param pParent   being passed to the base-class,
    82       * @param direction determines the load/save direction,
    83       * @param data      contains the wrapper(s) to load/save the data from/to,
    84       * @param pages     contains the page(s) to load/save the data to/from. */
    85     UISettingsSerializer(QObject *pParent, SerializationDirection direction,
     89    /** Constructs serializer passing @a pParent to the base-class.
     90      * @param  enmDirection  Brings the load/save direction.
     91      * @param  data          Brings the wrapper(s) to load/save the data from/to.
     92      * @param  pages         Brings the page(s) to load/save the data to/from. */
     93    UISettingsSerializer(QObject *pParent, SerializationDirection enmDirection,
    8694                         const QVariant &data, const UISettingsPageList &pages);
    8795
    88     /** Destructor. */
    89     ~UISettingsSerializer();
     96    /** Destructs serializer. */
     97    virtual ~UISettingsSerializer() /* override */;
    9098
    9199    /** Returns the load/save direction. */
    92     SerializationDirection direction() const { return m_direction; }
     100    SerializationDirection direction() const { return m_enmDirection; }
    93101
    94102    /** Returns the instance of wrapper(s) to load/save the data from/to. */
    95     QVariant& data() { return m_data; }
     103    QVariant &data() { return m_data; }
    96104
    97105    /** Returns the count of the page(s) to load/save the data to/from. */
     
    120128
    121129    /** Holds the load/save direction. */
    122     const SerializationDirection m_direction;
     130    const SerializationDirection  m_enmDirection;
    123131
    124132    /** Holds the wrapper(s) to load/save the data from/to. */
    125     QVariant m_data;
     133    QVariant           m_data;
    126134    /** Holds the page(s) to load/save the data to/from. */
    127     UISettingsPageMap m_pages;
     135    UISettingsPageMap  m_pages;
    128136    /** Holds the page(s) to load/save the data to/from for which that task was done. */
    129     UISettingsPageMap m_pagesDone;
     137    UISettingsPageMap  m_pagesDone;
    130138
    131139    /** Holds whether the save was complete. */
    132     bool m_fSavingComplete;
     140    bool            m_fSavingComplete;
    133141    /** Holds the ID of the high priority page. */
    134     int m_iIdOfHighPriorityPage;
     142    int             m_iIdOfHighPriorityPage;
    135143    /** Holds the synchronization mutex. */
    136     QMutex m_mutex;
     144    QMutex          m_mutex;
    137145    /** Holds the synchronization condition. */
    138     QWaitCondition m_condition;
     146    QWaitCondition  m_condition;
    139147};
     148
    140149
    141150/** QIDialog reimplementation used to
    142151  * reflect the settings serialization operation. */
    143 class UISettingsSerializerProgress : public QIWithRetranslateUI<QIDialog>
     152class SHARED_LIBRARY_STUFF UISettingsSerializerProgress : public QIWithRetranslateUI<QIDialog>
    144153{
    145154    Q_OBJECT;
     
    152161public:
    153162
    154     /** Constructor.
    155       * @param pParent   being passed to the base-class,
    156       * @param direction determines the load/save direction,
    157       * @param data      contains the wrapper(s) to load/save the data from/to,
    158       * @param pages     contains the page(s) to load/save the data to/from. */
    159     UISettingsSerializerProgress(QWidget *pParent, UISettingsSerializer::SerializationDirection direction,
     163    /** Constructs serializer passing @a pParent to the base-class.
     164      * @param  enmDirection  Brings the load/save direction.
     165      * @param  data          Brings the wrapper(s) to load/save the data from/to.
     166      * @param  pages         Brings the page(s) to load/save the data to/from. */
     167    UISettingsSerializerProgress(QWidget *pParent, UISettingsSerializer::SerializationDirection enmDirection,
    160168                                 const QVariant &data, const UISettingsPageList &pages);
    161169
     
    164172
    165173    /** Returns the instance of wrapper(s) to load/save the data from/to. */
    166     QVariant& data();
     174    QVariant &data();
    167175
    168176    /** Returns whether there were no errors. */
     
    192200
    193201    /** Handles particular operation progress change.
    194       * @param iOperations  holds the number of operations CProgress have,
    195       * @param strOperation holds the description of the current CProgress operation,
    196       * @param iOperation   holds the index of the current CProgress operation,
    197       * @param iPercent     holds the percentage of the current CProgress operation. */
     202      * @param  iOperations   Brings the number of operations CProgress have.
     203      * @param  strOperation  Brings the description of the current CProgress operation.
     204      * @param  iOperation    Brings the index of the current CProgress operation.
     205      * @param  iPercent      Brings the percentage of the current CProgress operation. */
    198206    void sltHandleOperationProgressChange(ulong iOperations, QString strOperation,
    199207                                          ulong iOperation, ulong iPercent);
    200208
    201209    /** Handles particular COM error.
    202       * @param strErrorInfo holds the details of the error happened. */
     210      * @param  strErrorInfo  Brings the details of the error happened. */
    203211    void sltHandleOperationProgressError(QString strErrorInfo);
    204212
     
    206214
    207215    /** Holds the load/save direction. */
    208     const UISettingsSerializer::SerializationDirection m_direction;
     216    const UISettingsSerializer::SerializationDirection  m_enmDirection;
    209217
    210218    /** Holds the wrapper(s) to load/save the data from/to. */
    211     QVariant m_data;
     219    QVariant            m_data;
    212220    /** Holds the page(s) to load/save the data to/from. */
    213     UISettingsPageList m_pages;
     221    UISettingsPageList  m_pages;
    214222
    215223    /** Holds the pointer to the thread loading/saving settings in async mode. */
     
    217225
    218226    /** Holds the operation progress label. */
    219     QLabel *m_pLabelOperationProgress;
     227    QLabel       *m_pLabelOperationProgress;
    220228    /** Holds the operation progress bar. */
    221229    QProgressBar *m_pBarOperationProgress;
    222230
    223231    /** Holds the sub-operation progress label. */
    224     QILabel *m_pLabelSubOperationProgress;
     232    QILabel      *m_pLabelSubOperationProgress;
    225233    /** Holds the sub-operation progress bar. */
    226234    QProgressBar *m_pBarSubOperationProgress;
    227235
    228236    /** Holds whether there were no errors. */
    229     bool m_fClean;
     237    bool  m_fClean;
    230238
    231239    /** Holds the template for the sub-operation progress label. */
    232     static QString m_strProgressDescriptionTemplate;
     240    static QString  s_strProgressDescriptionTemplate;
    233241};
    234242
     243
    235244#endif /* !___UISettingsSerializer_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