Skip to content

Commit 414307f

Browse files
committed
Add "Launch at Login" functionality
1 parent 0fdf7e8 commit 414307f

File tree

7 files changed

+100
-12
lines changed

7 files changed

+100
-12
lines changed

TinyTimeTracker/TinyTimeTracker.xcodeproj/project.pbxproj

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
5760FE502826B71B00711481 /* LaunchAtLogin in Frameworks */ = {isa = PBXBuildFile; productRef = 5760FE4F2826B71B00711481 /* LaunchAtLogin */; };
1011
579298A9280B6B78004E0F90 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 579298A8280B6B78004E0F90 /* AppDelegate.swift */; };
1112
579298AD280B6B78004E0F90 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 579298AC280B6B78004E0F90 /* Assets.xcassets */; };
1213
579298B0280B6B78004E0F90 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 579298AE280B6B78004E0F90 /* Main.storyboard */; };
@@ -29,6 +30,7 @@
2930
isa = PBXFrameworksBuildPhase;
3031
buildActionMask = 2147483647;
3132
files = (
33+
5760FE502826B71B00711481 /* LaunchAtLogin in Frameworks */,
3234
);
3335
runOnlyForDeploymentPostprocessing = 0;
3436
};
@@ -74,12 +76,16 @@
7476
579298A1280B6B78004E0F90 /* Sources */,
7577
579298A2280B6B78004E0F90 /* Frameworks */,
7678
579298A3280B6B78004E0F90 /* Resources */,
79+
5760FE512826B73900711481 /* ShellScript */,
7780
);
7881
buildRules = (
7982
);
8083
dependencies = (
8184
);
8285
name = TinyTimeTracker;
86+
packageProductDependencies = (
87+
5760FE4F2826B71B00711481 /* LaunchAtLogin */,
88+
);
8389
productName = TinyTimeTracker;
8490
productReference = 579298A5280B6B78004E0F90 /* TinyTimeTracker.app */;
8591
productType = "com.apple.product-type.application";
@@ -109,6 +115,9 @@
109115
ru,
110116
);
111117
mainGroup = 5792989C280B6B77004E0F90;
118+
packageReferences = (
119+
5760FE4E2826B71B00711481 /* XCRemoteSwiftPackageReference "LaunchAtLogin" */,
120+
);
112121
productRefGroup = 579298A6280B6B78004E0F90 /* Products */;
113122
projectDirPath = "";
114123
projectRoot = "";
@@ -131,6 +140,26 @@
131140
};
132141
/* End PBXResourcesBuildPhase section */
133142

143+
/* Begin PBXShellScriptBuildPhase section */
144+
5760FE512826B73900711481 /* ShellScript */ = {
145+
isa = PBXShellScriptBuildPhase;
146+
buildActionMask = 2147483647;
147+
files = (
148+
);
149+
inputFileListPaths = (
150+
);
151+
inputPaths = (
152+
);
153+
outputFileListPaths = (
154+
);
155+
outputPaths = (
156+
);
157+
runOnlyForDeploymentPostprocessing = 0;
158+
shellPath = /bin/sh;
159+
shellScript = "${BUILT_PRODUCTS_DIR}/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/copy-helper-swiftpm.sh\n";
160+
};
161+
/* End PBXShellScriptBuildPhase section */
162+
134163
/* Begin PBXSourcesBuildPhase section */
135164
579298A1280B6B78004E0F90 /* Sources */ = {
136165
isa = PBXSourcesBuildPhase;
@@ -301,7 +330,7 @@
301330
"$(inherited)",
302331
"@executable_path/../Frameworks",
303332
);
304-
MARKETING_VERSION = 1.0;
333+
MARKETING_VERSION = 1.1.0;
305334
PRODUCT_BUNDLE_IDENTIFIER = nyok.TinyTimeTracker;
306335
PRODUCT_NAME = "$(TARGET_NAME)";
307336
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -331,7 +360,7 @@
331360
"$(inherited)",
332361
"@executable_path/../Frameworks",
333362
);
334-
MARKETING_VERSION = 1.0;
363+
MARKETING_VERSION = 1.1.0;
335364
PRODUCT_BUNDLE_IDENTIFIER = nyok.TinyTimeTracker;
336365
PRODUCT_NAME = "$(TARGET_NAME)";
337366
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -362,6 +391,25 @@
362391
defaultConfigurationName = Release;
363392
};
364393
/* End XCConfigurationList section */
394+
395+
/* Begin XCRemoteSwiftPackageReference section */
396+
5760FE4E2826B71B00711481 /* XCRemoteSwiftPackageReference "LaunchAtLogin" */ = {
397+
isa = XCRemoteSwiftPackageReference;
398+
repositoryURL = "https://github.com/sindresorhus/LaunchAtLogin";
399+
requirement = {
400+
branch = main;
401+
kind = branch;
402+
};
403+
};
404+
/* End XCRemoteSwiftPackageReference section */
405+
406+
/* Begin XCSwiftPackageProductDependency section */
407+
5760FE4F2826B71B00711481 /* LaunchAtLogin */ = {
408+
isa = XCSwiftPackageProductDependency;
409+
package = 5760FE4E2826B71B00711481 /* XCRemoteSwiftPackageReference "LaunchAtLogin" */;
410+
productName = LaunchAtLogin;
411+
};
412+
/* End XCSwiftPackageProductDependency section */
365413
};
366414
rootObject = 5792989D280B6B77004E0F90 /* Project object */;
367415
}

TinyTimeTracker/TinyTimeTracker.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TinyTimeTracker/TinyTimeTracker.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TinyTimeTracker/TinyTimeTracker/AppDelegate.swift

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55

66
import Cocoa
7+
import LaunchAtLogin
78

89
@main
910
class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
@@ -28,6 +29,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
2829
@IBOutlet weak var statisticsMenuItem: NSMenuItem!
2930
@IBOutlet weak var workTimerMenuItem: NSMenuItem!
3031
@IBOutlet weak var restTimerMenuItem: NSMenuItem!
32+
@IBOutlet weak var launchAtLoginMenuItem: NSMenuItem!
3133
@IBOutlet weak var quitMenuItem: NSMenuItem!
3234

3335
@IBAction func startStopClicked(_ sender: NSMenuItem) {
@@ -59,6 +61,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
5961
NSWorkspace.shared.open(logFile)
6062
}
6163

64+
@IBAction func launchAtLoginClicked(_ sender: NSMenuItem) {
65+
sender.state = sender.state == .on ? .off : .on
66+
if sender.state == .on {
67+
LaunchAtLogin.isEnabled = true
68+
} else {
69+
LaunchAtLogin.isEnabled = false
70+
}
71+
}
72+
6273
@IBAction func quitClicked(_ sender: NSMenuItem) {
6374
if(appRunning) {
6475
stopAllTimer()
@@ -71,13 +82,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
7182
}
7283

7384
func applicationDidFinishLaunching(_ aNotification: Notification) {
74-
icon?.isTemplate = true
75-
iconWork?.isTemplate = true
76-
iconRest?.isTemplate = true
77-
changeModeMenuItem.title = NSLocalizedString("menuTextChangemode", comment: "")
78-
79-
statisticsMenuItem.title = NSLocalizedString("menuTextStatistics", comment: "")
80-
quitMenuItem.title = NSLocalizedString("menuTextQuit", comment: "")
8185
createStatusMenu()
8286
}
8387

@@ -90,7 +94,19 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
9094

9195
func createStatusMenu() {
9296
statusItem.button?.image = icon
97+
icon?.isTemplate = true
98+
iconWork?.isTemplate = true
99+
iconRest?.isTemplate = true
93100
statusItem.menu = statusMenu
101+
if LaunchAtLogin.isEnabled {
102+
launchAtLoginMenuItem.state = .on
103+
} else {
104+
launchAtLoginMenuItem.state = .off
105+
}
106+
changeModeMenuItem.title = NSLocalizedString("menuTextChangemode", comment: "")
107+
statisticsMenuItem.title = NSLocalizedString("menuTextStatistics", comment: "")
108+
launchAtLoginMenuItem.title = NSLocalizedString("menuTextLaunchAtLogin", comment: "")
109+
quitMenuItem.title = NSLocalizedString("menuTextQuit", comment: "")
94110
}
95111

96112
func menuWillOpen(_: NSMenu) {

TinyTimeTracker/TinyTimeTracker/Base.lproj/Main.storyboard

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
55
</dependencies>
66
<scenes>
77
<!--Application-->
@@ -12,6 +12,7 @@
1212
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="TinyTimeTracker" customModuleProvider="target">
1313
<connections>
1414
<outlet property="changeModeMenuItem" destination="zcj-5o-7BO" id="VId-mH-dfZ"/>
15+
<outlet property="launchAtLoginMenuItem" destination="kHe-cK-j9E" id="YjN-ax-Q9e"/>
1516
<outlet property="quitMenuItem" destination="u81-b3-YS7" id="Def-Kc-Oyv"/>
1617
<outlet property="restTimerMenuItem" destination="dmx-g4-gzN" id="9Vc-8P-9Np"/>
1718
<outlet property="startStopMenuItem" destination="k7j-Rw-Pdr" id="bR1-t9-XIO"/>
@@ -69,6 +70,13 @@
6970
<action selector="statisticsClicked:" target="Voe-Tx-rLC" id="JYZ-uM-3hx"/>
7071
</connections>
7172
</menuItem>
73+
<menuItem isSeparatorItem="YES" id="uas-QH-cD5"/>
74+
<menuItem title="launchAtLogin" id="kHe-cK-j9E">
75+
<modifierMask key="keyEquivalentModifierMask"/>
76+
<connections>
77+
<action selector="launchAtLoginClicked:" target="Voe-Tx-rLC" id="ibo-Dk-ZVX"/>
78+
</connections>
79+
</menuItem>
7280
<menuItem title="quit" keyEquivalent="q" id="u81-b3-YS7">
7381
<connections>
7482
<action selector="quitClicked:" target="Voe-Tx-rLC" id="tIy-Hj-ZOV"/>

TinyTimeTracker/TinyTimeTracker/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"menuTextStop" = "Stop";
88
"menuTextChangemode" = "Change mode";
99
"menuTextStatistics" = "Statistics";
10+
"menuTextLaunchAtLogin" = "Launch at login";
1011
"menuTextQuit" = "Quit";
1112
"textWork" = "Work";
1213
"textRest" = "Rest";

TinyTimeTracker/TinyTimeTracker/ru.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"menuTextStop" = "Стоп";
88
"menuTextChangemode" = "Сменить режим";
99
"menuTextStatistics" = "Статистика";
10+
"menuTextLaunchAtLogin" = "Запускать при старте";
1011
"menuTextQuit" = "Выход";
1112
"textWork" = "Работа";
1213
"textRest" = "Безделье";

0 commit comments

Comments
 (0)