| 84 } |
84 } |
| 85 } |
85 } |
| 86 |
86 |
| 87 void ui_toolbar_add_item(UiObject *obj, QToolBar *toolbar, UiToolbarItem *item) { |
87 void ui_toolbar_add_item(UiObject *obj, QToolBar *toolbar, UiToolbarItem *item) { |
| 88 QAction *action = new QAction(); |
88 QAction *action = new QAction(); |
| 89 action->setText(item->args.label); |
89 if(item->args.label) { |
| |
90 action->setText(item->args.label); |
| |
91 } |
| |
92 if(item->args.icon) { |
| |
93 action->setIcon(QIcon::fromTheme(item->args.icon)); |
| |
94 } |
| 90 toolbar->addAction(action); |
95 toolbar->addAction(action); |
| |
96 |
| |
97 UiEventWrapper *event = new UiEventWrapper(obj, item->args.onclick, item->args.onclickdata); |
| |
98 action->connect(action, SIGNAL(clicked()), event, SLOT(slot())); |
| |
99 action->connect(action, SIGNAL(destroyed()), event, SLOT(destroy())); |
| |
100 } |
| |
101 |
| |
102 static void toolbar_togglebutton_event(UiEvent *event, UiEventWrapper *wrapper) { |
| |
103 QAction *action = (QAction*)wrapper->customdata1; |
| |
104 event->intval = action->isChecked(); |
| |
105 if(wrapper->var) { |
| |
106 event->eventdata = wrapper->var->value; |
| |
107 } |
| 91 } |
108 } |
| 92 |
109 |
| 93 void ui_toolbar_add_toggleitem(UiObject *obj, QToolBar *toolbar, UiToolbarToggleItem *item) { |
110 void ui_toolbar_add_toggleitem(UiObject *obj, QToolBar *toolbar, UiToolbarToggleItem *item) { |
| |
111 QAction *action = new QAction(); |
| |
112 action->setCheckable(true); |
| |
113 if(item->args.label) { |
| |
114 action->setText(item->args.label); |
| |
115 } |
| |
116 if(item->args.icon) { |
| |
117 action->setIcon(QIcon::fromTheme(item->args.icon)); |
| |
118 } |
| |
119 toolbar->addAction(action); |
| 94 |
120 |
| |
121 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, nullptr, item->args.varname, UI_VAR_INTEGER); |
| |
122 UiEventWrapper *event = new UiEventWrapper(obj, item->args.onchange, item->args.onchangedata); |
| |
123 event->var = var; |
| |
124 event->customdata1 = action; |
| |
125 event->prepare_event = toolbar_togglebutton_event; |
| |
126 action->connect(action, SIGNAL(clicked()), event, SLOT(slot())); |
| |
127 action->connect(action, SIGNAL(destroyed()), event, SLOT(destroy())); |
| 95 } |
128 } |
| 96 |
129 |
| 97 void ui_toolbar_add_menu(UiObject *obj, QToolBar *toolbar, UiToolbarMenuItem *item) { |
130 void ui_toolbar_add_menu(UiObject *obj, QToolBar *toolbar, UiToolbarMenuItem *item) { |
| 98 |
131 |
| 99 } |
132 } |