This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from mribeiro/feature/option_to_hide_dock_icon
Added possibility to hide dock icon.
- Loading branch information
Showing
6 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// DockerIconManager.swift | ||
// Timetracker | ||
// | ||
// Created by Antonio Ribeiro on 11/04/2020. | ||
// Copyright © 2020 Antonio Ribeiro. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Cocoa | ||
|
||
class DockIconManager { | ||
|
||
class func shouldHideIcon() -> Bool { | ||
return UserDefaults().bool(forKey: "hide_dock_icon") | ||
} | ||
|
||
class func set(hideIcon: Bool) { | ||
UserDefaults().set(hideIcon, forKey: "hide_dock_icon") | ||
let policy: NSApplication.ActivationPolicy = hideIcon ? .accessory : .regular | ||
NSApplication.shared.setActivationPolicy(policy) | ||
} | ||
|
||
class func setIconPerConfiguration() { | ||
let hideIcon = shouldHideIcon() | ||
iconHidden(hideIcon) | ||
} | ||
|
||
private class func iconHidden(_ hideIcon: Bool) { | ||
let policy: NSApplication.ActivationPolicy = hideIcon ? .accessory : .regular | ||
NSApplication.shared.setActivationPolicy(policy) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16096" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<objects> | ||
<customObject id="-2" userLabel="File's Owner" customClass="PreferenceMiscViewController" customModule="Timetracker" customModuleProvider="target"> | ||
<connections> | ||
<outlet property="checkboxHideDockIcon" destination="FIw-kP-UfD" id="DU9-Hl-0tY"/> | ||
<outlet property="view" destination="c22-O7-iKe" id="FVV-sG-ed5"/> | ||
</connections> | ||
</customObject> | ||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> | ||
<customObject id="-3" userLabel="Application" customClass="NSObject"/> | ||
<customView id="c22-O7-iKe"> | ||
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | ||
<subviews> | ||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FIw-kP-UfD"> | ||
<rect key="frame" x="18" y="236" width="113" height="18"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | ||
<buttonCell key="cell" type="check" title="Hide dock icon" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="30b-cz-svK"> | ||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> | ||
<font key="font" metaFont="system"/> | ||
</buttonCell> | ||
<connections> | ||
<action selector="hideDockIconChanged:" target="-2" id="4Zh-Ka-NXK"/> | ||
</connections> | ||
</button> | ||
</subviews> | ||
<point key="canvasLocation" x="124" y="154"/> | ||
</customView> | ||
</objects> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// PreferenceMiscViewController.swift | ||
// Timetracker | ||
// | ||
// Created by Antonio Ribeiro on 11/04/2020. | ||
// Copyright © 2020 Antonio Ribeiro. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import AppKit | ||
import Preferences | ||
|
||
class PreferenceMiscViewController: NSViewController, Preferenceable { | ||
@IBOutlet weak var checkboxHideDockIcon: NSButton! | ||
|
||
var toolbarItemTitle: String = "Misc" | ||
|
||
var toolbarItemIcon: NSImage = NSImage(named: "log")! | ||
|
||
override var nibName: NSNib.Name? { | ||
return "PreferenceMiscView" | ||
} | ||
|
||
override func viewWillAppear() { | ||
self.checkboxHideDockIcon.state = DockIconManager.shouldHideIcon() ? .on : .off | ||
} | ||
|
||
@IBAction func hideDockIconChanged(_ sender: NSButtonCell) { | ||
DockIconManager.set(hideIcon: sender.state == .on) | ||
} | ||
|
||
|
||
|
||
|
||
} |