Made system-tray only for this app.
This commit is contained in:
parent
3992a4f9d0
commit
b2d6f95f70
11 changed files with 80 additions and 841 deletions
|
|
@ -1,10 +1,3 @@
|
|||
//
|
||||
// TetheringHiderApp.swift
|
||||
//
|
||||
//
|
||||
// Created by Jesús David Chapman Vélez on 12/08/26.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import AppKit
|
||||
|
||||
|
|
@ -45,6 +38,7 @@ final class StatusBarController: NSObject, NSMenuDelegate {
|
|||
let menu = NSMenu()
|
||||
menu.delegate = self
|
||||
|
||||
// 1. Status Header with Cloak/Visible Icon
|
||||
let statusTitle = ttlManager.isProtected
|
||||
? String(localized: "Tethering Hider — Hotspot Cloaked")
|
||||
: String(localized: "Tethering Hider — Standard Tethering")
|
||||
|
|
@ -59,6 +53,7 @@ final class StatusBarController: NSObject, NSMenuDelegate {
|
|||
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
|
||||
// 2. Toggle Action with Cloak/Uncloak Icon
|
||||
let toggleTitle = ttlManager.isProtected
|
||||
? String(localized: "Disable Hotspot Cloak (Set TTL 64)")
|
||||
: String(localized: "Enable Hotspot Cloak (Set TTL 65)")
|
||||
|
|
@ -73,6 +68,7 @@ final class StatusBarController: NSObject, NSMenuDelegate {
|
|||
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
|
||||
// 3. Info Items with Network & DNS Icons
|
||||
let ipv4Format = String(localized: "IPv4 TTL: %d")
|
||||
let ipv4Item = NSMenuItem(title: String(format: ipv4Format, ttlManager.currentTTL), action: nil, keyEquivalent: "")
|
||||
ipv4Item.isEnabled = false
|
||||
|
|
@ -93,6 +89,7 @@ final class StatusBarController: NSObject, NSMenuDelegate {
|
|||
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
|
||||
// 4. About Panel Option
|
||||
let aboutTitle = String(localized: "About Tethering Hider...")
|
||||
let aboutItem = NSMenuItem(title: aboutTitle, action: #selector(aboutAction), keyEquivalent: "")
|
||||
aboutItem.target = self
|
||||
|
|
@ -101,6 +98,7 @@ final class StatusBarController: NSObject, NSMenuDelegate {
|
|||
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
|
||||
// 5. Quit Option with Standard macOS Exit Icon
|
||||
let quitTitle = String(localized: "Quit Tethering Hider")
|
||||
let quitItem = NSMenuItem(title: quitTitle, action: #selector(quitAction), keyEquivalent: "q")
|
||||
quitItem.target = self
|
||||
|
|
@ -136,7 +134,7 @@ final class StatusBarController: NSObject, NSMenuDelegate {
|
|||
|
||||
@objc private func aboutAction() {
|
||||
let creditsString = String(localized: "Bypasses mobile carrier hotspot tethering detection by adjusting outgoing IPv4 TTL to 65, IPv6 Hop Limit to 65, and flushing system DNS caches.\n\nDesigned for macOS.")
|
||||
let options: [NSApplication.AboutPanelOptionKey: Any] = [
|
||||
var options: [NSApplication.AboutPanelOptionKey: Any] = [
|
||||
.credits: NSAttributedString(
|
||||
string: creditsString,
|
||||
attributes: [
|
||||
|
|
@ -147,6 +145,11 @@ final class StatusBarController: NSObject, NSMenuDelegate {
|
|||
.applicationName: "Tethering Hider",
|
||||
.version: "1.0.0"
|
||||
]
|
||||
|
||||
if let appIcon = NSImage(named: NSImage.applicationIconName) ?? NSApplication.shared.applicationIconImage {
|
||||
options[.applicationIcon] = appIcon
|
||||
}
|
||||
|
||||
NSApp.orderFrontStandardAboutPanel(options: options)
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue