3 QnstMenu::QnstMenu(QWidget* parent)
16 addAction(actionCopy);
17 addAction(actionPaste);
19 addAction(actionDelete);
21 addAction(actionExport);
40 void QnstMenu::createActions()
43 actionHelp =
new QAction(
this);
44 actionHelp->setText(tr(
"Help"));
45 actionHelp->setIcon(QIcon(
":/icon/help"));
46 actionHelp->setShortcut(QKeySequence(
"F1"));
47 actionHelp->setEnabled(
false);
64 actionCut =
new QAction(
this);
65 actionCut->setText(tr(
"Cut"));
66 actionCut->setIcon(QIcon(
":/icon/cut"));
67 actionCut->setShortcut(QKeySequence(
"Ctrl+X"));
68 actionCut->setEnabled(
false);
71 actionCopy =
new QAction(
this);
72 actionCopy->setText(tr(
"Copy"));
73 actionCopy->setIcon(QIcon(
":/icon/copy"));
74 actionCopy->setShortcut(QKeySequence(
"Ctrl+C"));
75 actionCopy->setEnabled(
false);
78 actionPaste =
new QAction(
this);
79 actionPaste->setText(tr(
"Paste"));
80 actionPaste->setIcon(QIcon(
":/icon/paste"));
81 actionPaste->setShortcut(QKeySequence(
"Ctrl+V"));
82 actionPaste->setEnabled(
false);
85 actionDelete =
new QAction(
this);
86 actionDelete->setText(tr(
"Delete"));
87 actionDelete->setIcon(QIcon(
":/icon/delete"));
88 actionDelete->setShortcut(QKeySequence(
"Del"));
89 actionDelete->setEnabled(
false);
92 actionZoomIn =
new QAction(
this);
93 actionZoomIn->setText(tr(
"Zoom In"));
94 actionZoomIn->setIcon(QIcon(
":/icon/zoomin"));
95 actionZoomIn->setShortcut(QKeySequence(
"Ctrl++"));
96 actionZoomIn->setEnabled(
false);
99 actionZoomOut =
new QAction(
this);
100 actionZoomOut->setText(tr(
"Zoom Out"));
101 actionZoomOut->setIcon(QIcon(
":/icon/zoomout"));
102 actionZoomOut->setShortcut(QKeySequence(
"Ctrl+-"));
103 actionZoomOut->setEnabled(
false);
106 actionZoomReset =
new QAction(
this);
107 actionZoomReset->setText(tr(
"Reset"));
108 actionZoomReset->setIcon(QIcon(
":/icon/zoomreset"));
109 actionZoomReset->setShortcut(QKeySequence(
"Ctrl+0"));
110 actionZoomReset->setEnabled(
false);
113 actionFullscreen =
new QAction(
this);
114 actionFullscreen->setText(tr(
"Full Screen"));
115 actionFullscreen->setIcon(QIcon(
":/icon/fullscreen"));
116 actionFullscreen->setShortcut(QKeySequence(
"F11"));
117 actionFullscreen->setEnabled(
false);
120 actionExport =
new QAction(
this);
121 actionExport->setText(tr(
"Export..."));
122 actionExport->setIcon(QIcon(
":/icon/export"));
123 actionExport->setEnabled(
false);
126 actionAddMedia =
new QAction(
this);
127 actionAddMedia->setText(tr(
"Media"));
128 actionAddMedia->setData(Qnst::Media);
130 actionAddMedia->setEnabled(
false);
133 actionAddContext =
new QAction(
this);
134 actionAddContext->setText(tr(
"Context"));
135 actionAddContext->setData(Qnst::Context);
137 actionAddContext->setEnabled(
false);
140 actionAddSwitch =
new QAction(
this);
141 actionAddSwitch->setText(tr(
"Switch"));
142 actionAddSwitch->setData(Qnst::Switch);
144 actionAddSwitch->setEnabled(
false);
147 actionAddBody =
new QAction(
this);
148 actionAddBody->setText(tr(
"Body"));
149 actionAddBody->setData(Qnst::Body);
151 actionAddBody->setEnabled(
false);
154 actionAddPort =
new QAction(
this);
155 actionAddPort->setText(tr(
"Port"));
156 actionAddPort->setData(Qnst::Port);
158 actionAddPort->setEnabled(
false);
161 actionAddSwitchPort =
new QAction(
this);
162 actionAddSwitchPort->setText(tr(
"Switch Port"));
163 actionAddSwitchPort->setData(Qnst::SwitchPort);
165 actionAddSwitchPort->setEnabled(
false);
168 actionAddArea =
new QAction(
this);
169 actionAddArea->setText(tr(
"Area"));
170 actionAddArea->setData(Qnst::Area);
172 actionAddArea->setEnabled(
false);
175 actionAddProperty =
new QAction(
this);
176 actionAddProperty->setText(tr(
"Property"));
177 actionAddProperty->setData(Qnst::Property);
179 actionAddProperty->setEnabled(
false);
182 actionAddAggregator =
new QAction(
this);
183 actionAddAggregator->setText(tr(
"Link"));
184 actionAddAggregator->setData(Qnst::Link);
186 actionAddAggregator->setEnabled(
false);
189 actionBringfront =
new QAction(
this);
190 actionBringfront->setText(tr(
"Bring to Front"));
191 actionBringfront->setIcon(QIcon(
":/icon/bringfront"));
192 actionBringfront->setShortcut(QKeySequence(
"Shift+Ctrl+]"));
193 actionBringfront->setEnabled(
false);
196 actionBringforward =
new QAction(
this);
197 actionBringforward->setText(tr(
"Bring Forward"));
198 actionBringforward->setIcon(QIcon(
":/icon/bringforward"));
199 actionBringforward->setShortcut(QKeySequence(
"Ctrl+]"));
200 actionBringforward->setEnabled(
false);
203 actionSendbackward =
new QAction(
this);
204 actionSendbackward->setText(tr(
"Send Backward"));
205 actionSendbackward->setIcon(QIcon(
":/icon/sendbackward"));
206 actionSendbackward->setShortcut(QKeySequence(
"Ctrl+["));
207 actionSendbackward->setEnabled(
false);
210 actionSendback =
new QAction(
this);
211 actionSendback->setText(tr(
"Send to Back"));
212 actionSendback->setIcon(QIcon(
":/icon/sendback"));
213 actionSendback->setShortcut(QKeySequence(
"Shift+Ctrl+["));
214 actionSendback->setEnabled(
false);
217 actionHide =
new QAction(
this);
218 actionHide->setText(tr(
"Hide"));
219 actionHide->setShortcut(QKeySequence(
"Ctrl+H"));
220 actionHide->setEnabled(
false);
223 actionProperties =
new QAction(
this);
224 actionProperties->setText(tr(
"Properties"));
225 actionProperties->setEnabled(
false);
228 actionAuto =
new QAction(
this);
229 actionAuto->setText(tr(
"Auto (Unstable)"));
230 actionAuto->setEnabled(
false);
233 void QnstMenu::createMenus()
236 menuView =
new QMenu();
237 menuView->setTitle(tr(
"View"));
239 menuView->addAction(actionZoomIn);
240 menuView->addAction(actionZoomOut);
241 menuView->addAction(actionZoomReset);
242 menuView->addSeparator();
243 menuView->addAction(actionFullscreen);
245 menuView->setEnabled(
false);
248 menuInsert =
new QMenu();
249 menuInsert->setTitle(tr(
"Insert"));
251 menuInsert->addAction(actionAddMedia);
252 menuInsert->addSeparator();
253 menuInsert->addAction(actionAddContext);
254 menuInsert->addAction(actionAddSwitch);
255 menuInsert->addSeparator();
256 menuInsert->addAction(actionAddBody);
257 menuInsert->addSeparator();
258 menuInsert->addAction(actionAddPort);
259 menuInsert->addAction(actionAddSwitchPort);
260 menuInsert->addAction(actionAddArea);
261 menuInsert->addAction(actionAddProperty);
262 menuInsert->addSeparator();
263 menuInsert->addAction(actionAddAggregator);
265 menuInsert->setEnabled(
false);
268 menuShow =
new QMenu();
269 menuShow->setTitle(tr(
"Show"));
271 menuShow->setEnabled(
false);
274 menuArrange =
new QMenu();
275 menuArrange->setTitle(tr(
"Arrange"));
277 menuArrange->addAction(actionBringfront);
278 menuArrange->addAction(actionBringforward);
279 menuArrange->addAction(actionSendbackward);
280 menuArrange->addAction(actionSendback);
282 menuArrange->setEnabled(
false);
285 menuAdjust =
new QMenu();
286 menuAdjust->setTitle(tr(
"Adjust"));
288 menuAdjust->addAction(actionAuto);
290 menuAdjust->setEnabled(
false);
293 void QnstMenu::createConnections()
295 connect(actionHelp, SIGNAL(triggered()), SIGNAL(helpRequested()));
300 connect(actionCut, SIGNAL(triggered()), SIGNAL(cutRequested()));
301 connect(actionCopy, SIGNAL(triggered()), SIGNAL(copyRequested()));
302 connect(actionPaste, SIGNAL(triggered()), SIGNAL(pasteRequested()));
304 connect(actionDelete, SIGNAL(triggered()), SIGNAL(deleteRequested()));
306 connect(actionExport, SIGNAL(triggered()), SIGNAL(exportRequested()));
308 connect(actionZoomIn, SIGNAL(triggered()), SIGNAL(zoominRequested()));
309 connect(actionZoomOut, SIGNAL(triggered()), SIGNAL(zoomoutRequested()));
310 connect(actionZoomReset, SIGNAL(triggered()), SIGNAL(zoomresetRequested()));
311 connect(actionFullscreen, SIGNAL(triggered()), SIGNAL(fullscreenRequested()));
313 connect(actionAddMedia, SIGNAL(triggered()), SLOT(dispatchAddAction()));
316 connect(actionAddContext, SIGNAL(triggered()), SLOT(dispatchAddAction()));
317 connect(actionAddSwitch, SIGNAL(triggered()), SLOT(dispatchAddAction()));
318 connect(actionAddBody, SIGNAL(triggered()), SLOT(dispatchAddAction()));
319 connect(actionAddPort, SIGNAL(triggered()), SLOT(dispatchAddAction()));
320 connect(actionAddSwitchPort, SIGNAL(triggered()), SLOT(dispatchAddAction()));
321 connect(actionAddArea, SIGNAL(triggered()), SLOT(dispatchAddAction()));
322 connect(actionAddProperty, SIGNAL(triggered()), SLOT(dispatchAddAction()));
323 connect(actionAddAggregator, SIGNAL(triggered()), SLOT(dispatchAddAction()));
325 connect(actionBringfront, SIGNAL(triggered()), SIGNAL(bringfrontRequested()));
326 connect(actionBringforward, SIGNAL(triggered()), SIGNAL(bringforwardRequested()));
327 connect(actionSendbackward, SIGNAL(triggered()), SIGNAL(sendbackwardRequested()));
328 connect(actionSendback, SIGNAL(triggered()), SIGNAL(sendbackRequested()));
330 connect(actionHide, SIGNAL(triggered()), SIGNAL(hideRequested()));
332 connect(actionProperties, SIGNAL(triggered()), SIGNAL(propertiesRequested()));
334 connect(actionAuto, SIGNAL(triggered()), SIGNAL(autoRequested()));
337 void QnstMenu::dispatchAddAction()
339 QAction *action = dynamic_cast <QAction*> (QObject::sender());