Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/kis_layer_manager.cc
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | |||||
76 | #include "dialogs/kis_dlg_layer_style.h" | 76 | #include "dialogs/kis_dlg_layer_style.h" | ||
77 | #include "KisDocument.h" | 77 | #include "KisDocument.h" | ||
78 | #include "kis_filter_manager.h" | 78 | #include "kis_filter_manager.h" | ||
79 | #include "kis_node_visitor.h" | 79 | #include "kis_node_visitor.h" | ||
80 | #include "kis_paint_layer.h" | 80 | #include "kis_paint_layer.h" | ||
81 | #include "commands/kis_image_commands.h" | 81 | #include "commands/kis_image_commands.h" | ||
82 | #include "commands/kis_layer_command.h" | 82 | #include "commands/kis_layer_command.h" | ||
83 | #include "commands/kis_node_commands.h" | 83 | #include "commands/kis_node_commands.h" | ||
84 | #include "kis_change_file_layer_command.h" | ||||
84 | #include "kis_canvas_resource_provider.h" | 85 | #include "kis_canvas_resource_provider.h" | ||
85 | #include "kis_selection_manager.h" | 86 | #include "kis_selection_manager.h" | ||
86 | #include "kis_statusbar.h" | 87 | #include "kis_statusbar.h" | ||
87 | #include "KisViewManager.h" | 88 | #include "KisViewManager.h" | ||
88 | #include "kis_zoom_manager.h" | 89 | #include "kis_zoom_manager.h" | ||
89 | #include "canvas/kis_canvas2.h" | 90 | #include "canvas/kis_canvas2.h" | ||
90 | #include "widgets/kis_meta_data_merge_strategy_chooser_widget.h" | 91 | #include "widgets/kis_meta_data_merge_strategy_chooser_widget.h" | ||
91 | #include "widgets/kis_wdg_generator.h" | 92 | #include "widgets/kis_wdg_generator.h" | ||
▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Line(s) | 238 | { | |||
240 | 241 | | |||
241 | KisLayerSP layer = activeLayer(); | 242 | KisLayerSP layer = activeLayer(); | ||
242 | QList<KisNodeSP> selectedNodes = m_view->nodeManager()->selectedNodes(); | 243 | QList<KisNodeSP> selectedNodes = m_view->nodeManager()->selectedNodes(); | ||
243 | const bool multipleLayersSelected = selectedNodes.size() > 1; | 244 | const bool multipleLayersSelected = selectedNodes.size() > 1; | ||
244 | 245 | | |||
245 | if (!layer) return; | 246 | if (!layer) return; | ||
246 | 247 | | |||
247 | KisAdjustmentLayerSP alayer = KisAdjustmentLayerSP(dynamic_cast<KisAdjustmentLayer*>(layer.data())); | 248 | KisAdjustmentLayerSP alayer = KisAdjustmentLayerSP(dynamic_cast<KisAdjustmentLayer*>(layer.data())); | ||
248 | KisGeneratorLayerSP glayer = KisGeneratorLayerSP(dynamic_cast<KisGeneratorLayer*>(layer.data())); | 249 | KisGeneratorLayerSP glayer = KisGeneratorLayerSP(dynamic_cast<KisGeneratorLayer*>(layer.data())); | ||
dkazakov: It is both fine to use either raw or shared pointers here. There is a `layer` shared pointer… | |||||
250 | KisFileLayerSP flayer = KisFileLayerSP(dynamic_cast<KisFileLayer*>(layer.data())); | ||||
249 | 251 | | |||
250 | if (alayer && !multipleLayersSelected) { | 252 | if (alayer && !multipleLayersSelected) { | ||
251 | 253 | | |||
252 | KisPaintDeviceSP dev = alayer->projection(); | 254 | KisPaintDeviceSP dev = alayer->projection(); | ||
253 | 255 | | |||
254 | KisDlgAdjLayerProps dlg(alayer, alayer.data(), dev, m_view, alayer->filter().data(), alayer->name(), i18n("Filter Layer Properties"), m_view->mainWindow(), "dlgadjlayerprops"); | 256 | KisDlgAdjLayerProps dlg(alayer, alayer.data(), dev, m_view, alayer->filter().data(), alayer->name(), i18n("Filter Layer Properties"), m_view->mainWindow(), "dlgadjlayerprops"); | ||
255 | dlg.resize(dlg.minimumSizeHint()); | 257 | dlg.resize(dlg.minimumSizeHint()); | ||
256 | 258 | | |||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 320 | = new KisChangeFilterCmd(glayer, | |||
323 | true); | 325 | true); | ||
324 | // FIXME: check whether is needed | 326 | // FIXME: check whether is needed | ||
325 | cmd->redo(); | 327 | cmd->redo(); | ||
326 | m_view->undoAdapter()->addCommand(cmd); | 328 | m_view->undoAdapter()->addCommand(cmd); | ||
327 | m_view->document()->setModified(true); | 329 | m_view->document()->setModified(true); | ||
328 | } | 330 | } | ||
329 | 331 | | |||
330 | } | 332 | } | ||
333 | } else if (flayer && !multipleLayersSelected){ | ||||
334 | QString basePath = QFileInfo(m_view->document()->url().toLocalFile()).absolutePath(); | ||||
335 | QString fileNameOld = flayer->fileName(); | ||||
336 | KisFileLayer::ScalingMethod scalingMethodOld = flayer->scalingMethod(); | ||||
337 | KisDlgFileLayer dlg(basePath, flayer->name(), m_view->mainWindow()); | ||||
338 | dlg.setCaption(i18n("File Layer Properties")); | ||||
339 | dlg.setFileName(fileNameOld); | ||||
340 | dlg.setScalingMethod(scalingMethodOld); | ||||
341 | | ||||
342 | if (dlg.exec() == QDialog::Accepted) { | ||||
343 | const QString fileNameNew = dlg.fileName(); | ||||
344 | KisFileLayer::ScalingMethod scalingMethodNew = dlg.scaleToImageResolution(); | ||||
345 | | ||||
346 | if(fileNameNew.isEmpty()){ | ||||
347 | QMessageBox::critical(m_view->mainWindow(), i18nc("@title:window", "Krita"), i18n("No file name specified")); | ||||
348 | return; | ||||
349 | } | ||||
350 | flayer->setName(dlg.layerName()); | ||||
351 | | ||||
352 | if (fileNameOld!= fileNameNew || scalingMethodOld != scalingMethodNew) { | ||||
353 | KisChangeFileLayerCmd *cmd | ||||
354 | = new KisChangeFileLayerCmd(flayer, | ||||
355 | basePath, | ||||
356 | fileNameOld, | ||||
357 | scalingMethodOld, | ||||
358 | basePath, | ||||
359 | fileNameNew, | ||||
360 | scalingMethodNew); | ||||
361 | m_view->undoAdapter()->addCommand(cmd); | ||||
362 | } | ||||
363 | } | ||||
331 | } else { // If layer == normal painting layer, vector layer, or group layer | 364 | } else { // If layer == normal painting layer, vector layer, or group layer | ||
332 | QList<KisNodeSP> selectedNodes = m_view->nodeManager()->selectedNodes(); | 365 | QList<KisNodeSP> selectedNodes = m_view->nodeManager()->selectedNodes(); | ||
333 | 366 | | |||
334 | KisDlgLayerProperties *dialog = new KisDlgLayerProperties(selectedNodes, m_view); | 367 | KisDlgLayerProperties *dialog = new KisDlgLayerProperties(selectedNodes, m_view); | ||
335 | dialog->resize(dialog->minimumSizeHint()); | 368 | dialog->resize(dialog->minimumSizeHint()); | ||
336 | dialog->setAttribute(Qt::WA_DeleteOnClose); | 369 | dialog->setAttribute(Qt::WA_DeleteOnClose); | ||
337 | Qt::WindowFlags flags = dialog->windowFlags(); | 370 | Qt::WindowFlags flags = dialog->windowFlags(); | ||
338 | dialog->setWindowFlags(flags | Qt::WindowStaysOnTopHint | Qt::Dialog); | 371 | dialog->setWindowFlags(flags | Qt::WindowStaysOnTopHint | Qt::Dialog); | ||
▲ Show 20 Lines • Show All 585 Lines • Show Last 20 Lines |
It is both fine to use either raw or shared pointers here. There is a layer shared pointer, which guarantees the object will never be deleted. If you passed flayer anywhere is a function, it would be a good idea to explicitly convert it into a SP, but you don't pass it anywhere, so it is fine.