Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Remove attaching to menubar feature on Windows & Linux (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
quanglam2807 authored Mar 20, 2021
1 parent 4ff06af commit 9f5b41a
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 129 deletions.
11 changes: 4 additions & 7 deletions main-src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ if (!gotTheLock) {

const createWindowAsync = () => new Promise((resolve) => {
const updaterEnabled = process.env.SNAP == null && !process.mas && !process.windowsStore;
const attachToMenubar = getPreference('attachToMenubar');
global.attachToMenubar = attachToMenubar;
if (attachToMenubar) {
global.attachToMenubar = process.platform === 'darwin' && getPreference('attachToMenubar');
if (global.attachToMenubar) {
// setImage after Tray instance is created to avoid
// "Segmentation fault (core dumped)" bug on Linux
// https://github.com/electron/electron/issues/22137#issuecomment-586105622
Expand Down Expand Up @@ -328,9 +327,8 @@ if (!gotTheLock) {
const showWindow = () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
const attachToMenubar = getPreference('attachToMenubar');

if (attachToMenubar) {
if (global.attachToMenubar) {
if (mb == null) {
createWindowAsync();
} else {
Expand Down Expand Up @@ -421,8 +419,7 @@ if (!gotTheLock) {
const urlObj = url.parse(urlStr, true);
const text = decodeURIComponent(urlObj.query.text || '');

const attachToMenubar = getPreference('attachToMenubar');
if (attachToMenubar) {
if (global.attachToMenubar) {
if (mb && mb.window) {
mb.window.send('go-to-home');
mb.window.send('set-input-lang', 'auto');
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/de/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "Systemstandard",
"light": "Hell",
"dark": "Dunkel",
"taskbar": "Taskleiste",
"menubar": "Menüleiste",
"attachToMenubar": "An Menüleiste anhängen",
"attachToTaskbar": "An Taskleiste anhängen",
"translateWhenPressingEnter": "Bei Drücken der Eingabetaste übersetzen",
"showTransliteration": "Transliteration anzeigen",
"rateMacAppStore": "{appName} im Mac App Store bewerten",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/en/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "System default",
"light": "Light",
"dark": "Dark",
"taskbar": "Taskbar",
"menubar": "Menu bar",
"attachToMenubar": "Attach to menu bar",
"attachToTaskbar": "Attach to taskbar",
"translateWhenPressingEnter": "Translate when pressing Enter",
"showTransliteration": "Show transliteration",
"rateMacAppStore": "Rate {appName} on Mac App Store",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/es/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "Valor predeterminado del sistema",
"light": "Claro",
"dark": "Oscuro",
"taskbar": "Barra de tareas",
"menubar": "Barra de menús",
"attachToMenubar": "Adjuntar a la barra de menús",
"attachToTaskbar": "Adjuntar a la barra de tareas",
"translateWhenPressingEnter": "Traducir al pulsar Enter",
"showTransliteration": "Mostrar transliteración",
"rateMacAppStore": "Califique a {appName} en Mac App Store",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/fr/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "Par défaut",
"light": "Clair",
"dark": "Sombre",
"taskbar": "Barre des tâches",
"menubar": "Barre de menu",
"attachToMenubar": "Attacher à la barre de menu",
"attachToTaskbar": "Attacher à la barre des tâches",
"translateWhenPressingEnter": "Traduire lorsque vous appuyez sur Entrée",
"showTransliteration": "Afficher la translittération",
"rateMacAppStore": "Évaluez {appName} sur l'App Store Mac",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/it/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "Predefinito di sistema",
"light": "Chiaro",
"dark": "Scuro",
"taskbar": "Barra delle applicazioni",
"menubar": "Barra dei menu",
"attachToMenubar": "Aggiungere a barra dei menu",
"attachToTaskbar": "Aggiungere a barra delle applicazioni",
"translateWhenPressingEnter": "Tradurre alla pressione di Invio",
"showTransliteration": "Mostrare traslitterazione",
"rateMacAppStore": "Valutare {appName} su Mac App Store",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/ja/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "システムデフォルト",
"light": "ライトテーマ",
"dark": "ダークテーマ",
"taskbar": "タスクバー",
"menubar": "メニューバー",
"attachToMenubar": "メニューバーに追加",
"attachToTaskbar": "タスクバーに追加",
"translateWhenPressingEnter": "Enterキーを押して翻訳する",
"showTransliteration": "音訳を表示する",
"rateMacAppStore": "{appName}をMac App Storeで評価",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/ko/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "시스템 기본값",
"light": "밝음",
"dark": "어두움",
"taskbar": "작업 표시줄",
"menubar": "메뉴 모음",
"attachToMenubar": "메뉴 모음에 연결",
"attachToTaskbar": "작업 표시줄에 연결",
"translateWhenPressingEnter": "Enter 키를 누르면 번역",
"showTransliteration": "음역 표시",
"rateMacAppStore": "Mac App Store에서 {appName} 평가하기",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/pt-PT/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "Predefinição do sistema",
"light": "Claro",
"dark": "Escuro",
"taskbar": "Barra de tarefas",
"menubar": "Barra de menu",
"attachToMenubar": "Anexar à barra de menu",
"attachToTaskbar": "Anexar à barra de tarefas",
"translateWhenPressingEnter": "Traduzir ao pressionar Enter",
"showTransliteration": "Mostrar transliteração",
"rateMacAppStore": "Avalie {appName} na Mac App Store",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/ru/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "По умолчанию для системы",
"light": "Светлая",
"dark": "Темная",
"taskbar": "Панель задач",
"menubar": "Строка меню",
"attachToMenubar": "Привязать к строке меню",
"attachToTaskbar": "Привязать к панели задач",
"translateWhenPressingEnter": "Переводить по нажатию Enter",
"showTransliteration": "Показывать транслитерацию",
"rateMacAppStore": "Оценить {appName} в Mac App Store",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/vi/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "Mặc định hệ thống",
"light": "Sáng",
"dark": "Tối",
"taskbar": "Thanh tác vụ",
"menubar": "Thanh menu",
"attachToMenubar": "Gắn vào thanh menu",
"attachToTaskbar": "Gắn vào thanh tác vụ",
"translateWhenPressingEnter": "Dịch khi nhấn Enter",
"showTransliteration": "Hiển thị phiên âm",
"rateMacAppStore": "Đánh giá {appName} trên Mac App Store",
Expand Down
2 changes: 0 additions & 2 deletions main-src/libs/locales/zh-CN/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
"system": "系统默认值",
"light": "浅色",
"dark": "深色",
"taskbar": "任务栏",
"menubar": "菜单栏",
"attachToMenubar": "附加到菜单栏",
"attachToTaskbar": "附加到任务栏",
"translateWhenPressingEnter": "按 Enter 键时翻译",
"showTransliteration": "显示音译",
"rateMacAppStore": "在 Mac App Store 上评价 {appName}",
Expand Down
204 changes: 104 additions & 100 deletions src/components/pages/preferences/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,75 +247,79 @@ const Preferences = (props) => {
</List>
</Paper>

<Typography variant="body2" className={classes.paperTitle}>
{getLocale(window.process.platform === 'win32' ? 'taskbar' : 'menubar')}
</Typography>
<Paper elevation={0} className={classes.paper}>
<List dense disablePadding>
<ListItem>
<ListItemText primary={window.process.platform === 'win32' ? getLocale('attachToTaskbar') : getLocale('attachToMenubar')} />
<ListItemSecondaryAction>
<Switch
edge="end"
checked={attachToMenubar}
onChange={(e) => {
requestSetPreference('attachToMenubar', e.target.checked);
requestShowRequireRestartDialog();
}}
color="primary"
/>
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ListItem
button
key="openOnMenubar"
onClick={() => onOpenDialogShortcut('openOnMenubar', openOnMenubarShortcut)}
disabled={!attachToMenubar}
>
<ListItemText
primary={getLocale('openKeyboardShortcut')}
secondary={openOnMenubarShortcut
? renderCombinator(openOnMenubarShortcut) : null}
/>
<ChevronRightIcon color="action" />
</ListItem>
<Divider />
<ListItem>
<ListItemText
primary={getLocale('translateClipboardOnShortcut')}
secondary={getLocale('translateClipboardOnShortcutDesc')}
/>
<ListItemSecondaryAction>
<Switch
edge="end"
checked={attachToMenubar ? translateClipboardOnShortcut : false}
onChange={() => onToggleSetting('translateClipboardOnShortcut')}
color="primary"
disabled={!attachToMenubar}
/>
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ListItem>
<ListItemText
primary={getLocale('alwaysOnTop')}
/>
<ListItemSecondaryAction>
<Switch
edge="end"
checked={attachToMenubar ? alwaysOnTop : false}
onChange={(e) => {
requestSetPreference('alwaysOnTop', e.target.checked);
requestShowRequireRestartDialog();
}}
color="primary"
{window.process.platform === 'darwin' && (
<>
<Typography variant="body2" className={classes.paperTitle}>
{getLocale('menubar')}
</Typography>
<Paper elevation={0} className={classes.paper}>
<List dense disablePadding>
<ListItem>
<ListItemText primary={getLocale('attachToMenubar')} />
<ListItemSecondaryAction>
<Switch
edge="end"
checked={attachToMenubar}
onChange={(e) => {
requestSetPreference('attachToMenubar', e.target.checked);
requestShowRequireRestartDialog();
}}
color="primary"
/>
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ListItem
button
key="openOnMenubar"
onClick={() => onOpenDialogShortcut('openOnMenubar', openOnMenubarShortcut)}
disabled={!attachToMenubar}
/>
</ListItemSecondaryAction>
</ListItem>
</List>
</Paper>
>
<ListItemText
primary={getLocale('openKeyboardShortcut')}
secondary={openOnMenubarShortcut
? renderCombinator(openOnMenubarShortcut) : null}
/>
<ChevronRightIcon color="action" />
</ListItem>
<Divider />
<ListItem>
<ListItemText
primary={getLocale('translateClipboardOnShortcut')}
secondary={getLocale('translateClipboardOnShortcutDesc')}
/>
<ListItemSecondaryAction>
<Switch
edge="end"
checked={attachToMenubar ? translateClipboardOnShortcut : false}
onChange={() => onToggleSetting('translateClipboardOnShortcut')}
color="primary"
disabled={!attachToMenubar}
/>
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ListItem>
<ListItemText
primary={getLocale('alwaysOnTop')}
/>
<ListItemSecondaryAction>
<Switch
edge="end"
checked={attachToMenubar ? alwaysOnTop : false}
onChange={(e) => {
requestSetPreference('alwaysOnTop', e.target.checked);
requestShowRequireRestartDialog();
}}
color="primary"
disabled={!attachToMenubar}
/>
</ListItemSecondaryAction>
</ListItem>
</List>
</Paper>
</>
)}

<Typography variant="body2" className={classes.paperTitle}>
{getLocale('advanced')}
Expand Down Expand Up @@ -644,39 +648,39 @@ const Preferences = (props) => {
</div>
<ChevronRightIcon color="action" />
</ListItem>
<Divider />
<ListItem
button
onClick={() => {
let url = `https://dynamail.app?utm_source=${utmSource}`;
if (window.process.mas) {
url = 'macappstore://apps.apple.com/app/dynamail-for-gmail/id1550739756';
} else if (window.process.windowsStore) {
url = 'ms-windows-store://pdp/?productid=9N57L5VQTB21';
}
requestOpenInBrowser(url);
}}
className={classes.listItemPromotion}
>
<div className={classes.promotionBlock}>
<div className={classes.promotionLeft}>
<img src={dynamailIconPng} alt="DynaMail" className={classes.appIcon} />
</div>
<div className={classes.promotionRight}>
<div>
<Typography variant="body1" className={classes.appTitle}>
DynaMail
</Typography>
<Typography variant="body2" color="textSecondary">
The Best Gmail Client
</Typography>
</div>
</div>
</div>
<ChevronRightIcon color="action" />
</ListItem>
{!window.process.windowsStore && (
{window.process.platform === 'darwin' && (
<>
<Divider />
<ListItem
button
onClick={() => {
let url = `https://dynamail.app?utm_source=${utmSource}`;
if (window.process.mas) {
url = 'macappstore://apps.apple.com/app/dynamail-for-gmail/id1550739756';
} else if (window.process.windowsStore) {
url = 'ms-windows-store://pdp/?productid=9N57L5VQTB21';
}
requestOpenInBrowser(url);
}}
className={classes.listItemPromotion}
>
<div className={classes.promotionBlock}>
<div className={classes.promotionLeft}>
<img src={dynamailIconPng} alt="DynaMail" className={classes.appIcon} />
</div>
<div className={classes.promotionRight}>
<div>
<Typography variant="body1" className={classes.appTitle}>
DynaMail
</Typography>
<Typography variant="body2" color="textSecondary">
The Best Gmail Client
</Typography>
</div>
</div>
</div>
<ChevronRightIcon color="action" />
</ListItem>
<Divider />
<ListItem
button
Expand Down

0 comments on commit 9f5b41a

Please sign in to comment.