Adds menubar, menu, systemtrayicon, shortcut and action docs

This commit is contained in:
Atul R 2019-10-26 22:21:17 +02:00
parent cb535e33e7
commit a9a1535a12
11 changed files with 314 additions and 12 deletions

View File

@ -1,11 +1,11 @@
import addon from "../../utils/addon";
import { NodeWidget } from "../QWidget";
import { EventWidget, BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { QMenu } from "../QMenu";
import { QIcon } from "../../QtGui/QIcon";
import { QKeySequence } from "../../QtGui/QKeySequence";
import { ShortcutContext } from "../../QtEnums";
import { QObject } from "../../QtCore/QObject";
export const QActionEvents = Object.freeze({
triggered: "triggered",
@ -13,7 +13,7 @@ export const QActionEvents = Object.freeze({
hovered: "hovered",
toggled: "toggled"
});
export class QAction extends EventWidget {
export class QAction extends QObject {
native: NativeElement;
icon?: QIcon;
menu?: QMenu;

View File

@ -1,16 +1,16 @@
import addon from "../../utils/addon";
import { NodeWidget } from "../QWidget";
import { EventWidget } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { QKeySequence } from "../../QtGui/QKeySequence";
import { ShortcutContext } from "../../QtEnums";
import { QObject } from "../../QtCore/QObject";
export const QShortcutEvents = Object.freeze({
activated: "activated",
activatedAmbiguously: "activatedAmbiguously"
});
export class QShortcut extends EventWidget {
export class QShortcut extends QObject {
native: NativeElement;
constructor(parent: NodeWidget) {
let native = new addon.QShortcut(parent.native);

View File

@ -1,14 +1,15 @@
import addon from "../../utils/addon";
import { NodeWidget } from "../QWidget";
import { EventWidget, BaseWidgetEvents } from "../../core/EventWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { QIcon } from "../../QtGui/QIcon";
import { QMenu } from "../QMenu";
import { QObject } from "../../QtCore/QObject";
export const QSystemTrayIconEvents = Object.freeze({
...BaseWidgetEvents
});
export class QSystemTrayIcon extends EventWidget {
export class QSystemTrayIcon extends QObject {
native: NativeElement;
contextMenu?: QMenu;
constructor(parent?: NodeWidget) {

View File

@ -0,0 +1,76 @@
---
sidebar_label: QAction
title: QAction
---
> The QAction class provides an abstract user interface action that can be inserted into widgets.
**This class is a JS wrapper around Qt's [QAction class](https://doc.qt.io/qt-5/qaction.html)**
**QAction inherits from [EventWidget](api/EventWidget.md)**
### Example
```javascript
const { QAction, QMenu } = require("@nodegui/nodegui");
const menu = new QMenu();
const menuAction = new QAction();
menuAction.setText("subAction");
menuAction.addEventListener("triggered", () => {
console.log("Action clicked");
});
menu.addAction(menuAction);
```
### `new QAction(parent?)`
- `parent` NodeWidget. Constructs an action with parent. If parent is an action group the action will be automatically inserted into the group.
## Static Methods
QAction can access all the static methods defined in [EventWidget](api/EventWidget.md)
## Instance Properties
QAction can access all the instance properties defined in [EventWidget](api/EventWidget.md)
## Instance Methods
QAction can access all the instance methods defined in [EventWidget](api/EventWidget.md). Additionally it also has the following instance methods:
### `action.setEnabled(enabled)`
This property holds whether the action is enabled. It calls the native method [QAction: setEnabled](https://doc.qt.io/qt-5/qaction.html#enabled-prop).
- `enabled` - Boolean
### `action.setText(on)`
This property holds the action's descriptive text. It calls the native method [QAction: setText](https://doc.qt.io/qt-5/qaction.html#text-prop).
- `text` - string
### `action.setIcon(icon)`
Sets the icon of action. It calls the native method [QAction: setIcon](https://doc.qt.io/qt-5/qaction.html#icon-prop).
- `icon` [QIcon](api/QIcon.md)
### `action.setMenu(menu)`
Sets the menu contained by this action to the specified menu. It calls the native method [QAction: setMenu](https://doc.qt.io/qt-5/qaction.html#setMenu).
- `menu` [QMenu](api/QMenu.md)
### `action.setShortcut(keySequence)`
This property holds the action's key sequence. It calls the native method [QAction: setShortcut](https://doc.qt.io/qt-5/qaction.html#shortcut-prop).
- `keySequence` [QKeySequence](api/QKeySequence.md)
### `action.setShortcutContext(contextEnum)`
This property holds the context in which the action is valid. It calls the native method [QAction: setShortcutContext](https://doc.qt.io/qt-5/qaction.html#shortcutContext-prop).
- `contextEnum` - ShortcutContext enum.

View File

@ -0,0 +1,39 @@
---
sidebar_label: QKeySequence
title: QKeySequence
---
> The QKeySequence class encapsulates a key sequence as used by shortcuts. .
**This class is a JS wrapper around Qt's [QKeySequence class](https://doc.qt.io/qt-5/qkeysequence.html)**
**QKeySequence inherits from [Component](api/Component.md)**
### Example
```javascript
const { QKeySequence } = require("@nodegui/nodegui");
const keySequence = new QKeySequence(`Ctrl+L`);
```
### `new QKeySequence(sequence?)`
- `sequence` string (_optional_). String representation of the key sequence. For example: `Ctrl+M`
## Static Methods
QKeySequence can access all the static methods defined in [Component](api/Component.md)
## Instance Properties
QKeySequence can access all the instance properties defined in [Component](api/Component.md)
## Instance Methods
QKeySequence can access all the instance methods defined in [Component](api/Component.md)
Additionally it also has the following instance methods:
### `keySequence.count()`
Returns the number of keys in the key sequence. The maximum is 4. It calls the native method [QKeySequence: count](https://doc.qt.io/qt-5/QKeySequence.html#count).

View File

@ -58,3 +58,15 @@ Additionally it also has the following instance methods:
Sets the given widget to be the main window's central widget.
- `widget` NodeWidget - Any widget that inherits from NodeWidget class.
### `win.setMenuBar(menuBar)`
Sets the given menuBar to be the window's menubar widget.
- `menuBar` [QMenuBar](api/QMenuBar)
### `win.setMenuWidget(menuWidget)`
Sets the given widget to be the window's menubar widget.
- `menuWidget` NodeWidget

46
website/docs/api/QMenu.md Normal file
View File

@ -0,0 +1,46 @@
---
sidebar_label: QMenu
title: QMenu
---
> The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
**This class is a JS wrapper around Qt's [QMenu class](https://doc.qt.io/qt-5/qmenu.html)**
**QMenu inherits from [NodeWidget](api/NodeWidget.md)**
### Example
```javascript
const { QMenu } = require("@nodegui/nodegui");
const menu = new QMenu();
```
### `new QMenu(parent?)`
- `parent` NodeWidget (_optional_). Any widget inheriting from NodeWidget can be passed as a parent. This will make this widget, the child of the parent widget.
## Static Methods
QMenu can access all the static methods defined in [NodeWidget](api/NodeWidget.md)
## Instance Properties
QMenu can access all the instance properties defined in [NodeWidget](api/NodeWidget.md)
## Instance Methods
QMenu can access all the instance methods defined in [NodeWidget](api/NodeWidget.md). Additionally it also has the following instance methods:
### `menu.setTitle(title)`
This property holds the title of the menu. It calls the native method [QMenu: setTitle](https://doc.qt.io/qt-5/qmenu.html#title-prop).
- `title` string
### `menu.addAction(action)`
Appends the action action to this widget's list of actions. It calls the native method [QMenu: addAction](https://doc.qt.io/qt-5/qwidget.html#addAction).
- `action` [QAction](api/QAction).

View File

@ -0,0 +1,50 @@
---
sidebar_label: QMenuBar
title: QMenuBar
---
> The QMenuBar class provides a menu widget for use in menu bars, context menus, and other popup menus.
**This class is a JS wrapper around Qt's [QMenuBar class](https://doc.qt.io/qt-5/qmenu.html)**
**QMenuBar inherits from [NodeWidget](api/NodeWidget.md)**
### Example
```javascript
const { QMenuBar, QMainWindow } = require("@nodegui/nodegui");
const win = new QMainWindow();
const menu = new QMenuBar();
const menuBar = new QMenuBar();
win.setMenuBar(menuBar);
win.show();
global.win = win;
```
### `new QMenuBar(parent?)`
- `parent` NodeWidget (_optional_). Any widget inheriting from NodeWidget can be passed as a parent. This will make this widget, the child of the parent widget.
## Static Methods
QMenuBar can access all the static methods defined in [NodeWidget](api/NodeWidget.md)
## Instance Properties
QMenuBar can access all the instance properties defined in [NodeWidget](api/NodeWidget.md)
## Instance Methods
QMenuBar can access all the instance methods defined in [NodeWidget](api/NodeWidget.md). Additionally it also has the following instance methods:
### `menu.addMenu(menu)`
Appends menu to the menu bar. It calls the native method [QMenuBar: addMenu](https://doc.qt.io/qt-5/qmenubar.html#addMenu).
- `menu` [QMenu](api/QMenu).
### `menu.setNativeMenuBar(nativeMenuBar)`
This property holds whether or not a menubar will be used as a native menubar on platforms that support it. It calls the native method [QMenuBar: setNativeMenuBar](https://doc.qt.io/qt-5/qmenubar.html#nativeMenuBar-prop).
- `nativeMenuBar` Boolean.

View File

@ -0,0 +1,68 @@
---
sidebar_label: QShortcut
title: QShortcut
---
> The QShortcut class is used to create keyboard shortcuts.
**This class is a JS wrapper around Qt's [QShortcut class](https://doc.qt.io/qt-5/qshortcut.html)**
**QShortcut inherits from [EventWidget](api/EventWidget.md)**
### Example
```javascript
const { QShortcut, QKeySequence, QMainWindow } = require("@nodegui/nodegui");
const win = new QMainWindow();
const shortcut = new QShortcut(win);
shortcut.setKey(new QKeySequence("Ctrl+M"));
shortcut.setEnabled(true);
shortcut.addEventListener(QShortcutEvents.activated, () => {
console.log("Shortcut Activated");
});
win.show();
global.win = win;
global.shortcut = shortcut;
```
### `new QShortcut(parent)`
- `parent` NodeWidget. Any widget inheriting from NodeWidget can be passed as a parent. This will make this shortcut bind to the parent widget.
## Static Methods
QShortcut can access all the static methods defined in [EventWidget](api/EventWidget.md)
## Instance Properties
QShortcut can access all the instance properties defined in [EventWidget](api/EventWidget.md)
## Instance Methods
QShortcut can access all the instance methods defined in [EventWidget](api/EventWidget.md). Additionally it also has the following instance methods:
### `shortcut.setEnabled(enabled)`
This property holds whether the shortcut is enabled. It calls the native method [QShortcut: setEnabled](https://doc.qt.io/qt-5/qshortcut.html#enabled-prop).
- `enabled` - Boolean
### `shortcut.setAutoRepeat(on)`
This property holds whether the shortcut can auto repeat. It calls the native method [QShortcut: setAutoRepeat](https://doc.qt.io/qt-5/qshortcut.html#autoRepeat-prop).
- `on` - Boolean
### `shortcut.setKey(keySequence)`
This property holds the shortcut's key sequence. It calls the native method [QShortcut: setKey](https://doc.qt.io/qt-5/qshortcut.html#key-prop).
- `keySequence` [QKeySequence](api/QKeySequence.md)
### `shortcut.setContext(contextEnum)`
This property holds the context in which the shortcut is valid. It calls the native method [QShortcut: setContext](https://doc.qt.io/qt-5/qshortcut.html#context-prop).
- `contextEnum` - ShortcutContext enum.

View File

@ -1,6 +1,6 @@
---
sidebar_label: QSsystemTrayIcon
title: QSsystemTrayIcon
sidebar_label: QSystemTrayIcon
title: QSystemTrayIcon
---
> Create and control system tray icon.

View File

@ -5,7 +5,6 @@ module.exports = {
"api/QApplication",
"api/QCheckBox",
"api/QDial",
"api/QIcon",
"api/QLabel",
"api/QLineEdit",
"api/QMainWindow",
@ -15,12 +14,23 @@ module.exports = {
"api/QRadioButton",
"api/QScrollArea",
"api/QSpinBox",
"api/QSystemTrayIcon",
"api/QTabWidget",
"api/QWidget"
"api/QWidget",
"api/QMenu",
"api/QMenuBar"
],
Layouts: ["api/FlexLayout", "api/QGridLayout"],
Modules: ["api/QClipboard", "api/QCursor", "api/QPixmap", "api/QtEnums"],
Modules: [
"api/QClipboard",
"api/QCursor",
"api/QPixmap",
"api/QtEnums",
"api/QShortcut",
"api/QAction",
"api/QKeySequence",
"api/QIcon",
"api/QSystemTrayIcon"
],
"Internal Modules": [
"api/Component",
"api/EventWidget",