From 4b1fc1a5ceeba282a5df59d3f01609e50a82d7b5 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sat, 22 Apr 2023 10:08:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Improve=20visibility=20of=20Stan?= =?UTF-8?q?dalone=20Mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 42 +++++--- phpmon/Domain/Menu/MainMenu.swift | 12 +++ phpmon/Domain/Menu/StatusMenu+Items.swift | 4 + phpmon/Domain/Menu/StatusMenu.swift | 4 + .../Domain/Preferences/PreferencesTabs.swift | 87 +++++++++++++++ .../{PrefsVC.swift => PreferencesVC.swift} | 101 +++--------------- phpmon/Localizable.strings | 7 ++ 7 files changed, 152 insertions(+), 105 deletions(-) create mode 100644 phpmon/Domain/Preferences/PreferencesTabs.swift rename phpmon/Domain/Preferences/{PrefsVC.swift => PreferencesVC.swift} (70%) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 4bcc27f..fa0f7ee 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -9,7 +9,7 @@ /* Begin PBXBuildFile section */ 03E36FE728D9219000636F7F /* ActiveShell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E36FE628D9219000636F7F /* ActiveShell.swift */; }; 03E36FE828D9219000636F7F /* ActiveShell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E36FE628D9219000636F7F /* ActiveShell.swift */; }; - 5420395926135DC100FB00FA /* PrefsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PrefsVC.swift */; }; + 5420395926135DC100FB00FA /* PreferencesVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PreferencesVC.swift */; }; 5420395F2613607600FB00FA /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395E2613607600FB00FA /* Preferences.swift */; }; 5489625828312FAD004F647A /* CreatedFromFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5489625728312FAD004F647A /* CreatedFromFile.swift */; }; 5489625928313231004F647A /* CreatedFromFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5489625728312FAD004F647A /* CreatedFromFile.swift */; }; @@ -129,6 +129,10 @@ C42F26762805FEE200938AC7 /* nginx-secure-proxy.test in Resources */ = {isa = PBXBuildFile; fileRef = C42F26752805FEE200938AC7 /* nginx-secure-proxy.test */; }; C43603A0275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */; }; C43603A1275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */; }; + C436B39D29F3C42500B6A64E /* PreferencesTabs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436B39C29F3C42500B6A64E /* PreferencesTabs.swift */; }; + C436B39E29F3C42500B6A64E /* PreferencesTabs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436B39C29F3C42500B6A64E /* PreferencesTabs.swift */; }; + C436B39F29F3C42500B6A64E /* PreferencesTabs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436B39C29F3C42500B6A64E /* PreferencesTabs.swift */; }; + C436B3A029F3C42500B6A64E /* PreferencesTabs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C436B39C29F3C42500B6A64E /* PreferencesTabs.swift */; }; C43931C529C4BD610069165B /* PhpFormulaeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43931C429C4BD610069165B /* PhpFormulaeView.swift */; }; C43931C629C4BD610069165B /* PhpFormulaeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43931C429C4BD610069165B /* PhpFormulaeView.swift */; }; C43931C729C4BD610069165B /* PhpFormulaeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43931C429C4BD610069165B /* PhpFormulaeView.swift */; }; @@ -383,7 +387,7 @@ C471E86728F9BB650021E251 /* OnboardingWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4FACE82288F1F9700FC478F /* OnboardingWindowController.swift */; }; C471E86828F9BB650021E251 /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4998F092617633900B2526E /* PreferencesWindowController.swift */; }; C471E86928F9BB650021E251 /* PreferencesWindowController+Hotkey.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4FACE7F288F1C0D00FC478F /* PreferencesWindowController+Hotkey.swift */; }; - C471E86A28F9BB650021E251 /* PrefsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PrefsVC.swift */; }; + C471E86A28F9BB650021E251 /* PreferencesVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PreferencesVC.swift */; }; C471E86B28F9BB650021E251 /* PreferenceName.swift in Sources */ = {isa = PBXBuildFile; fileRef = C450C8C528C919EC002A2B4B /* PreferenceName.swift */; }; C471E86C28F9BB650021E251 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395E2613607600FB00FA /* Preferences.swift */; }; C471E86D28F9BB650021E251 /* CustomPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED4227834C5200AB15D8 /* CustomPrefs.swift */; }; @@ -472,7 +476,7 @@ C471E8CA28F9BB8F0021E251 /* OnboardingWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4FACE82288F1F9700FC478F /* OnboardingWindowController.swift */; }; C471E8CB28F9BB8F0021E251 /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4998F092617633900B2526E /* PreferencesWindowController.swift */; }; C471E8CC28F9BB8F0021E251 /* PreferencesWindowController+Hotkey.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4FACE7F288F1C0D00FC478F /* PreferencesWindowController+Hotkey.swift */; }; - C471E8CD28F9BB8F0021E251 /* PrefsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PrefsVC.swift */; }; + C471E8CD28F9BB8F0021E251 /* PreferencesVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PreferencesVC.swift */; }; C471E8CE28F9BB8F0021E251 /* PreferenceName.swift in Sources */ = {isa = PBXBuildFile; fileRef = C450C8C528C919EC002A2B4B /* PreferenceName.swift */; }; C471E8CF28F9BB8F0021E251 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395E2613607600FB00FA /* Preferences.swift */; }; C471E8D028F9BB8F0021E251 /* CustomPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED4227834C5200AB15D8 /* CustomPrefs.swift */; }; @@ -521,7 +525,7 @@ C47DF1B2299D5A3B0007055D /* LoginItemManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C47DF1AE299D5A3B0007055D /* LoginItemManager.swift */; }; C4811D2422D70A4700B5F6B3 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4811D2322D70A4700B5F6B3 /* App.swift */; }; C4811D2A22D70F9A00B5F6B3 /* MainMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */; }; - C481F79726164A78004FBCFF /* PrefsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PrefsVC.swift */; }; + C481F79726164A78004FBCFF /* PreferencesVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PreferencesVC.swift */; }; C481F79A26164A7C004FBCFF /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395E2613607600FB00FA /* Preferences.swift */; }; C485706D28BF450900539B36 /* NSMenuItemExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40508B028ADAB44008FAC1F /* NSMenuItemExtension.swift */; }; C485706E28BF451C00539B36 /* OnboardingWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4FACE82288F1F9700FC478F /* OnboardingWindowController.swift */; }; @@ -824,7 +828,7 @@ /* Begin PBXFileReference section */ 03E36FE628D9219000636F7F /* ActiveShell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveShell.swift; sourceTree = ""; }; - 5420395826135DC100FB00FA /* PrefsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrefsVC.swift; sourceTree = ""; }; + 5420395826135DC100FB00FA /* PreferencesVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesVC.swift; sourceTree = ""; }; 5420395E2613607600FB00FA /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = ""; }; 5489625728312FAD004F647A /* CreatedFromFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreatedFromFile.swift; sourceTree = ""; }; 54A18D3F282A566E000A0D81 /* nginx-secure-proxy-custom-tld.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "nginx-secure-proxy-custom-tld.test"; sourceTree = ""; }; @@ -903,6 +907,7 @@ C42F26722805B4B400938AC7 /* ValetListable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValetListable.swift; sourceTree = ""; }; C42F26752805FEE200938AC7 /* nginx-secure-proxy.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "nginx-secure-proxy.test"; sourceTree = ""; }; C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Notifications.swift"; sourceTree = ""; }; + C436B39C29F3C42500B6A64E /* PreferencesTabs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesTabs.swift; sourceTree = ""; }; C43931C429C4BD610069165B /* PhpFormulaeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpFormulaeView.swift; sourceTree = ""; }; C43931C929C4C03F0069165B /* Brew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Brew.swift; sourceTree = ""; }; C43A8A1925D9CD1000591B77 /* Utility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utility.swift; sourceTree = ""; }; @@ -1122,7 +1127,8 @@ children = ( C4998F092617633900B2526E /* PreferencesWindowController.swift */, C4FACE7F288F1C0D00FC478F /* PreferencesWindowController+Hotkey.swift */, - 5420395826135DC100FB00FA /* PrefsVC.swift */, + 5420395826135DC100FB00FA /* PreferencesVC.swift */, + C436B39C29F3C42500B6A64E /* PreferencesTabs.swift */, C450C8C528C919EC002A2B4B /* PreferenceName.swift */, 5420395E2613607600FB00FA /* Preferences.swift */, C4C3ED4227834C5200AB15D8 /* CustomPrefs.swift */, @@ -2275,7 +2281,7 @@ C4F8C0A422D4F12C002EFE61 /* DateExtension.swift in Sources */, C4AF9F7A2754499000D44ED0 /* Valet.swift in Sources */, C4EB53E728553117006F9937 /* ArrayExtension.swift in Sources */, - 5420395926135DC100FB00FA /* PrefsVC.swift in Sources */, + 5420395926135DC100FB00FA /* PreferencesVC.swift in Sources */, C4C8900328F0E28800CE5E97 /* FileSystemProtocol.swift in Sources */, C43603A0275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */, C45B9149295607F400F4EC78 /* Service.swift in Sources */, @@ -2320,6 +2326,7 @@ C4B79EBC29CA38DB00A483EE /* BrewCommand.swift in Sources */, C41CD0292628D8EE0065BBED /* GlobalKeybindPreference.swift in Sources */, C4B6091A2853AAD300C95265 /* SectionHeaderView.swift in Sources */, + C436B39D29F3C42500B6A64E /* PreferencesTabs.swift in Sources */, C44067F727E258410045BD4E /* DomainListPhpCell.swift in Sources */, C4FACE80288F1C0D00FC478F /* PreferencesWindowController+Hotkey.swift in Sources */, C415D3B72770F294005EF286 /* Actions.swift in Sources */, @@ -2519,7 +2526,7 @@ C48DDD0F29C75C9E00D032D9 /* BlockingOverlayView.swift in Sources */, C4777E0E29D71AFD007F0C67 /* UpgradePhpVersionCommand.swift in Sources */, C4AFC4B029C4F32F00BF4E0D /* BrewFormula.swift in Sources */, - C471E86A28F9BB650021E251 /* PrefsVC.swift in Sources */, + C471E86A28F9BB650021E251 /* PreferencesVC.swift in Sources */, C471E86B28F9BB650021E251 /* PreferenceName.swift in Sources */, C471E86C28F9BB650021E251 /* Preferences.swift in Sources */, C4D3660D29113F20006BD146 /* System.swift in Sources */, @@ -2602,6 +2609,7 @@ C471E82928F9BB330021E251 /* Valet.swift in Sources */, C471E80728F9BAD40021E251 /* PhpConfigurationFile.swift in Sources */, C471E7D528F9BA8F0021E251 /* TestableConfigurations.swift in Sources */, + C436B39F29F3C42500B6A64E /* PreferencesTabs.swift in Sources */, C471E7E328F9BAC20021E251 /* Logger.swift in Sources */, C471E7FD28F9BACE0021E251 /* HomebrewService.swift in Sources */, C471E7E428F9BAC20021E251 /* Helpers.swift in Sources */, @@ -2626,6 +2634,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + C436B3A029F3C42500B6A64E /* PreferencesTabs.swift in Sources */, C471E89028F9BB8F0021E251 /* AlertableError.swift in Sources */, C471E89128F9BB8F0021E251 /* Errors.swift in Sources */, C4B79EC929CA474200A483EE /* FakeCommand.swift in Sources */, @@ -2699,7 +2708,7 @@ C4D4CB3A29C109CF00DB9F93 /* InternalSwitcher+Valet.swift in Sources */, C471E8CB28F9BB8F0021E251 /* PreferencesWindowController.swift in Sources */, C471E8CC28F9BB8F0021E251 /* PreferencesWindowController+Hotkey.swift in Sources */, - C471E8CD28F9BB8F0021E251 /* PrefsVC.swift in Sources */, + C471E8CD28F9BB8F0021E251 /* PreferencesVC.swift in Sources */, C471E8CE28F9BB8F0021E251 /* PreferenceName.swift in Sources */, C471E8CF28F9BB8F0021E251 /* Preferences.swift in Sources */, C4E2E84D28FC1E70003B070C /* DataExtension.swift in Sources */, @@ -2906,7 +2915,7 @@ C4AFC4AF29C4F32F00BF4E0D /* BrewFormula.swift in Sources */, C4F780CD25D80B75000DBC97 /* Alert.swift in Sources */, C485706D28BF450900539B36 /* NSMenuItemExtension.swift in Sources */, - C481F79726164A78004FBCFF /* PrefsVC.swift in Sources */, + C481F79726164A78004FBCFF /* PreferencesVC.swift in Sources */, C495F5B028A42E080087F70A /* EnvironmentCheck.swift in Sources */, C41E871B2763D42300161EE0 /* DomainListVC+ContextMenu.swift in Sources */, C40C7F3127722E8D00DDDCDC /* Logger.swift in Sources */, @@ -3005,6 +3014,7 @@ C45E76152854A65300B4FE0C /* ServicesManager.swift in Sources */, C4D36602291132B7006BD146 /* ValetScanners.swift in Sources */, C40934AB298EEDA900D25014 /* CaskFileParserTest.swift in Sources */, + C436B39E29F3C42500B6A64E /* PreferencesTabs.swift in Sources */, C4551657297AED18009B8466 /* ValetRcTest.swift in Sources */, C464ADAD275A7A3F003FCD53 /* DomainListWindowController.swift in Sources */, C40C7F1F2772136000DDDCDC /* PhpEnv.swift in Sources */, @@ -3309,7 +3319,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1210; + CURRENT_PROJECT_VERSION = 1215; DEAD_CODE_STRIPPING = YES; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; @@ -3339,7 +3349,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1210; + CURRENT_PROJECT_VERSION = 1215; DEAD_CODE_STRIPPING = YES; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; @@ -3568,7 +3578,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1210; + CURRENT_PROJECT_VERSION = 1215; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -3679,7 +3689,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1210; + CURRENT_PROJECT_VERSION = 1215; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -3790,7 +3800,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1210; + CURRENT_PROJECT_VERSION = 1215; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -3963,7 +3973,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1210; + CURRENT_PROJECT_VERSION = 1215; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; diff --git a/phpmon/Domain/Menu/MainMenu.swift b/phpmon/Domain/Menu/MainMenu.swift index d2c479c..f73e900 100644 --- a/phpmon/Domain/Menu/MainMenu.swift +++ b/phpmon/Domain/Menu/MainMenu.swift @@ -178,6 +178,18 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate NSApplication.shared.orderFrontStandardAboutPanel() } + @objc func openLiteModeInfo() { + Task { @MainActor in + BetterAlert().withInformation( + title: "lite_mode_explanation.title".localized, + subtitle: "lite_mode_explanation.subtitle".localized, + description: "lite_mode_explanation.description".localized + ) + .withPrimary(text: "generic.ok".localized) + .show() + } + } + @objc func openPrefs() { PreferencesWindowController.show() } diff --git a/phpmon/Domain/Menu/StatusMenu+Items.swift b/phpmon/Domain/Menu/StatusMenu+Items.swift index 59e8dd3..270ad79 100644 --- a/phpmon/Domain/Menu/StatusMenu+Items.swift +++ b/phpmon/Domain/Menu/StatusMenu+Items.swift @@ -101,6 +101,10 @@ extension StatusMenu { } } + func addLiteModeMenuItem() { + addItem(NSMenuItem(title: "mi_lite_mode".localized, action: #selector(MainMenu.openLiteModeInfo))) + } + func addCoreMenuItems() { addItems([ NSMenuItem.separator(), diff --git a/phpmon/Domain/Menu/StatusMenu.swift b/phpmon/Domain/Menu/StatusMenu.swift index 88d6623..6750565 100644 --- a/phpmon/Domain/Menu/StatusMenu.swift +++ b/phpmon/Domain/Menu/StatusMenu.swift @@ -65,6 +65,10 @@ class StatusMenu: NSMenu { addItem(NSMenuItem.separator()) + if !Valet.installed { + addLiteModeMenuItem() + } + addCoreMenuItems() } } diff --git a/phpmon/Domain/Preferences/PreferencesTabs.swift b/phpmon/Domain/Preferences/PreferencesTabs.swift new file mode 100644 index 0000000..746356d --- /dev/null +++ b/phpmon/Domain/Preferences/PreferencesTabs.swift @@ -0,0 +1,87 @@ +// +// PreferencesTabs.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 22/04/2023. +// Copyright © 2023 Nico Verbruggen. All rights reserved. +// + +import Foundation +import Cocoa + +class GeneralPreferencesVC: GenericPreferenceVC { + + // MARK: - Lifecycle + + public static func fromStoryboard() -> GenericPreferenceVC { + let vc = NSStoryboard(name: "Main", bundle: nil) + .instantiateController(withIdentifier: "preferencesTemplateVC") as! GenericPreferenceVC + + _ = vc.addView(when: true, vc.getShowPhpDoctorSuggestionsPV()) + .addView(when: true, vc.getAutoRestartServicesPV()) + .addView(when: true, vc.getAutomaticComposerUpdatePV()) + .addView(when: true, vc.getShortcutPV()) + .addView(when: true, vc.getIntegrationsPV()) + .addView(when: true, vc.getAutomaticUpdateCheckPV()) + + if #available(macOS 13, *) { + vc.views.append(CheckboxPreferenceView.makeLoginItemView()) + } + + return vc + } +} + +class AppearancePreferencesVC: GenericPreferenceVC { + + public static func fromStoryboard() -> GenericPreferenceVC { + let vc = NSStoryboard(name: "Main", bundle: nil) + .instantiateController(withIdentifier: "preferencesTemplateVC") as! GenericPreferenceVC + + _ = vc.addView(when: true, vc.getDynamicIconPV()) + .addView(when: true, vc.getIconOptionsPV()) + .addView(when: true, vc.getIconDensityPV()) + + return vc + } +} + +class MenuStructurePreferencesVC: GenericPreferenceVC { + + // swiftlint:disable line_length + public static func fromStoryboard() -> GenericPreferenceVC { + let vc = NSStoryboard(name: "Main", bundle: nil) + .instantiateController(withIdentifier: "preferencesTemplateVC") as! GenericPreferenceVC + + _ = vc.addView(when: true, vc.displayFeature("prefs.display_global_version_switcher", .displayGlobalVersionSwitcher, true)) + .addView(when: Valet.installed, vc.displayFeature("prefs.display_services_manager", .displayServicesManager)) + .addView(when: Valet.installed, vc.displayFeature("prefs.display_valet_integration", .displayValetIntegration)) + .addView(when: true, vc.displayFeature("prefs.display_php_config_finder", .displayPhpConfigFinder)) + .addView(when: true, vc.displayFeature("prefs.display_composer_toolkit", .displayComposerToolkit)) + .addView(when: true, vc.displayFeature("prefs.display_limits_widget", .displayLimitsWidget)) + .addView(when: true, vc.displayFeature("prefs.display_extensions", .displayExtensions)) + .addView(when: true, vc.displayFeature("prefs.display_presets", .displayPresets)) + .addView(when: true, vc.displayFeature("prefs.display_misc", .displayMisc)) + + return vc + } +} + +class NotificationPreferencesVC: GenericPreferenceVC { + + public static func fromStoryboard() -> GenericPreferenceVC { + let vc = NSStoryboard(name: "Main", bundle: nil) + .instantiateController(withIdentifier: "preferencesTemplateVC") as! GenericPreferenceVC + + _ = vc.addView(when: true, vc.getNotifyAboutVersionChangePV()) + .addView(when: true, vc.getNotifyAboutPresetsPV()) + .addView(when: Valet.installed, vc.getNotifyAboutSecureTogglePV()) + .addView(when: true, vc.getNotifyAboutGlobalComposerStatusPV()) + .addView(when: true, vc.getNotifyAboutServicesPV()) + .addView(when: Valet.installed, vc.getNotifyAboutPhpFpmChangePV()) + .addView(when: Valet.installed, vc.getWarnAboutNonStandardTldPV()) + + return vc + } + +} diff --git a/phpmon/Domain/Preferences/PrefsVC.swift b/phpmon/Domain/Preferences/PreferencesVC.swift similarity index 70% rename from phpmon/Domain/Preferences/PrefsVC.swift rename to phpmon/Domain/Preferences/PreferencesVC.swift index 8091174..8b594fd 100644 --- a/phpmon/Domain/Preferences/PrefsVC.swift +++ b/phpmon/Domain/Preferences/PreferencesVC.swift @@ -1,5 +1,5 @@ // -// PrefsVC.swift +// PreferencesVC.swift // PHP Monitor // // Created by Nico Verbruggen on 30/03/2021. @@ -28,6 +28,14 @@ class GenericPreferenceVC: NSViewController { Log.perf("deinit: \(String(describing: self)).\(#function)") } + func addView(when condition: Bool, _ view: NSView) -> GenericPreferenceVC { + if condition { + self.views.append(view) + } + + return self + } + func getDynamicIconPV() -> NSView { return CheckboxPreferenceView.make( sectionText: "prefs.dynamic_icon".localized, @@ -66,7 +74,7 @@ class GenericPreferenceVC: NSViewController { ) } - func getAutoRestartPV() -> NSView { + func getAutoRestartServicesPV() -> NSView { return CheckboxPreferenceView.make( sectionText: "prefs.services".localized, descriptionText: "prefs.auto_restart_services_desc".localized, @@ -188,7 +196,7 @@ class GenericPreferenceVC: NSViewController { ) } - func getWarnAboutNonStandardTLD() -> NSView { + func getWarnAboutNonStandardTldPV() -> NSView { return CheckboxPreferenceView.make( sectionText: "prefs.warnings".localized, descriptionText: "prefs.warn_about_non_standard_tld_desc".localized, @@ -198,7 +206,7 @@ class GenericPreferenceVC: NSViewController { ) } - func getDisplayMenuSectionPV( + func displayFeature( _ localizationKey: String, _ preference: PreferenceName, _ first: Bool = false @@ -225,88 +233,3 @@ class GenericPreferenceVC: NSViewController { } } } - -class GeneralPreferencesVC: GenericPreferenceVC { - - // MARK: - Lifecycle - - public static func fromStoryboard() -> GenericPreferenceVC { - let vc = NSStoryboard(name: "Main", bundle: nil) - .instantiateController(withIdentifier: "preferencesTemplateVC") as! GenericPreferenceVC - - vc.views = [ - vc.getShowPhpDoctorSuggestionsPV(), - vc.getAutoRestartPV(), - vc.getAutomaticComposerUpdatePV(), - vc.getShortcutPV(), - vc.getIntegrationsPV(), - vc.getAutomaticUpdateCheckPV() - ] - - if #available(macOS 13, *) { - vc.views.append(CheckboxPreferenceView.makeLoginItemView()) - } - - return vc - } -} - -class NotificationPreferencesVC: GenericPreferenceVC { - - public static func fromStoryboard() -> GenericPreferenceVC { - let vc = NSStoryboard(name: "Main", bundle: nil) - .instantiateController(withIdentifier: "preferencesTemplateVC") as! GenericPreferenceVC - - vc.views = [ - vc.getNotifyAboutVersionChangePV(), - vc.getNotifyAboutPresetsPV(), - vc.getNotifyAboutSecureTogglePV(), - vc.getNotifyAboutGlobalComposerStatusPV(), - vc.getNotifyAboutServicesPV(), - vc.getNotifyAboutPhpFpmChangePV(), - vc.getWarnAboutNonStandardTLD() - ] - - return vc - } - -} - -class MenuStructurePreferencesVC: GenericPreferenceVC { - - public static func fromStoryboard() -> GenericPreferenceVC { - let vc = NSStoryboard(name: "Main", bundle: nil) - .instantiateController(withIdentifier: "preferencesTemplateVC") as! GenericPreferenceVC - - vc.views = [ - vc.getDisplayMenuSectionPV("prefs.display_global_version_switcher", .displayGlobalVersionSwitcher, true), - vc.getDisplayMenuSectionPV("prefs.display_services_manager", .displayServicesManager), - vc.getDisplayMenuSectionPV("prefs.display_valet_integration", .displayValetIntegration), - vc.getDisplayMenuSectionPV("prefs.display_php_config_finder", .displayPhpConfigFinder), - vc.getDisplayMenuSectionPV("prefs.display_composer_toolkit", .displayComposerToolkit), - vc.getDisplayMenuSectionPV("prefs.display_limits_widget", .displayLimitsWidget), - vc.getDisplayMenuSectionPV("prefs.display_extensions", .displayExtensions), - vc.getDisplayMenuSectionPV("prefs.display_presets", .displayPresets), - vc.getDisplayMenuSectionPV("prefs.display_misc", .displayMisc) - - ] - - return vc - } -} - -class AppearancePreferencesVC: GenericPreferenceVC { - - public static func fromStoryboard() -> GenericPreferenceVC { - let vc = NSStoryboard(name: "Main", bundle: nil) - .instantiateController(withIdentifier: "preferencesTemplateVC") as! GenericPreferenceVC - - vc.views = [ - vc.getDynamicIconPV(), - vc.getIconOptionsPV(), - vc.getIconDensityPV() - ] - - return vc - } -} diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index ecf27a4..22bae1c 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -71,6 +71,7 @@ "mi_preferences" = "Preferences..."; "mi_donate" = "Donate..."; "mi_check_for_updates" = "Check for Updates..."; +"mi_lite_mode" = "About Standalone Mode..."; "mi_quit" = "Quit PHP Monitor"; "mi_about" = "About PHP Monitor"; @@ -128,6 +129,12 @@ You may be asked for your password during the uninstallation process if file per "phpman.unlinked.desc" = "You likely still have some version of PHP that is currently installed, but currently no version of PHP is linked."; "phpman.unlinked.detail" = "Without any PHP version linked, the `php` binary is not accessible on your system and you cannot run any PHP scripts without explicitly being part of the PATH. You can have PHP Monitor automatically resolve this problem (choose Fix Automatically in the main menu), or fix it yourself by running `brew link php --force`."; +// LITE MODE + +"lite_mode_explanation.title" = "You are currently running PHP Monitor in Standalone Mode."; +"lite_mode_explanation.subtitle" = "PHP Monitor has additional features that are available for use if you happen to be a user of Laravel Valet. Right now, PHP Monitor could not detect an active installation of Valet on your system, so those features are unavailable."; +"lite_mode_explanation.description" = "For more information, I'd recommend checking out the README (accessible on GitHub) which will explain what steps you need to take to install Valet and make PHP Monitor run correctly with it installed. You will need to restart PHP Monitor after installing Laravel Valet before it will leave Standalone Mode."; + // GENERIC "generic.ok" = "OK";