Repository: nuttyartist/notes
File: src/mainwindow.cpp (C++)

Code before:
 * Minimize the window
 */
void MainWindow::minimizeWindow()
{
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
    //    QMargins margins(m_layoutMargin,m_layoutMargin,m_layoutMargin,m_layoutMargin);
    //    setMargins(margins);
#endif

    // BUG : QTBUG-57902 minimize doesn't store the window state before minimizing
    showMinimized();
}

/*!
 * \brief MainWindow::QuitApplication
 * Exit the application
 * If a new note created but wasn't edited, delete it from the database
 */
void MainWindow::QuitApplication()
{
    m_noteEditorLogic->closeEditor();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    // Works around an issue where trying to exit Notes using the
    // system tray menu action while our window is hidden, fails.
    if (MainWindow::isHidden())
        MainWindow::show();
#endif
    MainWindow::close();
}

/*!
 * \brief MainWindow::checkForUpdates
 * Called when the "Check for Updates" menu item is clicked, this function
 * instructs the updater window to check if there are any updates available
 */
void MainWindow::checkForUpdates()
{
    m_updater.checkForUpdates(true);
}

/*!
 * \brief MainWindow::importNotesFile
 * Called when the "Import Notes" menu button is clicked. this function will
 * prompt the user to select a file, attempt to load the file, and update the DB
 * if valid.
 * The user is presented with a dialog box if the upload/import fails for any reason.
 */
void MainWindow::importNotesFile()
{
    executeImport(false);
}

Review comment (suggestion):
Really interesting that this hack works. It makes it somewhat likely to be a Qt issue, and we should probably report it, but in that case we need to create a minimal example app that reproduces the problem.

Code after:
    }
#elif _WIN32
    if (isMaximized()) {
        setWindowState(windowState() & ~Qt::WindowMaximized);
        setWindowState(windowState() & ~Qt::WindowFullScreen);
    } else if (isFullScreen()) {
        setWindowState((windowState() | Qt::WindowMaximized) & ~Qt::WindowFullScreen);
        setGeometry(qApp->primaryScreen()->availableGeometry());
    } else {
        setWindowState(windowState() | Qt::WindowMaximized);
        setGeometry(qApp->primaryScreen()->availableGeometry());
    }
#endif
}

/*!
 * \brief MainWindow::minimizeWindow
 * Minimize the window
 */
void MainWindow::minimizeWindow()
{
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
    //    QMargins margins(m_layoutMargin,m_layoutMargin,m_layoutMargin,m_layoutMargin);
    //    setMargins(margins);
#endif

    // BUG : QTBUG-57902 minimize doesn't store the window state before minimizing
    showMinimized();
}

/*!
 * \brief MainWindow::QuitApplication
 * Exit the application
 * If a new note created but wasn't edited, delete it from the database
 */
void MainWindow::QuitApplication()
{
    if (windowState() != Qt::WindowFullScreen) {
        m_settingsDatabase->setValue(QStringLiteral("windowGeometry"), saveGeometry());
        if (m_styleEditorWindow.windowState() != Qt::WindowFullScreen)
            m_settingsDatabase->setValue(QStringLiteral("editorSettingsWindowGeometry"),
                                         m_styleEditorWindow.saveGeometry());
    }

    m_noteEditorLogic->saveNoteToDB();

#if defined(UPDATE_CHECKER)
    m_settingsDatabase->setValue(QStringLiteral("dontShowUpdateWindow"), m_dontShowUpdateWindow);
#endif
    m_settingsDatabase->setValue(QStringLiteral("splitterSizes"), m_splitter->saveState());