Skip to content

Commit

Permalink
Merge pull request #7 from ridvanaltun/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
ridvanaltun authored Mar 24, 2022
2 parents 665a47c + 58e2a5b commit 88b303f
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 66 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,25 @@
</p>
</div>

### **Features**
## **Features**

**Deasciifier:** Adapt your texts to Turkish with one click.
| Deasciifier | Asciifier | Correction Bubble | Auto |
|---|---|---|---|
| <img src="./docs/deasciify.gif" /> | <img src="./docs/asciify.gif" /> | <img src="./docs/correction-bubble.gif" /> | <img src="./docs/auto.gif" /> |
| 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.
Expand Down
Binary file added docs/asciify.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/auto.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/correction-bubble.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/deasciify.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});
</script>
</body>
Expand Down
97 changes: 53 additions & 44 deletions src/server/TrayGenerator.js
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand All @@ -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 = () => {
Expand All @@ -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 = [
{
Expand Down Expand Up @@ -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",
},
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 7 additions & 14 deletions src/server/main.js
Original file line number Diff line number Diff line change
@@ -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");

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 = () => {
Expand Down

0 comments on commit 88b303f

Please sign in to comment.