Rev 18477 | Rev 18629 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10934 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | /*************************************************************************** |
||
8 | * * |
||
9 | * This program is free software; you can redistribute it and/or modify * |
||
10 | * it under the terms of the GNU General Public License as published by * |
||
11 | * the Free Software Foundation; either version 2 of the License, or * |
||
12 | * (at your option) any later version. * |
||
13 | * * |
||
14 | ***************************************************************************/ |
||
15 | |||
11698 | cbradney | 16 | // #include <QDebug> |
16546 | jghali | 17 | #include <QApplication> |
10940 | cbradney | 18 | #include <QFrame> |
19 | #include <QGridLayout> |
||
20 | #include <QLabel> |
||
10941 | cbradney | 21 | #include <QTextEdit> |
10934 | cbradney | 22 | #include <QWidget> |
10940 | cbradney | 23 | #include <QWidgetAction> |
10934 | cbradney | 24 | |
25 | #include "contextmenu.h" |
||
11146 | cbradney | 26 | #include "prefsmanager.h" |
17826 | craig | 27 | #include "pageitem_textframe.h" |
12841 | jghali | 28 | #include "scmimedata.h" |
10940 | cbradney | 29 | #include "scraction.h" |
15516 | fschmid | 30 | #include "scrapbookpalette.h" |
10940 | cbradney | 31 | #include "scribus.h" |
32 | #include "scribusdoc.h" |
||
15516 | fschmid | 33 | #include "ui/scmwmenumanager.h" |
10940 | cbradney | 34 | #include "undomanager.h" |
16254 | fschmid | 35 | #include "canvasmode_normal.h" |
10934 | cbradney | 36 | |
14796 | fschmid | 37 | // #include "util.h" //just for tdebug |
13761 | cbradney | 38 | |
11146 | cbradney | 39 | ContextMenu::ContextMenu(Selection & sel, ScribusMainWindow *actionsParent, ScribusDoc* doc, QWidget * parent) : |
10934 | cbradney | 40 | QMenu(parent), |
10940 | cbradney | 41 | m_Sel(sel), |
18466 | craig | 42 | m_ScMW(actionsParent), |
11749 | cbradney | 43 | m_doc(doc), |
44 | onAPage(false) |
||
10934 | cbradney | 45 | { |
11146 | cbradney | 46 | if (m_Sel.count()>0) |
47 | { |
||
14796 | fschmid | 48 | // tDebug("process Selection start"); |
11146 | cbradney | 49 | processSelection(); |
14796 | fschmid | 50 | // tDebug("process Selection end"); |
11146 | cbradney | 51 | createMenuItems_Selection(); |
52 | } |
||
10934 | cbradney | 53 | } |
54 | |||
11146 | cbradney | 55 | ContextMenu::ContextMenu(ScribusMainWindow *actionsParent, ScribusDoc* doc, double mx, double my, QWidget * parent) : |
56 | QMenu(parent), |
||
57 | m_Sel(Selection(this)), |
||
18466 | craig | 58 | m_ScMW(actionsParent), |
11146 | cbradney | 59 | m_doc(doc) |
60 | { |
||
61 | createMenuItems_NoSelection(mx, my); |
||
62 | } |
||
63 | |||
10934 | cbradney | 64 | void ContextMenu::processSelection() |
65 | { |
||
66 | int selectedItemCount=m_Sel.count(); |
||
67 | if (selectedItemCount == 0) |
||
68 | return; |
||
69 | |||
10940 | cbradney | 70 | PageItem* currItem=NULL; |
10934 | cbradney | 71 | for (int i = 0; i < selectedItemCount; ++i) |
72 | { |
||
73 | currItem = m_Sel.itemAt(i); |
||
74 | if (currItem) |
||
75 | { |
||
76 | currItem->applicableActions(m_actionList); |
||
77 | } |
||
78 | } |
||
79 | } |
||
80 | |||
11146 | cbradney | 81 | void ContextMenu::createMenuItems_Selection() |
10934 | cbradney | 82 | { |
10940 | cbradney | 83 | //CB TODO clean |
84 | int selectedItemCount=m_Sel.count(); |
||
85 | if (selectedItemCount==0) |
||
86 | return; |
||
87 | bool itemsAreSameType=m_Sel.itemsAreSameType(); |
||
88 | //Find our doc from first item in selection if we have an item |
||
89 | PageItem *currItem = m_Sel.itemAt(0); |
||
90 | assert(m_doc!=0 && currItem!=0); |
||
91 | |||
92 | QMenu *menuConvertTo = new QMenu(this); |
||
10993 | cbradney | 93 | QMenu *menuEditContents = new QMenu(this); |
94 | QMenu *menuInfo = new QMenu(this); |
||
10940 | cbradney | 95 | QMenu *menuLayer = new QMenu(this); |
96 | QMenu *menuLevel = new QMenu(this); |
||
10993 | cbradney | 97 | QMenu *menuPDF = new QMenu(this); |
17826 | craig | 98 | QMenu *menuMark = new QMenu(this); |
10940 | cbradney | 99 | QMenu *menuResolution = new QMenu(this); |
18466 | craig | 100 | QMenu *menuLocking = new QMenu(this); |
101 | QMenu *menuSendTo = new QMenu(this); |
||
102 | QMenu *menuScrapbook = new QMenu(this); |
||
17145 | fschmid | 103 | // QMenu *menuWeld = new QMenu(this); |
18466 | craig | 104 | |
10940 | cbradney | 105 | //<-- Add Info |
10941 | cbradney | 106 | //Test new method with image frames first |
107 | if (selectedItemCount==1 && currItem->asImageFrame()) |
||
10940 | cbradney | 108 | { |
109 | QAction *act = addMenu(menuInfo); |
||
110 | act->setText( ScribusView::tr("In&fo")); |
||
10941 | cbradney | 111 | if (currItem->asImageFrame()) |
112 | { |
||
17064 | jghali | 113 | QLabel* menuLabel = new QLabel("<html>" + currItem->infoDescription() + "</html>", this); |
114 | menuLabel->setFrameShape(QFrame::NoFrame); |
||
10941 | cbradney | 115 | QWidgetAction* menuTextWidget = new QWidgetAction(this); |
17064 | jghali | 116 | menuTextWidget->setDefaultWidget(menuLabel); |
10941 | cbradney | 117 | menuInfo->addAction(menuTextWidget); |
118 | } |
||
10940 | cbradney | 119 | } |
10941 | cbradney | 120 | else |
121 | { |
||
122 | QFrame *infoGroup = new QFrame( m_doc->view() ); |
||
123 | infoGroup->setFrameShape( QFrame::NoFrame ); |
||
124 | QGridLayout *infoGroupLayout = new QGridLayout( infoGroup ); |
||
125 | infoGroupLayout->setAlignment( Qt::AlignTop ); |
||
126 | infoGroupLayout->setSpacing( 2 ); |
||
127 | infoGroupLayout->setMargin( 0 ); |
||
128 | if (currItem->createInfoGroup(infoGroup, infoGroupLayout)) |
||
129 | { |
||
130 | int row = infoGroupLayout->rowCount(); // <a.l.e> |
||
131 | |||
132 | QLabel *printCT = new QLabel(infoGroup); |
||
133 | QLabel *printT = new QLabel(infoGroup); |
||
134 | printCT->setText( ScribusView::tr("Print: ")); |
||
135 | infoGroupLayout->addWidget( printCT, row, 0, Qt::AlignRight ); |
||
136 | if (currItem->printEnabled()) |
||
137 | printT->setText( ScribusView::tr("Enabled")); |
||
138 | else |
||
139 | printT->setText( ScribusView::tr("Disabled")); |
||
140 | infoGroupLayout->addWidget( printT, row, 1 ); // </a.l.e> |
||
141 | |||
142 | QWidgetAction* MenAct = new QWidgetAction(this); |
||
143 | MenAct->setDefaultWidget(infoGroup); |
||
144 | menuInfo->addAction(MenAct); |
||
145 | |||
146 | // Qt4 menuInfo->insertItem(infoGroup); |
||
13033 | cbradney | 147 | // currItem->createContextMenu(menuInfo, 5); |
10941 | cbradney | 148 | QAction *act = addMenu(menuInfo); |
149 | act->setText( ScribusView::tr("In&fo")); |
||
150 | } else { |
||
151 | delete infoGroupLayout; |
||
152 | delete infoGroup; |
||
153 | } |
||
154 | } |
||
10940 | cbradney | 155 | //--> |
18466 | craig | 156 | |
10940 | cbradney | 157 | //<-- Add undo |
158 | UndoManager * const undoManager(UndoManager::instance()); |
||
159 | if (undoManager->hasUndoActions()) |
||
18466 | craig | 160 | addAction(m_ScMW->scrActions["editUndoAction"]); |
10940 | cbradney | 161 | if (undoManager->hasRedoActions()) |
18466 | craig | 162 | addAction(m_ScMW->scrActions["editRedoAction"]); |
10940 | cbradney | 163 | //--> |
18466 | craig | 164 | |
10940 | cbradney | 165 | //<-- Item specific actions |
166 | if (itemsAreSameType) |
||
167 | { |
||
12400 | cbradney | 168 | if (m_actionList.contains("editEditRenderSource")) |
10940 | cbradney | 169 | { |
170 | addSeparator(); |
||
18466 | craig | 171 | addAction(m_ScMW->scrActions["editEditRenderSource"]); |
10940 | cbradney | 172 | } |
17826 | craig | 173 | if (m_doc->appMode == modeEdit) |
174 | { |
||
175 | //add actions for marks in edit mode |
||
176 | addSeparator(); |
||
177 | QAction *act2 = addMenu(menuMark); |
||
178 | act2->setText( ScribusView::tr("Insert Mark")); |
||
18466 | craig | 179 | menuMark->addAction(m_ScMW->scrActions["insertMarkVariableText"]); |
17826 | craig | 180 | if (m_actionList.contains("insertMarkAnchor")) |
181 | { |
||
18466 | craig | 182 | menuMark->addAction(m_ScMW->scrActions["insertMarkAnchor"]); |
183 | menuMark->addAction(m_ScMW->scrActions["insertMarkItem"]); |
||
184 | menuMark->addAction(m_ScMW->scrActions["insertMark2Mark"]); |
||
17826 | craig | 185 | if (!currItem->isNoteFrame()) |
18466 | craig | 186 | menuMark->addAction(m_ScMW->scrActions["insertMarkNote"]); |
17826 | craig | 187 | // menuMark->addAction(m_AP->scrActions["insertMarkIndex"]); |
188 | } |
||
189 | if (currItem->itemText.cursorPosition() < currItem->itemText.length()) |
||
190 | { |
||
18524 | avox | 191 | if (currItem->itemText.hasMark(currItem->itemText.cursorPosition())) |
18466 | craig | 192 | addAction(m_ScMW->scrActions["editMark"]); |
17826 | craig | 193 | } |
194 | } |
||
195 | if (!m_doc->marksList().isEmpty()) |
||
196 | { |
||
197 | addSeparator(); |
||
18466 | craig | 198 | addAction(m_ScMW->scrActions["itemUpdateMarks"]); |
17826 | craig | 199 | } |
10940 | cbradney | 200 | if (m_actionList.contains("fileImportText")) |
201 | { |
||
202 | addSeparator(); |
||
18466 | craig | 203 | addAction(m_ScMW->scrActions["fileImportText"]); |
204 | addAction(m_ScMW->scrActions["fileImportAppendText"]); |
||
205 | addAction(m_ScMW->scrActions["toolsEditWithStoryEditor"]); |
||
206 | addAction(m_ScMW->scrActions["insertSampleText"]); |
||
10940 | cbradney | 207 | } |
11698 | cbradney | 208 | else //enable this for, eg, text on a path |
209 | if (m_actionList.contains("toolsEditWithStoryEditor")) |
||
210 | { |
||
211 | addSeparator(); |
||
18466 | craig | 212 | addAction(m_ScMW->scrActions["toolsEditWithStoryEditor"]); |
11698 | cbradney | 213 | } |
10940 | cbradney | 214 | addSeparator(); |
215 | if (m_actionList.contains("fileImportImage")) |
||
18466 | craig | 216 | addAction(m_ScMW->scrActions["fileImportImage"]); |
12860 | fschmid | 217 | if (selectedItemCount==1 && currItem->asImageFrame()) |
218 | { |
||
219 | if (QApplication::clipboard()->mimeData()->hasImage()) |
||
18466 | craig | 220 | addAction(m_ScMW->scrActions["editPasteImageFromClipboard"]); |
12860 | fschmid | 221 | } |
10940 | cbradney | 222 | if (m_actionList.contains("itemAdjustFrameToImage")) |
18466 | craig | 223 | addAction(m_ScMW->scrActions["itemAdjustFrameToImage"]); |
12591 | fschmid | 224 | if (m_actionList.contains("itemAdjustImageToFrame")) |
18466 | craig | 225 | addAction(m_ScMW->scrActions["itemAdjustImageToFrame"]); |
16856 | craig | 226 | |
227 | if (m_actionList.contains("tableInsertRows")) |
||
18466 | craig | 228 | addAction(m_ScMW->scrActions["tableInsertRows"]); |
16856 | craig | 229 | if (m_actionList.contains("tableInsertColumns")) |
18466 | craig | 230 | addAction(m_ScMW->scrActions["tableInsertColumns"]); |
16856 | craig | 231 | if (m_actionList.contains("tableDeleteRows")) |
18466 | craig | 232 | addAction(m_ScMW->scrActions["tableDeleteRows"]); |
16856 | craig | 233 | if (m_actionList.contains("tableDeleteColumns")) |
18466 | craig | 234 | addAction(m_ScMW->scrActions["tableDeleteColumns"]); |
16856 | craig | 235 | if (m_actionList.contains("tableMergeCells")) |
18466 | craig | 236 | addAction(m_ScMW->scrActions["tableMergeCells"]); |
16856 | craig | 237 | if (m_actionList.contains("tableSplitCells")) |
18466 | craig | 238 | addAction(m_ScMW->scrActions["tableSplitCells"]); |
16856 | craig | 239 | if (m_actionList.contains("tableSetRowHeights")) |
18466 | craig | 240 | addAction(m_ScMW->scrActions["tableSetRowHeights"]); |
16856 | craig | 241 | if (m_actionList.contains("tableSetColumnWidths")) |
18466 | craig | 242 | addAction(m_ScMW->scrActions["tableSetColumnWidths"]); |
16856 | craig | 243 | if (m_actionList.contains("tableDistributeRowsEvenly")) |
18466 | craig | 244 | addAction(m_ScMW->scrActions["tableDistributeRowsEvenly"]); |
16856 | craig | 245 | if (m_actionList.contains("tableDistributeColumnsEvenly")) |
18466 | craig | 246 | addAction(m_ScMW->scrActions["tableDistributeColumnsEvenly"]); |
16856 | craig | 247 | if (m_actionList.contains("tableAdjustFrameToTable")) |
18466 | craig | 248 | addAction(m_ScMW->scrActions["tableAdjustFrameToTable"]); |
16856 | craig | 249 | if (m_actionList.contains("tableAdjustTableToFrame")) |
18466 | craig | 250 | addAction(m_ScMW->scrActions["tableAdjustTableToFrame"]); |
17595 | craig | 251 | if (m_actionList.contains("itemAdjustFrameHeightToText")) |
18466 | craig | 252 | addAction(m_ScMW->scrActions["itemAdjustFrameHeightToText"]); |
10940 | cbradney | 253 | if (m_actionList.contains("itemExtendedImageProperties")) |
18466 | craig | 254 | addAction(m_ScMW->scrActions["itemExtendedImageProperties"]); |
14796 | fschmid | 255 | if (m_actionList.contains("itemAdjustFrameToImage")) |
256 | { |
||
257 | if (currItem->PictureIsAvailable) |
||
18466 | craig | 258 | addAction(m_ScMW->scrActions["itemToggleInlineImage"]); |
14796 | fschmid | 259 | } |
12553 | fschmid | 260 | if (m_actionList.contains("itemImageInfo")) |
18466 | craig | 261 | addAction(m_ScMW->scrActions["itemImageInfo"]); |
10940 | cbradney | 262 | if (m_actionList.contains("itemUpdateImage")) |
18466 | craig | 263 | addAction(m_ScMW->scrActions["itemUpdateImage"]); |
10940 | cbradney | 264 | |
265 | if (m_actionList.contains("itemPreviewLow")) |
||
266 | { |
||
267 | if (m_actionList.contains("itemImageIsVisible")) |
||
18466 | craig | 268 | menuResolution->addAction(m_ScMW->scrActions["itemImageIsVisible"]); |
10940 | cbradney | 269 | menuResolution->addSeparator(); |
270 | if (m_actionList.contains("itemPreviewLow")) |
||
18466 | craig | 271 | menuResolution->addAction(m_ScMW->scrActions["itemPreviewLow"]); |
10940 | cbradney | 272 | if (m_actionList.contains("itemPreviewNormal")) |
18466 | craig | 273 | menuResolution->addAction(m_ScMW->scrActions["itemPreviewNormal"]); |
10940 | cbradney | 274 | if (m_actionList.contains("itemPreviewFull")) |
18466 | craig | 275 | menuResolution->addAction(m_ScMW->scrActions["itemPreviewFull"]); |
10940 | cbradney | 276 | if (menuResolution->actions().count()>0) |
277 | { |
||
278 | QAction *act = addMenu(menuResolution); |
||
279 | act->setText( tr("Preview Settings")); |
||
280 | } |
||
281 | } |
||
282 | |||
283 | if (m_actionList.contains("styleImageEffects")) |
||
18466 | craig | 284 | addAction(m_ScMW->scrActions["styleImageEffects"]); |
10940 | cbradney | 285 | if (m_actionList.contains("editEditWithImageEditor")) |
18466 | craig | 286 | addAction(m_ScMW->scrActions["editEditWithImageEditor"]); |
11789 | fschmid | 287 | if (selectedItemCount==1 && currItem->asImageFrame()) |
288 | { |
||
13097 | subik | 289 | if (currItem->PictureIsAvailable) |
11789 | fschmid | 290 | { |
18466 | craig | 291 | m_ScMW->scrActions["itemAdjustFrameToImage"]->setEnabled(true); |
292 | m_ScMW->scrActions["itemAdjustImageToFrame"]->setEnabled(true); |
||
11789 | fschmid | 293 | if (currItem->pixm.imgInfo.valid) |
18466 | craig | 294 | m_ScMW->scrActions["itemExtendedImageProperties"]->setEnabled(true); |
11789 | fschmid | 295 | if (currItem->pixm.imgInfo.exifDataValid) |
18466 | craig | 296 | m_ScMW->scrActions["itemImageInfo"]->setEnabled(true); |
297 | m_ScMW->scrActions["itemUpdateImage"]->setEnabled(true); |
||
11789 | fschmid | 298 | if (currItem->isRaster) |
299 | { |
||
18466 | craig | 300 | m_ScMW->scrActions["styleImageEffects"]->setEnabled(true); |
301 | m_ScMW->scrActions["editEditWithImageEditor"]->setEnabled(true); |
||
11789 | fschmid | 302 | } |
303 | } |
||
304 | } |
||
10940 | cbradney | 305 | |
17595 | craig | 306 | if ((selectedItemCount==1) && currItem->asTextFrame()) |
307 | { |
||
308 | if (currItem->itemText.length() > 0) |
||
18466 | craig | 309 | m_ScMW->scrActions["itemAdjustFrameHeightToText"]->setEnabled(true); |
17595 | craig | 310 | } |
10940 | cbradney | 311 | } |
312 | //--> |
||
18466 | craig | 313 | |
10940 | cbradney | 314 | //<-- Item Attributes |
315 | if (selectedItemCount == 1) |
||
316 | { |
||
317 | addSeparator(); |
||
18466 | craig | 318 | addAction(m_ScMW->scrActions["itemAttributes"]); |
10940 | cbradney | 319 | } |
320 | //--> |
||
18466 | craig | 321 | |
10993 | cbradney | 322 | //<-- Item PDF Options |
12211 | fschmid | 323 | if (currItem->itemType() == PageItem::TextFrame) |
10993 | cbradney | 324 | { |
12211 | fschmid | 325 | QAction *act = addMenu(menuPDF); |
326 | act->setText( ScribusView::tr("&PDF Options")); |
||
18466 | craig | 327 | menuPDF->addAction(m_ScMW->scrActions["itemPDFIsAnnotation"]); |
12211 | fschmid | 328 | if (!m_doc->masterPageMode()) |
18466 | craig | 329 | menuPDF->addAction(m_ScMW->scrActions["itemPDFIsBookmark"]); |
12211 | fschmid | 330 | if (selectedItemCount == 1) |
331 | { |
||
332 | menuPDF->addSeparator(); |
||
333 | if (m_actionList.contains("itemPDFAnnotationProps")) |
||
18466 | craig | 334 | menuPDF->addAction(m_ScMW->scrActions["itemPDFAnnotationProps"]); |
12211 | fschmid | 335 | if (m_actionList.contains("itemPDFFieldProps")) |
18466 | craig | 336 | menuPDF->addAction(m_ScMW->scrActions["itemPDFFieldProps"]); |
12211 | fschmid | 337 | } |
10993 | cbradney | 338 | } |
339 | //--> |
||
18466 | craig | 340 | |
10940 | cbradney | 341 | //<-- Item Locking |
342 | addSeparator(); |
||
343 | //--> |
||
344 | |||
345 | if (selectedItemCount>0) |
||
346 | { |
||
18466 | craig | 347 | menuLocking->addAction(m_ScMW->scrActions["itemLock"]); |
348 | menuLocking->addAction(m_ScMW->scrActions["itemLockSize"]); |
||
349 | QAction *actL = addMenu(menuLocking); |
||
350 | actL->setText( ScribusView::tr("Locking")); |
||
351 | |||
352 | QAction *actST = addMenu(menuSendTo); |
||
353 | actST->setText( ScribusView::tr("Send to")); |
||
354 | QAction *actScr = menuSendTo->addMenu(menuScrapbook); |
||
355 | actScr->setText( ScribusView::tr("Scrapbook")); |
||
356 | menuSendTo->addAction(m_ScMW->scrActions["itemSendToPattern"]); |
||
357 | menuSendTo->addAction(m_ScMW->scrActions["itemSendToInline"]); |
||
358 | |||
359 | QStringList scrapNames = m_ScMW->scrapbookNames(); |
||
360 | scrapNames.removeAt(1); |
||
361 | for (int i = 0; i < scrapNames.count(); i++) |
||
362 | { |
||
363 | ScrAction *act = new ScrAction( ScrAction::DataInt, QPixmap(), QPixmap(), scrapNames[i], QKeySequence(), this, i); |
||
364 | menuScrapbook->addAction(act); |
||
365 | connect(act, SIGNAL(triggeredData(int)), m_ScMW, SLOT(PutScrap(int))); |
||
366 | } |
||
367 | |||
10940 | cbradney | 368 | if (m_doc->layerCount() > 1) |
369 | { |
||
370 | QMap<int,int> layerMap; |
||
371 | for (ScLayers::iterator it = m_doc->Layers.begin(); it != m_doc->Layers.end(); ++it) |
||
13875 | jghali | 372 | layerMap.insert((*it).Level, (*it).ID); |
10940 | cbradney | 373 | int i=layerMap.count()-1; |
374 | while (i>=0) |
||
375 | { |
||
376 | if (m_doc->layerLocked(layerMap[i])) |
||
18466 | craig | 377 | m_ScMW->scrLayersActions[QString::number(layerMap[i])]->setEnabled(false); |
10940 | cbradney | 378 | else |
18466 | craig | 379 | m_ScMW->scrLayersActions[QString::number(layerMap[i])]->setEnabled(true); |
11464 | fschmid | 380 | QPixmap pm(20,15); |
381 | pm.fill(m_doc->layerMarker(layerMap[i])); |
||
18466 | craig | 382 | m_ScMW->scrLayersActions[QString::number(layerMap[i])]->setIcon(pm); |
383 | menuLayer->addAction(m_ScMW->scrLayersActions[QString::number(layerMap[i--])]); |
||
10940 | cbradney | 384 | } |
385 | QAction *act = addMenu(menuLayer); |
||
386 | act->setText( ScribusView::tr("Send to La&yer")); |
||
387 | } |
||
388 | //--> |
||
389 | } |
||
390 | //<-- Add Groups Items |
||
16105 | fschmid | 391 | if (selectedItemCount > 1) |
10940 | cbradney | 392 | { |
17454 | fschmid | 393 | if (m_Sel.objectsLayer() != -1) |
18466 | craig | 394 | addAction(m_ScMW->scrActions["itemGroup"]); |
10940 | cbradney | 395 | } |
16105 | fschmid | 396 | else |
397 | { |
||
398 | if (currItem->isGroup()) |
||
17905 | fschmid | 399 | { |
18466 | craig | 400 | addAction(m_ScMW->scrActions["itemUngroup"]); |
401 | addAction(m_ScMW->scrActions["itemGroupAdjust"]); |
||
17905 | fschmid | 402 | } |
16105 | fschmid | 403 | } |
10940 | cbradney | 404 | //--> |
405 | |||
406 | //<-- Add Level Item |
||
407 | if (!currItem->locked()) |
||
408 | { |
||
18466 | craig | 409 | menuLevel->addAction(m_ScMW->scrActions["itemRaiseToTop"]); |
410 | menuLevel->addAction(m_ScMW->scrActions["itemRaise"]); |
||
411 | menuLevel->addAction(m_ScMW->scrActions["itemLower"]); |
||
412 | menuLevel->addAction(m_ScMW->scrActions["itemLowerToBottom"]); |
||
17418 | fschmid | 413 | if (menuLevel->actions().count()>0) |
10940 | cbradney | 414 | { |
17418 | fschmid | 415 | QAction *act = addMenu(menuLevel); |
416 | act->setText( ScribusView::tr("Le&vel")); |
||
10940 | cbradney | 417 | } |
418 | } |
||
419 | //--> |
||
420 | |||
421 | //<-- Add Convert To Items |
||
422 | if (m_doc->appMode != modeEdit && (itemsAreSameType || currItem->isSingleSel)) //Create convertTo Menu |
||
423 | { |
||
18466 | craig | 424 | if (m_ScMW->scrActions["itemConvertToBezierCurve"]->isEnabled() && m_actionList.contains("itemConvertToBezierCurve")) |
425 | menuConvertTo->addAction(m_ScMW->scrActions["itemConvertToBezierCurve"]); |
||
426 | if (m_ScMW->scrActions["itemConvertToImageFrame"]->isEnabled() && m_actionList.contains("itemConvertToImageFrame")) |
||
427 | menuConvertTo->addAction(m_ScMW->scrActions["itemConvertToImageFrame"]); |
||
428 | if (m_ScMW->scrActions["itemConvertToOutlines"]->isEnabled() && m_actionList.contains("itemConvertToOutlines")) |
||
429 | menuConvertTo->addAction(m_ScMW->scrActions["itemConvertToOutlines"]); |
||
430 | if (m_ScMW->scrActions["itemConvertToPolygon"]->isEnabled() && m_actionList.contains("itemConvertToPolygon")) |
||
431 | menuConvertTo->addAction(m_ScMW->scrActions["itemConvertToPolygon"]); |
||
432 | if (m_ScMW->scrActions["itemConvertToTextFrame"]->isEnabled() && m_actionList.contains("itemConvertToTextFrame")) |
||
433 | menuConvertTo->addAction(m_ScMW->scrActions["itemConvertToTextFrame"]); |
||
434 | if (m_ScMW->scrActions["itemConvertToSymbolFrame"]->isEnabled() && !currItem->isSymbol()) |
||
435 | menuConvertTo->addAction(m_ScMW->scrActions["itemConvertToSymbolFrame"]); |
||
10940 | cbradney | 436 | if (menuConvertTo->actions().count()>0) |
437 | { |
||
438 | QAction *act = addMenu(menuConvertTo); |
||
439 | act->setText( ScribusView::tr("Conve&rt to")); |
||
440 | } |
||
441 | } |
||
442 | //--> |
||
443 | |||
444 | //<-- Add Copy/Paste Actions |
||
445 | addSeparator(); |
||
446 | if (!currItem->locked() && !(currItem->isSingleSel)) |
||
18466 | craig | 447 | addAction(m_ScMW->scrActions["editCut"]); |
10940 | cbradney | 448 | if (!(currItem->isSingleSel)) |
18466 | craig | 449 | addAction(m_ScMW->scrActions["editCopy"]); |
13833 | cbradney | 450 | if ((m_doc->appMode == modeEdit) && (ScMimeData::clipboardHasScribusText()||ScMimeData::clipboardHasPlainText()) && (currItem->itemType() == PageItem::TextFrame)) |
18466 | craig | 451 | addAction(m_ScMW->scrActions["editPaste"]); |
10940 | cbradney | 452 | if (!currItem->locked() && (m_doc->appMode != modeEdit) && (!(currItem->isSingleSel))) |
18466 | craig | 453 | addAction(m_ScMW->scrActions["itemDelete"]); |
10940 | cbradney | 454 | //--> |
455 | |||
456 | //<-- Add Contents Actions |
||
457 | if (itemsAreSameType) |
||
458 | { |
||
459 | if (m_actionList.contains("editCopyContents")) |
||
18466 | craig | 460 | menuEditContents->addAction(m_ScMW->scrActions["editCopyContents"]); |
10940 | cbradney | 461 | if (m_actionList.contains("editPasteContents")) |
18466 | craig | 462 | menuEditContents->addAction(m_ScMW->scrActions["editPasteContents"]); |
18185 | craig | 463 | if (currItem->asImageFrame() && m_actionList.contains("editPasteContentsAbs")) |
18466 | craig | 464 | menuEditContents->addAction(m_ScMW->scrActions["editPasteContentsAbs"]); |
10940 | cbradney | 465 | } |
466 | if (m_actionList.contains("editClearContents")) |
||
18466 | craig | 467 | menuEditContents->addAction(m_ScMW->scrActions["editClearContents"]); |
10940 | cbradney | 468 | if (menuEditContents->actions().count()>0) |
469 | { |
||
470 | QAction *act = addMenu(menuEditContents); |
||
471 | act->setText( ScribusView::tr("Contents")); |
||
472 | } |
||
473 | //--> |
||
474 | |||
16926 | fschmid | 475 | //<-- Add Welding Menu |
476 | addSeparator(); |
||
477 | if (selectedItemCount > 0 && m_doc->appMode != modeEdit) |
||
478 | { |
||
479 | PageItem *currItem; |
||
480 | for (int a = 0; a < m_Sel.count(); ++a) |
||
481 | { |
||
482 | currItem = m_Sel.itemAt(a); |
||
483 | if (currItem->isWelded()) |
||
484 | { |
||
18466 | craig | 485 | addAction(m_ScMW->scrActions["itemsUnWeld"]); |
16926 | fschmid | 486 | break; |
487 | } |
||
488 | } |
||
489 | } |
||
490 | if (selectedItemCount == 2 && m_doc->appMode != modeEdit) |
||
18466 | craig | 491 | addAction(m_ScMW->scrActions["itemWeld"]); |
492 | // { |
||
493 | // menuWeld->addAction(m_AP->scrActions["itemWeld17"]); |
||
494 | // menuWeld->addAction(m_AP->scrActions["itemWeld71"]); |
||
495 | // menuWeld->addAction(m_AP->scrActions["itemWeld13"]); |
||
496 | // menuWeld->addAction(m_AP->scrActions["itemWeld31"]); |
||
497 | // QAction *act = addMenu(menuWeld); |
||
498 | // act->setText( ScribusView::tr("Weld to last...")); |
||
499 | // } |
||
16926 | fschmid | 500 | //--> |
501 | |||
10940 | cbradney | 502 | //<-- Add Properties |
503 | addSeparator(); |
||
18466 | craig | 504 | addAction(m_ScMW->scrActions["toolsProperties"]); |
10940 | cbradney | 505 | //--> |
18466 | craig | 506 | |
10934 | cbradney | 507 | } |
10940 | cbradney | 508 | |
11146 | cbradney | 509 | void ContextMenu::createMenuItems_NoSelection(double mx, double my) |
510 | { |
||
511 | int selectedItemCount=m_Sel.count(); |
||
512 | if (selectedItemCount!=0) |
||
513 | return; |
||
514 | |||
12841 | jghali | 515 | if (ScMimeData::clipboardHasScribusElem() || ScMimeData::clipboardHasScribusFragment() ) |
11289 | fschmid | 516 | { |
517 | m_doc->view()->dragX = mx; |
||
518 | m_doc->view()->dragY = my; |
||
18477 | fschmid | 519 | addAction( ScribusView::tr("&Paste Here") , m_doc->view(), SLOT(PasteToPage())); |
11289 | fschmid | 520 | } |
18466 | craig | 521 | if (m_ScMW->scrRecentPasteActions.count()>0) |
11146 | cbradney | 522 | { |
17150 | fschmid | 523 | m_doc->view()->dragX = mx; |
524 | m_doc->view()->dragY = my; |
||
11146 | cbradney | 525 | QMenu* menuPasteRecent = new QMenu(this); |
526 | QAction *act = addMenu(menuPasteRecent); |
||
527 | act->setText( ScribusView::tr("Paste Recent")); |
||
528 | |||
529 | QMap<QString, QPointer<ScrAction> > scrRecentPasteActions; |
||
530 | ScrAction *recentPasteAction; |
||
18466 | craig | 531 | foreach (recentPasteAction, m_ScMW->scrRecentPasteActions) |
11146 | cbradney | 532 | menuPasteRecent->addAction(recentPasteAction); |
533 | addSeparator(); |
||
534 | } |
||
11291 | fschmid | 535 | QAction *act = addAction( tr("Paste File...")); |
536 | connect(act, SIGNAL(triggered()), dynamic_cast<QObject*>(m_doc->view()->m_canvasMode), SLOT(importToPage())); |
||
537 | addSeparator(); |
||
11146 | cbradney | 538 | |
18466 | craig | 539 | addAction(m_ScMW->scrActions["editUndoAction"]); |
540 | addAction(m_ScMW->scrActions["editRedoAction"]); |
||
11146 | cbradney | 541 | addSeparator(); |
18466 | craig | 542 | addAction(m_ScMW->scrActions["viewShowMargins"]); |
543 | addAction(m_ScMW->scrActions["viewShowFrames"]); |
||
544 | addAction(m_ScMW->scrActions["viewShowLayerMarkers"]); |
||
545 | addAction(m_ScMW->scrActions["viewShowImages"]); |
||
546 | addAction(m_ScMW->scrActions["viewShowGrid"]); |
||
547 | addAction(m_ScMW->scrActions["viewShowGuides"]); |
||
548 | addAction(m_ScMW->scrActions["viewShowColumnBorders"]); |
||
549 | addAction(m_ScMW->scrActions["viewShowBaseline"]); |
||
550 | addAction(m_ScMW->scrActions["viewShowTextChain"]); |
||
551 | addAction(m_ScMW->scrActions["viewShowRulers"]); |
||
552 | addAction(m_ScMW->scrActions["viewRulerMode"]); |
||
11146 | cbradney | 553 | addSeparator(); |
18466 | craig | 554 | addAction(m_ScMW->scrActions["viewSnapToGrid"]); |
555 | addAction(m_ScMW->scrActions["viewSnapToGuides"]); |
||
556 | addAction(m_ScMW->scrActions["viewSnapToElements"]); |
||
11146 | cbradney | 557 | |
11749 | cbradney | 558 | onAPage = (m_doc->OnPage(mx, my) != -1); |
559 | if (onAPage) |
||
11146 | cbradney | 560 | { |
561 | addSeparator(); |
||
18466 | craig | 562 | addAction(m_ScMW->scrActions["pageApplyMasterPage"]); |
563 | addAction(m_ScMW->scrActions["pageManageGuides"]); |
||
564 | addAction(m_ScMW->scrActions["pageManageMargins"]); |
||
565 | if (m_ScMW->scrActions["pageDelete"]->isEnabled()) |
||
11749 | cbradney | 566 | { |
567 | addSeparator(); |
||
18466 | craig | 568 | pageDeletePrimaryString=m_ScMW->scrActions["pageDelete"]->text(); |
569 | m_ScMW->scrActions["pageDelete"]->setText(tr("Delete Page")); |
||
570 | addAction(m_ScMW->scrActions["pageDelete"]); |
||
11749 | cbradney | 571 | } |
11146 | cbradney | 572 | } |
573 | } |
||
11749 | cbradney | 574 | |
575 | ContextMenu::~ContextMenu() |
||
576 | { |
||
18466 | craig | 577 | if (onAPage && m_ScMW->scrActions["pageDelete"]->isEnabled()) |
578 | m_ScMW->scrActions["pageDelete"]->setText(pageDeletePrimaryString); |
||
11749 | cbradney | 579 | } |