Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System tray #22

Merged
merged 10 commits into from
May 19, 2023
Merged

System tray #22

merged 10 commits into from
May 19, 2023

Conversation

neuroblack
Copy link
Contributor

@neuroblack neuroblack commented May 1, 2023

Adds start and exit with system tray behaviours.
Both can be toggled on demand in general settings. There is some new entries in the i18n dictionary.

FYI : For now the splash screen is not hidden when start with system tray is enabled, only the main window is.

Copy link
Owner

@Raphiiko Raphiiko left a comment

Choose a reason for hiding this comment

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

Thanks a bunch for the contribution! It's looking great, the code you wrote is really clean ^^

I have some comments on it below, they're mostly just nits and one missing part for the app config migration. Would you be able to update those last few things? Once those changes are in I'm pretty sure we can get this merged.

Comment on lines 9 to 14
oscReceivingPort: number;
enableDesktopNotifications: boolean;
enableXSOverlayNotifications: boolean;
exitInSystemTray: boolean;
startInSystemTray: boolean;
}
Copy link
Owner

@Raphiiko Raphiiko May 2, 2023

Choose a reason for hiding this comment

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

So these interfaces have a version property that gets bumped whenever they are modified. This is so that people's existing configurations can be migrated once they update.

In this case, two new fields got added, which means the version property should be bumped from 4 to 5, and a migration should be written in src/app/migrations/app-settings.migrations.ts that bumps this version and adds the missing fields. If you take a look at the previous migrations in there, you'll see it's quite simple!

@@ -0,0 +1,48 @@
import { Injectable } from '@angular/core';
import { AppSettingsService } from './app-settings.service';
import { debounceTime, filter, first, last, map, pairwise, take } from 'rxjs';
Copy link
Owner

Choose a reason for hiding this comment

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

Nit: there's still a few unused imports here :)

map(settings => settings.exitInSystemTray),
pairwise(),
filter(([oldVal, newVal]) => oldVal !== newVal),
map(([_, newVal]) => newVal),
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
map(([_, newVal]) => newVal),
map(([, newVal]) => newVal),

Nit: in the case of unused array parameters, they can be left empty!

map(settings => settings.startInSystemTray),
pairwise(),
filter(([oldVal, newVal]) => oldVal !== newVal),
map(([_, newVal]) => newVal),
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
map(([_, newVal]) => newVal),
map(([, newVal]) => newVal),

<h2 translate>settings.general.systemTray.title</h2>
<div class="settings">
<div class="setting-row">
<div class="setting-row-label" translate>
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
<div class="setting-row-label" translate>
<div class="setting-row-label">

Nit: unneeded translate directive

"title": "System tray",
"close": {
"label": "Exit in system tray",
"description": "Collapses the program into the system tray upon clicking on exit button"
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
"description": "Collapses the program into the system tray upon clicking on exit button"
"description": "When closing Oyasumi, it will continue to run in the system tray"

},
"start": {
"label": "Start in system tray",
"description": "Starts the program reduced in the system tray."
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
"description": "Starts the program reduced in the system tray."
"description": "The main window will remain hidden when Oyasumi is started"

Comment on lines +423 to +430
"close": {
"label": "Fermer l'application dans la barre d'état",
"description": "Réduit l'application dans la barre d'état système lorsque vous cliquez sur le bouton 'Fermer'"
},
"start": {
"label": "Démarrer dans la barre d'état",
"description": "Démarrer l'application cachée dans la barre d'état. Vous pouvez la restaurer en cliquant sur l'icône dans la barre d'état."
}
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe these need to be updated based on the previous changes to the English translations?

// Initializes the system tray with menus.
pub fn init_system_tray() -> SystemTray {
// Menus
let menu_quit = CustomMenuItem::new(QUIT, "Quit");
Copy link
Owner

Choose a reason for hiding this comment

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

We should probably find a way of localizing this as well, but I understand there's currently not yet a nice way of getting the translations to the rust side. I think doing that might be a bit outside of this PR's scope, especially when you consider the translations should change when the user switches language on the front, so that's probably something to look into after getting this merged.

tl;dr: this is fine as is, feel free to ignore. I've opened a separate issue for this in #23.

Comment on lines +21 to +29
// pub fn handle_window_exit<R: Runtime>(&self) -> impl Fn(GlobalWindowEvent<R>) + Send + Sync + 'static {
// return |event| match event.event() {
// tauri::WindowEvent::CloseRequested { api, .. } => {
// event.window().hide().unwrap();
// api.prevent_close();
// }
// _ => {}
// }
// }
Copy link
Owner

Choose a reason for hiding this comment

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

Since it's commented out, I assume this can be removed?

@@ -9,6 +9,8 @@ export interface AppSettings {
oscReceivingPort: number;
enableDesktopNotifications: boolean;
enableXSOverlayNotifications: boolean;
exitInSystemTray: boolean;
Copy link
Owner

@Raphiiko Raphiiko May 2, 2023

Choose a reason for hiding this comment

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

nit: Can you refactor this to closeToSystemTray?


#[derive(Debug, Clone)]
pub struct SystemTrayManager {
pub exit_in_tray: bool,
Copy link
Owner

Choose a reason for hiding this comment

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

Same here I guess

Suggested change
pub exit_in_tray: bool,
pub close_to_tray: bool,

@Raphiiko Raphiiko changed the base branch from develop to feature/system-tray May 19, 2023 16:38
@Raphiiko Raphiiko merged commit 7776f99 into Raphiiko:feature/system-tray May 19, 2023
1 check failed
@Raphiiko
Copy link
Owner

Raphiiko commented May 19, 2023

As I've refactored a majority of Oyasumi's Rust core, this PR ended up requiring quite a bit more changes to fit into the new structure. I didn't really want to ask you to update your work to get it working again, so I've made a few changes for it myself so that it could be merged. You'll find the changes in 7776f99. Thanks a bunch for your contribution!

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.

None yet

2 participants