Index: scribus/actionmanager.cpp =================================================================== --- scribus/actionmanager.cpp (revision 27827) +++ scribus/actionmanager.cpp (working copy) @@ -925,7 +925,8 @@ name = "toolsLinkTextFrame"; scrActions->insert(name, new ScrAction(ScrAction::DataInt, "tool-link-text-frame", "tool-link-text-frame", "", defaultKey(name), mainWindow, modeLinkFrames)); name = "toolsUnlinkTextFrame"; - scrActions->insert(name, new ScrAction(ScrAction::DataInt, "tool-unlink-text-frame", "tool-unlink-text-frame", "", defaultKey(name), mainWindow, modeUnlinkFrames)); + scrActions->insert(name, new ScrAction("tool-unlink-text-frame", "tool-unlink-text-frame", "", defaultKey(name), mainWindow)); + (*scrActions)[name]->setEnabled(false); name = "toolsEyeDropper"; scrActions->insert(name, new ScrAction(ScrAction::DataInt, "tool-color-picker", "tool-color-picker", "", defaultKey(name), mainWindow, modeEyeDropper)); name = "toolsCopyProperties"; @@ -982,7 +983,7 @@ *modeActionNames << "toolsSelect" << "toolsInsertTextFrame" << "toolsInsertImageFrame" << "toolsInsertTable"; *modeActionNames << "toolsInsertShape" << "toolsInsertPolygon" << "toolsInsertArc" << "toolsInsertSpiral" << "toolsInsertLine" << "toolsInsertBezier"; *modeActionNames << "toolsInsertFreehandLine" << "toolsInsertCalligraphicLine" << "toolsInsertRenderFrame" << "toolsRotate" << "toolsZoom" << "toolsEditContents"; - *modeActionNames << "toolsEditWithStoryEditor" << "toolsLinkTextFrame" << "toolsUnlinkTextFrame"; //<< "toolsUnlinkTextFrameAndCutText"; + *modeActionNames << "toolsEditWithStoryEditor" << "toolsLinkTextFrame"; //<< "toolsUnlinkTextFrameAndCutText"; *modeActionNames << "toolsEyeDropper" << "toolsCopyProperties"; *modeActionNames << "toolsPDFPushButton" << "toolsPDFRadioButton" << "toolsPDFTextField" << "toolsPDFCheckBox" << "toolsPDFComboBox" << "toolsPDFListBox" << "toolsPDFAnnotText" << "toolsPDFAnnotLink"; #ifdef HAVE_OSG @@ -995,7 +996,7 @@ } - *nonEditActionNames << "itemLowerToBottom" << "itemRaiseToTop" << "itemRaise" << "itemLower"; + *nonEditActionNames << "itemLowerToBottom" << "itemRaiseToTop" << "itemRaise" << "itemLower" << "toolsUnlinkTextFrame"; connect( (*scrActions)["toolsResources"], SIGNAL(triggered()), mainWindow, SLOT(slotResourceManager()) ); connectModeActions(); @@ -1309,6 +1310,7 @@ (*scrActions)["itemRaiseToTop"]->disconnect(); (*scrActions)["itemLower"]->disconnect(); (*scrActions)["itemRaise"]->disconnect(); + (*scrActions)["toolsUnlinkTextFrame"]->disconnect(); (*scrActions)["toolsUnlinkTextFrameAndCutText"]->disconnect(); (*scrActions)["itemTextTransformLowercase"]->disconnect(SIGNAL(triggeredData(int))); @@ -1363,6 +1365,7 @@ connect( (*scrActions)["itemRaiseToTop"], SIGNAL(triggered()), currDoc, SLOT(bringItemSelectionToFront()) ); connect( (*scrActions)["itemLower"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_LowerItem()) ); connect( (*scrActions)["itemRaise"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_RaiseItem()) ); + connect( (*scrActions)["toolsUnlinkTextFrame"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_UnlinkTextFrames()) ); connect( (*scrActions)["toolsUnlinkTextFrameAndCutText"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_UnlinkTextFrameAndCutText()) ); connect( (*scrActions)["itemTextTransformLowercase"], SIGNAL(triggeredData(int)), currDoc, SLOT(itemSelection_SetItemTextCaseTransform(int)) ); connect( (*scrActions)["itemTextTransformUppercase"], SIGNAL(triggeredData(int)), currDoc, SLOT(itemSelection_SetItemTextCaseTransform(int)) ); @@ -1914,7 +1917,7 @@ (*scrActions)["toolsDocumentLog"]->setStatusTextAndShortcut( tr("Display logged warnings and errors from editing activities")); (*scrActions)["toolsRotate"]->setStatusTextAndShortcut( tr("Rotate an item")); (*scrActions)["toolsSelect"]->setStatusTextAndShortcut( tr("Select an item")); - (*scrActions)["toolsUnlinkTextFrame"]->setStatusTextAndShortcut( tr("Break a text chain before the clicked frame")); + (*scrActions)["toolsUnlinkTextFrame"]->setStatusTextAndShortcut( tr("Break the outgoing chain connection from a selected text frame, or chain connections between selected text frames")); (*scrActions)["toolsUnlinkTextFrameAndCutText"]->setStatusTextAndShortcut( tr("Break the text chain at the selected frame and split its text between the resulting chains")); (*scrActions)["toolsZoom"]->setStatusTextAndShortcut( tr("Zoom in or out")); (*scrActions)["viewPreviewMode"]->setStatusTextAndShortcut( tr("Enable preview mode")); Index: scribus/appmodehelper.cpp =================================================================== --- scribus/appmodehelper.cpp (revision 27827) +++ scribus/appmodehelper.cpp (working copy) @@ -993,6 +993,9 @@ scmw->layerMenu->setEnabled(!inAnEditMode); } + // Ordinary chain breaking is selection-driven: enable it only when the + // current selection identifies at least one connection to break. + (*a_scrActions)["toolsUnlinkTextFrame"]->setEnabled(doc->itemSelection_CanUnlinkTextFrames()); } void AppModeHelper::setModeActionsPerMode(int newMode) @@ -1016,7 +1019,6 @@ (*a_scrActions)["toolsEditContents"]->setChecked(newMode == modeEdit); (*a_scrActions)["toolsEditWithStoryEditor"]->setChecked(newMode == modeStoryEditor); (*a_scrActions)["toolsLinkTextFrame"]->setChecked(newMode == modeLinkFrames); - (*a_scrActions)["toolsUnlinkTextFrame"]->setChecked(newMode == modeUnlinkFrames); // (*a_scrActions)["toolsUnlinkTextFrameAndCutText"]->setChecked(newMode == modeUnlinkFrames); (*a_scrActions)["toolsEyeDropper"]->setChecked(newMode == modeEyeDropper); (*a_scrActions)["toolsMeasurements"]->setChecked(newMode == modeMeasurementTool); Index: scribus/scribusdoc.cpp =================================================================== --- scribus/scribusdoc.cpp (revision 27827) +++ scribus/scribusdoc.cpp (working copy) @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -17440,6 +17441,74 @@ m_documentFileName = documentFileName; } +static QList unlinkableTextFrameSources(Selection* itemSelection) +{ + QList textFrames; + QSet selectedTextFrames; + textFrames.reserve(itemSelection->count()); + selectedTextFrames.reserve(itemSelection->count()); + for (int i = 0; i < itemSelection->count(); ++i) + { + PageItem* item = itemSelection->itemAt(i); + if (item && item->isTextFrame()) + { + textFrames.append(item); + selectedTextFrames.insert(item); + } + } + + QList sources; + if (textFrames.count() == 1) + { + PageItem* item = textFrames.first(); + if (item->nextInChain()) + sources.append(item); + return sources; + } + + for (PageItem* item : textFrames) + { + PageItem* next = item->nextInChain(); + if (next && selectedTextFrames.contains(next)) + sources.append(item); + } + return sources; +} + +bool ScribusDoc::itemSelection_CanUnlinkTextFrames(Selection* customSelection) const +{ + Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection; + return itemSelection && !unlinkableTextFrameSources(itemSelection).isEmpty(); +} + +void ScribusDoc::itemSelection_UnlinkTextFrames(Selection* customSelection) +{ + Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection; + if (!itemSelection) + return; + + const QList sources = unlinkableTextFrameSources(itemSelection); + if (sources.isEmpty()) + return; + + UndoTransaction transaction; + if (UndoManager::undoEnabled() && sources.count() > 1) + transaction = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::UnlinkTextFrame, "", Um::ITextFrame); + + for (PageItem* source : sources) + source->unlink(); + + if (transaction) + transaction.commit(); + + regionsChanged()->update(QRectF()); + changed(); + if (itemSelection->count() > 0) + itemSelection->itemAt(0)->emitAllToGUI(); + if (customSelection == nullptr && m_ScMW) + m_ScMW->HaveNewSel(); +} + void ScribusDoc::itemSelection_UnlinkTextFrameAndCutText( Selection *customSelection) { Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection; Index: scribus/scribusdoc.h =================================================================== --- scribus/scribusdoc.h (revision 27827) +++ scribus/scribusdoc.h (working copy) @@ -1620,6 +1620,8 @@ void itemSelection_Rotate(double angle, Selection* customSelection = nullptr); void itemSelection_DoHyphenate(); void itemSelection_DoDeHyphenate(); + bool itemSelection_CanUnlinkTextFrames(Selection* customSelection = nullptr) const; + void itemSelection_UnlinkTextFrames(Selection* customSelection = nullptr); void itemSelection_UnlinkTextFrameAndCutText(Selection* customSelection = nullptr); void itemSelection_SendToLayer(int layerID); void itemSelection_SetImageOffset(double x, double y, Selection* customSelection = nullptr);