mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-02 05:00:40 +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 {
|
export default class TouchBarWidget extends Component {
|
||||||
|
|
||||||
|
nativeImage: typeof import("electron").nativeImage;
|
||||||
remote: typeof import("@electron/remote");
|
remote: typeof import("@electron/remote");
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
this.nativeImage = utils.dynamicRequire("electron").nativeImage;
|
||||||
this.remote = utils.dynamicRequire("@electron/remote") as typeof import("@electron/remote");
|
this.remote = utils.dynamicRequire("@electron/remote") as typeof import("@electron/remote");
|
||||||
this.#setTouchBar();
|
this.#setTouchBar();
|
||||||
}
|
}
|
||||||
@ -14,22 +16,24 @@ export default class TouchBarWidget extends Component {
|
|||||||
#setTouchBar() {
|
#setTouchBar() {
|
||||||
const touchBarData = this.#buildTouchBar();
|
const touchBarData = this.#buildTouchBar();
|
||||||
this.remote.getCurrentWindow().setTouchBar(touchBarData);
|
this.remote.getCurrentWindow().setTouchBar(touchBarData);
|
||||||
console.log("Setting touch bar", touchBarData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#buildTouchBar() {
|
#buildTouchBar() {
|
||||||
|
const { nativeImage } = this;
|
||||||
|
const { TouchBar } = this.remote;
|
||||||
const { TouchBarButton } = this.remote.TouchBar;
|
const { TouchBarButton } = this.remote.TouchBar;
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
new TouchBarButton({
|
new TouchBarButton({
|
||||||
label: "New note",
|
icon: nativeImage.createFromNamedImage("NSTouchBarAddDetailTemplate", [-1, 0, 1]),
|
||||||
click: () => {
|
click: () => {
|
||||||
console.log("New note pressed.");
|
console.log("New note pressed.");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
return new this.remote.TouchBar({
|
console.log("Update ", items);
|
||||||
|
return new TouchBar({
|
||||||
items
|
items
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user