Skip to content

Commit

Permalink
Merge branch 'main' into feature/gamepads
Browse files Browse the repository at this point in the history
  • Loading branch information
Schneegans committed Oct 24, 2024
2 parents c89a42c + c70e5ce commit 11b6ddc
Show file tree
Hide file tree
Showing 27 changed files with 234 additions and 70 deletions.
16 changes: 12 additions & 4 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ This changelog follows the rules of [Keep a Changelog](http://keepachangelog.com

- **Paste-Text Action:** You can now paste text into the currently focused window using the new "Paste Text" action. This uses your clipboard internally, so it can paste any text including special characters like emojis 🎊!
- **Support for base64 icons:** This allows you to directly embed base64 encoded images. This will be especially helpful for menus which are dynamically generated via some sort of API in the future. Use `"base64"` as the icon theme and provide the base64 encoded image as the `"icon"`. This will be a string starting with something like `"data:image/svg+xml;base64, ..."`. This even supports animated gifs!
- **Version information in the sidebar:** The sidebar now shows some version information in the development tab. This includes the version of Kando, the version of Electron, and the currently used backend.
- An option to the menu editor which **allows warping the mouse pointer to the center of the menu** when the menu is opened in centered mode. This allows to directly engage in turbo mode even if the menu is shown at the center of the screen.
- **Change the fade-in and fade-out duration of the menu:** For now, it is only possible to change this via the `"menuOptions": {"fadeInDuration": 150}` and `"menuOptions": {"fadeOutDuration": 250}` properties in the `config.json` file. In the future, this will be exposed in the settings UI.
- **Disable Marking Mode and Turbo Mode altogether:** This can be useful if you never use these features and want to avoid accidental selections. For now, this can be done via the `"menuOptions": {"enableMarkingMode": true}` and `"menuOptions": {"enableTurboMode": true}` in your `config.json`. In the future, this will be exposed in the settings UI.
- **Select parent with mouse and keyboard:** Your mouse's navigate-back button as well as <kbd>Backspace</kbd> will now select the parent menu.
- **Optionally select parent with RMB:** If you set `"menuOptions": {"rmbSelectsParent": true}`, your right mouse button will now select the parent menu instead of closing the menu.
- **Adjustable fade-in and fade-out duration of the menu:** For now, it is only possible to change this via the `"menuOptions": {"fadeInDuration": 150}` and `"menuOptions": {"fadeOutDuration": 250}` properties in the `config.json` file. In the future, this will be exposed in the settings UI.
- **Possibility to hide sidebar and editor buttons:** You can now add
```json
"editorOptions": {
"showSidebarButtonVisible": false,
"showEditorButtonVisible": false
}
```
to your `config.json` to hide the show-sidebar and the show-editor buttons respectively. They will still be clickable, so you can still use them if you aim carefully.
- **Possibility to disable Marking Mode and Turbo Mode altogether:** This can be useful if you never use these features and want to avoid accidental selections. For now, this can be done via the `"menuOptions": {"enableMarkingMode": true}` and `"menuOptions": {"enableTurboMode": true}` in your `config.json`. In the future, this will be exposed in the settings UI.
- **New options to select parent with mouse and keyboard:** Your mouse's navigate-back button as well as <kbd>Backspace</kbd> will now select the parent menu. Also, if you set `"menuOptions": {"rmbSelectsParent": true}`, your right mouse button will now select the parent menu instead of closing the menu.
- **More configurable properties:** Some variables which were constants before are now configurable via the `config.json`. See the [corresponding documentation](https://github.com/kando-menu/kando/blob/main/docs/config-files.md#the-menuoptions-property) for details.
- **Icon themes are now also loaded from the installation directory:** This can be interesting if you are packaging icon themes using a package manager. However, as an end user, you should not put your icon themes there, as they might be overwritten during an update. The directory is `resources/app/.webpack/renderer/assets/icon-themes/`.
- **Several translation updates:** Thanks to all the contributors!
Expand Down
8 changes: 8 additions & 0 deletions docs/config-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Property | Default Value | Description
`zoomFactor` | `1.0` | The zoom factor of the menu. This can be used to scale the menu on high-resolution screens.
`enableVersionCheck` | `true` | If set to `true`, Kando will check for new version regularly, and show a notification if a new version is available.
`menuOptions` | _see below_ | The parameters configure the general behavior of the menus.
`editorOptions` | _see below_ | The parameters configure the behavior of the menu editor.

### The `menuOptions` Property

Expand All @@ -55,6 +56,13 @@ Property | Default Value | Description
`gesturePauseTimeout` | `100` | If the pointer is stationary for this many milliseconds, the current item will be selected during gesture recognition.
`rmbSelectsParent` | `false` | If enabled, the parent of a selected item will be selected on a right mouse button click. Else the menu will be closed directly.

### The `editorOptions` Property

Property | Default Value | Description
-------- | ------------- | -----------
`showSidebarButtonVisible` | `true` | Set this to `false` to hide the show-sidebar button. It will still be clickable, though.
`showEditorButtonVisible` | `true` | Set this to `false` to hide the show-editor button. It will still be clickable, though.

## The Menu Configuration: `menus.json`

This file contains the configuration of the individual menus.
Expand Down
3 changes: 3 additions & 0 deletions docs/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ There are three ways to open the menu editor:
In the editor, you can create new menus, and edit existing menus.
Drag new items from the toolbar to the menu preview, reorder them, and change their properties on the right side of the screen.

> [!TIP]
> There are several advanced options which are not yet exposed in the editor UI. See the [Config-File Documentation](config-files.md) for all advanced options.
## Tips for Creating Efficient Menu Layouts :rocket:

When designing your own menus, keep the following tips in mind:
Expand Down
7 changes: 6 additions & 1 deletion locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,12 @@
"dev-tools-button": "Show Developer Tools",
"dev-tools-button-tooltip": "Open the web developer tools for inspecting the UI.",
"reload-menu-theme-button": "Reload Current Menu Theme",
"reload-menu-theme-button-tooltip": "CSS changes will be applied immediately, for changes made to the theme.json file, you need to re-open the menu."
"reload-menu-theme-button-tooltip": "CSS changes will be applied immediately, for changes made to the theme.json file, you need to re-open the menu.",
"kando-version": "Kando Version",
"electron-version": "Electron Version",
"chrome-version": "Chrome Version",
"node-version": "Node Version",
"backend": "Kando Backend"
},
"toolbar": {
"menu-themes-tab": {
Expand Down
9 changes: 8 additions & 1 deletion locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
"name": "Открыть URI",
"description": "Открывает файлы или вебсайты.",
"uri-hint": "Это будет открыто."
},
"text": {
"tip-1": "Это действие использует ваш буфер обмена, чтобы вставить текст. После этого действия буфер обмена будет содержать текст.",
"placeholder": "Введите любой текст…",
"name": "Вставить текст",
"description": "Вставляет данный текст."
}
},
"example-menu": {
Expand Down Expand Up @@ -139,7 +145,8 @@
"anchored-mode-checked-hint": "Утсанавливая этот флажок, вы отключите Режим Маркировки.",
"anchored-mode-hint": "Открывать подменю в той же позиции, что и главное меню.",
"anchored-mode": "Закрепленный режим",
"heading": "Настроить поведение Меню"
"heading": "Настроить поведение Меню",
"warp-mouse-hint": "Переместить указатель в центр меню, когда оно откроется."
},
"condition-picker": {
"heading": "Выберите Условия Меню",
Expand Down
32 changes: 16 additions & 16 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"prettier": "^3.3.3",
"prettier-plugin-jsdoc": "^1.3.0",
"raw-loader": "^4.0.2",
"sass": "^1.80.2",
"sass": "^1.80.3",
"sass-loader": "^16.0.1",
"string-replace-loader": "^3.1.0",
"style-loader": "^4.0.0",
Expand All @@ -72,16 +72,16 @@
"electron-squirrel-startup": "^1.0.0",
"emojilib": "^4.0.0",
"handlebars": "^4.7.8",
"i18next": "^23.16.0",
"i18next": "^23.16.2",
"i18next-fs-backend": "^2.3.2",
"json5": "^2.2.3",
"lodash": "^4.17.21",
"lodash.isequal": "^4.5.0",
"match-sorter": "^6.3.4",
"match-sorter": "^7.0.0",
"material-symbols": "^0.25.1",
"mime-types": "^2.1.35",
"node-addon-api": "^8.2.1",
"octokit": "^4.0.2",
"simple-icons-font": "^13.14.0"
"simple-icons-font": "^13.14.1"
}
}
2 changes: 2 additions & 0 deletions src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
IShowMenuOptions,
IShowEditorOptions,
IIconThemesInfo,
IVersionInfo,
} from '../common';

// Declare the API to the host process. See preload.ts for more information on the exposed
Expand All @@ -41,6 +42,7 @@ declare global {
set: (data: IMenuSettings) => void;
getCurrentMenu: () => Promise<number>;
};
getVersion: () => Promise<IVersionInfo>;
getBackendInfo: () => Promise<IBackendInfo>;
getMenuTheme: () => Promise<IMenuThemeDescription>;
getAllMenuThemes: () => Promise<Array<IMenuThemeDescription>>;
Expand Down
18 changes: 18 additions & 0 deletions src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// SPDX-License-Identifier: MIT

import { MenuOptions } from '../renderer/menu/menu';
import { EditorOptions } from '../renderer/editor/editor';

/**
* A simple 2D vector.
Expand All @@ -22,6 +23,12 @@ export interface IVec2 {

/** This interface describes some information about the currently used backend. */
export interface IBackendInfo {
/**
* The name of the backend. This is shown in the user interface so that users can see
* which backend is currently active.
*/
name: string;

/**
* Each backend should return a suitable window type here. The window type determines
* how Kando's window is drawn. The most suitable type is dependent on the operating
Expand Down Expand Up @@ -50,6 +57,14 @@ export interface IBackendInfo {
shortcutHint?: string;
}

/** This interface describes some information about the current version of Kando. */
export interface IVersionInfo {
kandoVersion: string;
electronVersion: string;
chromeVersion: string;
nodeVersion: string;
}

/**
* The description of a menu theme. These are the properties which can be defined in the
* JSON file of a menu theme.
Expand Down Expand Up @@ -431,4 +446,7 @@ export interface IAppSettings {

/** The options which are passed to the menu. */
menuOptions: MenuOptions;

/** The options which are passed to the menu editor. */
editorOptions: EditorOptions;
}
14 changes: 14 additions & 0 deletions src/main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ export class KandoApp {
gesturePauseTimeout: 100,
rmbSelectsParent: false,
},
editorOptions: {
showSidebarButtonVisible: true,
showEditorButtonVisible: true,
},
},
});

Expand Down Expand Up @@ -669,6 +673,16 @@ export class KandoApp {
return Math.max(index, 0);
});

// Allow the renderer to retrieve information about the current app version.
ipcMain.handle('get-version', () => {
return {
kandoVersion: app.getVersion(),
electronVersion: process.versions.electron,
chromeVersion: process.versions.chrome,
nodeVersion: process.versions.node,
};
});

// Allow the renderer to retrieve information about the backend.
ipcMain.handle('get-backend-info', () => {
return this.backend.getBackendInfo();
Expand Down
1 change: 1 addition & 0 deletions src/main/backends/linux/cinnamon/x11/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class CinnamonBackend extends X11Backend {
*/
public getBackendInfo() {
const info = super.getBackendInfo();
info.name = 'Cinnamon Backend';
info.windowType = 'normal';
return info;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/backends/linux/gnome/wayland/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class GnomeBackend implements Backend {
*/
public getBackendInfo() {
return {
name: 'GNOME Wayland Backend',
windowType: 'dock',
supportsShortcuts: true,
};
Expand Down
1 change: 1 addition & 0 deletions src/main/backends/linux/hyprland/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ for more information.
*/
public getBackendInfo() {
return {
name: 'Hyprland Backend',
windowType: 'splash',
supportsShortcuts: false,
shortcutHint: i18next.t('backends.hyprland.shortcut-hint'),
Expand Down
1 change: 1 addition & 0 deletions src/main/backends/linux/kde/wayland/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class KDEWaylandBackend implements Backend {
*/
public getBackendInfo() {
return {
name: 'KDE Wayland Backend',
windowType: 'toolbar',
supportsShortcuts: false,
shortcutHint: i18next.t('backends.kde-wayland.shortcut-hint'),
Expand Down
1 change: 1 addition & 0 deletions src/main/backends/linux/kde/x11/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class KDEX11Backend extends X11Backend {
*/
public getBackendInfo() {
const info = super.getBackendInfo();
info.name = 'KDE X11 Backend';
info.windowType = 'toolbar';
return info;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/backends/linux/x11/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class X11Backend implements Backend {
*/
public getBackendInfo() {
return {
name: 'X11 Backend',
windowType: 'dock',
supportsShortcuts: true,
};
Expand Down
1 change: 1 addition & 0 deletions src/main/backends/macos/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class MacosBackend implements Backend {
*/
public getBackendInfo() {
return {
name: 'macOS Backend',
windowType: 'normal',
supportsShortcuts: true,
};
Expand Down
1 change: 1 addition & 0 deletions src/main/backends/windows/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class WindowsBackend implements Backend {
*/
public getBackendInfo() {
return {
name: 'Windows Backend',
windowType: 'toolbar',
supportsShortcuts: true,
};
Expand Down
6 changes: 3 additions & 3 deletions src/main/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import fs from 'fs-extra';
import path from 'path';
import chokidar from 'chokidar';
import isEqual from 'lodash.isequal';
import lodash from 'lodash';

/**
* This type is used to define all possible events which can be emitted by the
Expand Down Expand Up @@ -253,7 +253,7 @@ export class Settings<T extends object> extends PropertyChangeEmitter<T> {
try {
console.log('Loading settings from', this.filePath);
const data = fs.readJSONSync(this.filePath);
return { ...defaultSettings, ...data };
return lodash.merge({}, defaultSettings, data);
} catch (error) {
if (error.code === 'ENOENT') {
// The settings file does not exist yet. Create it.
Expand Down Expand Up @@ -288,7 +288,7 @@ export class Settings<T extends object> extends PropertyChangeEmitter<T> {
for (const key in newSettings) {
if (
Object.prototype.hasOwnProperty.call(newSettings, key) &&
!isEqual(newSettings[key], oldSettings[key])
!lodash.isEqual(newSettings[key], oldSettings[key])
) {
this.emit(key, this.settings[key], oldSettings[key]);
}
Expand Down
Loading

0 comments on commit 11b6ddc

Please sign in to comment.