MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / disableAll

Method disableAll

src/uilocker.cpp:551–617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551void UILocker::disableAll()
552{
553 // the goal is to disable the main window and any dialog that's opened,
554 // without disabling the overlay itself
555 //
556 // the overlay might be a regular widget overlayed on top of a window, or an
557 // actual dialog if a shortcut is launched when MO isn't running
558
559 // top level widgets include the main window and dialogs
560 for (auto* w : QApplication::topLevelWidgets()) {
561 if (auto* mw = dynamic_cast<QMainWindow*>(w)) {
562 // this is the main window, disable the central widgets and the stuff
563 // around it
564
565 disable(mw->centralWidget());
566 disable(mw->menuBar());
567 disable(mw->statusBar());
568
569 // every toolbar
570 for (auto* tb : findChildrenImmediate<QToolBar*>(w)) {
571 disable(tb);
572 }
573
574 // every docked widget
575 for (auto* d : findChildrenImmediate<QDockWidget*>(w)) {
576 disable(d);
577 }
578 }
579
580 if (auto* d = dynamic_cast<QDialog*>(w)) {
581 // this is a dialog
582
583 if (d == m_ui->topLevel()) {
584 // but it's the overlay itself, skip it; this happens if a shortcut is
585 // launched but MO itself isn't running, in which case the lock ui is
586 // a dialog, not an overlay
587 continue;
588 }
589
590 // disable all the dialog's immediate children, except for the overlay
591 // itself or other dialogs
592 for (auto* child : findChildrenImmediate<QWidget*>(d)) {
593 if (child == m_ui->topLevel()) {
594 // this is the overlay itself, skip it
595 continue;
596 }
597
598 if (dynamic_cast<QDialog*>(child)) {
599 // this is a child dialog, skip it
600 //
601 // this typically happens when there's a second level modal dialog,
602 // like the create instance dialog that's opened from the instance
603 // manager
604 //
605 // the lock overlay is probably a child of that dialog, so disabling
606 // the dialog would also disable the buttons on the lock overlay
607 //
608 // since this is a dialog, it will be part of `topLevel` from the main

Callers

nothing calls this directly

Calls 1

topLevelMethod · 0.80

Tested by

no test coverage detected