@dark-engine/platform-desktop
Version:
Dark renderer to desktop platforms like Windows, Linux, macOS via Nodegui and Qt
36 lines (35 loc) • 1.03 kB
JavaScript
import { QSystemTrayIcon } from '@nodegui/nodegui';
import { component } from '@dark-engine/core';
import { qSystemTrayIcon } from '../factory';
import { throwUnsupported } from '../utils';
import { detectIsMenu } from './menu';
const SystemTrayIcon = component(props => qSystemTrayIcon(props), {
displayName: 'SystemTrayIcon',
});
class QDarkSystemTrayIcon extends QSystemTrayIcon {
constructor() {
super();
globalThis.tray = this;
}
detectIsContainer() {
return true;
}
setVisible(value) {
value ? this.show() : this.hide();
}
appendChild(child) {
if (!detectIsMenu(child)) return console.warn(`SystemTrayIcon supports only Menu as its children`);
this.setContextMenu(child);
}
insertBefore() {
throwUnsupported(this);
}
removeChild() {
throwUnsupported(this);
}
}
function detectIsSystemTrayIcon(value) {
return value instanceof QDarkSystemTrayIcon;
}
export { SystemTrayIcon, QDarkSystemTrayIcon, detectIsSystemTrayIcon };
//# sourceMappingURL=system-tray-icon.js.map