Skip to content

Commit

Permalink
Add initial application.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyáš Kříž committed Sep 8, 2021
1 parent 69816fc commit eb8b14f
Show file tree
Hide file tree
Showing 51 changed files with 2,226 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode
build
Accento.zip
diacritics-macos.xcodeproj/project.xcworkspace/xcuserdata/
diacritics-macos.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Matyáš Kříž

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div align="center">
<img style="width: 150px" src="./img/Accento-logo.png">
</div>

# Acčento
##### [Ak·čento]

---

Acčento is an easy-to-use tool for adding Czech diacritics to copied text. The app lives in the menu bar and is activated using a global hot key.

The app also contains preferences allowing you to customize the hot key as well as other quality of life features.

Props to [<img style="height: 24px" src="./img/Lingea-logo.png">](https://www.nechybujte.cz/nastroje) for providing the incredible diacritics service.

## Installation
Visit [Releases](https://github.com/MatyasKriz/Accento/releases) and download a `.zip` file of the latest version, open it, move the app into the `Applications` folder and launch it.

### Contributing
If you'd like to see a feature implemented, feel free to open a pull request or just a proposal as an issue.

This project isn't following any best practices; that said, please try to keep the code clean and simple. Same with commit messages. Thanks!
485 changes: 485 additions & 0 deletions diacritics-macos.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "LaunchAtLogin",
"repositoryURL": "https://github.com/sindresorhus/LaunchAtLogin",
"state": {
"branch": null,
"revision": "6b16bcdf7d45a9d76a768a5c4912dde925cf0e95",
"version": "4.1.0"
}
}
]
},
"version": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "68B1C7F426DD3A4300A7E552"
BuildableName = "diacritics-macos.app"
BlueprintName = "diacritics-macos"
ReferencedContainer = "container:diacritics-macos.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "68B1C7F426DD3A4300A7E552"
BuildableName = "diacritics-macos.app"
BlueprintName = "diacritics-macos"
ReferencedContainer = "container:diacritics-macos.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "68B1C7F426DD3A4300A7E552"
BuildableName = "diacritics-macos.app"
BlueprintName = "diacritics-macos"
ReferencedContainer = "container:diacritics-macos.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>diacritics-macos.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>68B1C7F426DD3A4300A7E552</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
80 changes: 80 additions & 0 deletions diacritics-macos/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import Cocoa
import Carbon
import SwiftUI

@main
class AppDelegate: NSObject, NSApplicationDelegate {

private var window: NSWindow!

private var popover: NSPopover!
private var statusBarItem: NSStatusItem!

func applicationDidFinishLaunching(_ aNotification: Notification) {
GlobalHotKeyService.installHandler()

let isInitialRegistrationSuccessful: Bool
if let initialHotKey = StorageService.hotKey {
isInitialRegistrationSuccessful = GlobalHotKeyService.registerHotKey(hotKey: initialHotKey)
} else {
isInitialRegistrationSuccessful = true
}

// Create the SwiftUI view that provides the window contents.
let contentView = ContentView(
hotKey: StorageService.hotKey,
isErrored: !isInitialRegistrationSuccessful
)

popover = NSPopover()
popover.contentSize = NSSize(width: 240, height: 360)
popover.behavior = .transient
popover.contentViewController = NSHostingController(rootView: contentView)

statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
constructMenu()

if let button = statusBarItem.button {
button.image = NSImage(named: "logo")
button.image?.size = NSSize(width: 18.0, height: 18.0)
}
}

private func constructMenu() {
let menu = NSMenu()

menu.addItem(NSMenuItem(title: "Menu.Diacriticize".localized, action: #selector(AppDelegate.addDiacritics(_:)), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: "Menu.Preferences".localized, action: #selector(AppDelegate.togglePopover(_:)), keyEquivalent: ","))
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(title: "Menu.Quit".localized, action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q"))

statusBarItem.menu = menu
}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}

@objc
func togglePopover(_ sender: AnyObject?) {
if let button = statusBarItem.button {
if popover.isShown {
popover.performClose(sender)
} else {
popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY)
popover.contentViewController?.view.window?.becomeKey()
}
}
}

@objc
func addDiacritics(_ sender: AnyObject?) {
DiacriticsService.addDiacriticsToClipboardText()
}
}

func hotKeyHandler(nextHandler: EventHandlerCallRef?, eventRef: EventRef?, userData: UnsafeMutableRawPointer?) -> OSStatus {
DiacriticsService.addDiacriticsToClipboardText()

return noErr
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions diacritics-macos/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "AppIcon-16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "AppIcon-32.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "AppIcon-33.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "AppIcon-64.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "AppIcon-128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "AppIcon-256.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "AppIcon-257.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "AppIcon-513.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "AppIcon-512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "AppIcon-1024.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions diacritics-macos/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
29 changes: 29 additions & 0 deletions diacritics-macos/Assets.xcassets/blurple.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xF2",
"green" : "0x65",
"red" : "0x58"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
29 changes: 29 additions & 0 deletions diacritics-macos/Assets.xcassets/crimson.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x3C",
"green" : "0x14",
"red" : "0xDC"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit eb8b14f

Please sign in to comment.