mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
✨ Allow hiding of global version switcher
This commit is contained in:
@ -32,9 +32,15 @@ extension StatusMenu {
|
||||
if PhpEnv.shared.availablePhpVersions.isEmpty { return }
|
||||
|
||||
addSwitchToPhpMenuItems()
|
||||
self.addItem(NSMenuItem.separator())
|
||||
}
|
||||
|
||||
func addValetServicesMenuItems() {
|
||||
if PhpEnv.shared.isBusy {
|
||||
return
|
||||
}
|
||||
|
||||
addItems([
|
||||
NSMenuItem.separator(),
|
||||
ServicesView.asMenuItem(),
|
||||
NSMenuItem.separator()
|
||||
])
|
||||
|
@ -12,7 +12,12 @@ class StatusMenu: NSMenu {
|
||||
addPhpVersionMenuItems()
|
||||
addItem(NSMenuItem.separator())
|
||||
|
||||
addPhpActionMenuItems()
|
||||
if Preferences.isEnabled(.displayGlobalVersionSwitcher) {
|
||||
addPhpActionMenuItems()
|
||||
addItem(NSMenuItem.separator())
|
||||
}
|
||||
|
||||
addValetServicesMenuItems()
|
||||
addItem(NSMenuItem.separator())
|
||||
|
||||
addValetMenuItems()
|
||||
|
@ -35,7 +35,7 @@ enum PreferenceName: String {
|
||||
case notifyAboutGlobalComposerStatus = "notify_about_composer_status"
|
||||
|
||||
// MENU CUSTOMIZATION
|
||||
case displayVersionSwitcher = "display_version_switcher"
|
||||
case displayGlobalVersionSwitcher = "display_global_version_switcher"
|
||||
case displayServicesManager = "display_services_manager"
|
||||
case displayValetConfigFinder = "display_valet_config_finder"
|
||||
case displayPhpConfigFinder = "display_php_config_finder"
|
||||
@ -66,7 +66,7 @@ enum PreferenceName: String {
|
||||
.notifyAboutGlobalComposerStatus,
|
||||
|
||||
// UI Preferences
|
||||
.displayVersionSwitcher,
|
||||
.displayGlobalVersionSwitcher,
|
||||
.displayServicesManager,
|
||||
.displayValetConfigFinder,
|
||||
.displayPhpConfigFinder,
|
||||
|
@ -65,7 +65,7 @@ class Preferences {
|
||||
PreferenceName.notifyAboutGlobalComposerStatus.rawValue: true,
|
||||
|
||||
/// Preferences: UI Preferences
|
||||
PreferenceName.displayVersionSwitcher.rawValue: true,
|
||||
PreferenceName.displayGlobalVersionSwitcher.rawValue: true,
|
||||
PreferenceName.displayServicesManager.rawValue: true,
|
||||
PreferenceName.displayValetConfigFinder.rawValue: true,
|
||||
PreferenceName.displayPhpConfigFinder.rawValue: true,
|
||||
|
@ -188,6 +188,23 @@ class GenericPreferenceVC: NSViewController {
|
||||
)
|
||||
}
|
||||
|
||||
func getDisplayMenuSectionPV(
|
||||
_ localizationKey: String,
|
||||
_ preference: PreferenceName,
|
||||
_ first: Bool = false
|
||||
) -> NSView {
|
||||
return CheckboxPreferenceView.make(
|
||||
sectionText: first ? "prefs.menu_contents".localized : "",
|
||||
descriptionText: "\(localizationKey)_desc".localized,
|
||||
checkboxText: localizationKey.localized,
|
||||
preference: preference,
|
||||
action: {
|
||||
MainMenu.shared.refreshIcon()
|
||||
MainMenu.shared.rebuild()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Listening for hotkey delegate
|
||||
|
||||
var listeningForHotkeyView: HotkeyPreferenceView?
|
||||
@ -251,7 +268,8 @@ class AppearancePreferencesVC: GenericPreferenceVC {
|
||||
vc.views = [
|
||||
vc.getDynamicIconPV(),
|
||||
vc.getIconOptionsPV(),
|
||||
vc.getIconDensityPV()
|
||||
vc.getIconDensityPV(),
|
||||
vc.getDisplayMenuSectionPV("prefs.display_global_version_switcher", .displayGlobalVersionSwitcher, true)
|
||||
]
|
||||
|
||||
return vc
|
||||
|
@ -227,6 +227,7 @@
|
||||
"prefs.integrations" = "Integrations:";
|
||||
"prefs.updates" = "Updates:";
|
||||
"prefs.notifications" = "Notifications:";
|
||||
"prefs.menu_contents" = "Display In Menu:";
|
||||
|
||||
"prefs.icon_options.php" = "Display PHP Icon";
|
||||
"prefs.icon_options.elephant" = "Display Elephant Icon";
|
||||
@ -278,6 +279,9 @@
|
||||
"prefs.notify_about_composer_success_desc" = "Displays a notification when the global Composer configuration was successfully updated.";
|
||||
"prefs.notify_about_composer_success" = "Notify about global composer update";
|
||||
|
||||
"prefs.display_global_version_switcher_desc" = "Display the global PHP version switcher. If disabled, the global switcher will not be accessible via the main menu.";
|
||||
"prefs.display_global_version_switcher" = "Show Global PHP Switcher";
|
||||
|
||||
// NOTIFICATIONS
|
||||
|
||||
"notification.version_changed_title" = "PHP %@ now active";
|
||||
|
Reference in New Issue
Block a user