Changeset View
Changeset View
Standalone View
Standalone View
krita/ui/kis_node_manager.cpp
Show First 20 Lines • Show All 185 Lines • ▼ Show 20 Line(s) | 184 | if (m_d->imageView) { | |||
---|---|---|---|---|---|
186 | Q_ASSERT(shapeController); | 186 | Q_ASSERT(shapeController); | ||
187 | connect(shapeController, SIGNAL(sigActivateNode(KisNodeSP)), SLOT(slotNonUiActivatedNode(KisNodeSP))); | 187 | connect(shapeController, SIGNAL(sigActivateNode(KisNodeSP)), SLOT(slotNonUiActivatedNode(KisNodeSP))); | ||
188 | connect(m_d->imageView->image(), SIGNAL(sigIsolatedModeChanged()),this, SLOT(slotUpdateIsolateModeAction())); | 188 | connect(m_d->imageView->image(), SIGNAL(sigIsolatedModeChanged()),this, SLOT(slotUpdateIsolateModeAction())); | ||
189 | m_d->imageView->resourceProvider()->slotNodeActivated(m_d->imageView->currentNode()); | 189 | m_d->imageView->resourceProvider()->slotNodeActivated(m_d->imageView->currentNode()); | ||
190 | } | 190 | } | ||
191 | 191 | | |||
192 | } | 192 | } | ||
193 | 193 | | |||
194 | #define NEW_LAYER_ACTION(id, text, layerType, icon) \ | 194 | #define NEW_LAYER_ACTION(id, layerType) \ | ||
195 | { \ | 195 | { \ | ||
196 | action = new KisAction(icon, text, this); \ | 196 | action = actionManager->createAction(id); \ | ||
197 | action->setActivationFlags(KisAction::ACTIVE_NODE); \ | 197 | action->setActivationFlags(KisAction::ACTIVE_NODE); \ | ||
198 | actionManager->addAction(id, action); \ | | |||
199 | m_d->nodeCreationSignalMapper.setMapping(action, layerType); \ | 198 | m_d->nodeCreationSignalMapper.setMapping(action, layerType); \ | ||
200 | connect(action, SIGNAL(triggered()), \ | 199 | connect(action, SIGNAL(triggered()), \ | ||
201 | &m_d->nodeCreationSignalMapper, SLOT(map())); \ | 200 | &m_d->nodeCreationSignalMapper, SLOT(map())); \ | ||
202 | } | 201 | } | ||
203 | 202 | | |||
204 | #define NEW_LAYER_ACTION_KEY(id, text, layerType, icon, shortcut) \ | 203 | #define NEW_MASK_ACTION(id, layerType) \ | ||
205 | { \ | | |||
206 | NEW_LAYER_ACTION(id, text, layerType, icon); \ | | |||
207 | action->setShortcut(QKeySequence(shortcut)); \ | | |||
208 | } | | |||
209 | | ||||
210 | #define NEW_MASK_ACTION(id, text, layerType, icon) \ | | |||
211 | { \ | 204 | { \ | ||
212 | NEW_LAYER_ACTION(id, text, layerType, icon); \ | 205 | NEW_LAYER_ACTION(id, layerType); \ | ||
213 | action->setActivationFlags(KisAction::ACTIVE_LAYER); \ | 206 | action->setActivationFlags(KisAction::ACTIVE_LAYER); \ | ||
214 | } | 207 | } | ||
215 | 208 | | |||
216 | #define CONVERT_NODE_ACTION(id, text, layerType, icon) \ | 209 | #define CONVERT_NODE_ACTION(id, text, layerType, icon) \ | ||
217 | { \ | 210 | { \ | ||
218 | action = new KisAction(icon, text, this); \ | 211 | action = new KisAction(icon, text, this); \ | ||
219 | action->setActivationFlags(KisAction::ACTIVE_NODE); \ | 212 | action->setActivationFlags(KisAction::ACTIVE_NODE); \ | ||
220 | action->setExcludedNodeTypes(QStringList(layerType)); \ | 213 | action->setExcludedNodeTypes(QStringList(layerType)); \ | ||
221 | actionManager->addAction(id, action); \ | 214 | actionManager->addAction(id, action); \ | ||
222 | m_d->nodeConversionSignalMapper.setMapping(action, layerType); \ | 215 | m_d->nodeConversionSignalMapper.setMapping(action, layerType); \ | ||
223 | connect(action, SIGNAL(triggered()), \ | 216 | connect(action, SIGNAL(triggered()), \ | ||
224 | &m_d->nodeConversionSignalMapper, SLOT(map())); \ | 217 | &m_d->nodeConversionSignalMapper, SLOT(map())); \ | ||
225 | } | 218 | } | ||
226 | 219 | | |||
227 | void KisNodeManager::setup(KActionCollection * actionCollection, KisActionManager* actionManager) | 220 | void KisNodeManager::setup(KActionCollection * actionCollection, KisActionManager* actionManager) | ||
228 | { | 221 | { | ||
229 | m_d->layerManager.setup(actionManager); | 222 | m_d->layerManager.setup(actionManager); | ||
230 | m_d->maskManager.setup(actionCollection, actionManager); | 223 | m_d->maskManager.setup(actionCollection, actionManager); | ||
231 | 224 | | |||
232 | KisAction * action = new KisAction(KisIconUtils::loadIcon("symmetry-horizontal"), i18n("Mirror Layer Horizontally"), this); | 225 | KisAction * action = actionManager->createAction("mirrorNodeX"); | ||
233 | action->setActivationFlags(KisAction::ACTIVE_NODE); | 226 | action->setActivationFlags(KisAction::ACTIVE_NODE); | ||
234 | action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 227 | action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
235 | actionManager->addAction("mirrorNodeX", action); | | |||
236 | connect(action, SIGNAL(triggered()), this, SLOT(mirrorNodeX())); | 228 | connect(action, SIGNAL(triggered()), this, SLOT(mirrorNodeX())); | ||
237 | 229 | | |||
238 | action = new KisAction(KisIconUtils::loadIcon("symmetry-vertical"), i18n("Mirror Layer Vertically"), this); | 230 | action = actionManager->createAction("mirrorNodeY"); | ||
239 | action->setActivationFlags(KisAction::ACTIVE_NODE); | 231 | action->setActivationFlags(KisAction::ACTIVE_NODE); | ||
240 | action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 232 | action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
241 | actionManager->addAction("mirrorNodeY", action); | | |||
242 | connect(action, SIGNAL(triggered()), this, SLOT(mirrorNodeY())); | 233 | connect(action, SIGNAL(triggered()), this, SLOT(mirrorNodeY())); | ||
243 | 234 | | |||
244 | action = new KisAction(i18n("Activate next layer"), this); | 235 | action = actionManager->createAction("activateNextLayer"); | ||
245 | action->setActivationFlags(KisAction::ACTIVE_LAYER); | 236 | action->setActivationFlags(KisAction::ACTIVE_LAYER); | ||
246 | action->setDefaultShortcut(QKeySequence(Qt::Key_PageUp)); | | |||
247 | actionManager->addAction("activateNextLayer", action); | | |||
248 | connect(action, SIGNAL(triggered()), this, SLOT(activateNextNode())); | 237 | connect(action, SIGNAL(triggered()), this, SLOT(activateNextNode())); | ||
249 | 238 | | |||
250 | action = new KisAction(i18n("Activate previous layer"), this); | 239 | action = actionManager->createAction("activatePreviousLayer"); | ||
251 | action->setActivationFlags(KisAction::ACTIVE_LAYER); | 240 | action->setActivationFlags(KisAction::ACTIVE_LAYER); | ||
252 | action->setDefaultShortcut(QKeySequence(Qt::Key_PageDown)); | | |||
253 | actionManager->addAction("activatePreviousLayer", action); | | |||
254 | connect(action, SIGNAL(triggered()), this, SLOT(activatePreviousNode())); | 241 | connect(action, SIGNAL(triggered()), this, SLOT(activatePreviousNode())); | ||
255 | 242 | | |||
256 | action = new KisAction(KisIconUtils::loadIcon("document-save"), i18n("Save Layer/Mask..."), this); | 243 | action = actionManager->createAction("save_node_as_image"); | ||
257 | action->setActivationFlags(KisAction::ACTIVE_NODE); | 244 | action->setActivationFlags(KisAction::ACTIVE_NODE); | ||
258 | actionManager->addAction("save_node_as_image", action); | | |||
259 | connect(action, SIGNAL(triggered()), this, SLOT(saveNodeAsImage())); | 245 | connect(action, SIGNAL(triggered()), this, SLOT(saveNodeAsImage())); | ||
260 | 246 | | |||
261 | action = new KisAction(KisIconUtils::loadIcon("edit-copy"), i18n("&Duplicate Layer or Mask"), this); | 247 | action = actionManager->createAction("duplicatelayer"); | ||
262 | action->setActivationFlags(KisAction::ACTIVE_NODE); | 248 | action->setActivationFlags(KisAction::ACTIVE_NODE); | ||
263 | action->setDefaultShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_J)); | | |||
264 | actionManager->addAction("duplicatelayer", action); | | |||
265 | connect(action, SIGNAL(triggered()), this, SLOT(duplicateActiveNode())); | 249 | connect(action, SIGNAL(triggered()), this, SLOT(duplicateActiveNode())); | ||
266 | 250 | | |||
267 | 251 | | |||
268 | NEW_LAYER_ACTION_KEY("add_new_paint_layer", i18n("&Paint Layer"), | 252 | NEW_LAYER_ACTION("add_new_paint_layer", "KisPaintLayer"); | ||
269 | "KisPaintLayer", KisIconUtils::loadIcon("document-new"), | | |||
270 | Qt::Key_Insert); | | |||
271 | 253 | | |||
272 | NEW_LAYER_ACTION_KEY("add_new_group_layer", i18n("&Group Layer"), | 254 | NEW_LAYER_ACTION("add_new_group_layer", "KisGroupLayer"); | ||
273 | "KisGroupLayer", KisIconUtils::loadIcon("folder"), | | |||
274 | Qt::ControlModifier + Qt::Key_G); | | |||
275 | 255 | | |||
276 | NEW_LAYER_ACTION("add_new_clone_layer", i18n("&Clone Layer"), | 256 | NEW_LAYER_ACTION("add_new_clone_layer", "KisCloneLayer"); | ||
277 | "KisCloneLayer", KisIconUtils::loadIcon("edit-copy")); | | |||
278 | 257 | | |||
279 | NEW_LAYER_ACTION("add_new_shape_layer", i18n("&Vector Layer"), | 258 | NEW_LAYER_ACTION("add_new_shape_layer", "KisShapeLayer"); | ||
280 | "KisShapeLayer", KisIconUtils::loadIcon("bookmarks")); | | |||
281 | 259 | | |||
282 | NEW_LAYER_ACTION("add_new_adjustment_layer", i18n("&Filter Layer..."), | 260 | NEW_LAYER_ACTION("add_new_adjustment_layer", "KisAdjustmentLayer"); | ||
283 | "KisAdjustmentLayer", KisIconUtils::loadIcon("view-filter")); | | |||
284 | 261 | | |||
285 | NEW_LAYER_ACTION("add_new_fill_layer", i18n("&Fill Layer..."), | 262 | NEW_LAYER_ACTION("add_new_fill_layer", "KisGeneratorLayer"); | ||
286 | "KisGeneratorLayer", KisIconUtils::loadIcon("krita_tool_color_fill")); | | |||
287 | 263 | | |||
288 | NEW_LAYER_ACTION("add_new_file_layer", i18n("&File Layer..."), | 264 | NEW_LAYER_ACTION("add_new_file_layer", "KisFileLayer"); | ||
289 | "KisFileLayer", KisIconUtils::loadIcon("document-open")); | | |||
290 | 265 | | |||
291 | NEW_MASK_ACTION("add_new_transparency_mask", i18n("&Transparency Mask"), | 266 | NEW_MASK_ACTION("add_new_transparency_mask", "KisTransparencyMask"); | ||
292 | "KisTransparencyMask", KisIconUtils::loadIcon("edit-copy")); | | |||
293 | 267 | | |||
294 | NEW_MASK_ACTION("add_new_filter_mask", i18n("&Filter Mask..."), | 268 | NEW_MASK_ACTION("add_new_filter_mask", "KisFilterMask"); | ||
295 | "KisFilterMask", KisIconUtils::loadIcon("view-filter")); | | |||
296 | 269 | | |||
297 | NEW_MASK_ACTION("add_new_transform_mask", i18n("&Transform Mask..."), | 270 | NEW_MASK_ACTION("add_new_transform_mask", "KisTransformMask"); | ||
298 | "KisTransformMask", KisIconUtils::loadIcon("bookmarks")); | | |||
299 | 271 | | |||
300 | NEW_MASK_ACTION("add_new_selection_mask", i18n("&Local Selection"), | 272 | NEW_MASK_ACTION("add_new_selection_mask", "KisSelectionMask"); | ||
301 | "KisSelectionMask", KisIconUtils::loadIcon("edit-paste")); | | |||
302 | 273 | | |||
303 | connect(&m_d->nodeCreationSignalMapper, SIGNAL(mapped(const QString &)), | 274 | connect(&m_d->nodeCreationSignalMapper, SIGNAL(mapped(const QString &)), | ||
304 | this, SLOT(createNode(const QString &))); | 275 | this, SLOT(createNode(const QString &))); | ||
305 | 276 | | |||
306 | CONVERT_NODE_ACTION("convert_to_paint_layer", i18n("to &Paint Layer"), | 277 | CONVERT_NODE_ACTION("convert_to_paint_layer", i18n("to &Paint Layer"), | ||
307 | "KisPaintLayer", KisIconUtils::loadIcon("document-new")); | 278 | "KisPaintLayer", KisIconUtils::loadIcon("document-new")); | ||
308 | 279 | | |||
309 | CONVERT_NODE_ACTION("convert_to_selection_mask", i18n("to &Selection Mask"), | 280 | CONVERT_NODE_ACTION("convert_to_selection_mask", i18n("to &Selection Mask"), | ||
310 | "KisSelectionMask", KisIconUtils::loadIcon("edit-paste")); | 281 | "KisSelectionMask", KisIconUtils::loadIcon("edit-paste")); | ||
311 | 282 | | |||
312 | CONVERT_NODE_ACTION("convert_to_filter_mask", i18n("to &Filter Mask..."), | 283 | CONVERT_NODE_ACTION("convert_to_filter_mask", i18n("to &Filter Mask..."), | ||
313 | "KisFilterMask", KisIconUtils::loadIcon("view-filter")); | 284 | "KisFilterMask", KisIconUtils::loadIcon("view-filter")); | ||
314 | 285 | | |||
315 | CONVERT_NODE_ACTION("convert_to_transparency_mask", i18n("to &Transparency Mask"), | 286 | CONVERT_NODE_ACTION("convert_to_transparency_mask", i18n("to &Transparency Mask"), | ||
316 | "KisTransparencyMask", KisIconUtils::loadIcon("edit-copy")); | 287 | "KisTransparencyMask", KisIconUtils::loadIcon("edit-copy")); | ||
317 | 288 | | |||
318 | connect(&m_d->nodeConversionSignalMapper, SIGNAL(mapped(const QString &)), | 289 | connect(&m_d->nodeConversionSignalMapper, SIGNAL(mapped(const QString &)), | ||
319 | this, SLOT(convertNode(const QString &))); | 290 | this, SLOT(convertNode(const QString &))); | ||
320 | 291 | | |||
321 | action = new KisAction(KisIconUtils::loadIcon("layer-visible-off"), i18n("&Isolate Layer"), this); | 292 | action = actionManager->createAction("isolate_layer"); | ||
322 | action->setCheckable(true); | 293 | action->setCheckable(true); | ||
323 | action->setActivationFlags(KisAction::ACTIVE_NODE); | 294 | action->setActivationFlags(KisAction::ACTIVE_NODE); | ||
324 | actionManager->addAction("isolate_layer", action); | | |||
325 | connect(action, SIGNAL(triggered(bool)), this, SLOT(toggleIsolateMode(bool))); | 295 | connect(action, SIGNAL(triggered(bool)), this, SLOT(toggleIsolateMode(bool))); | ||
326 | 296 | | |||
327 | action = new KisAction(KisIconUtils::loadIcon("edit-copy"), i18n("Alpha into Mask"), this); | 297 | action = actionManager->createAction("split_alpha_into_mask"); | ||
328 | action->setActivationFlags(KisAction::ACTIVE_LAYER); | 298 | action->setActivationFlags(KisAction::ACTIVE_LAYER); | ||
329 | action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE_PAINT_DEVICE); | 299 | action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE_PAINT_DEVICE); | ||
330 | actionManager->addAction("split_alpha_into_mask", action); | | |||
331 | connect(action, SIGNAL(triggered()), this, SLOT(slotSplitAlphaIntoMask())); | 300 | connect(action, SIGNAL(triggered()), this, SLOT(slotSplitAlphaIntoMask())); | ||
332 | 301 | | |||
333 | action = new KisAction(KisIconUtils::loadIcon("transparency-enabled"), i18n("Write as Alpha"), this); | 302 | action = actionManager->createAction("split_alpha_write"); | ||
334 | action->setActivationFlags(KisAction::ACTIVE_TRANSPARENCY_MASK); | 303 | action->setActivationFlags(KisAction::ACTIVE_TRANSPARENCY_MASK); | ||
335 | action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 304 | action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
336 | actionManager->addAction("split_alpha_write", action); | | |||
337 | connect(action, SIGNAL(triggered()), this, SLOT(slotSplitAlphaWrite())); | 305 | connect(action, SIGNAL(triggered()), this, SLOT(slotSplitAlphaWrite())); | ||
338 | 306 | | |||
339 | action = new KisAction(KisIconUtils::loadIcon("document-save"), i18n("Save Merged..."), this); | 307 | action = actionManager->createAction("split_alpha_save_merged"); | ||
340 | action->setActivationFlags(KisAction::ACTIVE_TRANSPARENCY_MASK); | 308 | action->setActivationFlags(KisAction::ACTIVE_TRANSPARENCY_MASK); | ||
341 | // HINT: we can save even when the nodes are not editable | 309 | // HINT: we can save even when the nodes are not editable | ||
342 | actionManager->addAction("split_alpha_save_merged", action); | | |||
343 | connect(action, SIGNAL(triggered()), this, SLOT(slotSplitAlphaSaveMerged())); | 310 | connect(action, SIGNAL(triggered()), this, SLOT(slotSplitAlphaSaveMerged())); | ||
344 | 311 | | |||
345 | connect(this, SIGNAL(sigNodeActivated(KisNodeSP)), SLOT(slotUpdateIsolateModeAction())); | 312 | connect(this, SIGNAL(sigNodeActivated(KisNodeSP)), SLOT(slotUpdateIsolateModeAction())); | ||
346 | connect(this, SIGNAL(sigNodeActivated(KisNodeSP)), SLOT(slotTryFinishIsolatedMode())); | 313 | connect(this, SIGNAL(sigNodeActivated(KisNodeSP)), SLOT(slotTryFinishIsolatedMode())); | ||
347 | } | 314 | } | ||
348 | 315 | | |||
349 | void KisNodeManager::updateGUI() | 316 | void KisNodeManager::updateGUI() | ||
350 | { | 317 | { | ||
▲ Show 20 Lines • Show All 796 Lines • Show Last 20 Lines |