| 1 |
namespace phoenix { |
| 2 |
|
| 3 |
void pMenu::append(Action& action) { |
| 4 |
if(dynamic_cast<Menu*>(&action)) { |
| 5 |
qtMenu->addMenu(((Menu&)action).p.qtMenu); |
| 6 |
} else if(dynamic_cast<Separator*>(&action)) { |
| 7 |
qtMenu->addAction(((Separator&)action).p.qtAction); |
| 8 |
} else if(dynamic_cast<Item*>(&action)) { |
| 9 |
qtMenu->addAction(((Item&)action).p.qtAction); |
| 10 |
} else if(dynamic_cast<CheckItem*>(&action)) { |
| 11 |
qtMenu->addAction(((CheckItem&)action).p.qtAction); |
| 12 |
} else if(dynamic_cast<RadioItem*>(&action)) { |
| 13 |
qtMenu->addAction(((RadioItem&)action).p.qtAction); |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
void pMenu::remove(Action& action) { |
| 18 |
if(dynamic_cast<Menu*>(&action)) { |
| 19 |
//QMenu::removeMenu() does not exist |
| 20 |
qtMenu->clear(); |
| 21 |
for(auto &action : menu.state.action) append(action); |
| 22 |
} else if(dynamic_cast<Separator*>(&action)) { |
| 23 |
qtMenu->removeAction(((Separator&)action).p.qtAction); |
| 24 |
} else if(dynamic_cast<Item*>(&action)) { |
| 25 |
qtMenu->removeAction(((Item&)action).p.qtAction); |
| 26 |
} else if(dynamic_cast<CheckItem*>(&action)) { |
| 27 |
qtMenu->removeAction(((CheckItem&)action).p.qtAction); |
| 28 |
} else if(dynamic_cast<RadioItem*>(&action)) { |
| 29 |
qtMenu->removeAction(((CheckItem&)action).p.qtAction); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
void pMenu::setFont(string font) { |
| 34 |
qtMenu->setFont(pFont::create(font)); |
| 35 |
for(auto &item : menu.state.action) item.p.setFont(font); |
| 36 |
} |
| 37 |
|
| 38 |
void pMenu::setImage(const image& image) { |
| 39 |
qtMenu->setIcon(CreateIcon(image)); |
| 40 |
} |
| 41 |
|
| 42 |
void pMenu::setText(string text) { |
| 43 |
qtMenu->setTitle(QString::fromUtf8(text)); |
| 44 |
} |
| 45 |
|
| 46 |
void pMenu::constructor() { |
| 47 |
qtMenu = new QMenu; |
| 48 |
} |
| 49 |
|
| 50 |
void pMenu::destructor() { |
| 51 |
if(action.state.menu) action.state.menu->remove(menu); |
| 52 |
delete qtMenu; |
| 53 |
qtMenu = nullptr; |
| 54 |
} |
| 55 |
|
| 56 |
} |