MCPcopy Create free account
hub / github.com/alpha-liu-01/SpeedyNote / toggleLauncher

Method toggleLauncher

source/MainWindow.cpp:7719–7849  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7717}
7718
7719void MainWindow::toggleLauncher() {
7720 // Phase P.4.4: Toggle launcher visibility
7721 // Phase P.4.5: Smooth transition with fade animation
7722
7723 // Find existing Launcher among top-level widgets
7724 QWidget* launcher = nullptr;
7725 for (QWidget* widget : QApplication::topLevelWidgets()) {
7726 if (widget->inherits("Launcher")) {
7727 launcher = widget;
7728 break;
7729 }
7730 }
7731
7732 if (!launcher) {
7733 // No launcher exists - can't toggle
7734#ifdef SPEEDYNOTE_DEBUG
7735 qDebug() << "MainWindow::toggleLauncher: No launcher window found";
7736#endif
7737 return;
7738 }
7739
7740 // Animation duration in milliseconds
7741 const int fadeDuration = 150;
7742
7743 if (launcher->isVisible()) {
7744 // ========== LAUNCHER → MAINWINDOW ==========
7745 // Read Launcher state BEFORE we reset it below.
7746 const bool launcherMaximized = launcher->isMaximized();
7747 const bool launcherFullScreen = launcher->isFullScreen();
7748 const QPoint launcherPos = launcher->pos();
7749 const QSize launcherSize = launcher->size();
7750
7751 // Show MainWindow in the Launcher's window state.
7752 // Reset stale native state on the hidden MainWindow (same reasoning
7753 // as the Launcher reset in the other branch — QWidget skips the
7754 // platform update for hidden widgets, but QWindow does not).
7755 setWindowState(Qt::WindowNoState);
7756 if (QWindow* win = windowHandle()) {
7757 win->setWindowState(Qt::WindowNoState);
7758 }
7759 setWindowOpacity(0.0);
7760 if (launcherMaximized) {
7761 showMaximized();
7762 } else if (launcherFullScreen) {
7763 showFullScreen();
7764 } else {
7765 showNormal();
7766 // Set geometry AFTER show so our move()/resize() has the final
7767 // word. On Windows, ShowWindow(SW_SHOWNORMAL) can adjust the
7768 // position using stale placement data; applying geometry after
7769 // the show overrides that. The window is at opacity 0, so the
7770 // brief intermediate position is invisible.
7771 move(launcherPos);
7772 resize(launcherSize);
7773 }
7774 raise();
7775 activateWindow();
7776

Callers 1

Calls 3

setFullscreenCheckedMethod · 0.80
hideMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected