mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
👌 Polished context menu order and code
This commit is contained in:
@ -27,6 +27,8 @@
|
|||||||
C41C1B4B22B019FF00E7CF16 /* ActivePhpInstallation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B4A22B019FF00E7CF16 /* ActivePhpInstallation.swift */; };
|
C41C1B4B22B019FF00E7CF16 /* ActivePhpInstallation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B4A22B019FF00E7CF16 /* ActivePhpInstallation.swift */; };
|
||||||
C41C1B4D22B0215A00E7CF16 /* Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B4C22B0215A00E7CF16 /* Actions.swift */; };
|
C41C1B4D22B0215A00E7CF16 /* Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B4C22B0215A00E7CF16 /* Actions.swift */; };
|
||||||
C41CD0292628D8EE0065BBED /* GlobalKeybindPreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41CD0282628D8EE0065BBED /* GlobalKeybindPreference.swift */; };
|
C41CD0292628D8EE0065BBED /* GlobalKeybindPreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41CD0282628D8EE0065BBED /* GlobalKeybindPreference.swift */; };
|
||||||
|
C41E871A2763D42300161EE0 /* SiteListVC+ContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41E87192763D42300161EE0 /* SiteListVC+ContextMenu.swift */; };
|
||||||
|
C41E871B2763D42300161EE0 /* SiteListVC+ContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41E87192763D42300161EE0 /* SiteListVC+ContextMenu.swift */; };
|
||||||
C42295DD2358D02000E263B2 /* Command.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42295DC2358D02000E263B2 /* Command.swift */; };
|
C42295DD2358D02000E263B2 /* Command.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42295DC2358D02000E263B2 /* Command.swift */; };
|
||||||
C4232EE52612526500158FC6 /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = C4232EE42612526500158FC6 /* Credits.html */; };
|
C4232EE52612526500158FC6 /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = C4232EE42612526500158FC6 /* Credits.html */; };
|
||||||
C42759672627662800093CAE /* NSMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42759662627662800093CAE /* NSMenuExtension.swift */; };
|
C42759672627662800093CAE /* NSMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42759662627662800093CAE /* NSMenuExtension.swift */; };
|
||||||
@ -139,6 +141,7 @@
|
|||||||
C41C1B4A22B019FF00E7CF16 /* ActivePhpInstallation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivePhpInstallation.swift; sourceTree = "<group>"; };
|
C41C1B4A22B019FF00E7CF16 /* ActivePhpInstallation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivePhpInstallation.swift; sourceTree = "<group>"; };
|
||||||
C41C1B4C22B0215A00E7CF16 /* Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Actions.swift; sourceTree = "<group>"; };
|
C41C1B4C22B0215A00E7CF16 /* Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Actions.swift; sourceTree = "<group>"; };
|
||||||
C41CD0282628D8EE0065BBED /* GlobalKeybindPreference.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlobalKeybindPreference.swift; sourceTree = "<group>"; };
|
C41CD0282628D8EE0065BBED /* GlobalKeybindPreference.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlobalKeybindPreference.swift; sourceTree = "<group>"; };
|
||||||
|
C41E87192763D42300161EE0 /* SiteListVC+ContextMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SiteListVC+ContextMenu.swift"; sourceTree = "<group>"; };
|
||||||
C42295DC2358D02000E263B2 /* Command.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Command.swift; sourceTree = "<group>"; };
|
C42295DC2358D02000E263B2 /* Command.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Command.swift; sourceTree = "<group>"; };
|
||||||
C4232EE42612526500158FC6 /* Credits.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = Credits.html; sourceTree = "<group>"; };
|
C4232EE42612526500158FC6 /* Credits.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = Credits.html; sourceTree = "<group>"; };
|
||||||
C42759662627662800093CAE /* NSMenuExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSMenuExtension.swift; sourceTree = "<group>"; };
|
C42759662627662800093CAE /* NSMenuExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSMenuExtension.swift; sourceTree = "<group>"; };
|
||||||
@ -304,6 +307,7 @@
|
|||||||
children = (
|
children = (
|
||||||
C464ADAB275A7A3F003FCD53 /* SiteListWC.swift */,
|
C464ADAB275A7A3F003FCD53 /* SiteListWC.swift */,
|
||||||
C464ADAE275A7A69003FCD53 /* SiteListVC.swift */,
|
C464ADAE275A7A69003FCD53 /* SiteListVC.swift */,
|
||||||
|
C41E87192763D42300161EE0 /* SiteListVC+ContextMenu.swift */,
|
||||||
C464ADB1275A87CA003FCD53 /* SiteListCell.swift */,
|
C464ADB1275A87CA003FCD53 /* SiteListCell.swift */,
|
||||||
);
|
);
|
||||||
path = SiteList;
|
path = SiteList;
|
||||||
@ -543,6 +547,7 @@
|
|||||||
C41C1B4722B009A400E7CF16 /* Shell.swift in Sources */,
|
C41C1B4722B009A400E7CF16 /* Shell.swift in Sources */,
|
||||||
C4F2E43A2752F7D00020E974 /* PhpInstallation.swift in Sources */,
|
C4F2E43A2752F7D00020E974 /* PhpInstallation.swift in Sources */,
|
||||||
C41C1B4D22B0215A00E7CF16 /* Actions.swift in Sources */,
|
C41C1B4D22B0215A00E7CF16 /* Actions.swift in Sources */,
|
||||||
|
C41E871A2763D42300161EE0 /* SiteListVC+ContextMenu.swift in Sources */,
|
||||||
C48D0CA325CC992000CC7490 /* StatsView.swift in Sources */,
|
C48D0CA325CC992000CC7490 /* StatsView.swift in Sources */,
|
||||||
C4F2E4372752F0870020E974 /* HomebrewDiagnostics.swift in Sources */,
|
C4F2E4372752F0870020E974 /* HomebrewDiagnostics.swift in Sources */,
|
||||||
C4CCBA6C275C567B008C7055 /* PMWindowController.swift in Sources */,
|
C4CCBA6C275C567B008C7055 /* PMWindowController.swift in Sources */,
|
||||||
@ -602,6 +607,7 @@
|
|||||||
C4B97B76275CF08C003F3378 /* AppDelegate+MenuOutlets.swift in Sources */,
|
C4B97B76275CF08C003F3378 /* AppDelegate+MenuOutlets.swift in Sources */,
|
||||||
C4F780CD25D80B75000DBC97 /* Alert.swift in Sources */,
|
C4F780CD25D80B75000DBC97 /* Alert.swift in Sources */,
|
||||||
C481F79726164A78004FBCFF /* PrefsVC.swift in Sources */,
|
C481F79726164A78004FBCFF /* PrefsVC.swift in Sources */,
|
||||||
|
C41E871B2763D42300161EE0 /* SiteListVC+ContextMenu.swift in Sources */,
|
||||||
C464ADB3275A87CA003FCD53 /* SiteListCell.swift in Sources */,
|
C464ADB3275A87CA003FCD53 /* SiteListCell.swift in Sources */,
|
||||||
C4AF9F78275447F100D44ED0 /* ValetConfigParserTest.swift in Sources */,
|
C4AF9F78275447F100D44ED0 /* ValetConfigParserTest.swift in Sources */,
|
||||||
C4B97B7C275CF20A003F3378 /* App+GlobalHotkey.swift in Sources */,
|
C4B97B7C275CF20A003F3378 /* App+GlobalHotkey.swift in Sources */,
|
||||||
|
93
phpmon/Domain/SiteList/SiteListVC+ContextMenu.swift
Normal file
93
phpmon/Domain/SiteList/SiteListVC+ContextMenu.swift
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
//
|
||||||
|
// SiteListVC+ContextMenu.swift
|
||||||
|
// PHP Monitor
|
||||||
|
//
|
||||||
|
// Created by Nico Verbruggen on 10/12/2021.
|
||||||
|
// Copyright © 2021 Nico Verbruggen. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Cocoa
|
||||||
|
|
||||||
|
extension SiteListVC {
|
||||||
|
|
||||||
|
internal func reloadContextMenu() {
|
||||||
|
guard let site = selectedSite else {
|
||||||
|
tableView.menu = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let menu = NSMenu()
|
||||||
|
|
||||||
|
addSystemApps(to: menu)
|
||||||
|
addSeparator(to: menu)
|
||||||
|
addDetectedApps(to: menu)
|
||||||
|
addSeparator(to: menu)
|
||||||
|
|
||||||
|
addUnlink(to: menu, with: site)
|
||||||
|
addToggleSecure(to: menu, with: site)
|
||||||
|
|
||||||
|
tableView.menu = menu
|
||||||
|
}
|
||||||
|
|
||||||
|
private func addSystemApps(to menu: NSMenu) {
|
||||||
|
menu.addItem(withTitle: "site_list.system_apps".localized, action: nil, keyEquivalent: "")
|
||||||
|
menu.addItem(
|
||||||
|
withTitle: "site_list.open_in_finder".localized,
|
||||||
|
action: #selector(self.openInFinder),
|
||||||
|
keyEquivalent: "F"
|
||||||
|
)
|
||||||
|
menu.addItem(
|
||||||
|
withTitle: "site_list.open_in_terminal".localized,
|
||||||
|
action: #selector(self.openInTerminal),
|
||||||
|
keyEquivalent: "T"
|
||||||
|
)
|
||||||
|
menu.addItem(
|
||||||
|
withTitle: "site_list.open_in_browser".localized,
|
||||||
|
action: #selector(self.openInBrowser),
|
||||||
|
keyEquivalent: "O"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func addDetectedApps(to menu: NSMenu) {
|
||||||
|
if (applications.count > 0) {
|
||||||
|
menu.addItem(NSMenuItem.separator())
|
||||||
|
menu.addItem(withTitle: "site_list.detected_apps".localized, action: nil, keyEquivalent: "")
|
||||||
|
|
||||||
|
for (index, editor) in applications.enumerated() {
|
||||||
|
let editorMenuItem = EditorMenuItem(
|
||||||
|
title: "Open with \(editor.name)",
|
||||||
|
action: #selector(self.openWithEditor(sender:)),
|
||||||
|
keyEquivalent: "\(index + 1)"
|
||||||
|
)
|
||||||
|
editorMenuItem.editor = editor
|
||||||
|
menu.addItem(editorMenuItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func addUnlink(to menu: NSMenu, with site: Valet.Site) {
|
||||||
|
if (site.aliasPath != nil) {
|
||||||
|
menu.addItem(
|
||||||
|
withTitle: "site_list.unlink".localized,
|
||||||
|
action: #selector(self.unlinkSite),
|
||||||
|
keyEquivalent: "U"
|
||||||
|
)
|
||||||
|
menu.addItem(NSMenuItem.separator())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func addToggleSecure(to menu: NSMenu, with site: Valet.Site) {
|
||||||
|
menu.addItem(
|
||||||
|
withTitle: site.secured
|
||||||
|
? "site_list.unsecure".localized
|
||||||
|
: "site_list.secure".localized,
|
||||||
|
action: #selector(toggleSecure),
|
||||||
|
keyEquivalent: "L"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func addSeparator(to menu: NSMenu) {
|
||||||
|
menu.addItem(NSMenuItem.separator())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -261,67 +261,6 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
|||||||
|
|
||||||
// MARK: - Context Menu
|
// MARK: - Context Menu
|
||||||
|
|
||||||
private func reloadContextMenu() {
|
|
||||||
let menu = NSMenu()
|
|
||||||
|
|
||||||
guard let site = selectedSite else {
|
|
||||||
tableView.menu = nil
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (site.aliasPath != nil) {
|
|
||||||
menu.addItem(
|
|
||||||
withTitle: "site_list.unlink".localized,
|
|
||||||
action: #selector(self.unlinkSite),
|
|
||||||
keyEquivalent: "U"
|
|
||||||
)
|
|
||||||
menu.addItem(NSMenuItem.separator())
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.addItem(
|
|
||||||
withTitle: site.secured
|
|
||||||
? "site_list.unsecure".localized
|
|
||||||
: "site_list.secure".localized,
|
|
||||||
action: #selector(toggleSecure),
|
|
||||||
keyEquivalent: "L"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (applications.count > 0) {
|
|
||||||
menu.addItem(NSMenuItem.separator())
|
|
||||||
menu.addItem(withTitle: "site_list.detected_apps".localized, action: nil, keyEquivalent: "")
|
|
||||||
|
|
||||||
for (index, editor) in applications.enumerated() {
|
|
||||||
let editorMenuItem = EditorMenuItem(
|
|
||||||
title: "Open with \(editor.name)",
|
|
||||||
action: #selector(self.openWithEditor(sender:)),
|
|
||||||
keyEquivalent: "\(index + 1)"
|
|
||||||
)
|
|
||||||
editorMenuItem.editor = editor
|
|
||||||
menu.addItem(editorMenuItem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.addItem(NSMenuItem.separator())
|
|
||||||
menu.addItem(withTitle: "site_list.system_apps".localized, action: nil, keyEquivalent: "")
|
|
||||||
menu.addItem(
|
|
||||||
withTitle: "site_list.open_in_finder".localized,
|
|
||||||
action: #selector(self.openInFinder),
|
|
||||||
keyEquivalent: "F"
|
|
||||||
)
|
|
||||||
menu.addItem(
|
|
||||||
withTitle: "site_list.open_in_terminal".localized,
|
|
||||||
action: #selector(self.openInTerminal),
|
|
||||||
keyEquivalent: "T"
|
|
||||||
)
|
|
||||||
menu.addItem(
|
|
||||||
withTitle: "site_list.open_in_browser".localized,
|
|
||||||
action: #selector(self.openInBrowser),
|
|
||||||
keyEquivalent: "O"
|
|
||||||
)
|
|
||||||
|
|
||||||
tableView.menu = menu
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func openWithEditor(sender: EditorMenuItem) {
|
@objc func openWithEditor(sender: EditorMenuItem) {
|
||||||
guard let editor = sender.editor else { return }
|
guard let editor = sender.editor else { return }
|
||||||
editor.openDirectory(file: selectedSite!.absolutePath!)
|
editor.openDirectory(file: selectedSite!.absolutePath!)
|
||||||
|
@ -65,9 +65,9 @@
|
|||||||
|
|
||||||
// SITE LIST ACTIONS
|
// SITE LIST ACTIONS
|
||||||
|
|
||||||
"site_list.unlink" = "Unlink";
|
"site_list.unlink" = "Unlink Directory";
|
||||||
"site_list.secure" = "Secure";
|
"site_list.secure" = "Secure Domain";
|
||||||
"site_list.unsecure" = "Unsecure";
|
"site_list.unsecure" = "Unsecure Domain";
|
||||||
"site_list.open_in_finder" = "Open in Finder";
|
"site_list.open_in_finder" = "Open in Finder";
|
||||||
"site_list.open_in_browser" = "Open in Browser";
|
"site_list.open_in_browser" = "Open in Browser";
|
||||||
"site_list.open_in_terminal" = "Open in Terminal";
|
"site_list.open_in_terminal" = "Open in Terminal";
|
||||||
|
Reference in New Issue
Block a user