diff --git a/README.md b/README.md index e386d6f..b49ae59 100644 --- a/README.md +++ b/README.md @@ -33,20 +33,25 @@

-### **Features** +## **Features** -**Deasciifier:** Adapt your texts to Turkish with one click. +| Deasciifier | Asciifier | Correction Bubble | Auto | +|---|---|---|---| +| | | | | +| Adapt your texts to Turkish with one click. | Translate Turkish texts to ASCII with one click. | Use correction bubble for manuel edits. | Automatically deasciify as you type. | -**Asciifier:** Also, set your Turkish texts to ASCII with one click. +### **Other features worth mentioning** **Offline:** It works offline, no internet required. -**Tray Application:** It runs as a tray application, not bothering you with dummy screens. - -**Multiplatform:** Every platform are supported; macOS, Windows, and even Linux. +**Multiplatform:** Every platform are supported; **macOS**, **Windows**, and **Linux**. **Auto Update:** It comes with an updater, you can easily update the app. +## **Download** + +[Click go to the latest release](https://github.com/ridvanaltun/turkish-deasciifier/releases/latest) + ## **Authors** This project exists thanks to all the people who contribute. diff --git a/docs/asciify.gif b/docs/asciify.gif new file mode 100644 index 0000000..2a66ec5 Binary files /dev/null and b/docs/asciify.gif differ diff --git a/docs/auto.gif b/docs/auto.gif new file mode 100644 index 0000000..cd189bb Binary files /dev/null and b/docs/auto.gif differ diff --git a/docs/correction-bubble.gif b/docs/correction-bubble.gif new file mode 100644 index 0000000..ae687ef Binary files /dev/null and b/docs/correction-bubble.gif differ diff --git a/docs/deasciify.gif b/docs/deasciify.gif new file mode 100644 index 0000000..a22b88c Binary files /dev/null and b/docs/deasciify.gif differ diff --git a/package-lock.json b/package-lock.json index f8fa587..6024fba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "license": "MIT", "dependencies": { "electron-log": "^4.4.6", + "electron-positioner": "^4.1.0", "electron-store": "^6.0.1", "electron-updater": "^4.6.5", "electron-util": "^0.17.2" @@ -4760,6 +4761,11 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "node_modules/electron-positioner": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/electron-positioner/-/electron-positioner-4.1.0.tgz", + "integrity": "sha512-726DfbI9ZNoCg+Fcu6XLuTKTnzf+6nFqv7h+K/V6Ug7IbaPMI7s9S8URnGtWFCy5N5PL4HSzRFF2mXuinftDdg==" + }, "node_modules/electron-publish": { "version": "22.14.13", "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-22.14.13.tgz", @@ -17763,6 +17769,11 @@ } } }, + "electron-positioner": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/electron-positioner/-/electron-positioner-4.1.0.tgz", + "integrity": "sha512-726DfbI9ZNoCg+Fcu6XLuTKTnzf+6nFqv7h+K/V6Ug7IbaPMI7s9S8URnGtWFCy5N5PL4HSzRFF2mXuinftDdg==" + }, "electron-publish": { "version": "22.14.13", "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-22.14.13.tgz", diff --git a/package.json b/package.json index 6618a7e..aa4fd05 100755 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "homepage": "https://github.com/ridvanaltun/turkish-deasciifier#readme", "dependencies": { "electron-log": "^4.4.6", + "electron-positioner": "^4.1.0", "electron-store": "^6.0.1", "electron-updater": "^4.6.5", "electron-util": "^0.17.2" diff --git a/src/client/index.html b/src/client/index.html index 3dc54f1..461a68e 100644 --- a/src/client/index.html +++ b/src/client/index.html @@ -254,8 +254,8 @@ }); ipcRenderer.on("SET_ARROW_VISIBILITY", (_, enabled) => { - if (enabled) document.getElementById('arrow').style.display = "block" - else document.getElementById('arrow').style.display = "table" + if (enabled) document.getElementById('arrow').style.visibility = "visible" + else document.getElementById('arrow').style.visibility = "hidden" }); diff --git a/src/server/TrayGenerator.js b/src/server/TrayGenerator.js index 8177aa2..6c09be3 100644 --- a/src/server/TrayGenerator.js +++ b/src/server/TrayGenerator.js @@ -1,13 +1,29 @@ -const { Tray, Menu, globalShortcut, nativeImage } = require("electron"); +const { + Tray, + Menu, + globalShortcut, + nativeImage, + clipboard, +} = require("electron"); const path = require("path"); const { autoUpdater } = require("electron-updater"); +const Positioner = require("electron-positioner"); +const { is } = require("electron-util"); const { getWindowPosition } = require("../lib/getWindowPosition"); +const { Deasciifier } = require("../lib/deasciifier.min"); +const patterns = require("../lib/deasciifier.patterns.min"); + +Deasciifier.init(patterns); + class TrayGenerator { constructor(window, store) { this.tray = null; this.window = window; this.store = store; + this.positioner = new Positioner(window); + + Deasciifier.init(patterns); } setArrowVisibility = () => { @@ -30,44 +46,10 @@ class TrayGenerator { setWinPosition = () => { const whereIsTray = getWindowPosition(this.tray); - let x = null; - let y = null; - - const windowBounds = this.window.getBounds(); + // const windowBounds = this.window.getBounds(); const trayBounds = this.tray.getBounds(); - switch (whereIsTray) { - case "trayCenter": - x = Math.round( - trayBounds.x + trayBounds.width / 2 - windowBounds.width / 2 - ); - y = Math.round(trayBounds.y + trayBounds.height); - break; - - case "topRight": - x = Math.round(trayBounds.x + trayBounds.width / 2); - y = Math.round(trayBounds.y + trayBounds.height); - break; - - case "trayBottomCenter": - x = Math.round( - trayBounds.x + trayBounds.width / 2 - windowBounds.width / 2 - ); - y = Math.round(trayBounds.y - windowBounds.height); - break; - - case "bottomLeft": - x = Math.round(trayBounds.x + trayBounds.width); - y = Math.round(trayBounds.y + trayBounds.height - windowBounds.height); - break; - - case "bottomRight": - x = Math.round(trayBounds.x - windowBounds.width); - y = Math.round(trayBounds.y + trayBounds.height - windowBounds.height); - break; - } - - this.window.setPosition(x, y, false); + this.positioner.move(whereIsTray, trayBounds); }; showWindow = () => { @@ -91,16 +73,32 @@ class TrayGenerator { } }; - toggleShortcut = (event) => { - this.store.set("useShortcut", event); + deasciifyClipboard = () => { + const readText = clipboard.readText("clipboard"); + const deasciifyedObject = Deasciifier.deasciify(readText); + clipboard.write(deasciifyedObject, "clipboard"); + }; + + toggleShortcut = (enabled) => { + this.store.set("useToggleShortcut", enabled); - if (event) { + if (enabled) { globalShortcut.register("CommandOrControl+U", this.toggleWindow); } else { globalShortcut.unregister("CommandOrControl+U"); } }; + clipboardShortcut = (enabled) => { + this.store.set("useClipboardShortcut", enabled); + + if (enabled) { + globalShortcut.register("CommandOrControl+1", this.deasciifyClipboard); + } else { + globalShortcut.unregister("CommandOrControl+1"); + } + }; + rightClickMenu = () => { const menu = [ { @@ -140,11 +138,19 @@ class TrayGenerator { click: (event) => this.store.set("launchAtStart", event.checked), }, { - label: "Use CMD+U shortcut", + label: `Toggle with ${is.macos ? "CMD" : "CTRL"}+U shortcut`, type: "checkbox", - checked: this.store.get("useShortcut"), + checked: this.store.get("useToggleShortcut"), click: (event) => this.toggleShortcut(event.checked), }, + { + label: `Deasciify clipboard with ${ + is.macos ? "CMD" : "CTRL" + }+1 shortcut`, + type: "checkbox", + checked: this.store.get("useClipboardShortcut"), + click: (event) => this.clipboardShortcut(event.checked), + }, { type: "separator", }, @@ -195,8 +201,11 @@ class TrayGenerator { this.tray.setIgnoreDoubleClickEvents(true); - const isShortcutEnabled = this.store.get("useShortcut"); - this.toggleShortcut(isShortcutEnabled); + const isToggleShortcutEnabled = this.store.get("useToggleShortcut"); + this.toggleShortcut(isToggleShortcutEnabled); + + const isClipboardShortcutEnabled = this.store.get("useClipboardShortcut"); + this.clipboardShortcut(isClipboardShortcutEnabled); this.tray.on("click", this.toggleWindow); this.tray.on("right-click", this.rightClickMenu); diff --git a/src/server/main.js b/src/server/main.js index 3e56655..4d72027 100755 --- a/src/server/main.js +++ b/src/server/main.js @@ -1,13 +1,8 @@ const path = require("path"); -const { app, BrowserWindow, globalShortcut, clipboard } = require("electron"); +const { app, BrowserWindow, globalShortcut } = require("electron"); const { is } = require("electron-util"); const Store = require("electron-store"); -const { Deasciifier } = require("../lib/deasciifier.min"); -const patterns = require("../lib/deasciifier.patterns.min"); - -Deasciifier.init(patterns); - const TrayGenerator = require("./TrayGenerator"); const AppUpdater = require("./AppUpdater"); @@ -44,8 +39,12 @@ const initStore = () => { store.set("clearOnMinimize", true); } - if (store.get("useShortcut") === undefined) { - store.set("useShortcut", true); + if (store.get("useToggleShortcut") === undefined) { + store.set("useToggleShortcut", true); + } + + if (store.get("useClipboardShortcut") === undefined) { + store.set("useClipboardShortcut", true); } if (store.get("checkUpdates") === undefined) { @@ -111,12 +110,6 @@ const createMainWindow = () => { mainWindow.webContents.send("FOCUS_EDITOR"); }); - - globalShortcut.register("Command+1", () => { - const readText = clipboard.readText("clipboard"); - const deasciifyedObject = Deasciifier.deasciify(readText); - clipboard.write(deasciifyedObject, "clipboard"); - }); }; const createUpdater = () => {