File: menu.cpp

package info (click to toggle)
ares 134%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 34,680 kB
  • sloc: cpp: 338,717; ansic: 89,036; sh: 52; makefile: 27
file content (59 lines) | stat: -rw-r--r-- 1,192 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#if defined(Hiro_Menu)

namespace hiro {

auto pMenu::construct() -> void {
  qtMenu = new QMenu;

  if(auto parent = _parentMenu()) {
    parent->qtMenu->addMenu(qtMenu);
  }

  if(auto parent = _parentMenuBar()) {
    if(auto window = parent->_parent()) {
      window->qtMenuBar->addMenu(qtMenu);
    }
  }

  if(auto parent = _parentPopupMenu()) {
    parent->qtPopupMenu->addMenu(qtMenu);
  }

  _setState();
}

auto pMenu::destruct() -> void {
if(Application::state().quit) return;  //TODO: hack
  delete qtMenu;
  qtMenu = nullptr;
}

auto pMenu::append(sAction action) -> void {
}

auto pMenu::remove(sAction action) -> void {
}

auto pMenu::setIcon(const image& icon, bool force) -> void {
  _setState();
}

auto pMenu::setText(const string& text) -> void {
  _setState();
}

auto pMenu::_setState() -> void {
  qtMenu->setEnabled(self().enabled());
  qtMenu->setFont(pFont::create(self().font(true)));
  qtMenu->setIcon(CreateIcon(state().icon));
  qtMenu->setTitle(QString::fromUtf8(state().text));
  qtMenu->menuAction()->setVisible(self().visible());

  for(auto& action : state().actions) {
    if(auto self = action->self()) self->setFont(action->font(true));
  }
}

}

#endif