Skip to content

Conversation

@JonathanFeenstra
Copy link
Contributor

@JonathanFeenstra JonathanFeenstra commented Dec 29, 2025

This adds a checkbox to the executables window to minimize Mod Organizer to the system tray while the executable is running. It will automatically reappear after it finishes running, or if the user clicks on the system tray icon while it's still running. Closes #2119.

@Holt59
Copy link
Member

Holt59 commented Dec 30, 2025

I'm okay with the idea but maybe this could be isolated in a dedicated class to 1) avoid adding more clutter to MainWindow and 2) allow us to add more stuff to the tray icon in the future and keep them in a single location.

@JonathanFeenstra
Copy link
Contributor Author

I could move the code from MainWindow::createSystemTrayIcon to the constructor of a new QSystemTrayIcon subclass, would that be enough? minimizeToSystemTray and restoreFromSystemTray are really tied to the MainWindow, so I don't think those can easily be separated.

@Holt59
Copy link
Member

Holt59 commented Dec 30, 2025

I could move the code from MainWindow::createSystemTrayIcon to the constructor of a new QSystemTrayIcon subclass, would that be enough? minimizeToSystemTray and restoreFromSystemTray are really tied to the MainWindow, so I don't think those can easily be separated.

I don't think you need to subclass QSystemTrayIcon, having some kind of "system tray manager" class with a tray icon has an attribute should be enough. For the minimizeToSystemTray and restoreFromSystemTray, you can probably move them by passing the main window to the new class?

@JonathanFeenstra
Copy link
Contributor Author

Yes, that seems to work. I also passed the log dock widget because it can be in a separate floating window which should also be minimized to the tray.

void SystemTrayManager::minimizeToSystemTray()
{
if (!m_SystemTrayIcon) {
createSystemTrayIcon();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not to initialize m_SystemTrayIcon in the constructor? This would avoid a lot of check everywhere, and would remove the need for a custom destructor since Qt's ownership would delete the object for us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, I'll initialize it in the constructor to simplify the code.

@Holt59
Copy link
Member

Holt59 commented Jan 3, 2026

Can you merge or rebase from master to fix the CI build?

@Holt59 Holt59 merged commit e5ac1cc into ModOrganizer2:master Jan 3, 2026
3 checks passed
@JonathanFeenstra JonathanFeenstra deleted the systray branch January 3, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please add a Close/Minimize to Tray option

2 participants