Merge commit 'c2a02c24' into kvt/integratie
# Conflicts: # KVT-FORK.md # crates/app/src/kvt/mod.rs
@@ -313,6 +313,36 @@ tot er een `nl:`-regel bij staat; de test `every_key_resolves_in_english_and_ger
313
313
ontbreken. Bij een conflict in `app.yml` de upstream-versie nemen en de `nl:`-regels opnieuw
314
314
invoegen. Termen: «chat», «vergadering», «kanaal», «oproep», «agenda»; datums als «15 jan 2026».
315
315
316
### Eigen vensterknoppen
317
318
Op verzoek van Tim (t2263u): minimaliseren, maximaliseren/herstellen en sluiten als kleine
319
knoppen helemaal rechts in de titelbalk (na «…» en de avatar), in dezelfde stijl als de
320
andere titelbalkknoppen: chevron omlaag, chevron omhoog (herstellen: het bestaande
321
herstel-icoon) en een kruisje. Daarmee kunnen de vensterranden van het systeem weg, zonder
322
die functies te verliezen.
323
324
- Linux (KWin Wayland en X11) en Windows: bij een nieuwe installatie staan de eigen knoppen
325
aan en vraagt het hoofdvenster client-side decorations. Verslepen gaat via de lege
326
titelbalk, dubbelklikken maximaliseert, de randen en hoeken wijzigen de grootte
327
(bestaande GPUI-`WindowBorder` in `Root`).
328
- Instellingen › Weergave › «Eigen vensterknoppen» (standaard aan) zet het uit en brengt de
329
systeemranden terug. Een wijziging geldt meteen.
330
- Sluiten volgt dezelfde route als de systeemknop, inclusief «sluiten naar de tray».
331
- macOS houdt de verkeerslichten van het systeem; de instelling en de eigen knoppen blijven
332
daar weg.
333
- De ingebouwde vensterknoppen van de upstream-`TitleBar` (Windows-11-stijl) worden
334
verborgen zolang de KVT-knoppen aan staan, zodat ze niet verdubbelen.
335
336
| | |
337
|---|---|
338
| Wat | Eigen vensterknoppen in de titelbalk, client-side decorations, instelling |
339
| Eigen bestanden | `crates/app-base/src/kvt_window.rs` (opslag, standaard aan).<br>`crates/app/src/kvt/window_controls.rs` (knoppen, decorations, sluiten).<br>`crates/app-base/locales/kvt.yml` (`kvt.window.*`) |
340
| Upstream aangeraakt | `vendor/gpui-component/src/title_bar.rs` (`system_window_controls`, dubbelklik ook op Windows).<br>`crates/app/src/views/title_bar.rs` (die vlag).<br>`crates/app/src/views/shell.rs` (knoppen na avatar).<br>`crates/app/src/settings/appearance.rs` (schakelaar).<br>`crates/app/src/main.rs` (`window_decorations` van het hoofdvenster, `install`).<br>`crates/app-base/src/lib.rs` (`mod kvt_window`). |
341
342
Merge-tip: de haak in `title_bar.rs` van gpui-component is de nieuwe methode en de
343
Windows-tak van `on_double_click`. Blijft die bij een upstream-update weg, zet hem terug
344
en houd `system_window_controls(false)` in onze titelbalk.
345
316
346
## Eigen modules in het kort
317
347
318
348
| Pad | Rol |
@@ -328,4 +358,5 @@ invoegen. Termen: «chat», «vergadering», «kanaal», «oproep», «agenda»;
328
358
| `crates/app/src/kvt/`, `settings/kvt.rs`, `composer/kvt.rs` | BC-kaarten, detailvenster, picker, berichtmenu (Asclepius, Ponos), Ponos-bord (tegel), Daedalus-agenda, instellingen |
329
359
| `crates/app-state/src/kvt_calendar.rs` | Haak voor de Daedalus-planning in de weekweergave |
330
360
| `crates/browser/src/browser/kvt.rs` | Los tabblad in de sessiebrowser voor het koppelen |
361
| `crates/app-base/src/kvt_window.rs`, `crates/app/src/kvt/window_controls.rs` | Eigen vensterknoppen en client-side decorations |
331
362
| `blue-ci-cd.yml` | Sync, test (ook `cargo test -p kvt-sleutels` in `app_test`), lichtere Rust-jobs, release, AUR (KVT-gedeelte) |
@@ -313,6 +313,36 @@ tot er een `nl:`-regel bij staat; de test `every_key_resolves_in_english_and_ger313
ontbreken. Bij een conflict in `app.yml` de upstream-versie nemen en de `nl:`-regels opnieuw313
ontbreken. Bij een conflict in `app.yml` de upstream-versie nemen en de `nl:`-regels opnieuw314
invoegen. Termen: «chat», «vergadering», «kanaal», «oproep», «agenda»; datums als «15 jan 2026».314
invoegen. Termen: «chat», «vergadering», «kanaal», «oproep», «agenda»; datums als «15 jan 2026».315
315
316
### Eigen vensterknoppen317
318
Op verzoek van Tim (t2263u): minimaliseren, maximaliseren/herstellen en sluiten als kleine319
knoppen helemaal rechts in de titelbalk (na «…» en de avatar), in dezelfde stijl als de320
andere titelbalkknoppen: chevron omlaag, chevron omhoog (herstellen: het bestaande321
herstel-icoon) en een kruisje. Daarmee kunnen de vensterranden van het systeem weg, zonder322
die functies te verliezen.323
324
- Linux (KWin Wayland en X11) en Windows: bij een nieuwe installatie staan de eigen knoppen325
aan en vraagt het hoofdvenster client-side decorations. Verslepen gaat via de lege326
titelbalk, dubbelklikken maximaliseert, de randen en hoeken wijzigen de grootte327
(bestaande GPUI-`WindowBorder` in `Root`).328
- Instellingen › Weergave › «Eigen vensterknoppen» (standaard aan) zet het uit en brengt de329
systeemranden terug. Een wijziging geldt meteen.330
- Sluiten volgt dezelfde route als de systeemknop, inclusief «sluiten naar de tray».331
- macOS houdt de verkeerslichten van het systeem; de instelling en de eigen knoppen blijven332
daar weg.333
- De ingebouwde vensterknoppen van de upstream-`TitleBar` (Windows-11-stijl) worden334
verborgen zolang de KVT-knoppen aan staan, zodat ze niet verdubbelen.335
336
| | |337
|---|---|338
| Wat | Eigen vensterknoppen in de titelbalk, client-side decorations, instelling |339
| Eigen bestanden | `crates/app-base/src/kvt_window.rs` (opslag, standaard aan).<br>`crates/app/src/kvt/window_controls.rs` (knoppen, decorations, sluiten).<br>`crates/app-base/locales/kvt.yml` (`kvt.window.*`) |340
| Upstream aangeraakt | `vendor/gpui-component/src/title_bar.rs` (`system_window_controls`, dubbelklik ook op Windows).<br>`crates/app/src/views/title_bar.rs` (die vlag).<br>`crates/app/src/views/shell.rs` (knoppen na avatar).<br>`crates/app/src/settings/appearance.rs` (schakelaar).<br>`crates/app/src/main.rs` (`window_decorations` van het hoofdvenster, `install`).<br>`crates/app-base/src/lib.rs` (`mod kvt_window`). |341
342
Merge-tip: de haak in `title_bar.rs` van gpui-component is de nieuwe methode en de343
Windows-tak van `on_double_click`. Blijft die bij een upstream-update weg, zet hem terug344
en houd `system_window_controls(false)` in onze titelbalk.345
316
## Eigen modules in het kort346
## Eigen modules in het kort317
347
318
| Pad | Rol |348
| Pad | Rol |@@ -328,4 +358,5 @@ invoegen. Termen: «chat», «vergadering», «kanaal», «oproep», «agenda»;328
| `crates/app/src/kvt/`, `settings/kvt.rs`, `composer/kvt.rs` | BC-kaarten, detailvenster, picker, berichtmenu (Asclepius, Ponos), Ponos-bord (tegel), Daedalus-agenda, instellingen |358
| `crates/app/src/kvt/`, `settings/kvt.rs`, `composer/kvt.rs` | BC-kaarten, detailvenster, picker, berichtmenu (Asclepius, Ponos), Ponos-bord (tegel), Daedalus-agenda, instellingen |329
| `crates/app-state/src/kvt_calendar.rs` | Haak voor de Daedalus-planning in de weekweergave |359
| `crates/app-state/src/kvt_calendar.rs` | Haak voor de Daedalus-planning in de weekweergave |330
| `crates/browser/src/browser/kvt.rs` | Los tabblad in de sessiebrowser voor het koppelen |360
| `crates/browser/src/browser/kvt.rs` | Los tabblad in de sessiebrowser voor het koppelen |361
| `crates/app-base/src/kvt_window.rs`, `crates/app/src/kvt/window_controls.rs` | Eigen vensterknoppen en client-side decorations |331
| `blue-ci-cd.yml` | Sync, test (ook `cargo test -p kvt-sleutels` in `app_test`), lichtere Rust-jobs, release, AUR (KVT-gedeelte) |362
| `blue-ci-cd.yml` | Sync, test (ook `cargo test -p kvt-sleutels` in `app_test`), lichtere Rust-jobs, release, AUR (KVT-gedeelte) |@@ -302,3 +302,29 @@ kvt:
302
302
en: Connect to sleutels.kvt.nl again to see the Daedalus planning
303
303
de: Erneut mit sleutels.kvt.nl verbinden, um die Daedalus-Planung zu sehen
304
304
nl: Koppel opnieuw met sleutels.kvt.nl om de Daedalus-planning te zien
305
306
window:
307
title:
308
en: Custom window buttons
309
de: Eigene Fensterschaltflächen
310
nl: Eigen vensterknoppen
311
detail:
312
en: Place minimize, maximize and close in the title bar and hide the system window borders.
313
de: Minimieren, Maximieren und Schließen in der Titelleiste, ohne die Systemfensterrahmen.
314
nl: Minimaliseren, maximaliseren en sluiten in de titelbalk, zonder de vensterranden van het systeem.
315
minimize:
316
en: Minimize
317
de: Minimieren
318
nl: Minimaliseren
319
maximize:
320
en: Maximize
321
de: Maximieren
322
nl: Maximaliseren
323
restore:
324
en: Restore
325
de: Wiederherstellen
326
nl: Herstellen
327
close:
328
en: Close
329
de: Schließen
330
nl: Sluiten
@@ -302,3 +302,29 @@ kvt:302
en: Connect to sleutels.kvt.nl again to see the Daedalus planning302
en: Connect to sleutels.kvt.nl again to see the Daedalus planning303
de: Erneut mit sleutels.kvt.nl verbinden, um die Daedalus-Planung zu sehen303
de: Erneut mit sleutels.kvt.nl verbinden, um die Daedalus-Planung zu sehen304
nl: Koppel opnieuw met sleutels.kvt.nl om de Daedalus-planning te zien304
nl: Koppel opnieuw met sleutels.kvt.nl om de Daedalus-planning te zien305
306
window:307
title:308
en: Custom window buttons309
de: Eigene Fensterschaltflächen310
nl: Eigen vensterknoppen311
detail:312
en: Place minimize, maximize and close in the title bar and hide the system window borders.313
de: Minimieren, Maximieren und Schließen in der Titelleiste, ohne die Systemfensterrahmen.314
nl: Minimaliseren, maximaliseren en sluiten in de titelbalk, zonder de vensterranden van het systeem.315
minimize:316
en: Minimize317
de: Minimieren318
nl: Minimaliseren319
maximize:320
en: Maximize321
de: Maximieren322
nl: Maximaliseren323
restore:324
en: Restore325
de: Wiederherstellen326
nl: Herstellen327
close:328
en: Close329
de: Schließen330
nl: Sluiten@@ -0,0 +1,66 @@
1
//! KVT-fork: instelling voor eigen vensterknoppen (client-side decorations).
2
//!
3
//! Standaard aan in de KVT-build. Uit schakelen brengt de vensterranden van het
4
//! systeem terug. Zie KVT-FORK.md.
5
6
use store::Store;
7
8
const META_KEY: &str = "kvt.window.client_decorations";
9
10
/// Standaard in de KVT-build: eigen knoppen in de titelbalk, geen systeemranden.
11
pub const DEFAULT_ENABLED: bool = true;
12
13
/// Of de gebruiker eigen vensterknoppen wil (en dus client-side decorations).
14
///
15
/// Een ontbrekende sleutel betekent de KVT-standaard (aan). Alleen een
16
/// opgeslagen `false` zet het uit.
17
pub fn load(store: &Store) -> bool {
18
match store.meta(META_KEY).ok().flatten().as_deref() {
19
Some("false") | Some("0") => false,
20
Some("true") | Some("1") => true,
21
Some(other) if other.trim().eq_ignore_ascii_case("false") => false,
22
Some(_) | None => DEFAULT_ENABLED,
23
}
24
}
25
26
pub fn save(store: &Store, enabled: bool) {
27
let _ = store.set_meta(META_KEY, if enabled { "true" } else { "false" });
28
}
29
30
/// Of deze bouw de instelling en de eigen knoppen toont.
31
///
32
/// Op macOS blijven de verkeerslichten van het systeem; daar is de instelling
33
/// verborgen en staan de eigen knoppen uit.
34
pub fn available() -> bool {
35
!cfg!(target_os = "macos")
36
}
37
38
#[cfg(test)]
39
mod tests {
40
use super::*;
41
42
#[test]
43
fn missing_key_defaults_to_on() {
44
let store = Store::open_in_memory().unwrap();
45
assert!(load(&store));
46
assert!(DEFAULT_ENABLED);
47
}
48
49
#[test]
50
fn round_trips_off_and_on() {
51
let store = Store::open_in_memory().unwrap();
52
save(&store, false);
53
assert!(!load(&store));
54
save(&store, true);
55
assert!(load(&store));
56
}
57
58
#[test]
59
fn only_an_explicit_false_turns_it_off() {
60
let store = Store::open_in_memory().unwrap();
61
let _ = store.set_meta(META_KEY, "false");
62
assert!(!load(&store));
63
let _ = store.set_meta(META_KEY, "unexpected");
64
assert!(load(&store));
65
}
66
}
@@ -0,0 +1,66 @@1
//! KVT-fork: instelling voor eigen vensterknoppen (client-side decorations).2
//!3
//! Standaard aan in de KVT-build. Uit schakelen brengt de vensterranden van het4
//! systeem terug. Zie KVT-FORK.md.5
6
use store::Store;7
8
const META_KEY: &str = "kvt.window.client_decorations";9
10
/// Standaard in de KVT-build: eigen knoppen in de titelbalk, geen systeemranden.11
pub const DEFAULT_ENABLED: bool = true;12
13
/// Of de gebruiker eigen vensterknoppen wil (en dus client-side decorations).14
///15
/// Een ontbrekende sleutel betekent de KVT-standaard (aan). Alleen een16
/// opgeslagen `false` zet het uit.17
pub fn load(store: &Store) -> bool {18
match store.meta(META_KEY).ok().flatten().as_deref() {19
Some("false") | Some("0") => false,20
Some("true") | Some("1") => true,21
Some(other) if other.trim().eq_ignore_ascii_case("false") => false,22
Some(_) | None => DEFAULT_ENABLED,23
}24
}25
26
pub fn save(store: &Store, enabled: bool) {27
let _ = store.set_meta(META_KEY, if enabled { "true" } else { "false" });28
}29
30
/// Of deze bouw de instelling en de eigen knoppen toont.31
///32
/// Op macOS blijven de verkeerslichten van het systeem; daar is de instelling33
/// verborgen en staan de eigen knoppen uit.34
pub fn available() -> bool {35
!cfg!(target_os = "macos")36
}37
38
#[cfg(test)]39
mod tests {40
use super::*;41
42
#[test]43
fn missing_key_defaults_to_on() {44
let store = Store::open_in_memory().unwrap();45
assert!(load(&store));46
assert!(DEFAULT_ENABLED);47
}48
49
#[test]50
fn round_trips_off_and_on() {51
let store = Store::open_in_memory().unwrap();52
save(&store, false);53
assert!(!load(&store));54
save(&store, true);55
assert!(load(&store));56
}57
58
#[test]59
fn only_an_explicit_false_turns_it_off() {60
let store = Store::open_in_memory().unwrap();61
let _ = store.set_meta(META_KEY, "false");62
assert!(!load(&store));63
let _ = store.set_meta(META_KEY, "unexpected");64
assert!(load(&store));65
}66
}@@ -24,6 +24,7 @@ pub mod image_view_math;
24
24
pub mod inline_image;
25
25
pub mod kvt_brand;
26
26
pub mod kvt_feed;
27
pub mod kvt_window;
27
28
#[cfg(target_os = "linux")]
28
29
pub mod linux_desktop;
29
30
#[cfg(target_os = "linux")]
@@ -24,6 +24,7 @@ pub mod image_view_math;24
pub mod inline_image;24
pub mod inline_image;25
pub mod kvt_brand;25
pub mod kvt_brand;26
pub mod kvt_feed;26
pub mod kvt_feed;27
pub mod kvt_window;27
#[cfg(target_os = "linux")]28
#[cfg(target_os = "linux")]28
pub mod linux_desktop;29
pub mod linux_desktop;29
#[cfg(target_os = "linux")]30
#[cfg(target_os = "linux")]@@ -7,8 +7,8 @@
7
7
//!
8
8
//! Daarnaast: «Ticket maken in Asclepius» en «Taak maken in Ponos» in het
9
9
//! berichtmenu (`message`, `tasks`), het Ponos-bord achter de tegel in de
10
//! navigatierail (`board`) en de eigen Daedalus-planning als read-only agenda
11
//! (`calendar`).
10
//! navigatierail (`board`), de eigen Daedalus-planning als read-only agenda
11
//! (`calendar`) en eigen vensterknoppen in de titelbalk (`window_controls`).
12
12
//!
13
13
//! Upstream-haken: `views/shell.rs` (install, overlay, dialog-telling),
14
14
//! `views/message_row.rs` en `views/post_card.rs` (kaartjes), `settings/general.rs`
@@ -26,6 +26,7 @@ mod modal;
26
26
mod picker;
27
27
mod session;
28
28
mod tasks;
29
pub mod window_controls;
29
30
30
31
use std::collections::HashMap;
31
32
@@ -42,6 +43,7 @@ pub use card::{blocks_without_card_links, message_cards};
42
43
pub use message::{MenuEntry, menu_entries};
43
44
pub use modal::render_modal;
44
45
pub use picker::{open_picker, plus_item};
46
pub use window_controls::{title_bar_system_window_controls, title_buttons};
45
47
46
48
/// Alleen voor testen tegen een andere Login/Mímir (bijv. .test); altijd https.
47
49
const BASE_URL_ENV: &str = "KVT_SLEUTELS_URL";
@@ -7,8 +7,8 @@7
//!7
//!8
//! Daarnaast: «Ticket maken in Asclepius» en «Taak maken in Ponos» in het8
//! Daarnaast: «Ticket maken in Asclepius» en «Taak maken in Ponos» in het9
//! berichtmenu (`message`, `tasks`), het Ponos-bord achter de tegel in de9
//! berichtmenu (`message`, `tasks`), het Ponos-bord achter de tegel in de10
//! navigatierail (`board`) en de eigen Daedalus-planning als read-only agenda10
//! navigatierail (`board`), de eigen Daedalus-planning als read-only agenda11
//! (`calendar`).11
//! (`calendar`) en eigen vensterknoppen in de titelbalk (`window_controls`).12
//!12
//!13
//! Upstream-haken: `views/shell.rs` (install, overlay, dialog-telling),13
//! Upstream-haken: `views/shell.rs` (install, overlay, dialog-telling),14
//! `views/message_row.rs` en `views/post_card.rs` (kaartjes), `settings/general.rs`14
//! `views/message_row.rs` en `views/post_card.rs` (kaartjes), `settings/general.rs`@@ -26,6 +26,7 @@ mod modal;26
mod picker;26
mod picker;27
mod session;27
mod session;28
mod tasks;28
mod tasks;29
pub mod window_controls;29
30
30
use std::collections::HashMap;31
use std::collections::HashMap;31
32
@@ -42,6 +43,7 @@ pub use card::{blocks_without_card_links, message_cards};42
pub use message::{MenuEntry, menu_entries};43
pub use message::{MenuEntry, menu_entries};43
pub use modal::render_modal;44
pub use modal::render_modal;44
pub use picker::{open_picker, plus_item};45
pub use picker::{open_picker, plus_item};46
pub use window_controls::{title_bar_system_window_controls, title_buttons};45
47
46
/// Alleen voor testen tegen een andere Login/Mímir (bijv. .test); altijd https.48
/// Alleen voor testen tegen een andere Login/Mímir (bijv. .test); altijd https.47
const BASE_URL_ENV: &str = "KVT_SLEUTELS_URL";49
const BASE_URL_ENV: &str = "KVT_SLEUTELS_URL";@@ -0,0 +1,224 @@
1
//! KVT-fork: minimaliseren, maximaliseren/herstellen en sluiten in de titelbalk.
2
//!
3
//! Alleen op Linux en Windows, en alleen als de instelling aan staat. Op macOS
4
//! blijven de verkeerslichten van het systeem. Sluiten volgt dezelfde route als
5
//! de systeemknop (inclusief sluiten naar de tray). Zie KVT-FORK.md.
6
7
use gpui_kit::assets::IconName;
8
use gpui_kit::component::button::{Button, ButtonVariants as _};
9
use gpui_kit::component::h_flex;
10
use gpui_kit::prelude::FluentBuilder as _;
11
use gpui_kit::*;
12
use store::Store;
13
14
use crate::i18n::tr;
15
use crate::notify::NotificationCenter;
16
17
/// Kleine titelbalk-iconen, strak gegroepeerd zodat de zoekbalk ruimte houdt.
18
const CONTROL_SIZE: f32 = 20.;
19
const CONTROL_GAP: f32 = 0.;
20
21
/// Of de eigen knoppen en client-side decorations gewenst zijn.
22
pub fn enabled(cx: &App) -> bool {
23
app_base::kvt_window::available()
24
&& cx
25
.try_global::<Active>()
26
.map(|active| active.enabled)
27
.unwrap_or(app_base::kvt_window::DEFAULT_ENABLED)
28
}
29
30
pub fn install(store: &Store, cx: &mut App) {
31
cx.set_global(Active {
32
enabled: app_base::kvt_window::load(store),
33
});
34
}
35
36
/// Zet de instelling, vraagt de passende decorations aan en ververst de vensters.
37
pub fn set_enabled(enabled: bool, store: &Store, window: &Window, cx: &mut App) {
38
app_base::kvt_window::save(store, enabled);
39
cx.set_global(Active { enabled });
40
apply_decorations(window, enabled);
41
cx.refresh_windows();
42
}
43
44
/// Decorations voor het hoofdvenster bij het openen.
45
pub fn window_decorations(enabled: bool) -> WindowDecorations {
46
if enabled && app_base::kvt_window::available() {
47
WindowDecorations::Client
48
} else {
49
WindowDecorations::Server
50
}
51
}
52
53
pub fn apply_decorations(window: &Window, enabled: bool) {
54
if app_base::kvt_window::available() {
55
window.request_decorations(window_decorations(enabled));
56
}
57
}
58
59
pub fn title_bar_system_window_controls(cx: &App) -> bool {
60
!enabled(cx)
61
}
62
63
/// Knoppen rechts in de titelbalk, na «…» en de avatar, als één groep zodat
64
/// de zoekbalk bij een smal venster ruimte houdt. Leeg als ze niet getoond
65
/// moeten worden.
66
pub fn title_buttons(
67
notifications: &Entity<NotificationCenter>,
68
window: &Window,
69
cx: &App,
70
) -> Vec<AnyElement> {
71
if !enabled(cx) {
72
return Vec::new();
73
}
74
let supported = window.window_controls();
75
let maximized = window.is_maximized();
76
let mut buttons = Vec::new();
77
if supported.minimize {
78
buttons.push(control_button(
79
"title-window-minimize",
80
"shell/title-bar/minimize",
81
IconName::ChevronDown,
82
tr("kvt.window.minimize"),
83
Action::Minimize,
84
notifications.clone(),
85
));
86
}
87
if supported.maximize {
88
if maximized {
89
buttons.push(control_button(
90
"title-window-restore",
91
"shell/title-bar/restore",
92
IconName::WindowRestore,
93
tr("kvt.window.restore"),
94
Action::Restore,
95
notifications.clone(),
96
));
97
} else {
98
buttons.push(control_button(
99
"title-window-maximize",
100
"shell/title-bar/maximize",
101
IconName::ChevronUp,
102
tr("kvt.window.maximize"),
103
Action::Maximize,
104
notifications.clone(),
105
));
106
}
107
}
108
buttons.push(control_button(
109
"title-window-close",
110
"shell/title-bar/close",
111
IconName::Close,
112
tr("kvt.window.close"),
113
Action::Close,
114
notifications.clone(),
115
));
116
if buttons.is_empty() {
117
return Vec::new();
118
}
119
vec![
120
h_flex()
121
.debug_selector(|| "shell/title-bar/window-controls".into())
122
.flex_none()
123
.h_full()
124
.items_center()
125
.gap(px(CONTROL_GAP))
126
.children(buttons)
127
.into_any_element(),
128
]
129
}
130
131
#[derive(Clone, Copy)]
132
enum Action {
133
Minimize,
134
Maximize,
135
Restore,
136
Close,
137
}
138
139
impl Action {
140
fn window_control_area(self) -> WindowControlArea {
141
match self {
142
Self::Minimize => WindowControlArea::Min,
143
Self::Maximize | Self::Restore => WindowControlArea::Max,
144
Self::Close => WindowControlArea::Close,
145
}
146
}
147
}
148
149
fn control_button(
150
id: &'static str,
151
selector: &'static str,
152
icon: IconName,
153
tooltip: String,
154
action: Action,
155
notifications: Entity<NotificationCenter>,
156
) -> AnyElement {
157
let is_windows = cfg!(target_os = "windows");
158
let is_linux = cfg!(target_os = "linux");
159
Button::new(id)
160
.ghost()
161
.compact()
162
.p_0()
163
.size(px(CONTROL_SIZE))
164
.icon(icon)
165
.tooltip(tooltip)
166
.debug_selector(|| selector.into())
167
.when(is_windows, |button| {
168
button.window_control_area(action.window_control_area())
169
})
170
.when(is_linux || cfg!(not(any(target_os = "windows", target_os = "macos"))), |button| {
171
button
172
.on_mouse_down(MouseButton::Left, |_, window, cx| {
173
window.prevent_default();
174
cx.stop_propagation();
175
})
176
.on_click(move |_, window, cx| {
177
cx.stop_propagation();
178
match action {
179
Action::Minimize => window.minimize_window(),
180
Action::Maximize | Action::Restore => window.zoom_window(),
181
Action::Close => close_main_window(¬ifications, window, cx),
182
}
183
})
184
})
185
.into_any_element()
186
}
187
188
/// Zelfde pad als de systeem-sluitknop: `on_window_should_close` in de shell
189
/// (tray verbergen of echt sluiten).
190
fn close_main_window(
191
notifications: &Entity<NotificationCenter>,
192
window: &mut Window,
193
cx: &mut App,
194
) {
195
let keep_open = notifications.update(cx, |notifications, cx| notifications.intercept_close(cx));
196
if !keep_open {
197
window.remove_window();
198
}
199
}
200
201
struct Active {
202
enabled: bool,
203
}
204
205
impl Global for Active {}
206
207
#[cfg(test)]
208
mod tests {
209
use super::window_decorations;
210
use gpui_kit::WindowDecorations;
211
212
#[test]
213
fn client_decorations_follow_the_setting() {
214
assert_eq!(
215
window_decorations(true),
216
if cfg!(target_os = "macos") {
217
WindowDecorations::Server
218
} else {
219
WindowDecorations::Client
220
}
221
);
222
assert_eq!(window_decorations(false), WindowDecorations::Server);
223
}
224
}
@@ -0,0 +1,224 @@1
//! KVT-fork: minimaliseren, maximaliseren/herstellen en sluiten in de titelbalk.2
//!3
//! Alleen op Linux en Windows, en alleen als de instelling aan staat. Op macOS4
//! blijven de verkeerslichten van het systeem. Sluiten volgt dezelfde route als5
//! de systeemknop (inclusief sluiten naar de tray). Zie KVT-FORK.md.6
7
use gpui_kit::assets::IconName;8
use gpui_kit::component::button::{Button, ButtonVariants as _};9
use gpui_kit::component::h_flex;10
use gpui_kit::prelude::FluentBuilder as _;11
use gpui_kit::*;12
use store::Store;13
14
use crate::i18n::tr;15
use crate::notify::NotificationCenter;16
17
/// Kleine titelbalk-iconen, strak gegroepeerd zodat de zoekbalk ruimte houdt.18
const CONTROL_SIZE: f32 = 20.;19
const CONTROL_GAP: f32 = 0.;20
21
/// Of de eigen knoppen en client-side decorations gewenst zijn.22
pub fn enabled(cx: &App) -> bool {23
app_base::kvt_window::available()24
&& cx25
.try_global::<Active>()26
.map(|active| active.enabled)27
.unwrap_or(app_base::kvt_window::DEFAULT_ENABLED)28
}29
30
pub fn install(store: &Store, cx: &mut App) {31
cx.set_global(Active {32
enabled: app_base::kvt_window::load(store),33
});34
}35
36
/// Zet de instelling, vraagt de passende decorations aan en ververst de vensters.37
pub fn set_enabled(enabled: bool, store: &Store, window: &Window, cx: &mut App) {38
app_base::kvt_window::save(store, enabled);39
cx.set_global(Active { enabled });40
apply_decorations(window, enabled);41
cx.refresh_windows();42
}43
44
/// Decorations voor het hoofdvenster bij het openen.45
pub fn window_decorations(enabled: bool) -> WindowDecorations {46
if enabled && app_base::kvt_window::available() {47
WindowDecorations::Client48
} else {49
WindowDecorations::Server50
}51
}52
53
pub fn apply_decorations(window: &Window, enabled: bool) {54
if app_base::kvt_window::available() {55
window.request_decorations(window_decorations(enabled));56
}57
}58
59
pub fn title_bar_system_window_controls(cx: &App) -> bool {60
!enabled(cx)61
}62
63
/// Knoppen rechts in de titelbalk, na «…» en de avatar, als één groep zodat64
/// de zoekbalk bij een smal venster ruimte houdt. Leeg als ze niet getoond65
/// moeten worden.66
pub fn title_buttons(67
notifications: &Entity<NotificationCenter>,68
window: &Window,69
cx: &App,70
) -> Vec<AnyElement> {71
if !enabled(cx) {72
return Vec::new();73
}74
let supported = window.window_controls();75
let maximized = window.is_maximized();76
let mut buttons = Vec::new();77
if supported.minimize {78
buttons.push(control_button(79
"title-window-minimize",80
"shell/title-bar/minimize",81
IconName::ChevronDown,82
tr("kvt.window.minimize"),83
Action::Minimize,84
notifications.clone(),85
));86
}87
if supported.maximize {88
if maximized {89
buttons.push(control_button(90
"title-window-restore",91
"shell/title-bar/restore",92
IconName::WindowRestore,93
tr("kvt.window.restore"),94
Action::Restore,95
notifications.clone(),96
));97
} else {98
buttons.push(control_button(99
"title-window-maximize",100
"shell/title-bar/maximize",101
IconName::ChevronUp,102
tr("kvt.window.maximize"),103
Action::Maximize,104
notifications.clone(),105
));106
}107
}108
buttons.push(control_button(109
"title-window-close",110
"shell/title-bar/close",111
IconName::Close,112
tr("kvt.window.close"),113
Action::Close,114
notifications.clone(),115
));116
if buttons.is_empty() {117
return Vec::new();118
}119
vec![120
h_flex()121
.debug_selector(|| "shell/title-bar/window-controls".into())122
.flex_none()123
.h_full()124
.items_center()125
.gap(px(CONTROL_GAP))126
.children(buttons)127
.into_any_element(),128
]129
}130
131
#[derive(Clone, Copy)]132
enum Action {133
Minimize,134
Maximize,135
Restore,136
Close,137
}138
139
impl Action {140
fn window_control_area(self) -> WindowControlArea {141
match self {142
Self::Minimize => WindowControlArea::Min,143
Self::Maximize | Self::Restore => WindowControlArea::Max,144
Self::Close => WindowControlArea::Close,145
}146
}147
}148
149
fn control_button(150
id: &'static str,151
selector: &'static str,152
icon: IconName,153
tooltip: String,154
action: Action,155
notifications: Entity<NotificationCenter>,156
) -> AnyElement {157
let is_windows = cfg!(target_os = "windows");158
let is_linux = cfg!(target_os = "linux");159
Button::new(id)160
.ghost()161
.compact()162
.p_0()163
.size(px(CONTROL_SIZE))164
.icon(icon)165
.tooltip(tooltip)166
.debug_selector(|| selector.into())167
.when(is_windows, |button| {168
button.window_control_area(action.window_control_area())169
})170
.when(is_linux || cfg!(not(any(target_os = "windows", target_os = "macos"))), |button| {171
button172
.on_mouse_down(MouseButton::Left, |_, window, cx| {173
window.prevent_default();174
cx.stop_propagation();175
})176
.on_click(move |_, window, cx| {177
cx.stop_propagation();178
match action {179
Action::Minimize => window.minimize_window(),180
Action::Maximize | Action::Restore => window.zoom_window(),181
Action::Close => close_main_window(¬ifications, window, cx),182
}183
})184
})185
.into_any_element()186
}187
188
/// Zelfde pad als de systeem-sluitknop: `on_window_should_close` in de shell189
/// (tray verbergen of echt sluiten).190
fn close_main_window(191
notifications: &Entity<NotificationCenter>,192
window: &mut Window,193
cx: &mut App,194
) {195
let keep_open = notifications.update(cx, |notifications, cx| notifications.intercept_close(cx));196
if !keep_open {197
window.remove_window();198
}199
}200
201
struct Active {202
enabled: bool,203
}204
205
impl Global for Active {}206
207
#[cfg(test)]208
mod tests {209
use super::window_decorations;210
use gpui_kit::WindowDecorations;211
212
#[test]213
fn client_decorations_follow_the_setting() {214
assert_eq!(215
window_decorations(true),216
if cfg!(target_os = "macos") {217
WindowDecorations::Server218
} else {219
WindowDecorations::Client220
}221
);222
assert_eq!(window_decorations(false), WindowDecorations::Server);223
}224
}@@ -168,6 +168,9 @@ fn main_window_options(cx: &App) -> WindowOptions {
168
168
options.window_bounds = Some(WindowBounds::Windowed(bounds));
169
169
options.window_min_size = Some(size(px(WINDOW_MIN_WIDTH), px(WINDOW_MIN_HEIGHT)));
170
170
options.app_id = Some(LINUX_APP_ID.to_owned());
171
options.window_decorations = Some(crate::kvt::window_controls::window_decorations(
172
crate::kvt::window_controls::enabled(cx),
173
));
171
174
if let Some(titlebar) = options.titlebar.as_mut() {
172
175
titlebar.title = Some(APP_NAME.into());
173
176
}
@@ -326,6 +329,7 @@ fn main() {
326
329
.detach();
327
330
theme::load_fonts(cx);
328
331
active_appearance::install(&store, cx);
332
crate::kvt::window_controls::install(&store, cx);
329
333
active_locale::install(&store, cx);
330
334
theme::apply(cx);
331
335
bind_keys(cx);
@@ -168,6 +168,9 @@ fn main_window_options(cx: &App) -> WindowOptions {168
options.window_bounds = Some(WindowBounds::Windowed(bounds));168
options.window_bounds = Some(WindowBounds::Windowed(bounds));169
options.window_min_size = Some(size(px(WINDOW_MIN_WIDTH), px(WINDOW_MIN_HEIGHT)));169
options.window_min_size = Some(size(px(WINDOW_MIN_WIDTH), px(WINDOW_MIN_HEIGHT)));170
options.app_id = Some(LINUX_APP_ID.to_owned());170
options.app_id = Some(LINUX_APP_ID.to_owned());171
options.window_decorations = Some(crate::kvt::window_controls::window_decorations(172
crate::kvt::window_controls::enabled(cx),173
));171
if let Some(titlebar) = options.titlebar.as_mut() {174
if let Some(titlebar) = options.titlebar.as_mut() {172
titlebar.title = Some(APP_NAME.into());175
titlebar.title = Some(APP_NAME.into());173
}176
}@@ -326,6 +329,7 @@ fn main() {326
.detach();329
.detach();327
theme::load_fonts(cx);330
theme::load_fonts(cx);328
active_appearance::install(&store, cx);331
active_appearance::install(&store, cx);332
crate::kvt::window_controls::install(&store, cx);329
active_locale::install(&store, cx);333
active_locale::install(&store, cx);330
theme::apply(cx);334
theme::apply(cx);331
bind_keys(cx);335
bind_keys(cx);@@ -2,7 +2,7 @@ use gpui_kit::component::{h_flex, v_flex};
2
2
use gpui_kit::prelude::FluentBuilder as _;
3
3
use gpui_kit::*;
4
4
5
use super::rows::{Choice, ROW_INSET, caption, control_row, select_with_width, titled};
5
use super::rows::{Choice, ROW_INSET, caption, control_row, select_with_width, titled, toggle_row};
6
6
use crate::active_appearance;
7
7
use crate::active_locale;
8
8
use crate::app_state::AppState;
@@ -120,6 +120,21 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
120
120
theme_choices,
121
121
),
122
122
))
123
.when(app_base::kvt_window::available(), |view| {
124
let store = app.clone();
125
let on = crate::kvt::window_controls::enabled(cx);
126
view.child(toggle_row(
127
"settings-window-controls",
128
tr("kvt.window.title"),
129
tr("kvt.window.detail"),
130
theme::text_muted(),
131
on,
132
)
133
.on_click(move |_, window, cx| {
134
let store = store.read(cx).store.clone();
135
crate::kvt::window_controls::set_enabled(!on, &store, window, cx);
136
}))
137
})
123
138
.child(choice_group(
124
139
tr("settings.appearance.color_scheme"),
125
140
tr("settings.appearance.color_scheme_detail"),
@@ -2,7 +2,7 @@ use gpui_kit::component::{h_flex, v_flex};2
use gpui_kit::prelude::FluentBuilder as _;2
use gpui_kit::prelude::FluentBuilder as _;3
use gpui_kit::*;3
use gpui_kit::*;4
4
5
use super::rows::{Choice, ROW_INSET, caption, control_row, select_with_width, titled};5
use super::rows::{Choice, ROW_INSET, caption, control_row, select_with_width, titled, toggle_row};6
use crate::active_appearance;6
use crate::active_appearance;7
use crate::active_locale;7
use crate::active_locale;8
use crate::app_state::AppState;8
use crate::app_state::AppState;@@ -120,6 +120,21 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {120
theme_choices,120
theme_choices,121
),121
),122
))122
))123
.when(app_base::kvt_window::available(), |view| {124
let store = app.clone();125
let on = crate::kvt::window_controls::enabled(cx);126
view.child(toggle_row(127
"settings-window-controls",128
tr("kvt.window.title"),129
tr("kvt.window.detail"),130
theme::text_muted(),131
on,132
)133
.on_click(move |_, window, cx| {134
let store = store.read(cx).store.clone();135
crate::kvt::window_controls::set_enabled(!on, &store, window, cx);136
}))137
})123
.child(choice_group(138
.child(choice_group(124
tr("settings.appearance.color_scheme"),139
tr("settings.appearance.color_scheme"),125
tr("settings.appearance.color_scheme_detail"),140
tr("settings.appearance.color_scheme_detail"),@@ -1159,7 +1159,8 @@ impl Render for AppShell {
1159
1159
own_status_button(&self.state, state),
1160
1160
]
1161
1161
.into_iter()
1162
.flatten(),
1162
.flatten()
1163
.chain(crate::kvt::title_buttons(&self.notifications, window, cx)),
1163
1164
cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),
1164
1165
);
1165
1166
let shell = div()
@@ -1159,7 +1159,8 @@ impl Render for AppShell {1159
own_status_button(&self.state, state),1159
own_status_button(&self.state, state),1160
]1160
]1161
.into_iter()1161
.into_iter()1162
.flatten(),1162
.flatten()1163
.chain(crate::kvt::title_buttons(&self.notifications, window, cx)),1163
cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),1164
cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),1164
);1165
);1165
let shell = div()1166
let shell = div()@@ -307,6 +307,7 @@ impl RenderOnce for TitleBarRow {
307
307
.h(px(TITLE_BAR_HEIGHT))
308
308
.border_b_0()
309
309
.bg(theme::background())
310
.system_window_controls(crate::kvt::title_bar_system_window_controls(cx))
310
311
.child(row);
311
312
let on_search = self.on_search;
312
313
div()
@@ -307,6 +307,7 @@ impl RenderOnce for TitleBarRow {307
.h(px(TITLE_BAR_HEIGHT))307
.h(px(TITLE_BAR_HEIGHT))308
.border_b_0()308
.border_b_0()309
.bg(theme::background())309
.bg(theme::background())310
.system_window_controls(crate::kvt::title_bar_system_window_controls(cx))310
.child(row);311
.child(row);311
let on_search = self.on_search;312
let on_search = self.on_search;312
div()313
div()@@ -47,6 +47,7 @@ pub struct TitleBar {
47
47
style: StyleRefinement,
48
48
children: SmallVec<[AnyElement; 1]>,
49
49
on_close_window: Option<Rc<Box<dyn Fn(&ClickEvent, &mut Window, &mut App)>>>,
50
system_window_controls: bool,
50
51
}
51
52
52
53
impl TitleBar {
@@ -56,6 +57,7 @@ impl TitleBar {
56
57
style: StyleRefinement::default(),
57
58
children: SmallVec::new(),
58
59
on_close_window: None,
60
system_window_controls: true,
59
61
}
60
62
}
61
63
@@ -105,6 +107,15 @@ impl TitleBar {
105
107
}
106
108
self
107
109
}
110
111
/// Whether this title bar draws the built-in minimize/maximize/close buttons.
112
///
113
/// Defaults to `true`. Set to `false` when the window draws its own buttons,
114
/// so the two sets are not stacked.
115
pub fn system_window_controls(mut self, show: bool) -> Self {
116
self.system_window_controls = show;
117
self
118
}
108
119
}
109
120
110
121
// We don't need implementation the click event for the control buttons.
@@ -346,7 +357,7 @@ impl RenderOnce for TitleBar {
346
357
cx.theme().background,
347
358
))
348
359
.refine_style(&self.style)
349
.when(is_linux, |this| {
360
.when(is_linux || cfg!(target_os = "windows"), |this| {
350
361
this.on_double_click(|_, window, _| window.zoom_window())
351
362
})
352
363
.when(is_macos, |this| {
@@ -402,8 +413,10 @@ impl RenderOnce for TitleBar {
402
413
})
403
414
.children(self.children),
404
415
)
405
.child(WindowControls {
406
on_close_window: self.on_close_window,
416
.when(self.system_window_controls, |this| {
417
this.child(WindowControls {
418
on_close_window: self.on_close_window,
419
})
407
420
}),
408
421
)
409
422
}
@@ -47,6 +47,7 @@ pub struct TitleBar {47
style: StyleRefinement,47
style: StyleRefinement,48
children: SmallVec<[AnyElement; 1]>,48
children: SmallVec<[AnyElement; 1]>,49
on_close_window: Option<Rc<Box<dyn Fn(&ClickEvent, &mut Window, &mut App)>>>,49
on_close_window: Option<Rc<Box<dyn Fn(&ClickEvent, &mut Window, &mut App)>>>,50
system_window_controls: bool,50
}51
}51
52
52
impl TitleBar {53
impl TitleBar {@@ -56,6 +57,7 @@ impl TitleBar {56
style: StyleRefinement::default(),57
style: StyleRefinement::default(),57
children: SmallVec::new(),58
children: SmallVec::new(),58
on_close_window: None,59
on_close_window: None,60
system_window_controls: true,59
}61
}60
}62
}61
63
@@ -105,6 +107,15 @@ impl TitleBar {105
}107
}106
self108
self107
}109
}110
111
/// Whether this title bar draws the built-in minimize/maximize/close buttons.112
///113
/// Defaults to `true`. Set to `false` when the window draws its own buttons,114
/// so the two sets are not stacked.115
pub fn system_window_controls(mut self, show: bool) -> Self {116
self.system_window_controls = show;117
self118
}108
}119
}109
120
110
// We don't need implementation the click event for the control buttons.121
// We don't need implementation the click event for the control buttons.@@ -346,7 +357,7 @@ impl RenderOnce for TitleBar {346
cx.theme().background,357
cx.theme().background,347
))358
))348
.refine_style(&self.style)359
.refine_style(&self.style)349
.when(is_linux, |this| {360
.when(is_linux || cfg!(target_os = "windows"), |this| {350
this.on_double_click(|_, window, _| window.zoom_window())361
this.on_double_click(|_, window, _| window.zoom_window())351
})362
})352
.when(is_macos, |this| {363
.when(is_macos, |this| {@@ -402,8 +413,10 @@ impl RenderOnce for TitleBar {402
})413
})403
.children(self.children),414
.children(self.children),404
)415
)405
.child(WindowControls {416
.when(self.system_window_controls, |this| {406
on_close_window: self.on_close_window,417
this.child(WindowControls {418
on_close_window: self.on_close_window,419
})407
}),420
}),408
)421
)409
}422
}