Changeset 72105 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 4, 2018 8:57:19 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r72102 r72105 520 520 src/selector/graphics/details/UIGDetailsElements.h \ 521 521 src/selector/graphics/details/UIGMachinePreview.h \ 522 src/settings/UISettingsSerializer.h \523 522 src/settings/global/UIGlobalSettingsExtension.h \ 524 523 src/settings/global/UIGlobalSettingsGeneral.h \ … … 664 663 src/settings/UISettingsPage.h \ 665 664 src/settings/UISettingsSelector.h \ 665 src/settings/UISettingsSerializer.h \ 666 666 src/widgets/UIAddDiskEncryptionPasswordDialog.h \ 667 667 src/widgets/UIBootTable.h \ … … 781 781 src/settings/UISettingsPage.h \ 782 782 src/settings/UISettingsSelector.h \ 783 src/settings/UISettingsSerializer.h \ 783 784 src/widgets/UIAddDiskEncryptionPasswordDialog.h \ 784 785 src/widgets/UIBootTable.h \ … … 1038 1039 src/selector/graphics/details/UIGDetailsElements.cpp \ 1039 1040 src/selector/graphics/details/UIGMachinePreview.cpp \ 1040 src/settings/UISettingsSerializer.cpp \1041 1041 src/settings/global/UIGlobalSettingsExtension.cpp \ 1042 1042 src/settings/global/UIGlobalSettingsGeneral.cpp \ … … 1223 1223 src/settings/UISettingsPage.cpp \ 1224 1224 src/settings/UISettingsSelector.cpp \ 1225 src/settings/UISettingsSerializer.cpp \ 1225 1226 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 1226 1227 src/widgets/UIBootTable.cpp \ … … 1367 1368 src/settings/UISettingsPage.cpp \ 1368 1369 src/settings/UISettingsSelector.cpp \ 1370 src/settings/UISettingsSerializer.cpp \ 1369 1371 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 1370 1372 src/widgets/UIBootTable.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.cpp
r71027 r72105 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 33 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 34 34 35 UISettingsSerializer::UISettingsSerializer(QObject *pParent, SerializationDirection direction, 35 36 /********************************************************************************************************************************* 37 * Class UISettingsSerializer implementation. * 38 *********************************************************************************************************************************/ 39 40 UISettingsSerializer::UISettingsSerializer(QObject *pParent, SerializationDirection enmDirection, 36 41 const QVariant &data, const UISettingsPageList &pages) 37 42 : QThread(pParent) 38 , m_ direction(direction)43 , m_enmDirection(enmDirection) 39 44 , m_data(data) 40 , m_fSavingComplete(m_ direction == Load)45 , m_fSavingComplete(m_enmDirection == Load) 41 46 , m_iIdOfHighPriorityPage(-1) 42 47 { … … 76 81 77 82 /* If serializer saves settings: */ 78 if (m_ direction == Save)83 if (m_enmDirection == Save) 79 84 { 80 85 /* We should update internal page cache first: */ … … 96 101 97 102 /* If serializer loads settings: */ 98 if (m_ direction == Load)103 if (m_enmDirection == Load) 99 104 { 100 105 /* We should fetch internal page cache: */ … … 115 120 { 116 121 /* If serializer saves settings: */ 117 if (m_ direction == Save)122 if (m_enmDirection == Save) 118 123 { 119 124 /* We should flag GUI thread to unlock itself: */ … … 159 164 if (pPage->isEnabled()) 160 165 { 161 if (m_ direction == Load)166 if (m_enmDirection == Load) 162 167 pPage->loadToCacheFrom(m_data); 163 if (m_ direction == Save)168 if (m_enmDirection == Save) 164 169 pPage->saveFromCacheTo(m_data); 165 170 } … … 175 180 emit sigNotifyAboutPageProcessed(pPage->id()); 176 181 /* If serializer saves settings => wake up GUI thread: */ 177 if (m_ direction == Save)182 if (m_enmDirection == Save) 178 183 m_condition.wakeAll(); 179 184 /* Break further processing if page had failed: */ … … 184 189 emit sigNotifyAboutPagesProcessed(); 185 190 /* If serializer saves settings => wake up GUI thread: */ 186 if (m_ direction == Save)191 if (m_enmDirection == Save) 187 192 m_condition.wakeAll(); 188 193 … … 191 196 } 192 197 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 203 QString UISettingsSerializerProgress::s_strProgressDescriptionTemplate = QString("<compact elipsis=\"middle\">%1 (%2/%3)</compact>"); 204 205 UISettingsSerializerProgress::UISettingsSerializerProgress(QWidget *pParent, UISettingsSerializer::SerializationDirection enmDirection, 196 206 const QVariant &data, const UISettingsPageList &pages) 197 207 : QIWithRetranslateUI<QIDialog>(pParent) 198 , m_ direction(direction)208 , m_enmDirection(enmDirection) 199 209 , m_data(data) 200 210 , m_pages(pages) … … 221 231 } 222 232 223 QVariant &UISettingsSerializerProgress::data()233 QVariant &UISettingsSerializerProgress::data() 224 234 { 225 235 AssertPtrReturn(m_pSerializer, m_data); … … 236 246 237 247 /* 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); 239 249 AssertPtrReturnVoid(m_pSerializer); 240 250 { … … 378 388 m_pLabelSubOperationProgress->show(); 379 389 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)); 381 391 m_pBarSubOperationProgress->setValue(iPercent); 382 392 } … … 390 400 msgCenter().cannotSaveSettings(strErrorInfo, this); 391 401 } 392 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.h
r71027 r72105 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 21 21 /* Qt includes: */ 22 #include <QList> 23 #include <QMap> 24 #include <QMutex> 22 25 #include <QThread> 23 26 #include <QVariant> 24 27 #include <QWaitCondition> 25 #include <QMutex>26 #include <QList>27 #include <QMap>28 28 29 29 /* GUI includes: */ 30 #include "QIDialog.h" 30 31 #include "QIWithRetranslateUI.h" 31 #include "QIDialog.h"32 32 33 33 /* Forward declarations: */ 34 class QCloseEvent; 35 class QLabel; 36 class QMutex; 37 class QObject; 38 class QString; 39 class QThread; 40 class QProgressBar; 41 class QVariant; 42 class QWaitCondition; 43 class QWidget; 44 class QILabel; 34 45 class UISettingsPage; 35 class QProgressBar;36 class QILabel;37 class QLabel;38 46 39 47 /* Type definitions: */ … … 41 49 typedef QMap<int, UISettingsPage*> UISettingsPageMap; 42 50 51 43 52 /** QThread reimplementation used for 44 53 * loading/saving settings in async mode. */ 45 class UISettingsSerializer : public QThread54 class SHARED_LIBRARY_STUFF UISettingsSerializer : public QThread 46 55 { 47 56 Q_OBJECT; … … 62 71 63 72 /** 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. */ 68 77 void sigOperationProgressChange(ulong iOperations, QString strOperation, 69 78 ulong iOperation, ulong iPercent); 70 79 71 80 /** 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. */ 73 82 void sigOperationProgressError(QString strErrorInfo); 74 83 … … 78 87 enum SerializationDirection { Load, Save }; 79 88 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, 86 94 const QVariant &data, const UISettingsPageList &pages); 87 95 88 /** Destruct or. */89 ~UISettingsSerializer();96 /** Destructs serializer. */ 97 virtual ~UISettingsSerializer() /* override */; 90 98 91 99 /** Returns the load/save direction. */ 92 SerializationDirection direction() const { return m_ direction; }100 SerializationDirection direction() const { return m_enmDirection; } 93 101 94 102 /** 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; } 96 104 97 105 /** Returns the count of the page(s) to load/save the data to/from. */ … … 120 128 121 129 /** Holds the load/save direction. */ 122 const SerializationDirection m_direction;130 const SerializationDirection m_enmDirection; 123 131 124 132 /** Holds the wrapper(s) to load/save the data from/to. */ 125 QVariant m_data;133 QVariant m_data; 126 134 /** Holds the page(s) to load/save the data to/from. */ 127 UISettingsPageMap m_pages;135 UISettingsPageMap m_pages; 128 136 /** 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; 130 138 131 139 /** Holds whether the save was complete. */ 132 bool m_fSavingComplete;140 bool m_fSavingComplete; 133 141 /** Holds the ID of the high priority page. */ 134 int m_iIdOfHighPriorityPage;142 int m_iIdOfHighPriorityPage; 135 143 /** Holds the synchronization mutex. */ 136 QMutex m_mutex;144 QMutex m_mutex; 137 145 /** Holds the synchronization condition. */ 138 QWaitCondition m_condition;146 QWaitCondition m_condition; 139 147 }; 148 140 149 141 150 /** QIDialog reimplementation used to 142 151 * reflect the settings serialization operation. */ 143 class UISettingsSerializerProgress : public QIWithRetranslateUI<QIDialog>152 class SHARED_LIBRARY_STUFF UISettingsSerializerProgress : public QIWithRetranslateUI<QIDialog> 144 153 { 145 154 Q_OBJECT; … … 152 161 public: 153 162 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, 160 168 const QVariant &data, const UISettingsPageList &pages); 161 169 … … 164 172 165 173 /** Returns the instance of wrapper(s) to load/save the data from/to. */ 166 QVariant &data();174 QVariant &data(); 167 175 168 176 /** Returns whether there were no errors. */ … … 192 200 193 201 /** 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. */ 198 206 void sltHandleOperationProgressChange(ulong iOperations, QString strOperation, 199 207 ulong iOperation, ulong iPercent); 200 208 201 209 /** Handles particular COM error. 202 * @param strErrorInfo holds the details of the error happened. */210 * @param strErrorInfo Brings the details of the error happened. */ 203 211 void sltHandleOperationProgressError(QString strErrorInfo); 204 212 … … 206 214 207 215 /** Holds the load/save direction. */ 208 const UISettingsSerializer::SerializationDirection m_direction;216 const UISettingsSerializer::SerializationDirection m_enmDirection; 209 217 210 218 /** Holds the wrapper(s) to load/save the data from/to. */ 211 QVariant m_data;219 QVariant m_data; 212 220 /** Holds the page(s) to load/save the data to/from. */ 213 UISettingsPageList m_pages;221 UISettingsPageList m_pages; 214 222 215 223 /** Holds the pointer to the thread loading/saving settings in async mode. */ … … 217 225 218 226 /** Holds the operation progress label. */ 219 QLabel *m_pLabelOperationProgress;227 QLabel *m_pLabelOperationProgress; 220 228 /** Holds the operation progress bar. */ 221 229 QProgressBar *m_pBarOperationProgress; 222 230 223 231 /** Holds the sub-operation progress label. */ 224 QILabel *m_pLabelSubOperationProgress;232 QILabel *m_pLabelSubOperationProgress; 225 233 /** Holds the sub-operation progress bar. */ 226 234 QProgressBar *m_pBarSubOperationProgress; 227 235 228 236 /** Holds whether there were no errors. */ 229 bool m_fClean;237 bool m_fClean; 230 238 231 239 /** Holds the template for the sub-operation progress label. */ 232 static QString m_strProgressDescriptionTemplate;240 static QString s_strProgressDescriptionTemplate; 233 241 }; 234 242 243 235 244 #endif /* !___UISettingsSerializer_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.