File: menu.cpp

package info (click to toggle)
tuiwidgets 0.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,940 kB
  • sloc: cpp: 54,583; python: 495; sh: 83; makefile: 8
file content (34 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <Tui/ZCommandNotifier.h>
#include <Tui/ZHBoxLayout.h>
#include <Tui/ZMenu.h>
#include <Tui/ZWidget.h>

void exampleMenu(Tui::ZWidget *root, Tui::ZHBoxLayout *layout) {
// snippet-start
    QVector<Tui::ZMenuItem> items =  {
        {"Kilo", "", "kilo", {}},
        {"Mega", "", "mega", {}},
        {"<m>G</m>iga", "", "giga", {}},
        {"Tera", "", "tera", {}},
        {},
        {"Peta", "", "peta", {}},
        {"Exa", "", "exa", {}},
        {"Zetta", "", "zetta", {}},
        {"Yotta", "", "yotta", {}}
    };

    Tui::ZMenu *menu = new Tui::ZMenu(root);
    menu->setItems(items);

    QObject::connect(new Tui::ZCommandNotifier("mega", root), 
                     &Tui::ZCommandNotifier::activated, [&] { /* ... */ });

    QObject::connect(new Tui::ZCommandNotifier("giga", root),
                     &Tui::ZCommandNotifier::activated, [&] { /* ... */ });

    QObject::connect(new Tui::ZCommandNotifier("tera", root),
                     &Tui::ZCommandNotifier::activated, [&] { /* ... */ });

    menu->popup({1, 1});
// snippet-end
}