Changeset 97390 in vbox
- Timestamp:
- Nov 3, 2022 4:56:57 PM (2 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r97388 r97390 639 639 sltCloseManagerWindow(UIToolType_Cloud); 640 640 sltCloseManagerWindow(UIToolType_CloudConsole); 641 sltCloseSettingsDialog(); 642 sltClosePreferencesDialog(); 641 643 } 642 644 … … 974 976 m_fFirstMediumEnumerationHandled = true; 975 977 976 /* Lock the action preventing cascade calls: */ 977 UIQObjectPropertySetter guardBlock(actionPool()->action(UIActionIndex_M_Application_S_Preferences), "opened", true); 978 connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed, 979 this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest); 980 updateActionsAppearance(); 981 982 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 983 QWidget *pDialogParent = windowManager().realParentWindow(this); 984 UISafePointerSettingsDialogGlobal pDialog = new UISettingsDialogGlobal(pDialogParent); 985 windowManager().registerNewParent(pDialog, pDialogParent); 986 987 /* Execute dialog: */ 988 pDialog->execute(); 989 delete pDialog; 978 /* Create instance if not yet created: */ 979 if (!m_settings.contains(UISettingsDialog::DialogType_Global)) 980 { 981 m_settings[UISettingsDialog::DialogType_Global] = new UISettingsDialogGlobal(this); 982 connect(m_settings[UISettingsDialog::DialogType_Global], &UISettingsDialogGlobal::sigClose, 983 this, &UIVirtualBoxManager::sltClosePreferencesDialog); 984 m_settings.value(UISettingsDialog::DialogType_Global)->load(); 985 } 986 987 /* Expose instance: */ 988 UIDesktopWidgetWatchdog::restoreWidget(m_settings.value(UISettingsDialog::DialogType_Global)); 989 } 990 991 void UIVirtualBoxManager::sltClosePreferencesDialog() 992 { 993 /* Remove instance if exist: */ 994 delete m_settings.take(UISettingsDialog::DialogType_Global); 990 995 } 991 996 … … 1084 1089 m_fFirstMediumEnumerationHandled = true; 1085 1090 1086 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 1087 QWidget *pDialogParent = windowManager().realParentWindow(this); 1088 UISafePointerSettingsDialogMachine pDialog = new UISettingsDialogMachine(pDialogParent, 1089 uID.isNull() ? pItem->id() : uID, 1090 strCategory, strControl, actionPool()); 1091 windowManager().registerNewParent(pDialog, pDialogParent); 1092 1093 /* Execute dialog: */ 1094 pDialog->execute(); 1095 delete pDialog; 1091 /* Create instance if not yet created: */ 1092 if (!m_settings.contains(UISettingsDialog::DialogType_Machine)) 1093 { 1094 m_settings[UISettingsDialog::DialogType_Machine] = new UISettingsDialogMachine(this, 1095 uID.isNull() ? pItem->id() : uID, 1096 strCategory, 1097 strControl, 1098 actionPool()); 1099 connect(m_settings[UISettingsDialog::DialogType_Machine], &UISettingsDialogGlobal::sigClose, 1100 this, &UIVirtualBoxManager::sltCloseSettingsDialog); 1101 m_settings.value(UISettingsDialog::DialogType_Machine)->load(); 1102 } 1103 1104 /* Expose instance: */ 1105 UIDesktopWidgetWatchdog::restoreWidget(m_settings.value(UISettingsDialog::DialogType_Machine)); 1096 1106 } 1097 1107 } … … 1109 1119 delete pDialog; 1110 1120 } 1121 } 1122 1123 void UIVirtualBoxManager::sltCloseSettingsDialog() 1124 { 1125 /* Remove instance if exist: */ 1126 delete m_settings.take(UISettingsDialog::DialogType_Machine); 1111 1127 } 1112 1128 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r97388 r97390 41 41 #include "UICommon.h" 42 42 #include "UIExtraDataDefs.h" 43 #include "UISettingsDialog.h" 43 44 44 45 /* Forward declarations: */ … … 198 199 /** Handles call to open Preferences dialog. */ 199 200 void sltOpenPreferencesDialog(); 201 /** Handles call to close Preferences dialog. */ 202 void sltClosePreferencesDialog(); 200 203 201 204 /** Handles call to exit application. */ … … 224 227 /** Handles call to open Settings dialog the default way. */ 225 228 void sltOpenSettingsDialogDefault() { sltOpenSettingsDialog(); } 229 /** Handles call to close Settings dialog. */ 230 void sltCloseSettingsDialog(); 226 231 227 232 /** Handles call to open Clone Machine wizard. */ … … 491 496 QMap<UIToolType, QIManagerDialog*> m_managers; 492 497 498 /** Holds the map of various settings dialogs. */ 499 QMap<UISettingsDialog::DialogType, UISettingsDialog*> m_settings; 500 493 501 /** Holds the instance of UIVMLogViewerDialog. */ 494 502 QIManagerDialog *m_pLogViewerDialog; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r97389 r97390 47 47 #include "UICommon.h" 48 48 #include "UIConverter.h" 49 #include "UIDesktopWidgetWatchdog.h" 49 50 #include "UIExtraDataManager.h" 50 51 #include "UIFileManagerDialog.h" … … 1556 1557 return; 1557 1558 1558 /* Check that we do NOT handling that already: */ 1559 if (actionPool()->action(UIActionIndex_M_Application_S_Preferences)->data().toBool()) 1560 return; 1561 /* Remember that we handling that already: */ 1562 actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(true); 1563 1564 /* Create and execute global settings window: */ 1565 QPointer<UISettingsDialogGlobal> pDialog = new UISettingsDialogGlobal(activeMachineWindow(), 1566 strCategory, strControl); 1567 pDialog->execute(); 1568 if (pDialog) 1569 delete pDialog; 1570 1571 /* Remember that we do NOT handling that already: */ 1572 actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(false); 1559 /* Create instance if not yet created: */ 1560 if (!m_settings.contains(UISettingsDialog::DialogType_Global)) 1561 { 1562 m_settings[UISettingsDialog::DialogType_Global] = new UISettingsDialogGlobal(activeMachineWindow(), 1563 strCategory, 1564 strControl); 1565 connect(m_settings[UISettingsDialog::DialogType_Global], &UISettingsDialogGlobal::sigClose, 1566 this, &UIMachineLogic::sltClosePreferencesDialog); 1567 m_settings.value(UISettingsDialog::DialogType_Global)->load(); 1568 } 1569 1570 /* Expose instance: */ 1571 UIDesktopWidgetWatchdog::restoreWidget(m_settings.value(UISettingsDialog::DialogType_Global)); 1572 } 1573 1574 void UIMachineLogic::sltClosePreferencesDialog() 1575 { 1576 /* Remove instance if exist: */ 1577 delete m_settings.take(UISettingsDialog::DialogType_Global); 1573 1578 } 1574 1579 … … 1611 1616 return; 1612 1617 1613 /* Create VM settings window on the heap! 1614 * Its necessary to allow QObject hierarchy cleanup to delete this dialog if necessary: */ 1615 QPointer<UISettingsDialogMachine> pDialog = new UISettingsDialogMachine(activeMachineWindow(), 1616 machine().GetId(), 1617 strCategory, strControl, actionPool()); 1618 /* Executing VM settings window. 1619 * This blocking function calls for the internal event-loop to process all further events, 1620 * including event which can delete the dialog itself. */ 1621 pDialog->execute(); 1622 /* Delete dialog if its still valid: */ 1623 if (pDialog) 1624 delete pDialog; 1618 /* Create instance if not yet created: */ 1619 if (!m_settings.contains(UISettingsDialog::DialogType_Machine)) 1620 { 1621 m_settings[UISettingsDialog::DialogType_Machine] = new UISettingsDialogMachine(activeMachineWindow(), 1622 machine().GetId(), 1623 strCategory, 1624 strControl, 1625 actionPool()); 1626 connect(m_settings[UISettingsDialog::DialogType_Machine], &UISettingsDialogGlobal::sigClose, 1627 this, &UIMachineLogic::sltCloseSettingsDialog); 1628 m_settings.value(UISettingsDialog::DialogType_Machine)->load(); 1629 } 1630 1631 /* Expose instance: */ 1632 UIDesktopWidgetWatchdog::restoreWidget(m_settings.value(UISettingsDialog::DialogType_Machine)); 1633 } 1634 1635 void UIMachineLogic::sltCloseSettingsDialog() 1636 { 1637 /* Remove instance if exist: */ 1638 delete m_settings.take(UISettingsDialog::DialogType_Machine); 1625 1639 1626 1640 /* We can't rely on MediumChange events as they are not yet properly implemented within Main. … … 2767 2781 sltCloseSoftKeyboard(); 2768 2782 sltSwitchKeyboardLedsToPreviousLeds(); 2783 sltCloseSettingsDialog(); 2784 sltClosePreferencesDialog(); 2769 2785 } 2770 2786 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r97389 r97390 35 35 #include "QIWithRetranslateUI.h" 36 36 #include "UIExtraDataDefs.h" 37 #include "UISettingsDialog.h" 37 38 38 39 /* COM includes: */ … … 264 265 void sltOpenPreferencesDialog(const QString &strCategory = QString(), const QString &strControl = QString()); 265 266 void sltOpenPreferencesDialogDefault() { sltOpenPreferencesDialog(); } 267 void sltClosePreferencesDialog(); 266 268 void sltClose(); 267 269 … … 269 271 void sltOpenSettingsDialog(const QString &strCategory = QString(), const QString &strControl = QString()); 270 272 void sltOpenSettingsDialogDefault() { sltOpenSettingsDialog(); } 273 void sltCloseSettingsDialog(); 271 274 void sltTakeSnapshot(); 272 275 void sltShowInformationDialog(); … … 447 450 bool m_fIsHidLedsSyncEnabled; 448 451 452 /** Holds the map of settings dialogs. */ 453 QMap<UISettingsDialog::DialogType, UISettingsDialog*> m_settings; 454 449 455 /** Holds the log viewer dialog instance. */ 450 456 QIManagerDialog *m_pLogViewerDialog; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp
r97383 r97390 40 40 #include "UICommon.h" 41 41 #include "UIConverter.h" 42 #include "UIDesktopWidgetWatchdog.h" 42 43 #include "UIIconPool.h" 43 44 #include "UIMessageCenter.h" … … 60 61 61 62 UISettingsDialog::UISettingsDialog(QWidget *pParent) 62 : QIWithRetranslateUI<Q IMainDialog>(pParent)63 : QIWithRetranslateUI<QMainWindow>(pParent) 63 64 , m_pSelector(0) 64 65 , m_pStack(0) 65 66 , m_enmConfigurationAccessLevel(ConfigurationAccessLevel_Null) 66 67 , m_pSerializeProcess(0) 68 , m_fPolished(false) 67 69 , m_fSerializationIsInProgress(false) 68 70 , m_fSerializationClean(true) 71 , m_fClosed(false) 69 72 , m_pStatusBar(0) 70 73 , m_pProcessBar(0) … … 97 100 } 98 101 99 void UISettingsDialog::execute()100 {101 /* Load data: */102 load();103 104 /* Execute dialog: */105 exec();106 }107 108 102 void UISettingsDialog::accept() 109 103 { … … 114 108 if (m_fSerializationClean) 115 109 { 116 /* Call to base-class: */ 117 QIWithRetranslateUI<QIMainDialog>::accept(); 110 /* Tell the listener to close us (once): */ 111 if (!m_fClosed) 112 { 113 m_fClosed = true; 114 emit sigClose(); 115 } 118 116 } 119 117 } … … 122 120 { 123 121 if (!isSerializationInProgress()) 124 QIWithRetranslateUI<QIMainDialog>::reject();122 close(); 125 123 } 126 124 … … 222 220 /* Ignore objects which are NOT widgets: */ 223 221 if (!pObject->isWidgetType()) 224 return Q IMainDialog::eventFilter(pObject, pEvent);222 return QMainWindow::eventFilter(pObject, pEvent); 225 223 226 224 /* Ignore widgets which window is NOT settings window: */ 227 225 QWidget *pWidget = static_cast<QWidget*>(pObject); 228 226 if (pWidget->window() != this) 229 return Q IMainDialog::eventFilter(pObject, pEvent);227 return QMainWindow::eventFilter(pObject, pEvent); 230 228 231 229 /* Process different event-types: */ … … 255 253 256 254 /* Base-class processing: */ 257 return Q IMainDialog::eventFilter(pObject, pEvent);255 return QMainWindow::eventFilter(pObject, pEvent); 258 256 } 259 257 … … 281 279 } 282 280 283 void UISettingsDialog::polishEvent(QShowEvent *pEvent) 281 void UISettingsDialog::showEvent(QShowEvent *pEvent) 282 { 283 /* Polish stuff: */ 284 if (!m_fPolished) 285 { 286 m_fPolished = true; 287 polishEvent(pEvent); 288 } 289 290 /* Call to base-class: */ 291 QIWithRetranslateUI<QMainWindow>::showEvent(pEvent); 292 } 293 294 void UISettingsDialog::polishEvent(QShowEvent*) 284 295 { 285 296 /* Check what's the minimum selector size: */ … … 339 350 #endif /* VBOX_WS_MAC */ 340 351 341 /* Call to base-class: */342 QIWithRetranslateUI<QIMainDialog>::polishEvent(pEvent);352 /* Explicit centering according to our parent: */ 353 UIDesktopWidgetWatchdog::centerWidget(this, parentWidget(), false); 343 354 } 344 355 345 356 void UISettingsDialog::closeEvent(QCloseEvent *pEvent) 346 357 { 358 /* Ignore event initially: */ 359 pEvent->ignore(); 360 347 361 /* Check whether there are unsaved settings 348 362 * which will be lost in such case: */ … … 350 364 || msgCenter().confirmSettingsDiscarding(this)) 351 365 { 352 /* Call to base-class: */ 353 QIWithRetranslateUI<QIMainDialog>::closeEvent(pEvent); 354 } 355 else 356 { 357 /* Otherwise ignore this: */ 358 pEvent->ignore(); 366 /* Tell the listener to close us (once): */ 367 if (!m_fClosed) 368 { 369 m_fClosed = true; 370 emit sigClose(); 371 } 359 372 } 360 373 } … … 714 727 if (m_pButtonBox) 715 728 { 716 m_pButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);717 718 729 /* Create status-bar: */ 719 730 m_pStatusBar = new QStackedWidget; … … 821 832 QDialogButtonBox::NoButton); 822 833 #endif 834 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::Key_Return); 835 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 823 836 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UISettingsDialog::close); 824 837 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UISettingsDialog::accept); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h
r97384 r97390 33 33 34 34 /* Qt includes: */ 35 #include <QMainWindow> 35 36 #include <QPointer> 36 37 #include <QVariant> 37 38 38 39 /* GUI includes: */ 39 #include "QIMainDialog.h"40 40 #include "QIWithRetranslateUI.h" 41 41 #include "UISettingsDefs.h" … … 59 59 using namespace UISettingsDefs; 60 60 61 /** Q IMainDialogsubclass used as61 /** QMainWindow subclass used as 62 62 * base dialog class for both Global Preferences & Machine Settings 63 63 * dialogs, which encapsulates most of their common functionality. */ 64 class SHARED_LIBRARY_STUFF UISettingsDialog : public QIWithRetranslateUI<Q IMainDialog>64 class SHARED_LIBRARY_STUFF UISettingsDialog : public QIWithRetranslateUI<QMainWindow> 65 65 { 66 66 Q_OBJECT; 67 68 signals: 69 70 /** Notifies listeners about dialog should be closed. */ 71 void sigClose(); 67 72 68 73 public: … … 79 84 virtual DialogType dialogType() const = 0; 80 85 81 /** Performs modal dialog call. */ 82 void execute(); 86 /** Loads the dialog data. */ 87 virtual void load() = 0; 88 /** Saves the dialog data. */ 89 virtual void save() = 0; 83 90 84 91 protected slots: … … 108 115 /** Handles translation event. */ 109 116 virtual void retranslateUi() RT_OVERRIDE; 117 /** Handles show @a pEvent. */ 118 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE; 110 119 /** Handles first show @a pEvent. */ 111 virtual void polishEvent(QShowEvent *pEvent) RT_OVERRIDE;120 virtual void polishEvent(QShowEvent *pEvent); 112 121 /** Handles close @a pEvent. */ 113 122 virtual void closeEvent(QCloseEvent *pEvent) RT_OVERRIDE; … … 117 126 /** Saves the dialog @a data. */ 118 127 void saveData(QVariant &data); 119 120 /** Loads the dialog data. */121 virtual void load() = 0;122 /** Saves the dialog data. */123 virtual void save() = 0;124 128 125 129 /** Returns configuration access level. */ … … 199 203 UISettingsSerializer *m_pSerializeProcess; 200 204 205 /** Holds whether dialog is polished. */ 206 bool m_fPolished; 201 207 /** Holds whether the serialization is in progress. */ 202 208 bool m_fSerializationIsInProgress; 203 209 /** Holds whether there were no serialization errors. */ 204 210 bool m_fSerializationClean; 211 /** Holds whether the dialod had emitted signal to be closed. */ 212 bool m_fClosed; 205 213 206 214 /** Holds the status-bar widget instance. */
Note:
See TracChangeset
for help on using the changeset viewer.