Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom icon themes #520

Merged
merged 22 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d2938c2
:wrench: Add methods for listing user icons
Schneegans Jul 5, 2024
f50d9ad
:wrench: Use icon theme registry in the menu class
Schneegans Jul 5, 2024
045138c
:wrench: Allow loading local files during development
Schneegans Jul 6, 2024
cef629e
:tada: Add user icon themes
Schneegans Jul 6, 2024
61114eb
:wrench: Prevent custom icons from being draggable
Schneegans Jul 6, 2024
ae8f4ce
:bug: Hide custom icons on minimized menu items
Schneegans Jul 7, 2024
65cc444
:wrench: Load icons only if they are in view in the icon picker
Schneegans Jul 7, 2024
74e4158
:wrench: Load custom icon themes recursively
Schneegans Jul 7, 2024
ed47027
:wrench: Run checks also on pull requests
Schneegans Jul 7, 2024
0a511b7
:wrench: Delete tooltips when reloading the icon list
Schneegans Jul 7, 2024
0c2d9c3
Merge branch 'main' into feature/custom-icon-themes
Schneegans Jul 8, 2024
958b46c
:wrench: Show a question mark if no icon theme is found
Schneegans Jul 8, 2024
aed5932
:memo: Add changelog entry
Schneegans Jul 8, 2024
bbc3da9
:memo: Split configuring docs into two files
Schneegans Jul 8, 2024
201f4fa
:memo: Add some docs on icon themes
Schneegans Jul 8, 2024
1d25ae2
:memo: Update icon docs
Schneegans Jul 8, 2024
e5069ca
:memo: Rename docs page
Schneegans Jul 9, 2024
bdef677
:memo: Add new documentation chapter
Schneegans Jul 9, 2024
0dee79d
:twisted_rightwards_arrows: Merge branch 'main' into feature/custom-i…
Schneegans Jul 9, 2024
8a9784b
:bug: Properly close the editor when opening an external link
Schneegans Jul 9, 2024
47a96fb
:wrench: Add header to icon picker
Schneegans Jul 9, 2024
3b8ae33
:bug: Fix scrolling icon into view when opening the icon picker
Schneegans Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🔧 Add header to icon picker
  • Loading branch information
Schneegans committed Jul 9, 2024
commit 47a96fb8f225ebc3c056964fcaa36232d25c3d39
13 changes: 13 additions & 0 deletions src/common/icon-theme-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class IconThemeRegistry {
/** This is the fallback icon theme that is used if no valid icon theme is selected. */
private fallbackTheme: IIconTheme = new FallbackTheme();

/** The directory where the user's icon themes are stored. */
private _userIconThemeDirectory = '';

/**
* This is a singleton class. The constructor is private. Use `getInstance` to get the
* instance of this class.
Expand All @@ -73,6 +76,7 @@ export class IconThemeRegistry {
window.api.getUserIconThemeDirectory(),
window.api.getUserIconThemes(),
]).then(([directory, themes]) => {
this._userIconThemeDirectory = directory;
for (const theme of themes) {
this.iconThemes.set(theme, new UserIconTheme(directory, theme));
}
Expand All @@ -88,6 +92,15 @@ export class IconThemeRegistry {
return IconThemeRegistry.instance;
}

/**
* Use this method to get the directory where the user's icon themes are stored.
*
* @returns The directory where the user's icon themes are stored.
*/
get userIconThemeDirectory(): string {
return this._userIconThemeDirectory;
}

/**
* Use this method to get all available icon themes.
*
Expand Down
15 changes: 13 additions & 2 deletions src/renderer/editor/properties/icon-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ export class IconPicker extends EventEmitter {
// template below. The data object contains an array of objects with the keys `name`
// and `key`. The `name` is the display name of the theme and the `key` is the key
// that is used to identify the theme in the IconThemeRegistry.
const data: { themes: { name: string; key: string }[] } = { themes: [] };
const data = {
heading: 'Select an Icon',
subheading:
'You can add your own icon collections by putting a folder with icons into %1. Learn more <a %2>here</a>.'
.replace('%1', IconThemeRegistry.getInstance().userIconThemeDirectory)
.replace(
'%2',
'href="https://github.com/kando-menu/kando/blob/main/docs/configuring.md" target="_blank"'
),

themes: new Array<{ name: string; key: string }>(),
};
const themes = IconThemeRegistry.getInstance().getThemes();
themes.forEach((theme, key) => {
data.themes.push({ name: theme.name, key });
Expand Down Expand Up @@ -271,7 +282,7 @@ export class IconPicker extends EventEmitter {
}
});
},
{ root: scrollbox, delay: 100 }
{ root: scrollbox, delay: 250, rootMargin: '250px' }
);

// Observe all icons in the grid. We get the icons by querying the grid for all
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/editor/properties/templates/icon-picker.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
// SPDX-License-Identifier: MIT
}}

<div class="fs-1 kando-font">{{heading}}</div>
<div class="fs-5 kando-font mb-3">{{{subheading}}}</div>

<div class='d-flex'>
<input type="text" class="fs-3 kando-font form-control flex-grow-1 me-3" placeholder="Search Icons..." id="kando-properties-icon-filter" />
<select class="form-select fs-3 kando-font form-control" id="kando-properties-icon-theme-select">
Expand All @@ -18,7 +21,7 @@
</select>
</div>

<div class='scrollbox mx-2' style="height: 35vh;">
<div class='scrollbox mx-2' style="height: 30vh;">
<div class="scrollbox-content">
<div id="kando-properties-icon-picker-grid" class="justify-content-start"></div>
</div>
Expand Down