Commit b5f3cc4c authored by Dmitry Kazakov's avatar Dmitry Kazakov

Add Cut/Copy/Paste Layers actions to the context menu

parent b4795343
......@@ -518,48 +518,60 @@ void KisLayerBox::slotContextMenuRequested(const QPoint &pos, const QModelIndex
if (m_canvas) {
QMenu menu;
const bool singleLayer = m_nodeManager->selectedNodes().size() == 1;
if (index.isValid()) {
menu.addAction(m_propertiesAction);
addActionToMenu(&menu, "layer_style");
if (singleLayer) {
menu.addAction(m_propertiesAction);
addActionToMenu(&menu, "layer_style");
menu.addSeparator();
addActionToMenu(&menu, "show_in_timeline");
menu.addSeparator();
}
addActionToMenu(&menu, "cut_layer_clipboard");
addActionToMenu(&menu, "copy_layer_clipboard");
addActionToMenu(&menu, "paste_layer_from_clipboard");
menu.addSeparator();
addActionToMenu(&menu, "show_in_timeline");
menu.addSeparator();
menu.addAction(m_removeAction);
addActionToMenu(&menu, "duplicatelayer");
addActionToMenu(&menu, "flatten_image");
addActionToMenu(&menu, "flatten_layer");
addActionToMenu(&menu, "merge_layer");
if (singleLayer) {
addActionToMenu(&menu, "flatten_image");
addActionToMenu(&menu, "flatten_layer");
menu.addSeparator();
QMenu *convertToMenu = menu.addMenu(i18n("&Convert"));
addActionToMenu(convertToMenu, "convert_to_paint_layer");
addActionToMenu(convertToMenu, "convert_to_transparency_mask");
addActionToMenu(convertToMenu, "convert_to_filter_mask");
addActionToMenu(convertToMenu, "convert_to_selection_mask");
QMenu *splitAlphaMenu = menu.addMenu(i18n("S&plit Alpha"));
addActionToMenu(splitAlphaMenu, "split_alpha_into_mask");
addActionToMenu(splitAlphaMenu, "split_alpha_write");
addActionToMenu(splitAlphaMenu, "split_alpha_save_merged");
KisNodeSP node = m_nodeModel->nodeFromIndex(index);
if (node && !node->inherits("KisTransformMask")) {
addActionToMenu(&menu, "isolate_layer");
}
}
}
// TODO: missing icon "edit-merge"
QAction* mergeLayerDown = menu.addAction(i18n("&Merge with Layer Below"),
this, SLOT(slotMergeLayer()));
if (!index.sibling(index.row() + 1, 0).isValid()) mergeLayerDown->setEnabled(false);
if (singleLayer) {
menu.addSeparator();
QMenu *convertToMenu = menu.addMenu(i18n("&Convert"));
addActionToMenu(convertToMenu, "convert_to_paint_layer");
addActionToMenu(convertToMenu, "convert_to_transparency_mask");
addActionToMenu(convertToMenu, "convert_to_filter_mask");
addActionToMenu(convertToMenu, "convert_to_selection_mask");
QMenu *splitAlphaMenu = menu.addMenu(i18n("S&plit Alpha"));
addActionToMenu(splitAlphaMenu, "split_alpha_into_mask");
addActionToMenu(splitAlphaMenu, "split_alpha_write");
addActionToMenu(splitAlphaMenu, "split_alpha_save_merged");
KisNodeSP node = m_nodeModel->nodeFromIndex(index);
if (node && !node->inherits("KisTransformMask")) {
addActionToMenu(&menu, "isolate_layer");
}
addActionToMenu(&menu, "add_new_transparency_mask");
addActionToMenu(&menu, "add_new_filter_mask");
addActionToMenu(&menu, "add_new_transform_mask");
addActionToMenu(&menu, "add_new_selection_mask");
menu.addSeparator();
menu.addAction(m_selectOpaque);
}
menu.addSeparator();
addActionToMenu(&menu, "add_new_transparency_mask");
addActionToMenu(&menu, "add_new_filter_mask");
addActionToMenu(&menu, "add_new_transform_mask");
addActionToMenu(&menu, "add_new_selection_mask");
menu.addSeparator();
menu.addAction(m_selectOpaque);
menu.exec(pos);
}
}
......
......@@ -187,11 +187,6 @@ bool KisNodeDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, cons
model->setData(index, true, Model::AlternateActiveRole);
return true;
}
if (mouseEvent->button() != Qt::LeftButton) {
d->view->setCurrentIndex(index);
return false;
}
}
else if (event->type() == QEvent::ToolTip) {
if (!KisConfig().hidePopups()) {
......
......@@ -154,6 +154,13 @@ QItemSelectionModel::SelectionFlags KisNodeView::selectionCommand(const QModelIn
const QMouseEvent *mevent = static_cast<const QMouseEvent*>(event);
if (mevent->button() == Qt::RightButton &&
selectionModel()->selectedIndexes().contains(index)) {
// Allow calling context menu for multiple layers
return QItemSelectionModel::NoUpdate;
}
if (event->type() == QEvent::MouseButtonPress &&
(mevent->modifiers() & Qt::ControlModifier)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment