Changeset 92490 in vbox
- Timestamp:
- Nov 18, 2021 9:58:58 AM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMainDialog.cpp
r91109 r92490 44 44 , m_fPolished(false) 45 45 , m_iResult(QDialog::Rejected) 46 , m_fRejectByEscape(true) 46 47 { 47 48 /* Install event-filter: */ … … 269 270 case Qt::Key_Escape: 270 271 { 271 if (pEvent->modifiers() == Qt::NoModifier )272 if (pEvent->modifiers() == Qt::NoModifier && m_fRejectByEscape) 272 273 { 273 274 reject(); … … 330 331 hide(); 331 332 } 333 334 void QIMainDialog::setRejectByEscape(bool fRejectByEscape) 335 { 336 m_fRejectByEscape = fRejectByEscape; 337 } -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMainDialog.h
r87718 r92490 91 91 QPushButton *searchDefaultButton() const; 92 92 93 /** Sets reject-by-escape-key flag. */ 94 void setRejectByEscape(bool fRejectByEscape); 95 93 96 protected slots: 94 97 … … 121 124 /** Holds dialog's size-grip. */ 122 125 QPointer<QSizeGrip> m_pSizeGrip; 126 /** Holds reject by escape flag. When true pressing escape rejects the dialog. Default is true.*/ 127 bool m_fRejectByEscape; 123 128 }; 124 129 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp
r92478 r92490 446 446 void UIVisoCreatorWidget::manageEscapeShortCut() 447 447 { 448 // /* Take the escape key from m_pButtonBox and from the panels in case treeview(s) in 449 // host and/or content browser is open. We use the escape key to close those first: */ 450 // if ((m_pHostBrowser && m_pHostBrowser->isTreeViewVisible()) || 451 // (m_pVISOContentBrowser && m_pVISOContentBrowser->isTreeViewVisible())) 452 // { 453 // if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel)) 454 // m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence()); 455 // for (int i = 0; i < m_visiblePanelsList.size(); ++i) 456 // m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence()); 457 // return; 458 // } 459 460 // /* if there are no visible panels then assign esc. key to cancel button of the button box: */ 461 // if (m_visiblePanelsList.isEmpty()) 462 // { 463 // if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel)) 464 // m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence(Qt::Key_Escape)); 465 // return; 466 // } 467 // if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel)) 468 // m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence()); 448 /* Take the escape key from m_pButtonBox and from the panels in case treeview(s) in 449 host and/or content browser is open. We use the escape key to close those first: */ 450 if ((m_pHostBrowser && m_pHostBrowser->isTreeViewVisible()) || 451 (m_pVISOContentBrowser && m_pVISOContentBrowser->isTreeViewVisible())) 452 { 453 emit sigSetCancelButtonShortCut(QKeySequence()); 454 for (int i = 0; i < m_visiblePanelsList.size(); ++i) 455 m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence()); 456 return; 457 } 458 459 /* if there are no visible panels then assign esc. key to cancel button of the button box: */ 460 if (m_visiblePanelsList.isEmpty()) 461 { 462 emit sigSetCancelButtonShortCut(QKeySequence(Qt::Key_Escape)); 463 return; 464 } 465 emit sigSetCancelButtonShortCut(QKeySequence()); 469 466 470 467 /* Just loop thru the visible panel list and set the esc key to the 471 468 panel which made visible latest */ 472 //for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i)473 //m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());474 //m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape));469 for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i) 470 m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence()); 471 m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 475 472 } 476 473 … … 518 515 , m_pActionPool(pActionPool) 519 516 { 517 /* Make sure that the base class does not close this dialog upon pressing escape. 518 we manage escape key here with special casing: */ 519 setRejectByEscape(false); 520 520 prepareWidgets(); 521 521 prepareConnections(); … … 569 569 menuBar()->addMenu(m_pVisoCreatorWidget->menu()); 570 570 pMainLayout->addWidget(m_pVisoCreatorWidget); 571 connect(m_pVisoCreatorWidget, &UIVisoCreatorWidget::sigSetCancelButtonShortCut, 572 this, &UIVisoCreatorDialog::sltSetCancelButtonShortCut); 571 573 } 572 574 … … 575 577 { 576 578 m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 577 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Q t::Key_Escape);579 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence(Qt::Key_Escape)); 578 580 pMainLayout->addWidget(m_pButtonBox); 579 581 … … 610 612 m_pButtonBox->button(QDialogButtonBox::Help)->setToolTip(UIVisoCreatorWidget::tr("Opens the help browser and navigates to the related section")); 611 613 } 614 615 void UIVisoCreatorDialog::sltSetCancelButtonShortCut(QKeySequence keySequence) 616 { 617 if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel)) 618 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(keySequence); 619 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h
r92478 r92490 49 49 { 50 50 Q_OBJECT; 51 52 signals: 53 54 void sigSetCancelButtonShortCut(QKeySequence keySequence); 51 55 52 56 public: … … 184 188 void setCurrentPath(const QString &strPath); 185 189 190 private slots: 191 192 void sltSetCancelButtonShortCut(QKeySequence keySequence); 193 186 194 private: 187 195 void prepareWidgets();
Note:
See TracChangeset
for help on using the changeset viewer.