mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-01 12:27:41 +08:00
feat(touch_bar): use icon for new note
This commit is contained in:
parent
a170bec3db
commit
3358b405e9
@ -3,10 +3,12 @@ import Component from "../components/component.js";
|
||||
|
||||
export default class TouchBarWidget extends Component {
|
||||
|
||||
nativeImage: typeof import("electron").nativeImage;
|
||||
remote: typeof import("@electron/remote");
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.nativeImage = utils.dynamicRequire("electron").nativeImage;
|
||||
this.remote = utils.dynamicRequire("@electron/remote") as typeof import("@electron/remote");
|
||||
this.#setTouchBar();
|
||||
}
|
||||
@ -14,22 +16,24 @@ export default class TouchBarWidget extends Component {
|
||||
#setTouchBar() {
|
||||
const touchBarData = this.#buildTouchBar();
|
||||
this.remote.getCurrentWindow().setTouchBar(touchBarData);
|
||||
console.log("Setting touch bar", touchBarData);
|
||||
}
|
||||
|
||||
#buildTouchBar() {
|
||||
const { nativeImage } = this;
|
||||
const { TouchBar } = this.remote;
|
||||
const { TouchBarButton } = this.remote.TouchBar;
|
||||
|
||||
const items = [
|
||||
new TouchBarButton({
|
||||
label: "New note",
|
||||
icon: nativeImage.createFromNamedImage("NSTouchBarAddDetailTemplate", [-1, 0, 1]),
|
||||
click: () => {
|
||||
console.log("New note pressed.");
|
||||
}
|
||||
})
|
||||
];
|
||||
|
||||
return new this.remote.TouchBar({
|
||||
console.log("Update ", items);
|
||||
return new TouchBar({
|
||||
items
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user