How to use @nodegui/nodegui - 10 common examples

To help you get started, we’ve selected a few @nodegui/nodegui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github irustm / angular-nodegui / projects / angular-nodegui / src / lib / components / image.ts View on Github external
break;
      case 'src':
        if (!value) {
          return;
        }
        getLoadedPixmap(value as string)
        .then(pixmap => this.setPixmap(pixmap))
        .catch(console.warn);

        // TODO: not set current aspect size
        // const size = this.size();
        // this.scalePixmap(size.width, size.height);
        break;

      case 'buffer':
        const pixMap = new QPixmap();
        pixMap.loadFromData(value as Buffer);
        this.setPixmap(pixMap);
        break;

      case 'aspectRatioMode':
        this.setAspectRatioMode(value as AspectRatioMode);
        break;

      default:
        break;
    }
  }
github nodegui / examples / nodegui / systray / src / index.ts View on Github external
const app = QApplication.instance();
  app.exit(0);
});

// -------------------
// Action with Submenu
// -------------------
const actionWithSubmenu = new QAction();
const subMenu = new QMenu();
const hideDockAction = new QAction();
hideDockAction.setText("hide");
hideDockAction.addEventListener("triggered", () => {
  Dock.hide();
});
//-----
const showDockAction = new QAction();
showDockAction.setText("show");
showDockAction.addEventListener("triggered", () => {
  Dock.show();
});
//-----
subMenu.addAction(hideDockAction);
subMenu.addAction(showDockAction);
actionWithSubmenu.setMenu(subMenu);
actionWithSubmenu.setText("Mac Dock");

// ----------------
// Dock Hide/Show
// ----------------
const hideAction = new QAction();
hideAction.setText("hide window");
hideAction.setShortcut(new QKeySequence("Alt+H"));
github nodegui / examples / nodegui / systray / src / index.ts View on Github external
// Quit Action
// -------------------
const quitAction = new QAction();
quitAction.setText("Quit");
quitAction.setIcon(trayIcon);
quitAction.addEventListener("triggered", () => {
  const app = QApplication.instance();
  app.exit(0);
});

// -------------------
// Action with Submenu
// -------------------
const actionWithSubmenu = new QAction();
const subMenu = new QMenu();
const hideDockAction = new QAction();
hideDockAction.setText("hide");
hideDockAction.addEventListener("triggered", () => {
  Dock.hide();
});
//-----
const showDockAction = new QAction();
showDockAction.setText("show");
showDockAction.addEventListener("triggered", () => {
  Dock.show();
});
//-----
subMenu.addAction(hideDockAction);
subMenu.addAction(showDockAction);
actionWithSubmenu.setMenu(subMenu);
actionWithSubmenu.setText("Mac Dock");
github nodegui / examples / nodegui / systray / src / index.ts View on Github external
// -------------------
// Quit Action
// -------------------
const quitAction = new QAction();
quitAction.setText("Quit");
quitAction.setIcon(trayIcon);
quitAction.addEventListener("triggered", () => {
  const app = QApplication.instance();
  app.exit(0);
});

// -------------------
// Action with Submenu
// -------------------
const actionWithSubmenu = new QAction();
const subMenu = new QMenu();
const hideDockAction = new QAction();
hideDockAction.setText("hide");
hideDockAction.addEventListener("triggered", () => {
  Dock.hide();
});
//-----
const showDockAction = new QAction();
showDockAction.setText("show");
showDockAction.addEventListener("triggered", () => {
  Dock.show();
});
//-----
subMenu.addAction(hideDockAction);
subMenu.addAction(showDockAction);
actionWithSubmenu.setMenu(subMenu);
github nodegui / examples / nodegui / systray / src / index.ts View on Github external
const icon = require("../assets/nodegui_white.png");

const win = new QMainWindow();
const trayIcon = new QIcon(path.resolve(__dirname, icon));
const tray = new QSystemTrayIcon();
tray.setIcon(trayIcon);
tray.show();
tray.setToolTip("hello");

const menu = new QMenu();
tray.setContextMenu(menu);

// -------------------
// Quit Action
// -------------------
const quitAction = new QAction();
quitAction.setText("Quit");
quitAction.setIcon(trayIcon);
quitAction.addEventListener("triggered", () => {
  const app = QApplication.instance();
  app.exit(0);
});

// -------------------
// Action with Submenu
// -------------------
const actionWithSubmenu = new QAction();
const subMenu = new QMenu();
const hideDockAction = new QAction();
hideDockAction.setText("hide");
hideDockAction.addEventListener("triggered", () => {
  Dock.hide();
github irustm / angular-nodegui / projects / weather-demo / src / app / app.component.ts View on Github external
QApplication
} from '@nodegui/nodegui';
import { NgWindow } from '../../../../projects/angular-nodegui/src/lib/components/window';
import * as os from 'os';

@Component({
  // tslint:disable-next-line: component-selector
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
  encapsulation: ViewEncapsulation.None
})
export class AppComponent implements OnInit {
  @ViewChild('window', { static: true }) window: ElementRef;

  public aspectRatioMode: AspectRatioMode = AspectRatioMode.KeepAspectRatio;
  public date: Date = new Date();

  constructor() {}

  /**
   * Init component and configure window widget
   */
  ngOnInit() {
    const win = this.window.nativeElement.parent;

    win.hide();
    win.resize(300, 340);

    win.setWindowFlag(WindowType.FramelessWindowHint, true);
    win.setWindowFlag(WindowType.Widget, true);
github nodegui / examples / nodegui / systray / src / index.ts View on Github external
// -------------------
// Quit Action
// -------------------
const quitAction = new QAction();
quitAction.setText("Quit");
quitAction.setIcon(trayIcon);
quitAction.addEventListener("triggered", () => {
  const app = QApplication.instance();
  app.exit(0);
});

// -------------------
// Action with Submenu
// -------------------
const actionWithSubmenu = new QAction();
const subMenu = new QMenu();
const hideDockAction = new QAction();
hideDockAction.setText("hide");
hideDockAction.addEventListener("triggered", () => {
  Dock.hide();
});
//-----
const showDockAction = new QAction();
showDockAction.setText("show");
showDockAction.addEventListener("triggered", () => {
  Dock.show();
});
//-----
subMenu.addAction(hideDockAction);
subMenu.addAction(showDockAction);
actionWithSubmenu.setMenu(subMenu);
actionWithSubmenu.setText("Mac Dock");
github nodegui / examples / nodegui / systray / src / index.ts View on Github external
QIcon,
  QSystemTrayIcon,
  QAction
} from "@nodegui/nodegui";
import path from "path";
import { Dock } from "@nodegui/nodegui-os-utils";
const icon = require("../assets/nodegui_white.png");

const win = new QMainWindow();
const trayIcon = new QIcon(path.resolve(__dirname, icon));
const tray = new QSystemTrayIcon();
tray.setIcon(trayIcon);
tray.show();
tray.setToolTip("hello");

const menu = new QMenu();
tray.setContextMenu(menu);

// -------------------
// Quit Action
// -------------------
const quitAction = new QAction();
quitAction.setText("Quit");
quitAction.setIcon(trayIcon);
quitAction.addEventListener("triggered", () => {
  const app = QApplication.instance();
  app.exit(0);
});

// -------------------
// Action with Submenu
// -------------------
github nodegui / examples / nodegui / calculator / src / index.ts View on Github external
row1Layout.setFlexNode(row1.getFlexNode());
row1Layout.addWidget(btn7.ui, btn7.ui.getFlexNode());
row1Layout.addWidget(btn8.ui, btn8.ui.getFlexNode());
row1Layout.addWidget(btn9.ui, btn9.ui.getFlexNode());
row1Layout.addWidget(btnDivide.ui, btnDivide.ui.getFlexNode());
row1.setLayout(row1Layout);

// Second Row
const btn4 = getButton("4", 4, "value");
const btn5 = getButton("5", 5, "value");
const btn6 = getButton("6", 6, "value");
const btnMultiply = getButton("x", "*", "command");
btnMultiply.ui.setStyleSheet(operatorStyleSheet);
const row2 = new QWidget();
row2.setObjectName("row2");
const row2Layout = new FlexLayout();
row2Layout.setFlexNode(row2.getFlexNode());
row2Layout.addWidget(btn4.ui, btn4.ui.getFlexNode());
row2Layout.addWidget(btn5.ui, btn5.ui.getFlexNode());
row2Layout.addWidget(btn6.ui, btn6.ui.getFlexNode());
row2Layout.addWidget(btnMultiply.ui, btnMultiply.ui.getFlexNode());
row2.setLayout(row2Layout);

// Third Row
const btn1 = getButton("1", 1, "value");
const btn2 = getButton("2", 2, "value");
const btn3 = getButton("3", 3, "value");
const btnMinus = getButton("-", "-", "command");
btnMinus.ui.setStyleSheet(operatorStyleSheet);

const row3 = new QWidget();
row3.setObjectName("row3");
github nodegui / examples / nodegui / calculator / src / index.ts View on Github external
row3Layout.addWidget(btn1.ui, btn1.ui.getFlexNode());
row3Layout.addWidget(btn2.ui, btn2.ui.getFlexNode());
row3Layout.addWidget(btn3.ui, btn3.ui.getFlexNode());
row3Layout.addWidget(btnMinus.ui, btnMinus.ui.getFlexNode());
row3.setLayout(row3Layout);

// Fourth Row
const btn0 = getButton("0", 0, "value");
const btnDot = getButton(".", ".", "command");
const btnEquals = getButton("=", "=", "command");
const btnPlus = getButton("+", "+", "command");
btnPlus.ui.setStyleSheet(operatorStyleSheet);

const row4 = new QWidget();
row4.setObjectName("row4");
const row4Layout = new FlexLayout();
row4Layout.setFlexNode(row4.getFlexNode());
row4Layout.addWidget(btn0.ui, btn0.ui.getFlexNode());
row4Layout.addWidget(btnDot.ui, btnDot.ui.getFlexNode());
row4Layout.addWidget(btnEquals.ui, btnEquals.ui.getFlexNode());
row4Layout.addWidget(btnPlus.ui, btnPlus.ui.getFlexNode());
row4.setLayout(row4Layout);

// Add to root view
rootViewFlexLayout.addWidget(row0, row0.getFlexNode());
rootViewFlexLayout.addWidget(row1, row1.getFlexNode());
rootViewFlexLayout.addWidget(row2, row2.getFlexNode());
rootViewFlexLayout.addWidget(row3, row3.getFlexNode());
rootViewFlexLayout.addWidget(row4, row4.getFlexNode());

win.show();