✨ Adds icon, async changes, fixes
@ -24,20 +24,21 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
// Start with the ducky
|
// Start with the ducky
|
||||||
self.setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
self.setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
||||||
// Perform environment boot checks
|
// Perform environment boot checks
|
||||||
DispatchQueue.global(qos: .userInitiated).async {
|
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
||||||
Environment.performBootChecks()
|
Environment.performBootChecks()
|
||||||
|
self.availablePhpVersions = Services.detectPhpVersions()
|
||||||
|
print("The following PHP versions were detected:")
|
||||||
|
print(self.availablePhpVersions)
|
||||||
|
self.updatePhpVersionInStatusBar()
|
||||||
|
// Schedule a request to fetch the PHP version every 15 seconds
|
||||||
|
Timer.scheduledTimer(
|
||||||
|
timeInterval: 15,
|
||||||
|
target: self,
|
||||||
|
selector: #selector(self.updatePhpVersionInStatusBar),
|
||||||
|
userInfo: nil,
|
||||||
|
repeats: true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// Check if the correct stuff is installed
|
|
||||||
self.availablePhpVersions = Services.detectPhpVersions()
|
|
||||||
self.updatePhpVersionInStatusBar()
|
|
||||||
// Schedule a request to fetch the PHP version every 15 seconds
|
|
||||||
Timer.scheduledTimer(
|
|
||||||
timeInterval: 15,
|
|
||||||
target: self,
|
|
||||||
selector: #selector(updatePhpVersionInStatusBar),
|
|
||||||
userInfo: nil,
|
|
||||||
repeats: true
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setStatusBarImage(version: String) {
|
func setStatusBarImage(version: String) {
|
||||||
@ -58,11 +59,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
@objc func updatePhpVersionInStatusBar() {
|
@objc func updatePhpVersionInStatusBar() {
|
||||||
self.version = PHPVersion()
|
self.version = PHPVersion()
|
||||||
if (self.busy) {
|
if (self.busy) {
|
||||||
self.setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
DispatchQueue.main.async {
|
||||||
|
self.setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.setStatusBarImage(version: self.version!.short)
|
DispatchQueue.main.async {
|
||||||
|
self.setStatusBarImage(version: self.version!.short)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.updateMenu()
|
self.updateMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,10 +93,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
menu.addItem(NSMenuItem(title: "Switching PHP versions...", action: nil, keyEquivalent: ""))
|
menu.addItem(NSMenuItem(title: "Switching PHP versions...", action: nil, keyEquivalent: ""))
|
||||||
menu.addItem(NSMenuItem.separator())
|
menu.addItem(NSMenuItem.separator())
|
||||||
}
|
}
|
||||||
menu.addItem(NSMenuItem(title: Services.mysqlIsRunning() ? "You are running MySQL" : "MySQL is not active", action: nil, keyEquivalent: ""))
|
menu.addItem(NSMenuItem(title: "About phpmon", action: #selector(self.openAbout), keyEquivalent: ""))
|
||||||
menu.addItem(NSMenuItem(title: Services.nginxIsRunning() ? "You are running nginx" : "nginx is not active", action: nil, keyEquivalent: ""))
|
|
||||||
menu.addItem(NSMenuItem.separator())
|
|
||||||
// menu.addItem(NSMenuItem(title: "About phpmon", action: #selector(NSApplication.terminate(_:)), keyEquivalent: ""))
|
|
||||||
menu.addItem(NSMenuItem(title: "Quit phpmon", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q"))
|
menu.addItem(NSMenuItem(title: "Quit phpmon", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q"))
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.statusItem.menu = menu
|
self.statusItem.menu = menu
|
||||||
@ -100,13 +101,20 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc public func openAbout() {
|
||||||
|
NSApplication.shared.orderFrontStandardAboutPanel()
|
||||||
|
}
|
||||||
|
|
||||||
@objc public func switchToPhpVersion(sender: AnyObject) {
|
@objc public func switchToPhpVersion(sender: AnyObject) {
|
||||||
|
self.setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
||||||
let index = sender.tag!
|
let index = sender.tag!
|
||||||
let version = self.availablePhpVersions[index]
|
let version = self.availablePhpVersions[index]
|
||||||
self.busy = true
|
self.busy = true
|
||||||
self.updatePhpVersionInStatusBar()
|
|
||||||
self.updateMenu()
|
|
||||||
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
||||||
|
// Update the PHP version in the status bar
|
||||||
|
self.updatePhpVersionInStatusBar()
|
||||||
|
// Update the menu
|
||||||
|
self.updateMenu()
|
||||||
// Switch the PHP version
|
// Switch the PHP version
|
||||||
Services.switchToPhpVersion(version: version, availableVersions: self.availablePhpVersions)
|
Services.switchToPhpVersion(version: version, availableVersions: self.availablePhpVersions)
|
||||||
// Mark as no longer busy
|
// Mark as no longer busy
|
||||||
|
@ -1,53 +1,63 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "16x16",
|
"size" : "16x16",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_16x16.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "16x16",
|
"size" : "16x16",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_16x16@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "32x32",
|
"size" : "32x32",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_32x32.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "32x32",
|
"size" : "32x32",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_32x32@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "128x128",
|
"size" : "128x128",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_128x128.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "128x128",
|
"size" : "128x128",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_128x128@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "256x256",
|
"size" : "256x256",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_256x256.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "256x256",
|
"size" : "256x256",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_256x256@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "512x512",
|
"size" : "512x512",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_512x512.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "512x512",
|
"size" : "512x512",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_512x512@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_128x128.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_16x16.png
Normal file
After Width: | Height: | Size: 647 B |
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_256x256.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_32x32.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_512x512.png
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
phpmon/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png
Normal file
After Width: | Height: | Size: 432 KiB |
Before Width: | Height: | Size: 432 B After Width: | Height: | Size: 386 B |
Before Width: | Height: | Size: 801 B After Width: | Height: | Size: 780 B |
@ -19,7 +19,7 @@
|
|||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0</string>
|
<string>1.0</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>2</string>
|
<string>3</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||||
<key>LSUIElement</key>
|
<key>LSUIElement</key>
|
||||||
|