Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions localization/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Maximize = "Ma&ximieren"
Cascade = "&Ueberlappend"
BringToFront = "In den &Vordergrund"
HelpTopics = "Task-Manager-&Hilfethemen"
HelpOpenFailed = "Die Task-Manager-Hilfe konnte nicht geöffnet werden."
DiagnosticLogs = "&Diagnoseprotokolle..."
DiagnosticLogsTitle = "Diagnoseprotokolle"
DiagnosticStatusLabel = "Status:"
Expand Down
1 change: 1 addition & 0 deletions localization/en_us.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Maximize = "Ma&ximize"
Cascade = "&Cascade"
BringToFront = "&Bring to Front"
HelpTopics = "Task Manager &Help Topics"
HelpOpenFailed = "Task Manager Help could not be opened."
DiagnosticLogs = "&Diagnostic Logs..."
DiagnosticLogsTitle = "Diagnostic Logs"
DiagnosticStatusLabel = "Status:"
Expand Down
1 change: 1 addition & 0 deletions localization/es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Maximize = "Ma&ximizar"
Cascade = "&Cascada"
BringToFront = "Traer al &frente"
HelpTopics = "Temas de a&yuda del Administrador de tareas"
HelpOpenFailed = "No se pudo abrir la ayuda del Administrador de tareas."
DiagnosticLogs = "Registros de &diagnóstico..."
DiagnosticLogsTitle = "Registros de diagnóstico"
DiagnosticStatusLabel = "Estado:"
Expand Down
1 change: 1 addition & 0 deletions localization/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Maximize = "Ma&ximiser"
Cascade = "&Cascade"
BringToFront = "&Mettre au premier plan"
HelpTopics = "&Rubriques d'aide du Gestionnaire des tâches"
HelpOpenFailed = "Impossible d’ouvrir l’aide du Gestionnaire des tâches."
DiagnosticLogs = "Journaux de &diagnostic..."
DiagnosticLogsTitle = "Journaux de diagnostic"
DiagnosticStatusLabel = "État :"
Expand Down
1 change: 1 addition & 0 deletions localization/pt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Maximize = "Ma&ximizar"
Cascade = "&Em cascata"
BringToFront = "Trazer para &frente"
HelpTopics = "Tópicos de &ajuda do Gerenciador de Tarefas"
HelpOpenFailed = "Não foi possível abrir a ajuda do Gerenciador de Tarefas."
DiagnosticLogs = "Logs de &diagnóstico..."
DiagnosticLogsTitle = "Logs de diagnóstico"
DiagnosticStatusLabel = "Status:"
Expand Down
1 change: 1 addition & 0 deletions localization/ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Maximize = "Ра&звернуть"
Cascade = "&Каскадом"
BringToFront = "На &передний план"
HelpTopics = "&Разделы справки диспетчера задач"
HelpOpenFailed = "Не удалось открыть справку диспетчера задач."
DiagnosticLogs = "Журналы &диагностики..."
DiagnosticLogsTitle = "Журналы диагностики"
DiagnosticStatusLabel = "Состояние:"
Expand Down
1 change: 1 addition & 0 deletions localization/zh_cn.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Maximize = "最大化(&X)"
Cascade = "层叠(&C)"
BringToFront = "切换到前台(&B)"
HelpTopics = "任务管理器帮助主题(&H)"
HelpOpenFailed = "无法打开任务管理器帮助。"
DiagnosticLogs = "诊断日志(&D)..."
DiagnosticLogsTitle = "诊断日志"
DiagnosticStatusLabel = "状态:"
Expand Down
1 change: 1 addition & 0 deletions localization/zh_tw.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Maximize = "最大化(&X)"
Cascade = "重疊顯示(&C)"
BringToFront = "帶到前景(&B)"
HelpTopics = "工作管理員說明主題(&H)"
HelpOpenFailed = "無法開啟工作管理員說明。"
DiagnosticLogs = "診斷記錄(&D)..."
DiagnosticLogsTitle = "診斷記錄"
DiagnosticStatusLabel = "狀態:"
Expand Down
34 changes: 11 additions & 23 deletions src/app/controllers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use windows_sys::Win32::UI::Shell::{
use windows_sys::Win32::UI::WindowsAndMessaging::{HICON, HMENU, LR_DEFAULTCOLOR, LR_DEFAULTSIZE};

use crate::infrastructure::native::{
destroy_icon_handle, format_resource_string, record_win32_error, to_wide_null,
OwnedIcon, format_resource_string, record_win32_error, to_wide_null,
};
use crate::system::sampler::SystemSample;
use crate::ui::assets::{TRAY_CPU_ICON_RESOURCES, load_icon_resource};
Expand Down Expand Up @@ -59,7 +59,7 @@ impl RuntimeStatsController {
/// 托盘图标控制器。
/// 管理 12 级 CPU 占用图标和通知区域提示文本。
pub struct TrayController {
icons: Vec<HICON>,
icons: Vec<OwnedIcon>,
registered: Cell<bool>,
last_error: Cell<Option<u32>>,
}
Expand All @@ -78,28 +78,20 @@ impl TrayController {
pub fn load_icons(&mut self) -> Result<(), u32> {
let mut loaded = Vec::with_capacity(TRAY_CPU_ICON_RESOURCES.len());
for resource_name in TRAY_CPU_ICON_RESOURCES {
let icon_handle =
load_icon_resource(resource_name, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
if icon_handle.is_null() {
let error = unsafe { windows_sys::Win32::Foundation::GetLastError() };
for icon in loaded {
destroy_icon_handle(icon);
}
return Err(if error == 0 {
windows_sys::Win32::Foundation::ERROR_RESOURCE_DATA_NOT_FOUND
} else {
error
});
}
loaded.push(icon_handle);
loaded.push(load_icon_resource(
resource_name,
0,
0,
LR_DEFAULTCOLOR | LR_DEFAULTSIZE,
)?);
}
self.clear_icons();
self.icons = loaded;
Ok(())
}

pub fn first_icon(&self) -> Option<HICON> {
self.icons.first().copied()
self.icons.first().map(OwnedIcon::as_raw)
}

pub fn update_tray(&self, main_hwnd: HWND, command: u32, icon: HICON, tip: &str) {
Expand Down Expand Up @@ -163,17 +155,13 @@ impl TrayController {
self.update_tray(
main_hwnd,
windows_sys::Win32::UI::Shell::NIM_MODIFY,
self.icons[icon_index],
self.icons[icon_index].as_raw(),
&tooltip,
);
}

pub fn clear_icons(&mut self) {
for icon in self.icons.drain(..) {
if !icon.is_null() {
destroy_icon_handle(icon);
}
}
self.icons.clear();
}
}

Expand Down
Loading