Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit dd4d012

Browse files
committed
Mac Support done
1 parent d6aede9 commit dd4d012

File tree

10 files changed

+61
-25
lines changed

10 files changed

+61
-25
lines changed

core/Utilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
class Utilities {
66

7-
const VERSION = 'v0.6.0 alpha';
7+
const VERSION = 'v0.7.0 alpha';
88

99
/**
1010
* OS Consts

core/platform/MacDialog.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,37 @@
22

33
class MacDialog extends Dialog {
44

5+
const MAC_DIALOG = __DIR__ . '/macos/TaskTimeTerminate.app/Contents/MacOS/TaskTimeTerminate';
6+
57
public function open() : void {
8+
$cmd = array(
9+
self::MAC_DIALOG,
10+
'-cats',
11+
'"'. implode(',', $this->categories) .'"'
12+
);
13+
exec(implode(' ', $cmd), $stdout, $return);
614

7-
/**
8-
* ToDo
9-
*/
15+
if( $return === 0 && !empty($stdout) ){
16+
$stdout = json_decode($stdout[0], true);
1017

11-
$d = new InTerminalDialog();
12-
$d->setCategories($this->categories);
13-
$d->open();
14-
$this->chCategory = $d->getChosenCategory();
15-
$this->chName = $d->getChosenName();
16-
$this->chTime = $d->getChosenTime();
18+
if( $stdout['pause'] ){
19+
$this->shortBreak = true;
20+
}
21+
else{
22+
$this->chCategory = in_array($stdout['cat'], $this->categories) ? array_search($stdout['cat'], $this->categories) : null; // category id
23+
$this->chName = InputParser::checkNameInput($stdout['name']) ? $stdout['name'] : null;
24+
$this->chTime = InputParser::checkTimeInput($stdout['time']) ? $stdout['time'] : null;
1725

26+
if( is_null($this->chCategory) || is_null( $this->chTime ) || is_null($this->chName)){
27+
$this->open();
28+
return;
29+
}
30+
}
31+
}
32+
else { // error
33+
$this->open();
34+
return;
35+
}
1836
}
1937

2038
public static function checkOSPackages() : void {
Binary file not shown.

core/platform/macos/TaskTimeTerminate.app/Contents/_CodeSignature/CodeResources

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
<dict>
77
<key>Resources/Base.lproj/Main.storyboardc/Info.plist</key>
88
<data>
9-
ZN1eRSyZEALXwXo1ku1sRx63Q1k=
9+
DiSUbmXvQvqY7x2/oE96H2NEtUw=
1010
</data>
1111
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
1212
<data>
13-
aY9MJm+N6l6+8b5jLh3D59MNenc=
13+
IQsFH80gY6fBchH0ef9VMMLdZUk=
1414
</data>
1515
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
1616
<data>
17-
ddoJfBk/YT/X8jNv6qgAwgyjzCk=
17+
f+UKI1tIL0DBtbFgZJg1asfp4pY=
1818
</data>
1919
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
2020
<data>
21-
fqWkLyq0DlMIoyA82qD9i5+QQ9o=
21+
RQhhd8f6VNGPeZ//rXqtwUIL+Jo=
2222
</data>
2323
<key>Resources/en.lproj/Main.strings</key>
2424
<dict>
@@ -36,28 +36,28 @@
3636
<dict>
3737
<key>hash2</key>
3838
<data>
39-
RBg2dr2qv70fgwq1nEaDO0JxcQuvoAlBvu2zzxhTeco=
39+
fdTh9cwTl5YcU1c3bL4sqi1dUzrpHagjFZzlRzmAv7s=
4040
</data>
4141
</dict>
4242
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
4343
<dict>
4444
<key>hash2</key>
4545
<data>
46-
9WbD7MPxnz+d/D19b9AQCcHCJLzf7S0ED1VLRiAjDZY=
46+
2sHlhd/y5zaoN304U/77mvq4CKxgomuu3ZmquXYFMZ8=
4747
</data>
4848
</dict>
4949
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
5050
<dict>
5151
<key>hash2</key>
5252
<data>
53-
OMrsn7FvGRRh0Iyl3Kf/gXHBTdCoxwj06y9AcZUO+9g=
53+
w2aeIh12aIFgj58/49oNDNHmnQLt1r4ysmnx8sQ8dJI=
5454
</data>
5555
</dict>
5656
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
5757
<dict>
5858
<key>hash2</key>
5959
<data>
60-
yYx+hgxKr5pv8BzjutQ9SfbZqc8DDLGRR3AzB+422jM=
60+
6QebTVxtaLwhGPCIsNq8mM2tb4VwOe0KFKestIphND0=
6161
</data>
6262
</dict>
6363
<key>Resources/en.lproj/Main.strings</key>

core/platform/macos/TaskTimeTerminate/TaskTimeTerminate/AppDelegate.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
1616

1717
func applicationWillTerminate(_ aNotification: Notification) {
1818
}
19-
19+
2020
private func tapplicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
2121
return true;
2222
}
23+
24+
func windowShouldClose(_ sender: Any) {
25+
NSApplication.shared.terminate(self)
26+
}
2327
}

core/platform/macos/TaskTimeTerminate/TaskTimeTerminate/ViewController.swift

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
import Cocoa
1010

11+
extension FileHandle : TextOutputStream {
12+
public func write(_ string: String) {
13+
self.write(string.data(using: .utf8) ?? Data());
14+
}
15+
}
16+
1117
class ViewController: NSViewController {
1218

1319
@IBOutlet weak var categoryDropdown: NSPopUpButtonCell!
@@ -18,19 +24,22 @@ class ViewController: NSViewController {
1824

1925

2026
@IBAction func startClicked(_ sender: NSButton) {
21-
var output = "{ pause : false, ";
22-
output += " cat: \"" + (categoryDropdown.titleOfSelectedItem ?? "").replacingOccurrences(of: "\"", with: "") + "\", ";
23-
output += " name: \"" + nameInput.stringValue.replacingOccurrences(of: "\"", with: "") + "\", ";
24-
output += " time: \"" + timeInput.stringValue.replacingOccurrences(of: "\"", with: "") + "\" ";
27+
var output = "{ \"pause\" : false, ";
28+
output += " \"cat\": \"" + (categoryDropdown.titleOfSelectedItem ?? "").replacingOccurrences(of: "\"", with: "") + "\", ";
29+
output += " \"name\": \"" + nameInput.stringValue.replacingOccurrences(of: "\"", with: "") + "\", ";
30+
output += " \"time\": \"" + timeInput.stringValue.replacingOccurrences(of: "\"", with: "") + "\" ";
2531
output += "}";
2632

27-
print(output);
33+
var stdOut = FileHandle.standardOutput;
34+
print(output, to:&stdOut);
2835

2936
NSApplication.shared.terminate(self);
3037
}
3138

3239
@IBAction func pauseClicked(_ sender: NSButton) {
33-
print("{ pause : true, cat: \"\", name: \"\", time: \"\" }");
40+
var stdOut = FileHandle.standardOutput;
41+
print("{ \"pause\" : true, \"cat\": \"\", \"name\": \"\", \"time\": \"\" }", to:&stdOut);
42+
3443
NSApplication.shared.terminate(self);
3544
}
3645

@@ -45,6 +54,11 @@ class ViewController: NSViewController {
4554
categoryDropdown.removeAllItems();
4655
categoryDropdown.addItems(withTitles: catList);
4756
}
57+
58+
override func viewWillAppear() {
59+
NSApplication.shared.activate(ignoringOtherApps: true);
60+
view.window?.level = .floating;
61+
}
4862

4963
override var representedObject: Any? {
5064
didSet {}

0 commit comments

Comments
 (0)