mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
Everywhere: Move the Ladybird folder to UI
This commit is contained in:
parent
93712b24bf
commit
db47cc41f8
Notes:
github-actions[bot]
2024-11-10 11:51:45 +00:00
Author: https://github.com/trflynn89
Commit: db47cc41f8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
203 changed files with 266 additions and 244 deletions
46
UI/AppKit/Interface/TaskManager.swift
Normal file
46
UI/AppKit/Interface/TaskManager.swift
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
||||
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import Ladybird.WebView
|
||||
import Ladybird.WebViewApplication
|
||||
import Ladybird.WebViewWindow
|
||||
import SwiftUI
|
||||
|
||||
public class TaskManager: LadybirdWebViewWindow {
|
||||
|
||||
private let WINDOW_WIDTH: CGFloat = 600
|
||||
private let WINDOW_HEIGHT: CGFloat = 400
|
||||
|
||||
private var timer: Timer?
|
||||
|
||||
init() {
|
||||
let tab_rect = NSApplication.shared.keyWindow!.frame
|
||||
let position_x = tab_rect.origin.x + (tab_rect.size.width - WINDOW_WIDTH) / 2
|
||||
let position_y = tab_rect.origin.y + (tab_rect.size.height - WINDOW_HEIGHT) / 2
|
||||
let window_rect = NSMakeRect(position_x, position_y, WINDOW_WIDTH, WINDOW_HEIGHT)
|
||||
|
||||
super.init(webView: nil, windowRect: window_rect)
|
||||
|
||||
self.timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] timer in
|
||||
if let strong_self = self {
|
||||
strong_self.updateStatistics()
|
||||
}
|
||||
}
|
||||
|
||||
self.contentView = self.web_view
|
||||
self.title = "Task Manager"
|
||||
self.setIsVisible(true)
|
||||
|
||||
self.updateStatistics()
|
||||
}
|
||||
|
||||
func updateStatistics() {
|
||||
WebView.Application.the().update_process_statistics()
|
||||
self.web_view.loadHTML(WebView.Application.the().generate_process_statistics_html().__bytes_as_string_viewUnsafe())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue