Changeset 41122 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 2, 2012 3:58:51 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r41108 r41122 1031 1031 return; 1032 1032 1033 /* Propose to close active machine window: */ 1034 activeMachineWindow()->sltTryClose(); 1033 /* Do not try to close machine-window if restricted: */ 1034 if (isPreventAutoClose()) 1035 return; 1036 1037 /* First, we have to close/hide any opened modal & popup application widgets. 1038 * We have to make sure such window is hidden even if close-event was rejected. 1039 * We are re-throwing this slot if any widget present to test again. 1040 * If all opened widgets are closed/hidden, we can try to close machine-window: */ 1041 QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() : 1042 QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0; 1043 if (pWidget) 1044 { 1045 /* Closing/hiding all we found: */ 1046 pWidget->close(); 1047 if (!pWidget->isHidden()) 1048 pWidget->hide(); 1049 QTimer::singleShot(0, this, SLOT(sltClose())); 1050 return; 1051 } 1052 1053 /* Try to close active machine-window: */ 1054 activeMachineWindow()->close(); 1035 1055 } 1036 1056 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r41114 r41122 169 169 } 170 170 171 void UIMachineWindow::sltTryClose()172 {173 /* Do not try to close window if restricted: */174 if (machineLogic()->isPreventAutoClose())175 return;176 177 #if 0178 // TODO: Is that really needed?179 /* This thing here is from Qt3.180 * First close any open modal & popup widgets.181 * Use a single shot with timeout 0 to allow the widgets to cleanly close and test then again.182 * If all open widgets are closed destroy ourself: */183 QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :184 QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0;185 if (pWidget)186 {187 pWidget->close();188 QTimer::singleShot(0, this, SLOT(sltTryClose()));189 }190 else191 #endif192 193 close();194 }195 196 171 UIMachineWindow::UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId) 197 172 : QIWithRetranslateUI2<QMainWindow>(0, windowFlags(pMachineLogic->visualStateType())) … … 218 193 if (m_uScreenId == 0) 219 194 vboxGlobal().setMainWindow(this); 220 }221 222 UIMachineWindow::~UIMachineWindow()223 {224 #if 0225 // TODO: Is that really needed?226 /* This thing here is from Qt3.227 * Close any opened modal & popup widgets: */228 while (QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :229 QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0)230 {231 /* Set modal/popup window's parent to null early,232 * because deleteLater() is synchronous233 * and will be called later than this destructor: */234 pWidget->setParent(0);235 /* Close modal/popup window early to hide it236 * because deleteLater() is synchronous237 * and will be called later than this destructor: */238 pWidget->close();239 /* Delete modal/popup window synchronously (safe): */240 pWidget->deleteLater();241 }242 #endif243 195 } 244 196 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h
r41114 r41122 65 65 virtual void sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo); 66 66 67 /* Slot to close machine-window: */68 void sltTryClose();69 70 67 protected: 71 68 72 /* Constructor /destructor: */69 /* Constructor: */ 73 70 UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId); 74 ~UIMachineWindow();75 71 76 72 /* Show stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r41120 r41122 497 497 void UISession::sltCloseVirtualSession() 498 498 { 499 /* Recursively close all the usual modal & popup widgets... */ 500 QWidget *widget = QApplication::activeModalWidget() ? 501 QApplication::activeModalWidget() : 502 QApplication::activePopupWidget() ? 503 QApplication::activePopupWidget() : 0; 504 if (widget) 505 { 506 widget->hide(); 499 /* First, we have to close/hide any opened modal & popup application widgets. 500 * We have to make sure such window is hidden even if close-event was rejected. 501 * We are re-throwing this slot if any widget present to test again. 502 * If all opened widgets are closed/hidden, we can try to close machine-window: */ 503 QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() : 504 QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0; 505 if (pWidget) 506 { 507 /* Closing/hiding all we found: */ 508 pWidget->close(); 509 if (!pWidget->isHidden()) 510 pWidget->hide(); 507 511 QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession())); 508 512 return; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp
r38311 r41122 604 604 } 605 605 606 void UISettingsDialog::closeEvent(QCloseEvent *pEvent)607 {608 if (m_fLoaded)609 QIMainDialog::closeEvent(pEvent);610 else611 pEvent->ignore();612 }613 614 606 void UISettingsDialog::assignValidator(UISettingsPage *pPage) 615 607 { -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h
r37168 r41122 119 119 bool eventFilter(QObject *pObject, QEvent *pEvent); 120 120 void showEvent(QShowEvent *pEvent); 121 void closeEvent(QCloseEvent *pEvent);122 121 123 122 void assignValidator(UISettingsPage *pPage);
Note:
See TracChangeset
for help on using the changeset viewer.