r23937 by jghali - #16178, 16179: fix ability to modify locked layer after saving doc or reopening doc
scribus-commit
scribus-commit at lists.scribus.net
Mon Jul 20 08:47:02 UTC 2020
Author: jghali
Date: Mon Jul 20 08:47:02 2020
New Revision: 23937
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23937
Log:
#16178, 16179: fix ability to modify locked layer after saving doc or reopening doc
Modified:
trunk/Scribus/scribus/appmodehelper.cpp
trunk/Scribus/scribus/appmodehelper.h
trunk/Scribus/scribus/pluginmanager.cpp
trunk/Scribus/scribus/pluginmanager.h
trunk/Scribus/scribus/scplugin.cpp
trunk/Scribus/scribus/scribus.cpp
Modified: trunk/Scribus/scribus/appmodehelper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23937&path=/trunk/Scribus/scribus/appmodehelper.cpp
==============================================================================
--- trunk/Scribus/scribus/appmodehelper.cpp (original)
+++ trunk/Scribus/scribus/appmodehelper.cpp Mon Jul 20 08:47:02 2020
@@ -24,6 +24,7 @@
#include "pluginmanager.h"
#include "prefsmanager.h"
#include "scmimedata.h"
+#include "scplugin.h"
#include "scribus.h"
#include "scribuscore.h"
#include "scribusdoc.h"
@@ -114,6 +115,7 @@
if (newMode != modeNormal && newMode != modeStoryEditor)
scmw->activateWindow();
+ bool layerUnlocked = !doc->layerLocked(doc->activeLayer());
switch (oldMode)
{
@@ -217,7 +219,7 @@
(*a_scrActions)["editCut"]->setEnabled(currItem != nullptr);
(*a_scrActions)["editCopy"]->setEnabled(currItem != nullptr);
(*a_scrActions)["editClearContents"]->setEnabled(currItem != nullptr);
- (*a_scrActions)["editPaste"]->setEnabled(ScMimeData::clipboardHasScribusData());
+ (*a_scrActions)["editPaste"]->setEnabled(layerUnlocked && ScMimeData::clipboardHasScribusData());
(*a_scrActions)["editTruncateContents"]->setEnabled((currItem != nullptr) && currItem->isTextFrame());
scmw->propertiesPalette->setGradientEditMode(false);
@@ -1300,6 +1302,42 @@
(*a_scrActions)["ExportAsImage"]->setEnabled(b2);
}
+void AppModeHelper::updateActionPluginsActions(ScribusDoc* doc)
+{
+ int selectedType = -1;
+ if (doc->m_Selection->count() > 0)
+ {
+ PageItem *currItem = doc->m_Selection->itemAt(0);
+ selectedType = currItem->itemType();
+ }
+ bool isLayerLocked = doc->layerLocked(doc->activeLayer());
+
+ PluginManager& pluginManager(PluginManager::instance());
+ QStringList pluginNames(pluginManager.pluginNames(false));
+ ScPlugin* plugin;
+ ScActionPlugin* actionPlug;
+ ScrAction* pluginAction = nullptr;
+ QString pName;
+ for (int i = 0; i < pluginNames.count(); ++i)
+ {
+ pName = pluginNames.at(i);
+ plugin = pluginManager.getPlugin(pName, true);
+ Q_ASSERT(plugin); // all the returned names should represent loaded plugins
+ if (!plugin->inherits("ScActionPlugin"))
+ continue;
+ actionPlug = dynamic_cast<ScActionPlugin*>(plugin);
+ Q_ASSERT(actionPlug);
+ ScActionPlugin::ActionInfo actionInfo(actionPlug->actionInfo());
+ pluginAction = ScCore->primaryMainWindow()->scrActions[actionInfo.name];
+ if (!pluginAction)
+ continue;
+ if (isLayerLocked && !actionInfo.enabledOnStartup)
+ pluginAction->setEnabled(false);
+ else
+ pluginAction->setEnabled(actionPlug->handleSelection(doc, selectedType));
+ }
+}
+
void AppModeHelper::updateTableMenuActions(ScribusDoc* doc)
{
// Determine state.
@@ -1387,10 +1425,14 @@
(*a_scrActions)["toolsPDFListBox"]->setEnabled(setter2);
(*a_scrActions)["toolsPDFAnnotText"]->setEnabled(setter2);
(*a_scrActions)["toolsPDFAnnotLink"]->setEnabled(setter);
+
+ updateActionPluginsActions(doc);
}
void AppModeHelper::mainWindowHasNewDoc(ScribusDoc *doc, bool clipScrapHaveData)
{
+ bool layerUnlocked = !doc->layerLocked(doc->activeLayer());
+
(*a_scrActions)["filePrint"]->setEnabled(true);
(*a_scrActions)["fileSave"]->setEnabled(!doc->isConverted);
(*a_scrActions)["fileClose"]->setEnabled(true);
@@ -1416,7 +1458,7 @@
(*a_scrActions)["editCut"]->setEnabled(false);
(*a_scrActions)["editCopy"]->setEnabled(false);
- (*a_scrActions)["editPaste"]->setEnabled(clipScrapHaveData);
+ (*a_scrActions)["editPaste"]->setEnabled(layerUnlocked && clipScrapHaveData);
(*a_scrActions)["editCopyContents"]->setEnabled(false);
(*a_scrActions)["editPasteContents"]->setEnabled(false);
(*a_scrActions)["editPasteContentsAbs"]->setEnabled(false);
Modified: trunk/Scribus/scribus/appmodehelper.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23937&path=/trunk/Scribus/scribus/appmodehelper.h
==============================================================================
--- trunk/Scribus/scribus/appmodehelper.h (original)
+++ trunk/Scribus/scribus/appmodehelper.h Mon Jul 20 08:47:02 2020
@@ -48,6 +48,7 @@
void setSymbolEditMode(bool b, ScribusDoc* doc);
void setInlineEditMode(bool b, ScribusDoc* doc);
void setMasterPageEditMode(bool b, ScribusDoc *doc);
+ void updateActionPluginsActions(ScribusDoc* doc);
void updateTableMenuActions(ScribusDoc* doc);
void changeLayer(ScribusDoc *doc, bool clipScrapHaveData);
void mainWindowHasNewDoc(ScribusDoc *doc, bool clipScrapHaveData);
Modified: trunk/Scribus/scribus/pluginmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23937&path=/trunk/Scribus/scribus/pluginmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/pluginmanager.cpp (original)
+++ trunk/Scribus/scribus/pluginmanager.cpp Mon Jul 20 08:47:02 2020
@@ -455,31 +455,36 @@
void PluginManager::enablePluginActionsForSelection(ScribusMainWindow* mw)
{
Q_CHECK_PTR(mw);
- ScribusDoc* doc=mw->doc;
+ ScribusDoc* doc = mw->doc;
if (!doc)
return;
- ScActionPlugin* ixplug = nullptr;
+ int selectedType = -1;
+ if ( doc->m_Selection->count() > 0)
+ {
+ PageItem *currItem = doc->m_Selection->itemAt(0);
+ selectedType = currItem->itemType();
+ }
+ bool isLayerLocked = doc->layerLocked(doc->activeLayer());
+
+ ScActionPlugin* actionPlug = nullptr;
ScrAction* pluginAction = nullptr;
for (PluginMap::Iterator it = pluginMap.begin(); it != pluginMap.end(); ++it)
{
- if (it.value().plugin->inherits("ScActionPlugin"))
- {
- ixplug = dynamic_cast<ScActionPlugin*>(it.value().plugin);
- Q_ASSERT(ixplug);
- if (ixplug)
- {
- ScActionPlugin::ActionInfo ai(ixplug->actionInfo());
- pluginAction = mw->scrActions[ai.name];
- if (pluginAction != nullptr)
- {
- if (doc->m_Selection->count() != 0)
- pluginAction->setEnabled(ixplug->handleSelection(doc, doc->m_Selection->itemAt(0)->itemType()));
- else
- pluginAction->setEnabled(ixplug->handleSelection(doc));
- }
- }
- }
+ if (!it.value().plugin->inherits("ScActionPlugin"))
+ continue;
+ actionPlug = dynamic_cast<ScActionPlugin*>(it.value().plugin);
+ if (!actionPlug)
+ continue;
+
+ ScActionPlugin::ActionInfo actionInfo(actionPlug->actionInfo());
+ pluginAction = mw->scrActions[actionInfo.name];
+ if (pluginAction == nullptr)
+ continue;
+ if (isLayerLocked && !actionInfo.enabledOnStartup)
+ pluginAction->setEnabled(false);
+ else
+ pluginAction->setEnabled(actionPlug->handleSelection(doc, selectedType));
}
}
Modified: trunk/Scribus/scribus/pluginmanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23937&path=/trunk/Scribus/scribus/pluginmanager.h
==============================================================================
--- trunk/Scribus/scribus/pluginmanager.h (original)
+++ trunk/Scribus/scribus/pluginmanager.h Mon Jul 20 08:47:02 2020
@@ -72,9 +72,14 @@
/*! \brief Called when the last doc is closed
*/
void enableOnlyStartupPluginActions(ScribusMainWindow*);
- /*! \brief Called when the last doc is closed
+
+ /*! \brief Called when selection change
*/
void enablePluginActionsForSelection(ScribusMainWindow*);
+
+ /*! \brief Called when selection change
+ */
+ void enablePluginActionsForSelection(ScribusDoc*);
/*! \brief Checks if is the plugin is in the plugin map, is loaded, and is enabled.
*
Modified: trunk/Scribus/scribus/scplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23937&path=/trunk/Scribus/scribus/scplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/scplugin.cpp (original)
+++ trunk/Scribus/scribus/scplugin.cpp Mon Jul 20 08:47:02 2020
@@ -122,7 +122,7 @@
bool ScActionPlugin::handleSelection(ScribusDoc* doc, int SelectedType)
{
- const int docSelectionCount=doc->m_Selection->count();
+ const int docSelectionCount = doc->m_Selection->count();
ActionInfo ai(actionInfo());
if (SelectedType != -1)
{
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23937&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Mon Jul 20 08:47:02 2020
@@ -2787,6 +2787,12 @@
pagePalette->enablePalette(true);
setPreviewToolbar();
}
+
+ bool setter = !doc->layerLocked( doc->activeLayer() );
+ scrMenuMgr->setMenuEnabled("EditPasteRecent", ((scrapbookPalette->tempBView->objectMap.count() > 0) && (setter)));
+ scrMenuMgr->setMenuEnabled("Insert", setter);
+ scrMenuMgr->setMenuEnabled("ItemLayer", doc->layerCount() > 1);
+ appModeHelper->changeLayer(doc, (ScMimeData::clipboardHasScribusData() || (scrapbookPalette->tempHasContents())));
}
void ScribusMainWindow::HaveNewDoc()
@@ -2843,13 +2849,13 @@
{
if (doc == nullptr)
return;
- int SelectedType = -1;
+ int selectedType = -1;
PageItem *currItem = nullptr;
const int docSelectionCount = doc->m_Selection->count();
if (docSelectionCount > 0)
{
currItem = doc->m_Selection->itemAt(0);
- SelectedType = currItem->itemType();
+ selectedType = currItem->itemType();
}
assert (docSelectionCount == 0 || currItem != nullptr); // help coverity analysis
@@ -2863,7 +2869,7 @@
if (!doc->inAnEditMode())
appModeHelper->enableActionsForSelection(this, doc);
- switch (SelectedType)
+ switch (selectedType)
{
case -1: // None
outlinePalette->slotShowSelect(doc->currentPageNumber(), nullptr);
@@ -2927,33 +2933,13 @@
propertiesPalette->setTextFlowMode(currItem->textFlowMode());
}
- if (SelectedType != -1)
+ if (selectedType != -1)
{
outlinePalette->slotShowSelect(currItem->OwnPage, currItem);
actionManager->connectNewSelectionActions(view, doc);
}
- PluginManager& pluginManager(PluginManager::instance());
- QStringList pluginNames(pluginManager.pluginNames(false));
- ScPlugin* plugin;
- ScActionPlugin* ixplug;
- ScrAction* pluginAction = nullptr;
- QString pName;
- for (int i = 0; i < pluginNames.count(); ++i)
- {
- pName = pluginNames.at(i);
- plugin = pluginManager.getPlugin(pName, true);
- Q_ASSERT(plugin); // all the returned names should represent loaded plugins
- if (plugin->inherits("ScActionPlugin"))
- {
- ixplug = dynamic_cast<ScActionPlugin*>(plugin);
- Q_ASSERT(ixplug);
- ScActionPlugin::ActionInfo ai(ixplug->actionInfo());
- pluginAction = ScCore->primaryMainWindow()->scrActions[ai.name];
- if (pluginAction != nullptr)
- pluginAction->setEnabled(ixplug->handleSelection(doc, SelectedType));
- }
- }
+ appModeHelper->updateActionPluginsActions(doc);
}
void ScribusMainWindow::slotDocCh(bool /*reb*/)
@@ -3171,7 +3157,7 @@
{
UndoTransaction pasteAction;
if (UndoManager::undoEnabled())
- pasteAction = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate);
+ pasteAction = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create, QString(), Um::ICreate);
view->deselectItems(true);
int docItemCount = doc->Items->count();
bool savedAlignGrid = doc->SnapGrid;
More information about the scribus-commit
mailing list