we now have preferences

use it to:
 - move the dock/mouse
 - smaller deathzone
 - check for updates (sparkle yayyy)
 - quit
this took way too long
This commit is contained in:
neon443
2025-05-30 18:42:50 +01:00
parent 6c9d65f026
commit 8a4b0f0f65
6 changed files with 159 additions and 43 deletions

BIN
DockPhobia/.DS_Store vendored
View File

Binary file not shown.

View File

@@ -51,21 +51,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let start = NSMenuItem(title: describeStartButton(), action: #selector(didTapStart), keyEquivalent: "") let start = NSMenuItem(title: describeStartButton(), action: #selector(didTapStart), keyEquivalent: "")
menu.addItem(start) menu.addItem(start)
let checkforUpdatesMenuItem = NSMenuItem(
title: "Check for Updates...",
action: #selector(SPUStandardUpdaterController.checkForUpdates(_:)),
keyEquivalent: ""
)
checkforUpdatesMenuItem.target = updateController
menu.addItem(checkforUpdatesMenuItem)
let screen = NSMenuItem(
title: "\(mouseTracker.screen.width)x\(mouseTracker.screen.height)",
action: nil,
keyEquivalent: ""
)
menu.addItem(screen)
let dockMoves = NSMenuItem( let dockMoves = NSMenuItem(
title: "Moved the Dock \(settings.settings.dockMoves) time\(settings.settings.dockMoves.plural)", title: "Moved the Dock \(settings.settings.dockMoves) time\(settings.settings.dockMoves.plural)",
action: nil, action: nil,
@@ -91,29 +76,28 @@ class AppDelegate: NSObject, NSApplicationDelegate {
menu.addItem(NSMenuItem.separator()) menu.addItem(NSMenuItem.separator())
let checkfullscreenButton = NSMenuItem(
title: "Smaller deathzone in fullscreen",
action: #selector(checkFullscreenToggle),
keyEquivalent: ""
)
checkfullscreenButton.state = NSControl.StateValue(rawValue: settings.settings.checkFullscreen ? 1 : 0)
menu.addItem(checkfullscreenButton)
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem( menu.addItem(NSMenuItem(
title: "Move Dock to the left", title: "Move Dock to the left",
action: #selector(moveDockObjcLeft), action: #selector(moveDockObjcLeft),
keyEquivalent: "")) keyEquivalent: "1"))
menu.addItem(NSMenuItem( menu.addItem(NSMenuItem(
title: "Move Dock to the bottom", title: "Move Dock to the bottom",
action: #selector(moveDockObjcBottom), action: #selector(moveDockObjcBottom),
keyEquivalent: "")) keyEquivalent: "2"))
menu.addItem(NSMenuItem( menu.addItem(NSMenuItem(
title: "Move Dock to the right", title: "Move Dock to the right",
action: #selector(moveDockObjcRight), action: #selector(moveDockObjcRight),
keyEquivalent: "")) keyEquivalent: "3"))
menu.addItem(NSMenuItem.separator()) menu.addItem(NSMenuItem.separator())
let checkforUpdatesMenuItem = NSMenuItem(
title: "Check for Updates...",
action: #selector(SPUStandardUpdaterController.checkForUpdates(_:)),
keyEquivalent: ""
)
checkforUpdatesMenuItem.target = updateController
menu.addItem(checkforUpdatesMenuItem)
let prefs = NSMenuItem( let prefs = NSMenuItem(
title: "Preferences", title: "Preferences",
action: #selector(tappedPrefs), action: #selector(tappedPrefs),
@@ -136,9 +120,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
} }
@objc func tappedPrefs() { @objc func tappedPrefs() {
if prefsWindow == nil { if prefsWindow == nil {
prefsWindow = DPPreferencesWindowController() prefsWindow = DPPreferencesWindowController(
mouseTracker: mouseTracker,
settings: settings,
updater: updateController
)
} }
prefsWindow!.showWindow(nil)
prefsWindow!.window?.orderFront(nil) prefsWindow!.window?.orderFront(nil)
} }
@objc func didTapStart() { @objc func didTapStart() {

View File

@@ -196,7 +196,7 @@ class MouseTracker {
let scriptMove = """ let scriptMove = """
tell application "System Events" tell application "System Events"
tell dock preferences tell dock preferences
set screen edge to \(toSide) set screen edge to \(toSide)
end tell end tell
end tell end tell
""" """

View File

@@ -10,7 +10,16 @@ import AppKit
import Sparkle import Sparkle
class DPPreferencesWindowController: NSWindowController { class DPPreferencesWindowController: NSWindowController {
var mouseTracker: MouseTracker?
var settings: DPSettingsModel?
var updater: SPUStandardUpdaterController?
@IBOutlet weak var mouseRadio: NSButton!
@IBOutlet weak var dockRadio: NSButton!
@IBOutlet weak var updateCheckButton: NSButton! @IBOutlet weak var updateCheckButton: NSButton!
@IBOutlet weak var smallDeathzoneToggle: NSButton!
@IBOutlet weak var quitbutton: NSButton!
override init(window: NSWindow?) { override init(window: NSWindow?) {
super.init(window: window) super.init(window: window)
@@ -20,7 +29,43 @@ class DPPreferencesWindowController: NSWindowController {
super.init(coder: coder) super.init(coder: coder)
} }
convenience init() { convenience init(mouseTracker: MouseTracker, settings: DPSettingsModel, updater: SPUStandardUpdaterController) {
self.init(windowNibName: "Preferences") self.init(windowNibName: "Preferences")
self.mouseTracker = mouseTracker
self.settings = settings
self.updater = updater
}
override func windowDidLoad() {
smallDeathzoneToggle.state = NSControl.StateValue(
settings!.settings.checkFullscreen ? 1 : 0
)
dockRadio.state = NSControl.StateValue(
settings!.settings.moveMouseInstead ? 0 : 1
)
mouseRadio.state = NSControl.StateValue(
settings!.settings.moveMouseInstead ? 1 : 0
)
}
@IBAction func checkUpdates(_ sender: Any) {
updater?.checkForUpdates(nil)
}
@IBAction func MoveTypeSelect(_ sender: Any) {
if dockRadio.state.rawValue == 1 {
settings?.settings.moveMouseInstead = false
} else {
settings?.settings.moveMouseInstead = true
}
refreshMenus()
}
@IBAction func quit(_ sender: Any) {
NSApplication.shared.terminate(nil)
}
@IBAction func smallDeathzoneToggle(_ sender: Any) {
settings?.settings.checkFullscreen.toggle()
} }
} }

View File

@@ -8,32 +8,115 @@
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="DPPreferencesWindowController" customModule="DockPhobia" customModuleProvider="target"> <customObject id="-2" userLabel="File's Owner" customClass="DPPreferencesWindowController" customModule="DockPhobia" customModuleProvider="target">
<connections> <connections>
<outlet property="updateCheckButton" destination="bnA-Vz-L4F" id="8Zf-Am-gPt"/> <outlet property="dockRadio" destination="SML-7D-HqD" id="4QO-vf-9ma"/>
<outlet property="mouseRadio" destination="xQV-F8-e5K" id="2cJ-W4-uYY"/>
<outlet property="quitbutton" destination="7DK-yJ-I42" id="fDP-cd-88f"/>
<outlet property="smallDeathzoneToggle" destination="TNA-PK-KGC" id="rTv-BF-hv6"/>
<outlet property="updateCheckButton" destination="bnA-Vz-L4F" id="16N-mV-Agw"/>
<outlet property="window" destination="85c-fa-xeM" id="B5X-4l-mcR"/> <outlet property="window" destination="85c-fa-xeM" id="B5X-4l-mcR"/>
</connections> </connections>
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="85c-fa-xeM"> <window title="DockPhobia Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="85c-fa-xeM">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" texturedBackground="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="683" y="389" width="423" height="186"/>
<rect key="contentRect" x="167" y="210" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1710" height="1069"/> <rect key="screenRect" x="0.0" y="0.0" width="1710" height="1069"/>
<view key="contentView" id="wEz-dE-A27"> <view key="contentView" wantsLayer="YES" id="wEz-dE-A27">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/> <rect key="frame" x="0.0" y="0.0" width="423" height="186"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bnA-Vz-L4F"> <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bnA-Vz-L4F">
<rect key="frame" x="203" y="118" width="75" height="32"/> <rect key="frame" x="13" y="8" width="159" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XBJ-UK-x73"> <buttonCell key="cell" type="push" title="Check for Updates..." bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XBJ-UK-x73">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
</buttonCell> </buttonCell>
<connections>
<action selector="checkUpdates:" target="-2" id="AX2-PR-jPb"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="SML-7D-HqD">
<rect key="frame" x="87" y="149" width="67" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<buttonCell key="cell" type="radio" title="Dock" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="Lxi-8n-jY3">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="MoveTypeSelect:" target="-2" id="PP9-SC-6xN"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xQV-F8-e5K">
<rect key="frame" x="87" y="121" width="67" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<buttonCell key="cell" type="radio" title="Mouse" bezelStyle="regularSquare" imagePosition="left" inset="2" id="86E-Km-LZ7">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="MoveTypeSelect:" target="-2" id="dfh-6B-58k"/>
</connections>
</button>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="U5P-YK-hTs">
<rect key="frame" x="18" y="150" width="60" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Move the" id="4wN-vE-QCE">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vyh-vP-oAh">
<rect key="frame" x="160" y="150" width="245" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="when the cursor gets close to the Dock." id="y3x-vy-qbu">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="TNA-PK-KGC">
<rect key="frame" x="18" y="81" width="216" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Smaller deathzone in fullscreen" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="28Y-O4-oAQ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="smallDeathzoneToggle:" target="-2" id="zlu-Ca-p04"/>
</connections>
</button>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Pd-Xt-fTA">
<rect key="frame" x="18" y="60" width="136" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="May reduce performance" id="Orh-5m-Me2">
<font key="font" metaFont="system" size="11"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7DK-yJ-I42">
<rect key="frame" x="343" y="14" width="60" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="roundRect" title="Quit" bezelStyle="roundedRect" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="jbc-01-FBx">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="quit:" target="-2" id="483-Pc-QoS"/>
</connections>
</button> </button>
</subviews> </subviews>
</view> </view>
<point key="canvasLocation" x="-185" y="-61"/> <toolbar key="toolbar" implicitIdentifier="3DBA283D-9272-4F9B-8799-AA8355F2BE79" autosavesConfiguration="NO" showsBaselineSeparator="NO" displayMode="iconAndLabel" sizeMode="regular" id="MWN-PM-U77">
<allowedToolbarItems/>
<defaultToolbarItems/>
</toolbar>
<contentBorderThickness minY="0.0" maxY="0.0"/>
<point key="canvasLocation" x="-213.5" y="-103"/>
</window> </window>
<userDefaultsController representsSharedInstance="YES" id="zYZ-vc-iso"/>
</objects> </objects>
</document> </document>

BIN
DockPhobiaPy/.DS_Store vendored
View File

Binary file not shown.