Changeset 45192 in vbox
- Timestamp:
- Mar 26, 2013 1:37:41 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxTakeSnapshotDlg.cpp
r44528 r45192 45 45 : QIWithRetranslateUI<QIDialog>(pParent) 46 46 { 47 #ifdef Q_WS_MAC48 /* Check if Mac Sheet is allowed: */49 if (vboxGlobal().isSheetWindowAllowed(pParent))50 {51 vboxGlobal().setSheetWindowUsed(pParent, true);52 setWindowFlags(Qt::Sheet);53 }54 #endif /* Q_WS_MAC */55 56 47 /* Apply UI decorations */ 57 48 Ui::VBoxTakeSnapshotDlg::setupUi(this); … … 99 90 } 100 91 101 VBoxTakeSnapshotDlg::~VBoxTakeSnapshotDlg()102 {103 #ifdef Q_WS_MAC104 /* Check if Mac Sheet was used: */105 if ((windowFlags() & Qt::Sheet) == Qt::Sheet)106 vboxGlobal().setSheetWindowUsed(parentWidget(), false);107 #endif /* Q_WS_MAC */108 }109 110 92 void VBoxTakeSnapshotDlg::retranslateUi() 111 93 { -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxTakeSnapshotDlg.h
r44528 r45192 35 35 36 36 VBoxTakeSnapshotDlg(QWidget *pParent, const CMachine &machine); 37 ~VBoxTakeSnapshotDlg();38 37 39 38 protected: -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIDialog.cpp
r45166 r45192 21 21 #include "QIDialog.h" 22 22 #include "VBoxGlobal.h" 23 #ifdef Q_WS_MAC24 # include "VBoxUtils.h"25 #endif /* Q_WS_MAC */26 23 27 24 QIDialog::QIDialog(QWidget *pParent /* = 0 */, Qt::WindowFlags flags /* = 0 */) … … 29 26 , m_fPolished(false) 30 27 { 28 /* No need to count that window as important for application, 29 * it will NOT be taken into account when other top-level windows will be closed: */ 30 setAttribute(Qt::WA_QuitOnClose, false); 31 31 } 32 32 … … 53 53 54 54 /* Should we delete ourself on close in theory? */ 55 bool fWasDeleteOnClose = testAttribute(Qt::WA_DeleteOnClose); 55 bool fOldDeleteOnClose = testAttribute(Qt::WA_DeleteOnClose); 56 /* For the exec() time, set this attribute to 'false': */ 56 57 setAttribute(Qt::WA_DeleteOnClose, false); 57 58 58 #if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 59 /* After 4.5 Qt changed the behavior of Sheets for the window/application 60 * modal case. See "New Ways of Using Dialogs" in 61 * http://doc.trolltech.com/qq/QtQuarterly30.pdf why. We want the old 62 * behavior back, where all modal windows where shown as sheets. So make 63 * the modal mode window, but be application modal in any case. */ 64 Qt::WindowModality winModality = windowModality(); 65 bool wasSetWinModality = testAttribute(Qt::WA_SetWindowModality); 66 if ((windowFlags() & Qt::Sheet) == Qt::Sheet) 67 { 68 setWindowModality(Qt::WindowModal); 69 setAttribute(Qt::WA_SetWindowModality, false); 70 } 71 #endif /* defined(Q_WS_MAC) && QT_VERSION >= 0x040500 */ 72 /* The dialog has to modal in any case. 73 * Save the current modality to restore it later. */ 74 bool wasShowModal = testAttribute(Qt::WA_ShowModal); 75 setAttribute(Qt::WA_ShowModal, true); 59 /* Which is the current window-modality? */ 60 Qt::WindowModality oldModality = windowModality(); 61 /* For the exec() time, set this attribute to 'window-modal': */ 62 setWindowModality(Qt::WindowModal); 76 63 77 64 /* Show ourself if requested: */ … … 101 88 QDialog::DialogCode resultCode = (QDialog::DialogCode)result(); 102 89 103 #if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 104 /* Restore old modality mode: */ 105 if ((windowFlags() & Qt::Sheet) == Qt::Sheet) 106 { 107 setWindowModality(winModality); 108 setAttribute(Qt::WA_SetWindowModality, wasSetWinModality); 109 } 110 #endif /* defined(Q_WS_MAC) && QT_VERSION >= 0x040500 */ 111 /* Set the old show modal attribute: */ 112 setAttribute (Qt::WA_ShowModal, wasShowModal); 90 /* Return old modality: */ 91 setWindowModality(oldModality); 113 92 93 /* Reset attribute to previous value: */ 94 setAttribute(Qt::WA_DeleteOnClose, fOldDeleteOnClose); 114 95 /* Delete ourself if we should do that on close: */ 115 if (f WasDeleteOnClose)96 if (fOldDeleteOnClose) 116 97 delete this; 117 98 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.cpp
r43104 r45192 59 59 , mWasPolished (false) 60 60 { 61 #ifdef Q_WS_MAC62 /* Check if Mac Sheet is allowed: */63 if (vboxGlobal().isSheetWindowAllowed(aParent))64 {65 vboxGlobal().setSheetWindowUsed(aParent, true);66 setWindowFlags(Qt::Sheet);67 }68 #endif /* Q_WS_MAC */69 70 61 setWindowTitle (aCaption); 71 62 /* Necessary to later find some of the message boxes */ … … 174 165 /* this call is a must -- it initializes mFlagCB and mSpacer */ 175 166 setDetailsShown (false); 176 }177 178 QIMessageBox::~QIMessageBox()179 {180 #ifdef Q_WS_MAC181 /* Check if Mac Sheet was used: */182 if ((windowFlags() & Qt::Sheet) == Qt::Sheet)183 vboxGlobal().setSheetWindowUsed(parentWidget(), false);184 #endif /* Q_WS_MAC */185 167 } 186 168 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.h
r44528 r45192 77 77 Icon aIcon, int aButton0, int aButton1 = 0, int aButton2 = 0, 78 78 QWidget *aParent = 0, const char *aName = 0, bool aModal = TRUE); 79 ~QIMessageBox();80 79 81 80 QString buttonText (int aButton) const; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r45184 r45192 37 37 #include "UINetworkManagerDialog.h" 38 38 #include "UIConverter.h" 39 #include "UIModalWindowManager.h" 39 40 #ifdef VBOX_OSE 40 41 # include "UIDownloaderUserManual.h" … … 220 221 221 222 /* Create message-box: */ 222 QPointer<QIMessageBox> pBox = new QIMessageBox(title, strMessage, icon, button1, button2, 223 button3, pParent, pcszAutoConfirmId); 223 QWidget *pBoxParent = mwManager().realParentWindow(pParent); 224 QPointer<QIMessageBox> pBox = new QIMessageBox(title, strMessage, icon, 225 button1, button2, button3, 226 pBoxParent, pcszAutoConfirmId); 227 mwManager().registerNewParent(pBox, pBoxParent); 224 228 225 229 /* Configure message-box: */ … … 344 348 345 349 /* Create message-box: */ 350 QWidget *pBoxParent = mwManager().realParentWindow(pParent); 346 351 QPointer<QIMessageBox> pBox = new QIMessageBox(strTitle, strMessage, icon, 347 iButton1, iButton2, iButton3, pParent); 352 iButton1, iButton2, iButton3, pBoxParent); 353 mwManager().registerNewParent(pBox, pBoxParent); 348 354 349 355 /* Configure box: */ … … 407 413 int cMinDuration /* = 2000 */) 408 414 { 415 /* Prepare pixmap: */ 409 416 QPixmap *pPixmap = 0; 410 417 if (!strImage.isEmpty()) 411 418 pPixmap = new QPixmap(strImage); 412 419 413 UIProgressDialog progressDlg(progress, strTitle, pPixmap, fSheetOnDarwin, cMinDuration, pParent ? pParent : mainWindowShown()); 420 /* Create progress-dialog: */ 421 QWidget *pDlgParent = mwManager().realParentWindow(pParent); 422 QPointer<UIProgressDialog> pProgressDlg = new UIProgressDialog(progress, strTitle, pPixmap, fSheetOnDarwin, cMinDuration, pDlgParent); 423 mwManager().registerNewParent(pProgressDlg, pDlgParent); 424 414 425 /* Run the dialog with the 350 ms refresh interval. */ 415 progressDlg.run(350); 416 426 pProgressDlg->run(350); 427 428 /* Make sure progress-dialog still valid: */ 429 if (!pProgressDlg) 430 return false; 431 432 /* Delete progress-dialog: */ 433 delete pProgressDlg; 434 435 /* Cleanup pixmap: */ 417 436 if (pPixmap) 418 437 delete pPixmap; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r45167 r45192 3844 3844 } 3845 3845 #endif /* VBOX_WITH_CRHGSMI */ 3846 3847 #ifdef Q_WS_MAC3848 bool VBoxGlobal::isSheetWindowAllowed(QWidget *pParent) const3849 {3850 /* Disallow for null parent: */3851 if (!pParent)3852 return false;3853 3854 /* Make sure Mac Sheet is not used for the same parent now. */3855 if (sheetWindowUsed(pParent))3856 return false;3857 3858 /* No sheets for fullscreen/seamless now.3859 * Firstly it looks ugly and secondly in some cases it is broken. */3860 if (!(qobject_cast<UIMachineWindowFullscreen*>(pParent) ||3861 qobject_cast<UIMachineWindowSeamless*>(pParent)))3862 return true;3863 3864 return false;3865 }3866 3867 void VBoxGlobal::setSheetWindowUsed(QWidget *pParent, bool fUsed)3868 {3869 /* Ignore null parent: */3870 if (!pParent)3871 return;3872 3873 if (fUsed)3874 {3875 AssertMsg(!m_sheets.contains(pParent), ("Trying to use Mac Sheet for parent which already has one!"));3876 if (m_sheets.contains(pParent))3877 return;3878 }3879 else3880 {3881 AssertMsg(m_sheets.contains(pParent), ("Trying to cancel use Mac Sheet for parent which has no one!"));3882 if (!m_sheets.contains(pParent))3883 return;3884 }3885 3886 if (fUsed)3887 m_sheets.insert(pParent);3888 else3889 m_sheets.remove(pParent);3890 }3891 3892 bool VBoxGlobal::sheetWindowUsed(QWidget *pParent) const3893 {3894 return m_sheets.contains(pParent);3895 }3896 #endif /* Q_WS_MAC */3897 3846 3898 3847 /* static */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r45054 r45192 384 384 static quint64 required3DWddmOffscreenVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1); 385 385 #endif /* VBOX_WITH_CRHGSMI */ 386 387 #ifdef Q_WS_MAC388 bool isSheetWindowAllowed(QWidget *pParent) const;389 void setSheetWindowUsed(QWidget *pParent, bool fUsed);390 bool sheetWindowUsed(QWidget *pParent) const;391 #endif /* Q_WS_MAC */392 386 393 387 /* Returns full medium-format name for the given base medium-format name: */ … … 550 544 bool mSettingsPwSet; 551 545 552 #ifdef Q_WS_MAC553 QSet<QWidget*> m_sheets;554 #endif /* Q_WS_MAC */555 556 546 friend VBoxGlobal &vboxGlobal(); 557 547 }; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r45167 r45192 52 52 #include "UIVMLogViewer.h" 53 53 #include "UIConverter.h" 54 #include "UIModalWindowManager.h" 54 55 #ifdef Q_WS_MAC 55 56 # include "DockIconPreview.h" … … 988 989 989 990 /* Create take-snapshot dialog: */ 990 QPointer<VBoxTakeSnapshotDlg> pDlg = new VBoxTakeSnapshotDlg(activeMachineWindow(), machine); 991 QWidget *pDlgParent = mwManager().realParentWindow(activeMachineWindow()); 992 QPointer<VBoxTakeSnapshotDlg> pDlg = new VBoxTakeSnapshotDlg(pDlgParent, machine); 993 mwManager().registerNewParent(pDlg, pDlgParent); 991 994 992 995 /* Assign corresponding icon: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r45168 r45192 38 38 #include "UIVMCloseDialog.h" 39 39 #include "UIConverter.h" 40 #include "UIModalWindowManager.h" 40 41 41 42 /* COM includes: */ … … 273 274 274 275 /* Prepare close-dialog: */ 275 UIVMCloseDialog *pDlg = new UIVMCloseDialog(this); 276 QWidget *pDlgParent = mwManager().realParentWindow(this); 277 UIVMCloseDialog *pDlg = new UIVMCloseDialog(pDlgParent); 278 mwManager().registerNewParent(pDlg, pDlgParent); 276 279 277 280 /* Assign close-dialog pixmap: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp
r44528 r45192 36 36 : QIWithRetranslateUI<QIDialog>(pParent) 37 37 { 38 #ifdef Q_WS_MAC39 /* Check if Mac Sheet is allowed: */40 if (vboxGlobal().isSheetWindowAllowed(pParent))41 {42 vboxGlobal().setSheetWindowUsed(pParent, true);43 setWindowFlags(Qt::Sheet);44 }45 #endif /* Q_WS_MAC */46 47 38 /* Apply UI decorations */ 48 39 Ui::UIVMCloseDialog::setupUi(this); … … 62 53 } 63 54 64 UIVMCloseDialog::~UIVMCloseDialog()65 {66 #ifdef Q_WS_MAC67 /* Check if Mac Sheet was used: */68 if ((windowFlags() & Qt::Sheet) == Qt::Sheet)69 vboxGlobal().setSheetWindowUsed(parentWidget(), false);70 #endif /* Q_WS_MAC */71 }72 73 55 void UIVMCloseDialog::retranslateUi() 74 56 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h
r44528 r45192 32 32 33 33 UIVMCloseDialog(QWidget *pParent); 34 ~UIVMCloseDialog();35 34 36 35 protected: -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp
r44528 r45192 40 40 #include "UIVirtualBoxEventHandler.h" 41 41 #include "UIConverter.h" 42 #include "UIModalWindowManager.h" 42 43 43 44 /* COM includes: */ … … 816 817 { 817 818 /* Create take-snapshot dialog: */ 818 QPointer<VBoxTakeSnapshotDlg> pDlg = new VBoxTakeSnapshotDlg(this, mMachine); 819 QWidget *pDlgParent = mwManager().realParentWindow(this); 820 QPointer<VBoxTakeSnapshotDlg> pDlg = new VBoxTakeSnapshotDlg(pDlgParent, mMachine); 821 mwManager().registerNewParent(pDlg, pDlgParent); 819 822 820 823 /* Assign corresponding icon: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.cpp
r43857 r45192 7 7 8 8 /* 9 * Copyright (C) 2006-201 2Oracle Corporation9 * Copyright (C) 2006-2013 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 #include "UISpecialControls.h" 33 33 #include "VBoxGlobal.h" 34 #include "UIModalWindowManager.h" 34 35 #ifdef Q_WS_MAC 35 36 # include "VBoxUtils-darwin.h" … … 64 65 65 66 #ifdef Q_WS_MAC 66 /* Check if Mac Sheet is allowed: */67 if (fSheetOnDarwin && vboxGlobal().isSheetWindowAllowed(pParent))68 {69 vboxGlobal().setSheetWindowUsed(pParent, true);70 setWindowFlags(Qt::Sheet);71 }72 67 ::darwinSetHidesAllTitleButtons(this); 73 ::darwinSetShowsResizeIndicator(this, false);74 68 if (pImage) 75 69 pMainLayout->setContentsMargins(30, 15, 30, 15); 76 70 else 77 71 pMainLayout->setContentsMargins(6, 6, 6, 6); 78 #e lse/* Q_WS_MAC */72 #endif /* Q_WS_MAC */ 79 73 NOREF(fSheetOnDarwin); 80 #endif /* !Q_WS_MAC */81 74 82 75 /* Create image: */ … … 135 128 * the duration is over if progress is not finished yet. */ 136 129 QTimer::singleShot(cMinDuration, this, SLOT(sltShowDialog())); 137 }138 139 UIProgressDialog::~UIProgressDialog()140 {141 #ifdef Q_WS_MAC142 /* Check if Mac Sheet was used: */143 if ((windowFlags() & Qt::Sheet) == Qt::Sheet)144 vboxGlobal().setSheetWindowUsed(parentWidget(), false);145 #endif /* Q_WS_MAC */146 130 } 147 131 … … 200 184 * modal dialog prevents our event-loop from 201 185 * being exit overlapping 'this'. */ 202 if (m_fEnded && !isHidden() )186 if (m_fEnded && !isHidden() && mwManager().isWindowOnTheTopOfTheModalWindowStack(this)) 203 187 { 204 188 hide(); … … 210 194 if (!m_fEnded && (!m_progress.isOk() || m_progress.GetCompleted())) 211 195 { 212 /* Progress finished:*/213 if (m _progress.isOk())196 /* Is this progress-dialog a top-level modal-dialog now? */ 197 if (mwManager().isWindowOnTheTopOfTheModalWindowStack(this)) 214 198 { 215 m_pProgressBar->setValue(100); 216 done(Accepted); 199 /* Progress finished: */ 200 if (m_progress.isOk()) 201 { 202 m_pProgressBar->setValue(100); 203 done(Accepted); 204 } 205 /* Progress is not valid: */ 206 else 207 done(Rejected); 208 209 /* Request to exit loop: */ 210 m_fEnded = true; 211 return; 217 212 } 218 /* Progress is not valid: */ 219 else 220 done(Rejected); 221 222 /* Request to exit loop: */ 223 m_fEnded = true; 213 /* Else we should wait until all the subsequent 214 * top-level modal-dialog(s) will be dismissed: */ 224 215 return; 225 216 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.h
r43857 r45192 6 6 7 7 /* 8 * Copyright (C) 2009-201 2Oracle Corporation8 * Copyright (C) 2009-2013 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 44 44 * destroyed. 45 45 */ 46 class UIProgressDialog: p rotectedQIWithRetranslateUI2<QIDialog>46 class UIProgressDialog: public QIWithRetranslateUI2<QIDialog> 47 47 { 48 48 Q_OBJECT; … … 54 54 QPixmap *pImage = 0, bool fSheetOnDarwin = false, 55 55 int cMinDuration = 2000, QWidget *pParent = 0); 56 ~UIProgressDialog();57 56 58 57 /* API: Run stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.