Changeset 54928 in vbox for trunk/src/VBox
- Timestamp:
- Mar 24, 2015 4:35:25 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp
r54923 r54928 166 166 loadOwnData(); 167 167 168 /* Execute dialog and wait for completion: */ 169 if (exec() != QDialog::Accepted) 170 return; 171 168 /* Execute dialog: */ 169 exec(); 170 } 171 172 void UISettingsDialog::accept() 173 { 172 174 /* Save data: */ 173 175 saveOwnData(); 176 177 /* Call to base-class: */ 178 QIWithRetranslateUI<QIMainDialog>::accept(); 174 179 } 175 180 … … 245 250 246 251 /* Create settings loader: */ 247 UISettingsSerializer *pSettingsLoader = new UISettingsSerializer(this, 248 UISettingsSerializer::Load, 249 QVariant::fromValue(data), 250 m_pSelector->settingPages()); 252 UISettingsSerializer *pSettingsLoader = new UISettingsSerializer(this, UISettingsSerializer::Load, 253 data, m_pSelector->settingPages()); 251 254 AssertPtrReturnVoid(pSettingsLoader); 252 255 { … … 271 274 272 275 /* Create settings saver: */ 273 UISettingsSerializer *pSettingsSaver = new UISettingsSerializer(this,274 UISettingsSerializer::Save,275 QVariant::fromValue(data),276 m_pSelector->settingPages());277 AssertPtrReturnVoid(pSettingsSaver);278 {276 UISettingsSerializerProgress *pSettingsSaveProgress = new UISettingsSerializerProgress(this, UISettingsSerializer::Save, 277 data, m_pSelector->settingPages()); 278 AssertPtrReturnVoid(pSettingsSaveProgress); 279 { 280 /* Configure settings saver: */ 281 connect(pSettingsSaveProgress, SIGNAL(finished(int)), this, SLOT(sltMarkSaved())); 279 282 /* Start settings saver: */ 280 pSettingsSave r->start();283 pSettingsSaveProgress->exec(); 281 284 } 282 285 283 286 /* Upload data finally: */ 284 data = pSettingsSave r->data();287 data = pSettingsSaveProgress->data(); 285 288 } 286 289 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h
r54921 r54928 51 51 52 52 protected slots: 53 54 /** Hides the modal dialog and sets the result code to Accepted. */ 55 virtual void accept(); 53 56 54 57 /* Category-change slot: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp
r54922 r54928 235 235 else if (!(newSettings == settings)) 236 236 vboxGlobal().setSettings(newSettings); 237 238 /* Mark page processed: */239 sltMarkSaved();240 237 } 241 238 … … 576 573 if (!m_machine.isOk()) 577 574 msgCenter().cannotSaveMachineSettings(m_machine, this); 578 579 /* Mark page processed: */580 sltMarkSaved();581 575 } 582 576 … … 700 694 UISettingsDialog::sltMarkLoaded(); 701 695 702 sltSetFirstRunFlag(); 696 /* No need to reset 'first run' flag: */ 697 m_fResetFirstRunFlag = false; 703 698 704 699 /* Unlock the session if exists: */ … … 794 789 { 795 790 m_fAllowResetFirstRunFlag = true; 796 }797 798 void UISettingsDialogMachine::sltSetFirstRunFlag()799 {800 m_fResetFirstRunFlag = false;801 791 } 802 792 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.h
r54922 r54928 86 86 void sltCategoryChanged(int cId); 87 87 void sltAllowResetFirstRunFlag(); 88 void sltSetFirstRunFlag();89 88 void sltResetFirstRunFlag(); 90 89 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.cpp
r54923 r54928 40 40 41 41 /* Copy the page(s) from incoming list to our map: */ 42 for (int iPageIndex = 0; iPageIndex < pages.size(); ++iPageIndex) 43 { 44 UISettingsPage *pPage = pages[iPageIndex]; 42 foreach (UISettingsPage *pPage, pages) 45 43 m_pages.insert(pPage->id(), pPage); 46 }47 44 48 45 /* Handling internal signals, they are also redirected in their handlers: */ … … 89 86 /* Start async serializing thread: */ 90 87 QThread::start(priority); 91 92 /* If serializer saves settings: */93 if (m_direction == Save)94 {95 /* We should block calling thread until all pages will be saved: */96 while (!m_fSavingComplete)97 {98 /* Lock mutex initially: */99 m_mutex.lock();100 /* Perform idle-processing every 100ms,101 * and waiting for direct wake up signal: */102 m_condition.wait(&m_mutex, 100);103 /* Process queued signals posted to GUI thread: */104 qApp->processEvents();105 /* Unlock mutex finally: */106 m_mutex.unlock();107 }108 }109 88 } 110 89 … … 198 177 } 199 178 179 UISettingsSerializerProgress::UISettingsSerializerProgress(QWidget *pParent, UISettingsSerializer::SerializationDirection direction, 180 const QVariant &data, const UISettingsPageList &pages) 181 : QIWithRetranslateUI<QProgressDialog>(pParent) 182 , m_pSerializer(0) 183 , m_direction(direction) 184 , m_data(data) 185 , m_pages(pages) 186 { 187 /* Prepare: */ 188 prepare(); 189 190 /* Translate: */ 191 retranslateUi(); 192 } 193 194 int UISettingsSerializerProgress::exec() 195 { 196 /* Start the serializer: */ 197 m_pSerializer->start(); 198 199 /* Call to base-class: */ 200 return QIWithRetranslateUI<QProgressDialog>::exec(); 201 } 202 203 QVariant& UISettingsSerializerProgress::data() 204 { 205 AssertPtrReturn(m_pSerializer, m_data); 206 return m_pSerializer->data(); 207 } 208 209 void UISettingsSerializerProgress::prepare() 210 { 211 /* Create serializer: */ 212 m_pSerializer = new UISettingsSerializer(this, m_direction, m_data, m_pages); 213 AssertPtrReturnVoid(m_pSerializer); 214 { 215 /* Install progress handler: */ 216 connect(m_pSerializer, SIGNAL(sigNotifyAboutPagePostprocessed(int)), 217 this, SLOT(sltAdvanceProgressValue())); 218 connect(m_pSerializer, SIGNAL(sigNotifyAboutPagesPostprocessed()), 219 this, SLOT(sltAdvanceProgressValue())); 220 } 221 222 /* Set maximum/minimum/current values: */ 223 setMaximum(m_pSerializer->pageCount() + 1); 224 setMinimum(0); 225 setValue(0); 226 } 227 228 void UISettingsSerializerProgress::retranslateUi() 229 { 230 /* Translate title: */ 231 switch (m_pSerializer->direction()) 232 { 233 case UISettingsSerializer::Load: setLabelText(tr("Loading Settings...")); break; 234 case UISettingsSerializer::Save: setLabelText(tr("Saving Settings...")); break; 235 } 236 } 237 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.h
r54923 r54928 22 22 #include <QVariant> 23 23 #include <QWaitCondition> 24 #include <QProgressDialog> 24 25 #include <QMutex> 25 26 #include <QList> 26 27 #include <QMap> 28 29 /* GUI includes: */ 30 #include "QIWithRetranslateUI.h" 27 31 28 32 /* Forward declarations: */ … … 76 80 ~UISettingsSerializer(); 77 81 82 /** Returns the load/save direction. */ 83 SerializationDirection direction() const { return m_direction; } 84 78 85 /** Returns the instance of wrapper(s) to load/save the data from/to. */ 79 86 QVariant& data() { return m_data; } 87 88 /** Returns the count of the page(s) to load/save the data to/from. */ 89 int pageCount() const { return m_pages.size(); } 80 90 81 91 /** Raises the priority of page with @a iPageId. */ … … 103 113 static UISettingsSerializer *m_spInstance; 104 114 105 /** Holds the theload/save direction. */106 SerializationDirection m_direction;115 /** Holds the load/save direction. */ 116 const SerializationDirection m_direction; 107 117 108 118 /** Holds the wrapper(s) to load/save the data from/to. */ … … 121 131 }; 122 132 133 /** QProgressDialog reimplementation used to 134 * reflect the settings serialization operation. */ 135 class UISettingsSerializerProgress : public QIWithRetranslateUI<QProgressDialog> 136 { 137 Q_OBJECT; 138 139 public: 140 141 /** Constructor. 142 * @param pParent being passed to the base-class, 143 * @param direction determines the load/save direction, 144 * @param data contains the wrapper(s) to load/save the data from/to, 145 * @param pages contains the page(s) to load/save the data to/from. */ 146 UISettingsSerializerProgress(QWidget *pParent, UISettingsSerializer::SerializationDirection direction, 147 const QVariant &data, const UISettingsPageList &pages); 148 149 /** Executes the dialog. */ 150 int exec(); 151 152 /** Returns the instance of wrapper(s) to load/save the data from/to. */ 153 QVariant& data(); 154 155 protected: 156 157 /** Prepare routine. */ 158 void prepare(); 159 160 /** Translate routine: */ 161 void retranslateUi(); 162 163 private slots: 164 165 /** Advances the current progress value. */ 166 void sltAdvanceProgressValue() { setValue(value() + 1); } 167 168 private: 169 170 /** Holds the load/save direction. */ 171 const UISettingsSerializer::SerializationDirection m_direction; 172 173 /** Holds the wrapper(s) to load/save the data from/to. */ 174 QVariant m_data; 175 /** Holds the page(s) to load/save the data to/from. */ 176 UISettingsPageList m_pages; 177 178 /** Holds the pointer to the thread loading/saving settings in async mode. */ 179 UISettingsSerializer *m_pSerializer; 180 }; 181 123 182 #endif /* !___UISettingsSerializer_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.