# HG changeset patch # User Chris Cannam # Date 1202307309 0 # Node ID 1b217963e53acb8f32f1bc9e7b30f5627dda0d38 # Parent dd74c5332b49317386e5150ffb162b53cc62e7a0 * Update remaining editable layers to support proper realignment on copy/paste * Permit pasting when no suitable layer is current: create a new layer on paste * Add preference for showing the splash screen or not * Rename spectrogram smoothing prefs (partly following Craig's suggestions) diff -r dd74c5332b49 -r 1b217963e53a framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Wed Feb 06 12:49:49 2008 +0000 +++ b/framework/MainWindowBase.cpp Wed Feb 06 14:15:09 2008 +0000 @@ -344,7 +344,7 @@ emit canPlay(havePlayTarget); emit canFfwd(true); emit canRewind(true); - emit canPaste(haveCurrentEditableLayer && haveClipboardContents); + emit canPaste(haveClipboardContents); emit canInsertInstant(haveCurrentPane); emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection); emit canRenumberInstants(haveCurrentTimeInstantsLayer && haveSelection); @@ -605,30 +605,38 @@ Pane *currentPane = m_paneStack->getCurrentPane(); if (!currentPane) return; - //!!! if we have no current layer, we should create one of the most - // appropriate type - Layer *layer = currentPane->getSelectedLayer(); - if (!layer) return; Clipboard &clipboard = m_viewManager->getClipboard(); - Clipboard::PointList contents = clipboard.getPoints(); -/* - long minFrame = 0; - bool have = false; - for (int i = 0; i < contents.size(); ++i) { - if (!contents[i].haveFrame()) continue; - if (!have || contents[i].getFrame() < minFrame) { - minFrame = contents[i].getFrame(); - have = true; +// Clipboard::PointList contents = clipboard.getPoints(); + + bool inCompound = true; + + if (!layer || !layer->isLayerEditable()) { + + CommandHistory::getInstance()->startCompoundOperation + (tr("Paste"), true); + + // no suitable current layer: create one of the most + // appropriate sort + LayerFactory::LayerType type = + LayerFactory::getInstance()->getLayerTypeForClipboardContents(clipboard); + layer = m_document->createEmptyLayer(type); + + if (!layer) { + CommandHistory::getInstance()->endCompoundOperation(); + return; } + + m_document->addLayerToView(currentPane, layer); + m_paneStack->setCurrentLayer(currentPane, layer); + + inCompound = true; } - long frameOffset = long(m_viewManager->getGlobalCentreFrame()) - minFrame; + layer->paste(currentPane, clipboard, 0, true); - layer->paste(clipboard, frameOffset); -*/ - layer->paste(currentPane, clipboard, 0, true); + if (inCompound) CommandHistory::getInstance()->endCompoundOperation(); } void