View Issue Details

IDProjectCategoryView StatusLast Update
0014956ScribusGeneralpublic2025-01-30 10:50
Reporterutnik Assigned To 
PrioritylowSeveritytweakReproducibilityalways
Status newResolutionopen 
Platformall platforms 
Product Version1.5.4.svn 
Summary0014956: [PATCH] 'snap to guides' should be enabled by default. (maybe 'snap to items' too…)
Description'snap to guides' should be enabled by default, or at least have a global setting to enable the function in future documents.
the same might be good for 'snap to items'.
TagsNo tags attached.
PatchYes

Activities

jghali

2017-08-18 16:28

administrator   ~0044341

Hmmm... Snap to guides is already enabled by default for new docs in 1.5.3.

utnik

2017-08-18 16:46

updater   ~0044342

oh yes – sorry!
i checked it after searching for a setting to fix 'snap to items' as a default. and it doesn't show as enabled without an open document.
maybe it would be better to show it (i.e. 'sticky tools' shows the checkmark if it's enabled and no document is open…), but the bug could also be closed.

ale

2017-08-19 17:30

manager   ~0044344

i'm not sure that snap to items should be enabled by default.

not before it works in a way that feels very comfortable.

currently, i would say that in the general case i'm often not that happy with the snapping options...
in the current state, i prefer to enable it when it

ale

2025-01-25 19:02

manager   ~0051940

somehow, i have the feeling that at some time in the past, the snapping to guides was enabled by default...

it's not in the current versions of scribus.

can we really have it enabled by default?
(i mean: i create a new document, "snap to guides" should be enabled.)

ale

2025-01-25 19:06

manager   ~0051941

(on top of it, when all documents are closed one should be able to set the value for the snapping options in the page menu and that should be considered a preferences for all future documents)

ale

2025-01-26 21:10

manager   ~0051950

I'm working on a prefs tab

- disable the page > snapping items when no doc is open (they do nothing anyway)
- only show the tab in the prefs (not in the doc setup)
prefs-snapping.png (18,608 bytes)   
prefs-snapping.png (18,608 bytes)   

ale

2025-01-27 22:30

manager   ~0051954

after a huge refactoring to get the snapping to use the document settings instead of the ad hoc member variables, i think that i have some code that works.

i need some more tests and some clean up... then, i might be able to upload a patch.

ale

2025-01-30 10:50

manager   ~0051958

some comments about the patch i'm submitting:

- plugins/fileloader/scribus170format/scribus170format.cpp : there might be a bug in readPattern()
  the guides are stashed from m_Doc but restored on doc.
  I leave the potential there, since I don't fully understand the switching of context between m_Doc and doc.
  the mismatch is to be found in all file formats (you can grep for snappingStash to find which ones are affected) and it also applies to the master page restoring.
- i have created two functions: disableSnapping() and restoreSnapping() in scribusdoc.cpp to avoid errors when stashing the state of the snapping. i hope it's ok to have a function call there.
- i have moved the snapping actions from view (where they were in an ancient time) to page section. this allows to better check that the right thing is done, when switching context.
- there is a new "Snapping" tab in the preferences (not in the document setup: there are menus for the current document...)
- in ScribusMainWindow::slotEditPaste() the stash is not restored if retObj == nullptr
- snapping to the guides is now on by default (on the first start of scribus).
- canvasmode_create.cpp, canvasmode_edit.cpp, and canvasmode_bezier.cpp had wrong line endings... the diff is messy.
snap-to-guides.diff (237,237 bytes)   
From 274b7c31d2f92d014e52d7e27794b531136126fd Mon Sep 17 00:00:00 2001
From: ale rimoldi <ale@graphicslab.org>
Date: Thu, 30 Jan 2025 11:47:26 +0100
Subject: refactor the settings for snapping into the preferences; make snap to
 guides on by default


diff --git a/scribus/actionmanager.cpp b/scribus/actionmanager.cpp
index 17ce7c411..039511b44 100644
--- a/scribus/actionmanager.cpp
+++ b/scribus/actionmanager.cpp
@@ -615,6 +615,15 @@ void ActionManager::initPageMenuActions()
 	(*scrActions)["pageManageGuides"]->setToggleAction(true);
 	name = "pageManageProperties";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name = "pageSnapToGrid";
+	scrActions->insert(name, new ScrAction("snap-grid", "snap-grid", "", defaultKey(name), mainWindow));
+	name = "pageSnapToGuides";
+	scrActions->insert(name, new ScrAction("snap-guides", "snap-guides", "", defaultKey(name), mainWindow));
+	name = "pageSnapToElements";
+	scrActions->insert(name, new ScrAction("snap-items", "snap-items", "", defaultKey(name), mainWindow));
+	(*scrActions)["pageSnapToGrid"]->setToggleAction(true);
+	(*scrActions)["pageSnapToGuides"]->setToggleAction(true);
+	(*scrActions)["pageSnapToElements"]->setToggleAction(true);
 
 	connect( (*scrActions)["pageInsert"], SIGNAL(triggered()), mainWindow, SLOT(slotNewPageM()) );
 	connect( (*scrActions)["pageImport"], SIGNAL(triggered()), mainWindow, SLOT(slotPageImport()) );
@@ -624,6 +633,9 @@ void ActionManager::initPageMenuActions()
 	connect( (*scrActions)["pageApplyMasterPage"], SIGNAL(triggered()), mainWindow, SLOT(ApplyMasterPage()) );
 	connect( (*scrActions)["pageCopyToMasterPage"], SIGNAL(triggered()), mainWindow, SLOT(duplicateToMasterPage()) );
 	connect( (*scrActions)["pageManageProperties"], SIGNAL(triggered()), mainWindow, SLOT(changePageProperties()) );
+	connect( (*scrActions)["pageSnapToGrid"], SIGNAL(triggered()), mainWindow, SLOT(toggleSnapGrid()) );
+	connect( (*scrActions)["pageSnapToGuides"], SIGNAL(triggered()), mainWindow, SLOT(toggleSnapGuides()) );
+	connect( (*scrActions)["pageSnapToElements"], SIGNAL(triggered()), mainWindow, SLOT(toggleSnapElements()) );
 }
 
 void ActionManager::initTableMenuActions()
@@ -707,12 +719,6 @@ void ActionManager::initViewMenuActions()
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name = "viewRulerMode";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
-	name = "viewSnapToGrid";
-	scrActions->insert(name, new ScrAction("snap-grid", "snap-grid", "", defaultKey(name), mainWindow));
-	name = "viewSnapToGuides";
-	scrActions->insert(name, new ScrAction("snap-guides", "snap-guides", "", defaultKey(name), mainWindow));
-	name = "viewSnapToElements";
-	scrActions->insert(name, new ScrAction("snap-items", "snap-items", "", defaultKey(name), mainWindow));
 	name = "viewShowContextMenu";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name = "showMouseCoordinates";
@@ -745,9 +751,6 @@ void ActionManager::initViewMenuActions()
 	(*scrActions)["viewShowTextControls"]->setToggleAction(true);
 	(*scrActions)["viewShowRulers"]->setToggleAction(true);
 	(*scrActions)["viewRulerMode"]->setToggleAction(true);
-	(*scrActions)["viewSnapToGrid"]->setToggleAction(true);
-	(*scrActions)["viewSnapToGuides"]->setToggleAction(true);
-	(*scrActions)["viewSnapToElements"]->setToggleAction(true);
 	(*scrActions)["showMouseCoordinates"]->setToggleAction(true);
 
 	(*scrActions)["viewPreviewMode"]->setChecked(false);
@@ -785,9 +788,6 @@ void ActionManager::initViewMenuActions()
 	connect( (*scrActions)["viewShowTextControls"], SIGNAL(triggered()), mainWindow, SLOT(toggleTextControls()) );
 	connect( (*scrActions)["viewShowRulers"], SIGNAL(triggered()), mainWindow, SLOT(toggleRulers()) );
 	connect( (*scrActions)["viewRulerMode"], SIGNAL(triggered()), mainWindow, SLOT(toggleRulerMode()) );
-	connect( (*scrActions)["viewSnapToGrid"], SIGNAL(triggered()), mainWindow, SLOT(toggleSnapGrid()) );
-	connect( (*scrActions)["viewSnapToGuides"], SIGNAL(triggered()), mainWindow, SLOT(toggleSnapGuides()) );
-	connect( (*scrActions)["viewSnapToElements"], SIGNAL(triggered()), mainWindow, SLOT(toggleSnapElements()) );
 	connect( (*scrActions)["showMouseCoordinates"], SIGNAL(triggered()), mainWindow, SLOT(ToggleMouseTips()) );
 //	connect( (*scrActions)["viewNewView"], SIGNAL(triggered()), mainWindow, SLOT(newView()) );
 
@@ -1661,6 +1661,9 @@ void ActionManager::languageChange()
 	(*scrActions)["pageCopyToMasterPage"]->setTexts( tr("Convert to Master Page..."));
 	(*scrActions)["pageManageGuides"]->setTexts( tr("Manage &Guides..."));
 	(*scrActions)["pageManageProperties"]->setTexts( tr("Manage Page Properties..."));
+	(*scrActions)["pageSnapToGrid"]->setTexts( tr("Snap to &Grid"));
+	(*scrActions)["pageSnapToGuides"]->setTexts( tr("Sna&p to Guides"));
+	(*scrActions)["pageSnapToElements"]->setTexts( tr("Snap to &Items"));
 
 	//View Menu
 	(*scrActions)["viewFitInWindow"]->setTexts( tr("&Fit to Height"));
@@ -1687,9 +1690,6 @@ void ActionManager::languageChange()
 	(*scrActions)["viewShowTextControls"]->setTexts( tr("Show Control Characters"));
 	(*scrActions)["viewShowRulers"]->setTexts( tr("Show Rulers"));
 	(*scrActions)["viewRulerMode"]->setTexts( tr("Rulers Relative to Page"));
-	(*scrActions)["viewSnapToGrid"]->setTexts( tr("Sn&ap to Grid"));
-	(*scrActions)["viewSnapToGuides"]->setTexts( tr("Sna&p to Guides"));
-	(*scrActions)["viewSnapToElements"]->setTexts( tr("Snap to Items"));
 	(*scrActions)["viewShowContextMenu"]->setTexts( tr("Show Context Menu"));
 //	(*scrActions)["viewNewView"]->setTexts( tr("New View"));
 
@@ -2319,9 +2319,9 @@ void ActionManager::createDefaultMenus()
 		<< "pageCopyToMasterPage"
 		<< "pageManageGuides"
 		<< "pageManageProperties"
-		<< "viewSnapToGrid"
-		<< "viewSnapToGuides"
-		<< "viewSnapToElements";
+		<< "pageSnapToGrid"
+		<< "pageSnapToGuides"
+		<< "pageSnapToElements";
 	//View
 	++itmenu;
 	itmenu->second
diff --git a/scribus/appmodehelper.cpp b/scribus/appmodehelper.cpp
index 28f3dc61e..ff4257eeb 100644
--- a/scribus/appmodehelper.cpp
+++ b/scribus/appmodehelper.cpp
@@ -1439,7 +1439,7 @@ void AppModeHelper::changeLayer(ScribusDoc *doc, bool clipScrapHaveData)
 	updateActionPluginsActions(doc);
 }
 
-void AppModeHelper::mainWindowHasNewDoc(const ScribusDoc *doc, bool clipScrapHaveData)
+void AppModeHelper::mainWindowHasNewDoc(ScribusDoc *doc, bool clipScrapHaveData)
 {
 	bool layerUnlocked = !doc->layerLocked(doc->activeLayer());
 
@@ -1490,9 +1490,6 @@ void AppModeHelper::mainWindowHasNewDoc(const ScribusDoc *doc, bool clipScrapHav
 	(*a_scrActions)["viewFit200"]->setEnabled(true);
 	(*a_scrActions)["viewFit400"]->setEnabled(true);
 
-	(*a_scrActions)["viewSnapToGrid"]->setChecked(doc->SnapGrid);
-	(*a_scrActions)["viewSnapToGuides"]->setChecked(doc->SnapGuides);
-	(*a_scrActions)["viewSnapToElements"]->setChecked(doc->SnapElement);
 	(*a_scrActions)["viewShowRulers"]->setEnabled(true);
 
 	(*a_scrActions)["insertFrame"]->setEnabled(true);
@@ -1535,11 +1532,17 @@ void AppModeHelper::mainWindowHasNewDoc(const ScribusDoc *doc, bool clipScrapHav
 	(*a_scrActions)["pageCopyToMasterPage"]->setEnabled(true);
 	(*a_scrActions)["pageManageGuides"]->setEnabled(true);
 	(*a_scrActions)["pageManageProperties"]->setEnabled(true);
+	(*a_scrActions)["pageSnapToGrid"]->setEnabled(true);
+	(*a_scrActions)["pageSnapToGuides"]->setEnabled(true);
+	(*a_scrActions)["pageSnapToElements"]->setEnabled(true);
+	(*a_scrActions)["pageSnapToGrid"]->setChecked(doc->guidesPrefs().gridSnapping);
+	(*a_scrActions)["pageSnapToGuides"]->setChecked(doc->guidesPrefs().guidesSnapping);
+	(*a_scrActions)["pageSnapToElements"]->setChecked(doc->guidesPrefs().elementsSnapping);
 
 	enableExperimentalActions(doc);
 }
 
-void AppModeHelper::mainWindowSwitchWin(const ScribusDoc *doc)
+void AppModeHelper::mainWindowSwitchWin(ScribusDoc *doc)
 {
 	(*a_scrActions)["fileClose"]->setEnabled(true);
 	if (doc->masterPageMode() || doc->symbolEditMode() || doc->inlineEditMode())
@@ -1599,6 +1602,9 @@ void AppModeHelper::mainWindowSwitchWin(const ScribusDoc *doc)
 		(*a_scrActions)["pageCopyToMasterPage"]->setEnabled(true);
 		(*a_scrActions)["pageManageGuides"]->setEnabled(true);
 		(*a_scrActions)["pageManageProperties"]->setEnabled(true);
+		(*a_scrActions)["pageSnapToGrid"]->setEnabled(true);
+		(*a_scrActions)["pageSnapToGuides"]->setEnabled(true);
+		(*a_scrActions)["pageSnapToElements"]->setEnabled(true);
 
 		(*a_scrActions)["fileSaveAs"]->setEnabled(true);
 		(*a_scrActions)["fileCollect"]->setEnabled(true);
@@ -1614,9 +1620,9 @@ void AppModeHelper::mainWindowSwitchWin(const ScribusDoc *doc)
 #endif
 	}
 
-	(*a_scrActions)["viewSnapToGrid"]->setChecked(doc->SnapGrid);
-	(*a_scrActions)["viewSnapToGuides"]->setChecked(doc->SnapGuides);
-	(*a_scrActions)["viewSnapToElements"]->setChecked(doc->SnapElement);
+	(*a_scrActions)["pageSnapToGrid"]->setChecked(doc->guidesPrefs().gridSnapping);
+	(*a_scrActions)["pageSnapToGuides"]->setChecked(doc->guidesPrefs().guidesSnapping);
+	(*a_scrActions)["pageSnapToElements"]->setChecked(doc->guidesPrefs().elementsSnapping);
 
 	enableExperimentalActions(doc);
 }
@@ -1700,6 +1706,9 @@ void AppModeHelper::mainWindowCloseLastDoc()
 	(*a_scrActions)["pageManageGuides"]->setEnabled(false);
 	(*a_scrActions)["pageManageProperties"]->setEnabled(false);
 	(*a_scrActions)["pageMove"]->setEnabled(false);
+	(*a_scrActions)["pageSnapToGrid"]->setEnabled(false);
+	(*a_scrActions)["pageSnapToGuides"]->setEnabled(false);
+	(*a_scrActions)["pageSnapToElements"]->setEnabled(false);
 	(*a_scrActions)["toolsCopyProperties"]->setEnabled(false);
 	(*a_scrActions)["toolsEditContents"]->setEnabled(false);
 	(*a_scrActions)["toolsEditWithStoryEditor"]->setEnabled(false);
@@ -1740,9 +1749,6 @@ void AppModeHelper::mainWindowCloseLastDoc()
 	(*a_scrActions)["viewFitInWindow"]->setEnabled(false);
 	(*a_scrActions)["viewFitWidth"]->setEnabled(false);
 	(*a_scrActions)["viewShowRulers"]->setEnabled(false);
-	(*a_scrActions)["viewSnapToElements"]->setChecked(false);
-	(*a_scrActions)["viewSnapToGrid"]->setChecked(false);
-	(*a_scrActions)["viewSnapToGuides"]->setChecked(false);
 
 #ifdef HAVE_OSG
 	(*a_scrActions)["toolsPDFAnnot3D"]->setEnabled(false);
@@ -1864,6 +1870,9 @@ void AppModeHelper::setStartupActionsEnabled(bool enabled)
 	(*a_scrActions)["pageCopyToMasterPage"]->setEnabled(false);
 	(*a_scrActions)["pageManageGuides"]->setEnabled(false);
 	(*a_scrActions)["pageManageProperties"]->setEnabled(false);
+	(*a_scrActions)["pageSnapToGuides"]->setEnabled(false);
+	(*a_scrActions)["pageSnapToElements"]->setEnabled(false);
+	(*a_scrActions)["pageSnapToGrid"]->setEnabled(false);
 	(*a_scrActions)["editUndoAction"]->setEnabled(false);
 	(*a_scrActions)["editRedoAction"]->setEnabled(false);
 	(*a_scrActions)["editCut"]->setEnabled(false);
@@ -1901,9 +1910,6 @@ void AppModeHelper::setStartupActionsEnabled(bool enabled)
 	(*a_scrActions)["viewFit100"]->setEnabled(false);
 	(*a_scrActions)["viewFit200"]->setEnabled(false);
 	(*a_scrActions)["viewFit400"]->setEnabled(false);
-	(*a_scrActions)["viewSnapToGuides"]->setChecked(false);
-	(*a_scrActions)["viewSnapToElements"]->setChecked(false);
-	(*a_scrActions)["viewSnapToGrid"]->setChecked(false);
 	(*a_scrActions)["viewShowRulers"]->setEnabled(false);
 //	scrMenuMgr->setMenuEnabled("Insert", false);
 	(*a_scrActions)["insertFrame"]->setEnabled(false);
diff --git a/scribus/appmodehelper.h b/scribus/appmodehelper.h
index 1ac8e3fa6..7171e6f59 100644
--- a/scribus/appmodehelper.h
+++ b/scribus/appmodehelper.h
@@ -51,8 +51,8 @@ class AppModeHelper : public QObject
 		void updateActionPluginsActions(ScribusDoc* doc);
 		void updateTableMenuActions(const ScribusDoc* doc);
 		void changeLayer(ScribusDoc *doc, bool clipScrapHaveData);
-		void mainWindowHasNewDoc(const ScribusDoc *doc, bool clipScrapHaveData);
-		void mainWindowSwitchWin(const ScribusDoc *doc);
+		void mainWindowHasNewDoc(ScribusDoc *doc, bool clipScrapHaveData);
+		void mainWindowSwitchWin(ScribusDoc *doc);
 		void mainWindowCloseLastDoc();
 		void setPreviewMode(bool b);
 		//! \brief enable or disable the unicode actions and their menus
diff --git a/scribus/canvasgesture_linemove.cpp b/scribus/canvasgesture_linemove.cpp
index fdad4f5a6..a07fba5b0 100644
--- a/scribus/canvasgesture_linemove.cpp
+++ b/scribus/canvasgesture_linemove.cpp
@@ -224,7 +224,7 @@ void LineMove::adjustBounds(QMouseEvent *m, bool updateCanvas)
 	double newX = mousePointDoc.x();
 	double newY = mousePointDoc.y();
 	
-	if (m_doc->SnapGrid)
+	if (m_doc->guidesPrefs().gridSnapping)
 	{
 		newX = qRound(newX / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
 		newY = qRound(newY / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
diff --git a/scribus/canvasgesture_resize.cpp b/scribus/canvasgesture_resize.cpp
index 5a7b231eb..22fe23f82 100644
--- a/scribus/canvasgesture_resize.cpp
+++ b/scribus/canvasgesture_resize.cpp
@@ -713,7 +713,7 @@ FPoint ResizeGesture::applyGrid(const FPoint& docPoint)
 {
 	int pointPage;
 
-	if (!m_doc->SnapGrid)
+	if (!m_doc->guidesPrefs().gridSnapping)
 		return docPoint;
 	FPoint snappedPoint = docPoint;
 
@@ -814,7 +814,7 @@ FPoint ResizeGesture::applyGuides(const FPoint& docPoint)
 {
 	int pointPage;
 
-	if (!m_doc->SnapGuides && !m_doc->SnapElement)
+	if (!m_doc->guidesPrefs().guidesSnapping && !m_doc->guidesPrefs().elementsSnapping)
 		return docPoint;
 	FPoint snappedPoint = docPoint;
 
diff --git a/scribus/canvasgesture_rulermove.cpp b/scribus/canvasgesture_rulermove.cpp
index 365a603bf..57836fbf4 100644
--- a/scribus/canvasgesture_rulermove.cpp
+++ b/scribus/canvasgesture_rulermove.cpp
@@ -199,7 +199,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease)
 			if ((page >= 0) && (viewport.contains(m->globalPosition())))
 			{
 				ScPage* currentPage = m_doc->Pages->at(page);
-				if (m_doc->SnapElement)
+				if (m_doc->guidesPrefs().elementsSnapping)
 				{
 					double xout = 0;
 					double yout = 0;
@@ -267,7 +267,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease)
 			if ((page >= 0) && viewport.contains(m->globalPosition()))
 			{
 				ScPage* currentPage = m_doc->Pages->at(page);
-				if (m_doc->SnapElement)
+				if (m_doc->guidesPrefs().elementsSnapping)
 				{
 					double xout = 0;
 					double yout = 0;
diff --git a/scribus/canvasmode.cpp b/scribus/canvasmode.cpp
index ad8e10061..8b664a009 100644
--- a/scribus/canvasmode.cpp
+++ b/scribus/canvasmode.cpp
@@ -723,7 +723,7 @@ void CanvasMode::clearPixmapCache()
 
 void CanvasMode::drawSnapLine(QPainter* p)
 {
-	if (!m_doc->SnapElement)
+	if (!m_doc->guidesPrefs().elementsSnapping)
 		return;
 	if (xSnap == 0.0 && ySnap == 0.0)
 		return;
@@ -1322,22 +1322,15 @@ void CanvasMode::commonkeyPressEvent_NormalNodeEdit(QKeyEvent *e)
 						}
 						else
 						{
-						/* Don't use Grid or Guide Snapping when dragging Items or Groups with the keyboard */
-						/* as the user might be trying to fine tune a position */
-							bool sav1 = m_doc->SnapGuides;
-							bool sav2 = m_doc->SnapGrid;
-							bool sav3 = m_doc->SnapElement;
-							m_doc->SnapGuides = false;
-							m_doc->SnapGrid = false;
-							m_doc->SnapElement = false;
+							/* Don't use Grid or Guide Snapping when dragging Items or Groups with the keyboard */
+							/* as the user might be trying to fine tune a position */
+							const auto snappingStash = m_doc->disableSnapping();
 							if (m_doc->m_Selection->count() > 1)
 								m_view->startGroupTransaction(Um::Move, QString(), Um::IMove);
 							m_doc->moveGroup(-moveBy, 0);
 							if (m_doc->m_Selection->count() > 1)
 								m_view->endGroupTransaction();
-							m_doc->SnapGuides = sav1;
-							m_doc->SnapGrid = sav2;
-							m_doc->SnapElement = sav3;
+							m_doc->restoreSnapping(snappingStash);
 						}
 					}
 					else
@@ -1416,22 +1409,15 @@ void CanvasMode::commonkeyPressEvent_NormalNodeEdit(QKeyEvent *e)
 						}
 						else
 						{
-						/* Don't use Grid or Guide Snapping when dragging Items or Groups with the keyboard */
-						/* as the user might be trying to fine tune a position */
-							bool sav1 = m_doc->SnapGuides;
-							bool sav2 = m_doc->SnapGrid;
-							bool sav3 = m_doc->SnapElement;
-							m_doc->SnapGuides = false;
-							m_doc->SnapGrid = false;
-							m_doc->SnapElement = false;
+							/* Don't use Grid or Guide Snapping when dragging Items or Groups with the keyboard */
+							/* as the user might be trying to fine tune a position */
+							const auto snappingStash = m_doc->disableSnapping();
 							if (m_doc->m_Selection->count() > 1)
 								m_view->startGroupTransaction(Um::Move, QString(), Um::IMove);
 							m_doc->moveGroup(moveBy, 0);
 							if (m_doc->m_Selection->count() > 1)
 								m_view->endGroupTransaction();
-							m_doc->SnapGuides = sav1;
-							m_doc->SnapGrid = sav2;
-							m_doc->SnapElement = sav3;
+							m_doc->restoreSnapping(snappingStash);
 						}
 					}
 					else
@@ -1512,20 +1498,13 @@ void CanvasMode::commonkeyPressEvent_NormalNodeEdit(QKeyEvent *e)
 						{
 						/* Don't use Grid or Guide Snapping when dragging Items or Groups with the keyboard */
 						/* as the user might be trying to fine tune a position */
-							bool sav1 = m_doc->SnapGuides;
-							bool sav2 = m_doc->SnapGrid;
-							bool sav3 = m_doc->SnapElement;
-							m_doc->SnapGuides = false;
-							m_doc->SnapGrid = false;
-							m_doc->SnapElement = false;
+							const auto snappingStash = m_doc->disableSnapping();
 							if (m_doc->m_Selection->count() > 1)
 								m_view->startGroupTransaction(Um::Move, QString(), Um::IMove);
 							m_doc->moveGroup(0, -moveBy);
 							if (m_doc->m_Selection->count() > 1)
 								m_view->endGroupTransaction();
-							m_doc->SnapGuides = sav1;
-							m_doc->SnapGrid = sav2;
-							m_doc->SnapElement = sav3;
+							m_doc->restoreSnapping(snappingStash);
 						}
 					}
 					else
@@ -1606,20 +1585,13 @@ void CanvasMode::commonkeyPressEvent_NormalNodeEdit(QKeyEvent *e)
 						{
 						/* Don't use Grid or Guide Snapping when dragging Items or Groups with the keyboard */
 						/* as the user might be trying to fine tune a position */
-							bool sav1 = m_doc->SnapGuides;
-							bool sav2 = m_doc->SnapGrid;
-							bool sav3 = m_doc->SnapElement;
-							m_doc->SnapGuides = false;
-							m_doc->SnapGrid = false;
-							m_doc->SnapElement = false;
+							const auto snappingStash = m_doc->disableSnapping();
 							if (m_doc->m_Selection->count() > 1)
 								m_view->startGroupTransaction(Um::Move, QString(), Um::IMove);
 							m_doc->moveGroup(0, moveBy);
 							if (m_doc->m_Selection->count() > 1)
 								m_view->endGroupTransaction();
-							m_doc->SnapGuides = sav1;
-							m_doc->SnapGrid = sav2;
-							m_doc->SnapElement = sav3;
+							m_doc->restoreSnapping(snappingStash);
 						}
 					}
 					else
diff --git a/scribus/canvasmode_create.cpp b/scribus/canvasmode_create.cpp
index 731d99ab0..e75dca341 100644
--- a/scribus/canvasmode_create.cpp
+++ b/scribus/canvasmode_create.cpp
@@ -1,968 +1,968 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-***************************************************************************/
-
-
-#include "canvasmode_create.h"
-
-#include <QApplication>
-#include <QButtonGroup>
-#include <QCheckBox>
-#include <QCursor>
-#include <QEvent>
-#include <QMessageBox>
-#include <QMouseEvent>
-#include <QPainterPath>
-#include <QPoint>
-#include <QRect>
-#include <QWidgetAction>
-
-#include "appmodes.h"
-#include "canvas.h"
-#include "fpoint.h"
-#include "fpointarray.h"
-#include "pageitem_table.h"
-#include "prefscontext.h"
-#include "prefsfile.h"
-#include "prefsmanager.h"
-#include "scribus.h"
-#include "scribusdoc.h"
-#include "scribusview.h"
-#include "selection.h"
-#include "text/frect.h"
-#include "ui/insertTable.h"
-#include "undomanager.h"
-#include "util_math.h"
-
-CreateMode::CreateMode(ScribusView* view) : CanvasMode(view) 
-{
-	canvasPressCoord.setXY(-1.0, -1.0);
-	mouseGlobalCoord.setXY(-1.0, -1.0);
-}
-
-void CreateMode::drawControls(QPainter* p) 
-{
-	if (!inItemCreation) return;
-
-	QPointF topLeft(createObjectPos.x(), createObjectPos.y());
-	QPointF btRight(canvasCurrCoord.x(), canvasCurrCoord.y());
-	QColor  drawColor = QApplication::palette().color(QPalette::Active, QPalette::Highlight);
-
-	if (createObjectMode != modeDrawLine)
-	{
-		QRectF bounds = QRectF(topLeft, btRight).normalized();
-		//Lock Height to Width for Control Modifier for region drawing
-		if (modifiers == Qt::ControlModifier)
-		{
-			bounds.setHeight(bounds.width());
-			if (btRight.y() < topLeft.y())
-				bounds.moveBottom(topLeft.y());
-			if (btRight.x() < topLeft.x() && btRight.y() > topLeft.y())
-				bounds.moveTop(topLeft.y());
-		}
-		QRect localRect = m_canvas->canvasToLocal(bounds);
-		if (localRect.width() <= 0 || localRect.height() <= 0)
-			return;
-		p->setRenderHint(QPainter::Antialiasing);
-
-		p->save();
-		p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
-		drawColor.setAlpha(64);
-		p->setBrush(drawColor);
-		p->drawRect(localRect);
-
-		drawColor.setAlpha(255);
-		p->setBrush(Qt::NoBrush);
-		p->setPen(QPen(drawColor, 1, Qt::DashLine, Qt::FlatCap, Qt::MiterJoin));
-
-		int frameType = 0, itemType = 0;
-		getFrameItemTypes(itemType, frameType);
-		if (frameType == PageItem::Ellipse)
-		{
-			p->drawEllipse(localRect);
-		}
-		else if (createObjectMode == modeDrawArc)
-		{
-			QPainterPath path;
-			path.moveTo(localRect.width() / 2.0, localRect.height() / 2.0);
-			path.arcTo(0.0, 0.0, localRect.width(), localRect.height(), m_doc->itemToolPrefs().arcStartAngle, m_doc->itemToolPrefs().arcSweepAngle);
-			path.closeSubpath();
-			p->translate(localRect.left(), localRect.top());
-			p->drawPath(path);
-		}
-		else if (createObjectMode == modeDrawRegularPolygon)
-		{
-			QPainterPath path = regularPolygonPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().polyCorners, m_doc->itemToolPrefs().polyUseFactor, m_doc->itemToolPrefs().polyFactor, m_doc->itemToolPrefs().polyRotation, m_doc->itemToolPrefs().polyCurvature, m_doc->itemToolPrefs().polyInnerRot, m_doc->itemToolPrefs().polyOuterCurvature);
-			p->translate(localRect.left(), localRect.top());
-			p->drawPath(path);
-		}
-		else if (createObjectMode == modeDrawSpiral)
-		{
-			QPainterPath path = spiralPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().spiralStartAngle, m_doc->itemToolPrefs().spiralEndAngle, m_doc->itemToolPrefs().spiralFactor);
-			p->translate(localRect.left(), localRect.top());
-			p->drawPath(path);
-		}
-		else if ((createObjectMode == modeDrawShapes) && (createObjectSubMode > 1))
-		{
-			FPointArray poly;
-			int valCount = m_doc->ValCount;
-			const double *vals = m_doc->ShapeValues;
-			for (int a = 0; a < valCount-3; a += 4)
-			{
-				if (vals[a] < 0)
-				{
-					poly.setMarker();
-					continue;
-				}
-				double x1 = localRect.width()  * vals[a] / 100.0;
-				double y1 = localRect.height() * vals[a + 1] / 100.0;
-				double x2 = localRect.width()  * vals[a + 2] / 100.0;
-				double y2 = localRect.height() * vals[a + 3] / 100.0;
-				poly.addPoint(x1, y1);
-				poly.addPoint(x2, y2);
-			}
-			QPainterPath path = poly.toQPainterPath(false);
-			p->translate(localRect.left(), localRect.top());
-			p->drawPath(path);
-		}
-		p->restore();
-	}
-	else
-	{
-		QPoint p1 = m_canvas->canvasToLocal(topLeft);
-		QPoint p2 = m_canvas->canvasToLocal(btRight);
-		
-		p->save();
-		p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
-		p->setBrush(drawColor);
-		p->drawLine(p1, p2);
-		p->restore();
-	}
-}
-
-inline bool CreateMode::GetItem(PageItem** pi)
-{ 
-	*pi = m_doc->m_Selection->itemAt(0); 
-	return (*pi) != nullptr;
-}
-
-// the following code was moved from scribusview.cpp:
-
-
-void CreateMode::enterEvent(QEvent *e)
-{
-	if (!m_MouseButtonPressed)
-	{
-		setModeCursor();
-	}
-}
-
-
-void CreateMode::leaveEvent(QEvent *e)
-{
-}
-
-
-void CreateMode::activate(bool fromGesture)
-{
-//	qDebug() << "CreateMode::activate" << fromGesture;
-	CanvasMode::activate(fromGesture);
-
-	PageItem* currItem;
-	if (!fromGesture || !GetItem(&currItem) || !m_createTransaction)
-	{
-		if (m_createTransaction)
-		{
-//			qDebug() << "canceling left over create Transaction";
-			m_createTransaction.cancel();
-			m_createTransaction.reset();
-		}
-		canvasPressCoord.setXY(-1.0, -1.0);
-		mouseGlobalCoord.setXY(-1.0, -1.0);
-		inItemCreation = false;
-	}		
-	setModeCursor();
-}
-
-void CreateMode::deactivate(bool forGesture)
-{
-//	qDebug() << "CreateMode::deactivate" << forGesture;
-	if (!forGesture)
-	{		
-		if (m_createTransaction)
-		{
-//			qDebug() << "CreateMode::deactivate: canceling left over create Transaction";
-			m_createTransaction.cancel();
-			m_createTransaction.reset();
-		}
-	}
-
-	CanvasMode::deactivate(forGesture);
-}
-
-void CreateMode::keyPressEvent(QKeyEvent *e)
-{
-	commonkeyPressEvent_Default(e);
-}
-
-void CreateMode::keyReleaseEvent(QKeyEvent *e)
-{
-	commonkeyReleaseEvent(e);
-}
-
-void CreateMode::mouseDoubleClickEvent(QMouseEvent *m)
-{
-	m->accept();
-	m_MouseButtonPressed = false;
-	m_canvas->resetRenderMode();
-}
-
-void CreateMode::mouseMoveEvent(QMouseEvent *m)
-{
-	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	modifiers = m->modifiers();
-	
-	double newX, newY;
-	PageItem *currItem;
-	QPainter p;
-//	QRect tx;
-	m->accept();
-//	qDebug() << "legacy mode move:" << m->x() << m->y() << m_canvas->globalToCanvas(m->globalPosition()).x() << m_canvas->globalToCanvas(m->globalPosition()).y();
-//	emit MousePos(m->x()/m_canvas->scale(),// + m_doc->minCanvasCoordinate.x(), 
-//				  m->y()/m_canvas->scale()); // + m_doc->minCanvasCoordinate.y());
-
-	if (commonMouseMove(m))
-		return;
-	if (GetItem(&currItem))
-	{
-//		newX = mousePointDoc.x(); //m_view->translateToDoc(m->x(), m->y()).x());
-//		newY = mousePointDoc.y(); //m_view->translateToDoc(m->x(), m->y()).y());
-		return;
-	}
-	if ((!m_MouseButtonPressed) || !(m->buttons() & Qt::LeftButton))
-	{
-		m_canvas->displayCorrectedXYHUD(m->globalPosition(), mousePointDoc.x(), mousePointDoc.y());
-		return;
-	}
-
-	newX = mousePointDoc.x();
-	newY = mousePointDoc.y();
-	if (createObjectMode == modeDrawLine)
-	{
-		if (m_doc->SnapGrid)
-		{
-			newX = qRound(newX / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
-			newY = qRound(newY / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
-		}
-		if (m->modifiers() & Qt::ControlModifier)
-		{
-			QRectF bounds(QPointF(createObjectPos.x(), createObjectPos.y()), QPointF(newX, newY));
-			double newRot = xy2Deg(bounds.width(), bounds.height());
-			if (newRot < 0.0)
-				newRot += 360;
-			newRot = constrainAngle(newRot, m_doc->opToolPrefs().constrain);
-			double len = qMax(0.01, distance(bounds.width(), bounds.height()));
-			bounds.setSize(len * QSizeF(cosd(newRot), sind(newRot)));
-			newX = bounds.right();
-			newY = bounds.bottom();
-		}
-	}
-	//CB: #8099: Readd snapping for drag creation of lines by commenting this else..
-	//else
-	//{
-		FPoint np2 = m_doc->ApplyGridF(FPoint(newX, newY));
-		double nx = np2.x();
-		double ny = np2.y();
-		m_doc->ApplyGuides(&nx, &ny);
-		m_doc->ApplyGuides(&nx, &ny,true);
-		if (nx != np2.x())
-			xSnap = nx;
-		if (ny != np2.y())
-			ySnap = ny;
-		// #8959 : suppress qRound here as this prevent drawing line with angle constrain
-		// precisely and does not allow to stick precisely to grid or guides
-		newX = /*qRound(*/nx/*)*/;
-		newY = /*qRound(*/ny/*)*/;
-	//}
-
-	canvasCurrCoord.setXY(newX, newY);
-	m_view->HaveSelRect = true;
-
-	double wSize = canvasCurrCoord.x() - createObjectPos.x();
-	double hSize = canvasCurrCoord.y() - createObjectPos.y();
-	QRectF createObjectRect(createObjectPos.x(), createObjectPos.y(), wSize, hSize);
-	createObjectRect = createObjectRect.normalized();
-	if (createObjectMode != modeDrawLine)
-	{
-		if (modifiers == Qt::ControlModifier)
-			hSize = wSize;
-		m_canvas->displaySizeHUD(m->globalPosition(), wSize, hSize, false);
-	}
-	else
-	{
-		double angle = -xy2Deg(wSize, hSize);
-		if (angle < 0.0)
-			angle = angle + 360;
-		double trueLength = sqrt(pow(createObjectRect.width(), 2) + pow(createObjectRect.height(), 2));
-		m_canvas->displaySizeHUD(m->globalPosition(), trueLength, angle, true);
-	}
-
-	// Necessary for drawControls to be called
-	m_canvas->repaint();
-}
-
-void CreateMode::mousePressEvent(QMouseEvent *m)
-{
-	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	modifiers = m->modifiers();
-	
-	double Rxp = 0, Ryp = 0;
-	m_MouseButtonPressed = true;
-	m_view->HaveSelRect = false;
-	m_doc->DragP = false;
-	m_doc->leaveDrag = false;
-	inItemCreation = false;
-//	oldClip = 0;
-	m->accept();
-	m_view->registerMousePress(m->globalPosition());
-//	QRect mpo(m->x()-m_doc->guidesPrefs().grabRadius, m->y()-m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius*2, m_doc->guidesPrefs().grabRadius*2);
-//	mpo.moveBy(qRound(m_doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(m_doc->minCanvasCoordinate.y() * m_canvas->scale()));
-	canvasPressCoord = mousePointDoc;
-	createObjectMode = m_doc->appMode;
-	createObjectSubMode = m_doc->SubMode;
-	createObjectPos  = m_doc->ApplyGridF(canvasPressCoord);
-	
-	Rxp  = m_doc->ApplyGridF(canvasPressCoord).x();
-	canvasPressCoord.setX(qRound(Rxp));
-	Ryp  = m_doc->ApplyGridF(canvasPressCoord).y();
-	canvasPressCoord.setXY(qRound(Rxp), qRound(Ryp));
-
-	canvasCurrCoord = canvasPressCoord;
-	m_doc->ApplyGuides(&Rxp, &Ryp);
-	m_doc->ApplyGuides(&Rxp, &Ryp,true);
-	createObjectPos.setXY(Rxp, Ryp);
-
-	if (m->button() == Qt::MiddleButton)
-	{
-		m_view->MidButt = true;
-		if (m->modifiers() & Qt::ControlModifier)
-			m_view->DrawNew();
-		return;
-	}
-	
-	if (m->button() == Qt::RightButton)
-	{
-		m_view->requestMode(modeNormal);
-		return;
-	}
-	if (m->button() != Qt::LeftButton)
-		return;
-	selectPage(m);
-
-	switch (m_doc->appMode)
-	{
-		case modeDrawTable2:
-			m_view->deselectItems(false);
-			break;
-	}
-
-	inItemCreation = true;
-}
-
-void CreateMode::mouseReleaseEvent(QMouseEvent *m)
-{
-	modifiers = m->modifiers();
-
-	PageItem *currItem;
-	m_MouseButtonPressed = false;
-	m_canvas->resetRenderMode();
-	m->accept();
-//	m_view->stopDragTimer();
-
-	m_createTransaction = Um::instance()->beginTransaction("creating");
-	currItem = doCreateNewObject();
-	if (m_createTransaction && currItem)
-	{
-		m_view->resetMousePressed();
-		currItem->checkChanges(true);
-		QString targetName = Um::ScratchSpace;
-		if (currItem->OwnPage > -1)
-			targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
-		m_createTransaction.commit(targetName, currItem->getUPixmap(),
-									Um::Create + " " + currItem->getUName(),  "", Um::ICreate);
-		m_createTransaction.reset();
-		m_doc->changed();
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+*                                                                         *
+***************************************************************************/
+
+
+#include "canvasmode_create.h"
+
+#include <QApplication>
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QCursor>
+#include <QEvent>
+#include <QMessageBox>
+#include <QMouseEvent>
+#include <QPainterPath>
+#include <QPoint>
+#include <QRect>
+#include <QWidgetAction>
+
+#include "appmodes.h"
+#include "canvas.h"
+#include "fpoint.h"
+#include "fpointarray.h"
+#include "pageitem_table.h"
+#include "prefscontext.h"
+#include "prefsfile.h"
+#include "prefsmanager.h"
+#include "scribus.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "selection.h"
+#include "text/frect.h"
+#include "ui/insertTable.h"
+#include "undomanager.h"
+#include "util_math.h"
+
+CreateMode::CreateMode(ScribusView* view) : CanvasMode(view) 
+{
+	canvasPressCoord.setXY(-1.0, -1.0);
+	mouseGlobalCoord.setXY(-1.0, -1.0);
+}
+
+void CreateMode::drawControls(QPainter* p) 
+{
+	if (!inItemCreation) return;
+
+	QPointF topLeft(createObjectPos.x(), createObjectPos.y());
+	QPointF btRight(canvasCurrCoord.x(), canvasCurrCoord.y());
+	QColor  drawColor = QApplication::palette().color(QPalette::Active, QPalette::Highlight);
+
+	if (createObjectMode != modeDrawLine)
+	{
+		QRectF bounds = QRectF(topLeft, btRight).normalized();
+		//Lock Height to Width for Control Modifier for region drawing
+		if (modifiers == Qt::ControlModifier)
+		{
+			bounds.setHeight(bounds.width());
+			if (btRight.y() < topLeft.y())
+				bounds.moveBottom(topLeft.y());
+			if (btRight.x() < topLeft.x() && btRight.y() > topLeft.y())
+				bounds.moveTop(topLeft.y());
+		}
+		QRect localRect = m_canvas->canvasToLocal(bounds);
+		if (localRect.width() <= 0 || localRect.height() <= 0)
+			return;
+		p->setRenderHint(QPainter::Antialiasing);
+
+		p->save();
+		p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+		drawColor.setAlpha(64);
+		p->setBrush(drawColor);
+		p->drawRect(localRect);
+
+		drawColor.setAlpha(255);
+		p->setBrush(Qt::NoBrush);
+		p->setPen(QPen(drawColor, 1, Qt::DashLine, Qt::FlatCap, Qt::MiterJoin));
+
+		int frameType = 0, itemType = 0;
+		getFrameItemTypes(itemType, frameType);
+		if (frameType == PageItem::Ellipse)
+		{
+			p->drawEllipse(localRect);
+		}
+		else if (createObjectMode == modeDrawArc)
+		{
+			QPainterPath path;
+			path.moveTo(localRect.width() / 2.0, localRect.height() / 2.0);
+			path.arcTo(0.0, 0.0, localRect.width(), localRect.height(), m_doc->itemToolPrefs().arcStartAngle, m_doc->itemToolPrefs().arcSweepAngle);
+			path.closeSubpath();
+			p->translate(localRect.left(), localRect.top());
+			p->drawPath(path);
+		}
+		else if (createObjectMode == modeDrawRegularPolygon)
+		{
+			QPainterPath path = regularPolygonPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().polyCorners, m_doc->itemToolPrefs().polyUseFactor, m_doc->itemToolPrefs().polyFactor, m_doc->itemToolPrefs().polyRotation, m_doc->itemToolPrefs().polyCurvature, m_doc->itemToolPrefs().polyInnerRot, m_doc->itemToolPrefs().polyOuterCurvature);
+			p->translate(localRect.left(), localRect.top());
+			p->drawPath(path);
+		}
+		else if (createObjectMode == modeDrawSpiral)
+		{
+			QPainterPath path = spiralPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().spiralStartAngle, m_doc->itemToolPrefs().spiralEndAngle, m_doc->itemToolPrefs().spiralFactor);
+			p->translate(localRect.left(), localRect.top());
+			p->drawPath(path);
+		}
+		else if ((createObjectMode == modeDrawShapes) && (createObjectSubMode > 1))
+		{
+			FPointArray poly;
+			int valCount = m_doc->ValCount;
+			const double *vals = m_doc->ShapeValues;
+			for (int a = 0; a < valCount-3; a += 4)
+			{
+				if (vals[a] < 0)
+				{
+					poly.setMarker();
+					continue;
+				}
+				double x1 = localRect.width()  * vals[a] / 100.0;
+				double y1 = localRect.height() * vals[a + 1] / 100.0;
+				double x2 = localRect.width()  * vals[a + 2] / 100.0;
+				double y2 = localRect.height() * vals[a + 3] / 100.0;
+				poly.addPoint(x1, y1);
+				poly.addPoint(x2, y2);
+			}
+			QPainterPath path = poly.toQPainterPath(false);
+			p->translate(localRect.left(), localRect.top());
+			p->drawPath(path);
+		}
+		p->restore();
+	}
+	else
+	{
+		QPoint p1 = m_canvas->canvasToLocal(topLeft);
+		QPoint p2 = m_canvas->canvasToLocal(btRight);
+		
+		p->save();
+		p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+		p->setBrush(drawColor);
+		p->drawLine(p1, p2);
+		p->restore();
+	}
+}
+
+inline bool CreateMode::GetItem(PageItem** pi)
+{ 
+	*pi = m_doc->m_Selection->itemAt(0); 
+	return (*pi) != nullptr;
+}
+
+// the following code was moved from scribusview.cpp:
+
+
+void CreateMode::enterEvent(QEvent *e)
+{
+	if (!m_MouseButtonPressed)
+	{
+		setModeCursor();
+	}
+}
+
+
+void CreateMode::leaveEvent(QEvent *e)
+{
+}
+
+
+void CreateMode::activate(bool fromGesture)
+{
+//	qDebug() << "CreateMode::activate" << fromGesture;
+	CanvasMode::activate(fromGesture);
+
+	PageItem* currItem;
+	if (!fromGesture || !GetItem(&currItem) || !m_createTransaction)
+	{
+		if (m_createTransaction)
+		{
+//			qDebug() << "canceling left over create Transaction";
+			m_createTransaction.cancel();
+			m_createTransaction.reset();
+		}
+		canvasPressCoord.setXY(-1.0, -1.0);
+		mouseGlobalCoord.setXY(-1.0, -1.0);
+		inItemCreation = false;
+	}		
+	setModeCursor();
+}
+
+void CreateMode::deactivate(bool forGesture)
+{
+//	qDebug() << "CreateMode::deactivate" << forGesture;
+	if (!forGesture)
+	{		
+		if (m_createTransaction)
+		{
+//			qDebug() << "CreateMode::deactivate: canceling left over create Transaction";
+			m_createTransaction.cancel();
+			m_createTransaction.reset();
+		}
+	}
+
+	CanvasMode::deactivate(forGesture);
+}
+
+void CreateMode::keyPressEvent(QKeyEvent *e)
+{
+	commonkeyPressEvent_Default(e);
+}
+
+void CreateMode::keyReleaseEvent(QKeyEvent *e)
+{
+	commonkeyReleaseEvent(e);
+}
+
+void CreateMode::mouseDoubleClickEvent(QMouseEvent *m)
+{
+	m->accept();
+	m_MouseButtonPressed = false;
+	m_canvas->resetRenderMode();
+}
+
+void CreateMode::mouseMoveEvent(QMouseEvent *m)
+{
+	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+	modifiers = m->modifiers();
+	
+	double newX, newY;
+	PageItem *currItem;
+	QPainter p;
+//	QRect tx;
+	m->accept();
+//	qDebug() << "legacy mode move:" << m->x() << m->y() << m_canvas->globalToCanvas(m->globalPosition()).x() << m_canvas->globalToCanvas(m->globalPosition()).y();
+//	emit MousePos(m->x()/m_canvas->scale(),// + m_doc->minCanvasCoordinate.x(), 
+//				  m->y()/m_canvas->scale()); // + m_doc->minCanvasCoordinate.y());
+
+	if (commonMouseMove(m))
+		return;
+	if (GetItem(&currItem))
+	{
+//		newX = mousePointDoc.x(); //m_view->translateToDoc(m->x(), m->y()).x());
+//		newY = mousePointDoc.y(); //m_view->translateToDoc(m->x(), m->y()).y());
+		return;
+	}
+	if ((!m_MouseButtonPressed) || !(m->buttons() & Qt::LeftButton))
+	{
+		m_canvas->displayCorrectedXYHUD(m->globalPosition(), mousePointDoc.x(), mousePointDoc.y());
+		return;
+	}
+
+	newX = mousePointDoc.x();
+	newY = mousePointDoc.y();
+	if (createObjectMode == modeDrawLine)
+	{
+		if (m_doc->guidesPrefs().gridSnapping)
+		{
+			newX = qRound(newX / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
+			newY = qRound(newY / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
+		}
+		if (m->modifiers() & Qt::ControlModifier)
+		{
+			QRectF bounds(QPointF(createObjectPos.x(), createObjectPos.y()), QPointF(newX, newY));
+			double newRot = xy2Deg(bounds.width(), bounds.height());
+			if (newRot < 0.0)
+				newRot += 360;
+			newRot = constrainAngle(newRot, m_doc->opToolPrefs().constrain);
+			double len = qMax(0.01, distance(bounds.width(), bounds.height()));
+			bounds.setSize(len * QSizeF(cosd(newRot), sind(newRot)));
+			newX = bounds.right();
+			newY = bounds.bottom();
+		}
+	}
+	//CB: #8099: Readd snapping for drag creation of lines by commenting this else..
+	//else
+	//{
+		FPoint np2 = m_doc->ApplyGridF(FPoint(newX, newY));
+		double nx = np2.x();
+		double ny = np2.y();
+		m_doc->ApplyGuides(&nx, &ny);
+		m_doc->ApplyGuides(&nx, &ny,true);
+		if (nx != np2.x())
+			xSnap = nx;
+		if (ny != np2.y())
+			ySnap = ny;
+		// #8959 : suppress qRound here as this prevent drawing line with angle constrain
+		// precisely and does not allow to stick precisely to grid or guides
+		newX = /*qRound(*/nx/*)*/;
+		newY = /*qRound(*/ny/*)*/;
+	//}
+
+	canvasCurrCoord.setXY(newX, newY);
+	m_view->HaveSelRect = true;
+
+	double wSize = canvasCurrCoord.x() - createObjectPos.x();
+	double hSize = canvasCurrCoord.y() - createObjectPos.y();
+	QRectF createObjectRect(createObjectPos.x(), createObjectPos.y(), wSize, hSize);
+	createObjectRect = createObjectRect.normalized();
+	if (createObjectMode != modeDrawLine)
+	{
+		if (modifiers == Qt::ControlModifier)
+			hSize = wSize;
+		m_canvas->displaySizeHUD(m->globalPosition(), wSize, hSize, false);
+	}
+	else
+	{
+		double angle = -xy2Deg(wSize, hSize);
+		if (angle < 0.0)
+			angle = angle + 360;
+		double trueLength = sqrt(pow(createObjectRect.width(), 2) + pow(createObjectRect.height(), 2));
+		m_canvas->displaySizeHUD(m->globalPosition(), trueLength, angle, true);
+	}
+
+	// Necessary for drawControls to be called
+	m_canvas->repaint();
+}
+
+void CreateMode::mousePressEvent(QMouseEvent *m)
+{
+	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+	modifiers = m->modifiers();
+	
+	double Rxp = 0, Ryp = 0;
+	m_MouseButtonPressed = true;
+	m_view->HaveSelRect = false;
+	m_doc->DragP = false;
+	m_doc->leaveDrag = false;
+	inItemCreation = false;
+//	oldClip = 0;
+	m->accept();
+	m_view->registerMousePress(m->globalPosition());
+//	QRect mpo(m->x()-m_doc->guidesPrefs().grabRadius, m->y()-m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius*2, m_doc->guidesPrefs().grabRadius*2);
+//	mpo.moveBy(qRound(m_doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(m_doc->minCanvasCoordinate.y() * m_canvas->scale()));
+	canvasPressCoord = mousePointDoc;
+	createObjectMode = m_doc->appMode;
+	createObjectSubMode = m_doc->SubMode;
+	createObjectPos  = m_doc->ApplyGridF(canvasPressCoord);
+	
+	Rxp  = m_doc->ApplyGridF(canvasPressCoord).x();
+	canvasPressCoord.setX(qRound(Rxp));
+	Ryp  = m_doc->ApplyGridF(canvasPressCoord).y();
+	canvasPressCoord.setXY(qRound(Rxp), qRound(Ryp));
+
+	canvasCurrCoord = canvasPressCoord;
+	m_doc->ApplyGuides(&Rxp, &Ryp);
+	m_doc->ApplyGuides(&Rxp, &Ryp,true);
+	createObjectPos.setXY(Rxp, Ryp);
+
+	if (m->button() == Qt::MiddleButton)
+	{
+		m_view->MidButt = true;
+		if (m->modifiers() & Qt::ControlModifier)
+			m_view->DrawNew();
+		return;
+	}
+	
+	if (m->button() == Qt::RightButton)
+	{
+		m_view->requestMode(modeNormal);
+		return;
+	}
+	if (m->button() != Qt::LeftButton)
+		return;
+	selectPage(m);
+
+	switch (m_doc->appMode)
+	{
+		case modeDrawTable2:
+			m_view->deselectItems(false);
+			break;
+	}
+
+	inItemCreation = true;
+}
+
+void CreateMode::mouseReleaseEvent(QMouseEvent *m)
+{
+	modifiers = m->modifiers();
+
+	PageItem *currItem;
+	m_MouseButtonPressed = false;
+	m_canvas->resetRenderMode();
+	m->accept();
+//	m_view->stopDragTimer();
+
+	m_createTransaction = Um::instance()->beginTransaction("creating");
+	currItem = doCreateNewObject();
+	if (m_createTransaction && currItem)
+	{
+		m_view->resetMousePressed();
+		currItem->checkChanges(true);
+		QString targetName = Um::ScratchSpace;
+		if (currItem->OwnPage > -1)
+			targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
+		m_createTransaction.commit(targetName, currItem->getUPixmap(),
+									Um::Create + " " + currItem->getUName(),  "", Um::ICreate);
+		m_createTransaction.reset();
+		m_doc->changed();
 		m_doc->changedPagePreview();
-		/*currItem->update();
-		currItem->emitAllToGUI();*/
-	}
-	else if (m_createTransaction)
-	{
-		m_createTransaction.cancel();
-		m_createTransaction.reset();
-	}
-	if (!PrefsManager::instance().appPrefs.uiPrefs.stickyTools)
-	{
-		m_view->requestMode(modeNormal);
-	}
-	else
-	{
-		m_view->updateCanvas();
-		int appMode = m_doc->appMode;
-		m_view->requestMode(appMode);
-	}
-	inItemCreation = false;
-}
-
-void CreateMode::selectPage(QMouseEvent *m)
-{
-	m_MouseButtonPressed = true;
-	FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	canvasPressCoord     = mousePointDoc;
-//	QRect mpo(m->x()-m_doc->guidesPrefs().grabRadius, m->y()-m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius*2, m_doc->guidesPrefs().grabRadius*2);
-//	mpo.moveBy(qRound(Doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(m_doc->minCanvasCoordinate.y() * m_canvas->scale()));
-	m_doc->nodeEdit.deselect();
-	m_view->deselectItems(false);
-	if (!m_doc->masterPageMode())
-	{
-		int i = m_doc->OnPage(canvasPressCoord.x(), canvasPressCoord.y());
-		if (i!=-1)
-		{
-			uint docCurrPageNo = m_doc->currentPageNumber();
-			uint j = static_cast<uint>(i);
-			if (docCurrPageNo != j)
-			{
-				m_doc->setCurrentPage(m_doc->Pages->at(j));
-				m_view->m_ScMW->slotSetCurrentPage(j);
-				m_view->DrawNew();
-			}
-		}
-/*		uint docPagesCount = m_doc->Pages->count();
-		uint docCurrPageNo = m_doc->currentPageNumber();
-		for (uint i = 0; i < docPagesCount; ++i)
-		{
-			int x = static_cast<int>(m_doc->Pages->at(i)->xOffset() * m_canvas->scale());
-			int y = static_cast<int>(m_doc->Pages->at(i)->yOffset() * m_canvas->scale());
-			int w = static_cast<int>(m_doc->Pages->at(i)->width() * m_canvas->scale());
-			int h = static_cast<int>(m_doc->Pages->at(i)->height() * m_canvas->scale());
-			if (QRect(x, y, w, h).intersects(mpo))
-			{
-				if (docCurrPageNo != i)
-				{
-					m_doc->setCurrentPage(m_doc->Pages->at(i));
-					setMenTxt(i);
-					DrawNew();
-				}
-				break;
-			}
-		} */
-
-		//FIXME m_view->setRulerPos(m_view->contentsX(), m_view->contentsY());
-	}
-}
-
-void CreateMode::SetupDrawNoResize(int nr)
-{
-	PageItem* currItem = m_doc->Items->at(nr);
-	//	currItem->setFont(Doc->toolSettings.textFont);
-	//	currItem->setFontSize(Doc->toolSettings.textSize);
-	m_doc->m_Selection->delaySignalsOn();
-	m_doc->m_Selection->clear();
-	m_doc->m_Selection->addItem(currItem);
-	m_doc->m_Selection->delaySignalsOff();
-//	emit DocChanged();
-	currItem->Sizing =  false /*currItem->asLine() ? false : true*/;
-	//#6456 m_view->resetMoveTimer();
-}
-
-void CreateMode::getFrameItemTypes(int& itemType, int& frameType) const
-{
-	itemType  = (int) PageItem::Polygon;
-	frameType = (int) PageItem::Rectangle;
-	switch (createObjectMode)
-	{
-	case modeDrawShapes:
-		switch (createObjectSubMode)
-		{
-		case 0:
-			itemType  = (int) PageItem::Polygon;
-			frameType = (int) PageItem::Rectangle;
-			break;
-		case 1:
-			itemType  = (int) PageItem::Polygon;
-			frameType = (int) PageItem::Ellipse;
-			break;
-		default:
-			itemType  = (int) PageItem::Polygon;
-			frameType = (int) PageItem::Unspecified;
-			break;
-		}
-		break;
-	case modeDrawLine:
-		itemType  = (int) PageItem::Line;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	case modeDrawLatex:
-		itemType  = (int) PageItem::LatexFrame;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	case modeDrawImage:
-		itemType  = (int) PageItem::ImageFrame;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	case modeDrawText:
-		itemType  = (int) PageItem::TextFrame;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	case modeDrawRegularPolygon:
-		itemType  = (int) PageItem::RegularPolygon;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	case modeDrawArc:
-		itemType  = (int) PageItem::Arc;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	case modeDrawSpiral:
-		itemType  = (int) PageItem::Spiral;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	case modeInsertPDFButton:
-	case modeInsertPDFRadioButton:
-	case modeInsertPDFTextfield:
-	case modeInsertPDFCheckbox:
-	case modeInsertPDFCombobox:
-	case modeInsertPDFListbox:
-	case modeInsertPDFTextAnnotation:
-	case modeInsertPDFLinkAnnotation:
-		itemType  = (int) PageItem::TextFrame;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	case modeDrawTable2:
-		itemType  = (int) PageItem::Table;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	case modeInsertPDF3DAnnotation:
-		itemType  = (int) PageItem::OSGFrame;
-		frameType = (int) PageItem::Unspecified;
-		break;
-	}
-}
-
-PageItem* CreateMode::doCreateNewObject()
-{
-	int z = -1;
-	double rot, len;
-
-	double wSize = canvasCurrCoord.x() - createObjectPos.x();
-	double hSize = canvasCurrCoord.y() - createObjectPos.y();
-	bool   skipOneClick = (modifiers == Qt::ShiftModifier);
-	if ((createObjectMode == modeDrawLine) || (createObjectMode == modeDrawTable2) ||
-		(createObjectMode == modeInsertPDFButton) || (createObjectMode == modeInsertPDFTextfield) ||
-		(createObjectMode == modeInsertPDFTextfield) || (createObjectMode == modeInsertPDFCheckbox) ||
-		(createObjectMode == modeInsertPDFCombobox) || (createObjectMode == modeInsertPDFListbox) ||
-		(createObjectMode == modeInsertPDFTextAnnotation) || (createObjectMode == modeInsertPDFLinkAnnotation) ||
-		(createObjectMode == modeInsertPDF3DAnnotation) || (createObjectMode == modeInsertPDFRadioButton))
-	{
-		skipOneClick = false;
-	}
-	if (!skipOneClick)
-	{
-		if ((!m_view->moveTimerElapsed()) || ((fabs(wSize) < 2.0) && (fabs(hSize) < 2.0)))
-		{
-			if (!doOneClick(createObjectPos, canvasCurrCoord))
-			{
-				return nullptr;
-			}
-		}
-	}
-
-	wSize = canvasCurrCoord.x() - createObjectPos.x();
-	hSize = canvasCurrCoord.y() - createObjectPos.y();
-	//Lock Height to Width for Control Modifier for final item creation
-	if (createObjectMode != modeDrawLine)
-	{
-		if (modifiers == Qt::ControlModifier)
-			hSize = wSize;
-	}
-
-	PageItem *newObject = nullptr, *currItem = nullptr;
-	// FIXME for modeDrawLine
-	QRectF createObjectRect(createObjectPos.x(), createObjectPos.y(), wSize, hSize);
-	if (createObjectMode != modeDrawLine)
-	{
-		createObjectRect = createObjectRect.normalized();
-		if (modifiers == Qt::ControlModifier)
-		{
-			//bottom right and upper left are ok
-			//upper right
-			if (canvasCurrCoord.y() < createObjectPos.y() && createObjectPos.x()<canvasCurrCoord.x())
-				createObjectRect.translate(0.0, -createObjectRect.height());
-			//bottom left
-			if (canvasCurrCoord.x()<createObjectPos.x() && canvasCurrCoord.y()>createObjectPos.y())
-				createObjectRect.translate(0.0, createObjectRect.height());
-		}
-	}
-	double Rxp  = createObjectRect.x();
-	double Ryp  = createObjectRect.y();
-	double Rxpd = createObjectRect.width();
-	double Rypd = createObjectRect.height();
-
-	switch (createObjectMode)
-	{
-	case modeDrawShapes:
-		switch (createObjectSubMode)
-		{
-			case 0:
-				if (modifiers == Qt::ShiftModifier)
-					z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
-				else
-					z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
-				m_doc->Items->at(z)->FrameType = 0;
-				break;
-			case 1:
-				if (modifiers == Qt::ShiftModifier)
-					z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
-				else
-					z = m_doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
-				m_doc->Items->at(z)->FrameType = 1;
-				break;
-			default:
-				if (modifiers == Qt::ShiftModifier)
-					z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
-				else
-					z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
-				m_doc->Items->at(z)->SetFrameShape(m_doc->ValCount, m_doc->ShapeValues);
-				m_doc->adjustItemSize(m_doc->Items->at(z));
-				m_doc->setRedrawBounding(m_doc->Items->at(z));
-				m_doc->Items->at(z)->FrameType = createObjectSubMode + 2;
-				break;
-		}
-		break;
-	case modeDrawLine:
-		Rxp = createObjectPos.x();
-		Ryp = createObjectPos.y();
-		m_doc->ApplyGuides(&Rxp, &Ryp);
-		m_doc->ApplyGuides(&Rxp, &Ryp,true);
-		rot = xy2Deg(Rxpd, Rypd);
-		if (rot < 0.0) 
-			rot += 360;
-		len = qMax(0.01, distance(Rxpd, Rypd));
-		z = m_doc->itemAdd(PageItem::Line, PageItem::Unspecified, Rxp, Ryp, len, 1, m_doc->itemToolPrefs().lineWidth, CommonStrings::None, m_doc->itemToolPrefs().lineColor);
-		m_doc->Items->at(z)->setRotation(rot);
-		m_doc->Items->at(z)->setRedrawBounding();
-		break;
-	case modeDrawLatex:
-		if (modifiers == Qt::ShiftModifier)
-			z = m_doc->itemAddArea(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
-		else
-			z = m_doc->itemAdd(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
-		break;
-	case modeDrawImage:
-		if (modifiers == Qt::ShiftModifier)
-			z = m_doc->itemAddArea(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
-		else
-			z = m_doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
-		break;
-	case modeDrawText:
-		if (modifiers == Qt::ShiftModifier)
-			z = m_doc->itemAddArea(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().textFont);
-		else
-			z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().textFont);
-		break;
-	case modeDrawRegularPolygon:
-		if (modifiers == Qt::ShiftModifier)
-			z = m_doc->itemAddArea(PageItem::RegularPolygon, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().lineColor);
-		else
-			z = m_doc->itemAdd(PageItem::RegularPolygon, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().lineColor);
-		break;
-	case modeDrawArc:
-		if (modifiers == Qt::ShiftModifier)
-			z = m_doc->itemAddArea(PageItem::Arc, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().lineColor);
-		else
-			z = m_doc->itemAdd(PageItem::Arc, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().lineColor);
-		m_doc->setRedrawBounding(m_doc->Items->at(z));
-		break;
-	case modeDrawSpiral:
-		if (modifiers == Qt::ShiftModifier)
-			z = m_doc->itemAddArea(PageItem::Spiral, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().lineColor);
-		else
-			z = m_doc->itemAdd(PageItem::Spiral, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().lineColor);
-		m_doc->adjustItemSize(m_doc->Items->at(z));
-		m_doc->setRedrawBounding(m_doc->Items->at(z));
-		break;
-	case modeInsertPDFButton:
-	case modeInsertPDFRadioButton:
-	case modeInsertPDFTextfield:
-	case modeInsertPDFCheckbox:
-	case modeInsertPDFCombobox:
-	case modeInsertPDFListbox:
-	case modeInsertPDFTextAnnotation:
-	case modeInsertPDFLinkAnnotation:
-		z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().textColor);
-		currItem = m_doc->Items->at(z);
-		currItem->setIsAnnotation(true);
-		currItem->AutoName = false;
-		switch (m_doc->appMode)
-		{
-		case modeInsertPDFButton:
-			currItem->annotation().setType(Annotation::Button);
-			currItem->annotation().setFlag(Annotation::Flag_PushButton);
-			currItem->setItemName( CommonStrings::itemName_PushButton + QString("%1").arg(m_doc->TotalItems));
-			break;
-		case modeInsertPDFRadioButton:
-			currItem->annotation().setType(Annotation::RadioButton);
-			currItem->annotation().setFlag(Annotation::Flag_Radio | Annotation::Flag_NoToggleToOff);
-			currItem->setItemName( CommonStrings::itemName_RadioButton + QString("%1").arg(m_doc->TotalItems));
-			break;
-		case modeInsertPDFTextfield:
-			currItem->annotation().setType(Annotation::Textfield);
-			currItem->setItemName( CommonStrings::itemName_TextField + QString("%1").arg(m_doc->TotalItems));
-			break;
-		case modeInsertPDFCheckbox:
-			currItem->annotation().setType(Annotation::Checkbox);
-			currItem->setItemName( CommonStrings::itemName_CheckBox + QString("%1").arg(m_doc->TotalItems));
-			break;
-		case modeInsertPDFCombobox:
-			currItem->annotation().setType(Annotation::Combobox);
-			currItem->annotation().setFlag(Annotation::Flag_Combo);
-			currItem->setItemName( CommonStrings::itemName_ComboBox + QString("%1").arg(m_doc->TotalItems));
-			break;
-		case modeInsertPDFListbox:
-			currItem->annotation().setType(Annotation::Listbox);
-			currItem->setItemName( CommonStrings::itemName_ListBox + QString("%1").arg(m_doc->TotalItems));
-			break;
-		case modeInsertPDFTextAnnotation:
-			currItem->annotation().setType(Annotation::Text);
-			currItem->setItemName( CommonStrings::itemName_TextAnnotation + QString("%1").arg(m_doc->TotalItems));
-			break;
-		case modeInsertPDFLinkAnnotation:
-			currItem->annotation().setType(Annotation::Link);
-			currItem->annotation().setZiel(m_doc->currentPage()->pageNr());
-			currItem->annotation().setAction("0 0");
-			currItem->setItemName( CommonStrings::itemName_LinkAnnotation + QString("%1").arg(m_doc->TotalItems));
-			currItem->setTextFlowMode(PageItem::TextFlowDisabled);
-			break;
-		}
-		break;
-	case modeDrawTable2:
-		// TODO: Figure out what these conditions actually do.
-		if ((m_doc->m_Selection->isEmpty()) && (m_view->HaveSelRect) && (!m_view->MidButt))
-		{
-			m_view->HaveSelRect = false;
-			// Calculate table rectangle.
-			FRect tableRect = adjustedRect(canvasPressCoord, canvasCurrCoord);
-			if (tableRect.width() < 6 || tableRect.height() < 6)
-			{
-				// Ignore tiny tables.
-				m_view->requestMode(submodePaintingDone);
-				break;
-			}
-			// Show table insert dialog.
-		//	qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-			InsertTable *dia = new InsertTable(m_view, static_cast<int>(tableRect.height()/6), static_cast<int>(tableRect.width()/6));
-			if (!dia->exec())
-			{
-				m_view->requestMode(submodePaintingDone);
-				delete dia;
-				dia = nullptr;
-				break;
-			}
-			int numRows = dia->Rows->value();
-			int numColumns = dia->Cols->value();
-			delete dia;
-			dia = nullptr;
-			// Add the table item.
-			// TODO: This should be done in an undo transaction.
-			m_doc->dontResize = true;
-			z = m_doc->itemAdd(PageItem::Table, PageItem::Unspecified,
-						   tableRect.x(),
-						   tableRect.y(),
-						   tableRect.width(),
-						   tableRect.height(),
-						   0,                    // Unused.
-						   CommonStrings::None,  // Unused.
-						   CommonStrings::None); // Unused.
-			PageItem_Table *table = m_doc->Items->at(z)->asTable();
-			table->insertRows(0, numRows - 1);
-			table->insertColumns(0, numColumns - 1);
-			table->adjustTableToFrame();
-			table->adjustFrameToTable();
-			m_doc->dontResize = false;
-			m_doc->setRedrawBounding(table);
-		}
-		break;
-	case modeInsertPDF3DAnnotation:
-		if (modifiers == Qt::ShiftModifier)
-		{
-			z = m_doc->itemAddArea(PageItem::OSGFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
-		}
-		else
-		{
-			z = m_doc->itemAdd(PageItem::OSGFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
-		}
-		currItem = m_doc->Items->at(z);
-		currItem->setIsAnnotation(true);
-		currItem->AutoName = false;
-		currItem->annotation().setType(Annotation::Annot3D);
-		currItem->setItemName( tr("3DAnnot") + QString("%1").arg(m_doc->TotalItems));
-		break;
-	}
-	if (z >= 0)
-	{
-		SetupDrawNoResize(z);
-		newObject = m_doc->Items->at(z);
-		newObject->ContourLine = newObject->PoLine.copy();
-		m_doc->setRedrawBounding(newObject);
-	}
-	return newObject;
-}
-
-bool CreateMode::doOneClick(FPoint& startPoint, FPoint& endPoint)
-{
-	bool doCreate = false;
-	double xSize, ySize;
-	int  originPoint = 0;
-	
-	if (QApplication::keyboardModifiers() & Qt::ControlModifier)
-		return true;
-
-	PrefsContext* sizes = PrefsManager::instance().prefsFile->getContext("ObjectSize");
-	bool doRemember     = sizes->getBool("Remember", true);
-
-	int lmode = (createObjectMode == modeDrawLine) ? 1 : 0;
-	if (lmode == 0)
-	{
-		xSize = sizes->getDouble("defWidth", 100.0);
-		ySize = sizes->getDouble("defHeight", 100.0);
-		originPoint = sizes->getInt("Origin", 0);
-	}
-	else
-	{
-		xSize = sizes->getDouble("defLength", 100.0);
-		ySize = sizes->getDouble("defAngle", 0.0);
-		originPoint = sizes->getInt("OriginL", 0);
-	}
-
-	if (lmode == 0)
-	{
-		if (doRemember)
-		{
-			sizes->set("defWidth", xSize);
-			sizes->set("defHeight", ySize);
-			sizes->set("Origin", originPoint);
-		}
-		endPoint.setXY(startPoint.x() + xSize, startPoint.y() + ySize);
-		switch (originPoint)
-		{
-			case 0:
-				break;
-			case 1:
-				startPoint.setX(startPoint.x() - xSize);
-				endPoint.setX(endPoint.x() - xSize);
-				break;
-			case 2:
-				startPoint.setXY(startPoint.x() - xSize / 2.0, startPoint.y() - ySize / 2.0);
-				endPoint.setXY(endPoint.x() - xSize / 2.0, endPoint.y() - ySize / 2.0);
-				break;
-			case 3:
-				startPoint.setY(startPoint.y() - ySize);
-				endPoint.setY(endPoint.y() - ySize);
-				break;
-			case 4:
-				startPoint.setXY(startPoint.x() - xSize, startPoint.y() - ySize);
-				endPoint.setXY(endPoint.x() - xSize, endPoint.y() - ySize);
-				break;
-		}
-	}
-	else
-	{
-		FPoint oldStart = startPoint;
-		if (doRemember)
-		{
-			sizes->set("defLength", xSize);
-			sizes->set("defAngle", ySize);
-			sizes->set("OriginL", originPoint);
-		}
-		double angle = -ySize * M_PI / 180.0;
-		switch (originPoint)
-		{
-			case 0:
-				endPoint = FPoint(startPoint.x() + xSize * cos(angle), startPoint.y() + xSize * sin(angle));
-				break;
-			case 1:
-				startPoint = FPoint(oldStart.x() - xSize * cos(angle), oldStart.y() - xSize * sin(angle));
-				endPoint   = oldStart;
-				break;
-			case 2:
-				startPoint = FPoint(oldStart.x() - xSize / 2.0 * cos(angle), oldStart.y() - xSize / 2.0 * sin(angle));
-				endPoint   = FPoint(oldStart.x() + xSize / 2.0 * cos(angle), oldStart.y() + xSize / 2.0 * sin(angle));
-				break;
-		}
-	}
-	sizes->set("Remember", doRemember);
-	doCreate = true;
-
-	//delete dia;
-	return doCreate;
-}
-
-FRect CreateMode::adjustedRect(const FPoint &firstPoint, const FPoint &secondPoint)
-{
-	// Lock to grid.
-	FPoint first = m_doc->ApplyGridF(firstPoint);
-	FPoint second = m_doc->ApplyGridF(secondPoint);
-
-	// Lock to guides and items.
-	double firstX = first.x();
-	double firstY = first.y();
-	m_doc->ApplyGuides(&firstX, &firstY);
-	m_doc->ApplyGuides(&firstX, &firstY,true);
-
-	double secondX = second.x();
-	double secondY = second.y();
-	m_doc->ApplyGuides(&secondX, &secondY);
-	m_doc->ApplyGuides(&secondX, &secondY,true);
-
-	// Return normalized rectangle.
-	FRect rect(firstX, firstY, secondX - firstX, secondY - firstY);
-
-	return rect.normalize();
-}
-
-// void CreateMode::setResizeCursor(int how)
-// {
-// 	switch (how)
-// 	{
-// 		case 1:
-// 		case 2:
-// 			qApp->changeOverrideCursor(QCursor(Qt::SizeFDiagCursor));
-// 			break;
-// 		case 3:
-// 		case 4:
-// 			qApp->changeOverrideCursor(QCursor(Qt::SizeBDiagCursor));
-// 			break;
-// 		case 5:
-// 		case 8:
-// 			qApp->changeOverrideCursor(QCursor(Qt::SizeVerCursor));
-// 			break;
-// 		case 6:
-// 		case 7:
-// 			qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
-// 			break;
-// 		default:
-// 			qApp->changeOverrideCursor(QCursor(Qt::SizeAllCursor));
-// 			break;
-// 	}
-// }
-
+		/*currItem->update();
+		currItem->emitAllToGUI();*/
+	}
+	else if (m_createTransaction)
+	{
+		m_createTransaction.cancel();
+		m_createTransaction.reset();
+	}
+	if (!PrefsManager::instance().appPrefs.uiPrefs.stickyTools)
+	{
+		m_view->requestMode(modeNormal);
+	}
+	else
+	{
+		m_view->updateCanvas();
+		int appMode = m_doc->appMode;
+		m_view->requestMode(appMode);
+	}
+	inItemCreation = false;
+}
+
+void CreateMode::selectPage(QMouseEvent *m)
+{
+	m_MouseButtonPressed = true;
+	FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+	canvasPressCoord     = mousePointDoc;
+//	QRect mpo(m->x()-m_doc->guidesPrefs().grabRadius, m->y()-m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius*2, m_doc->guidesPrefs().grabRadius*2);
+//	mpo.moveBy(qRound(Doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(m_doc->minCanvasCoordinate.y() * m_canvas->scale()));
+	m_doc->nodeEdit.deselect();
+	m_view->deselectItems(false);
+	if (!m_doc->masterPageMode())
+	{
+		int i = m_doc->OnPage(canvasPressCoord.x(), canvasPressCoord.y());
+		if (i!=-1)
+		{
+			uint docCurrPageNo = m_doc->currentPageNumber();
+			uint j = static_cast<uint>(i);
+			if (docCurrPageNo != j)
+			{
+				m_doc->setCurrentPage(m_doc->Pages->at(j));
+				m_view->m_ScMW->slotSetCurrentPage(j);
+				m_view->DrawNew();
+			}
+		}
+/*		uint docPagesCount = m_doc->Pages->count();
+		uint docCurrPageNo = m_doc->currentPageNumber();
+		for (uint i = 0; i < docPagesCount; ++i)
+		{
+			int x = static_cast<int>(m_doc->Pages->at(i)->xOffset() * m_canvas->scale());
+			int y = static_cast<int>(m_doc->Pages->at(i)->yOffset() * m_canvas->scale());
+			int w = static_cast<int>(m_doc->Pages->at(i)->width() * m_canvas->scale());
+			int h = static_cast<int>(m_doc->Pages->at(i)->height() * m_canvas->scale());
+			if (QRect(x, y, w, h).intersects(mpo))
+			{
+				if (docCurrPageNo != i)
+				{
+					m_doc->setCurrentPage(m_doc->Pages->at(i));
+					setMenTxt(i);
+					DrawNew();
+				}
+				break;
+			}
+		} */
+
+		//FIXME m_view->setRulerPos(m_view->contentsX(), m_view->contentsY());
+	}
+}
+
+void CreateMode::SetupDrawNoResize(int nr)
+{
+	PageItem* currItem = m_doc->Items->at(nr);
+	//	currItem->setFont(Doc->toolSettings.textFont);
+	//	currItem->setFontSize(Doc->toolSettings.textSize);
+	m_doc->m_Selection->delaySignalsOn();
+	m_doc->m_Selection->clear();
+	m_doc->m_Selection->addItem(currItem);
+	m_doc->m_Selection->delaySignalsOff();
+//	emit DocChanged();
+	currItem->Sizing =  false /*currItem->asLine() ? false : true*/;
+	//#6456 m_view->resetMoveTimer();
+}
+
+void CreateMode::getFrameItemTypes(int& itemType, int& frameType) const
+{
+	itemType  = (int) PageItem::Polygon;
+	frameType = (int) PageItem::Rectangle;
+	switch (createObjectMode)
+	{
+	case modeDrawShapes:
+		switch (createObjectSubMode)
+		{
+		case 0:
+			itemType  = (int) PageItem::Polygon;
+			frameType = (int) PageItem::Rectangle;
+			break;
+		case 1:
+			itemType  = (int) PageItem::Polygon;
+			frameType = (int) PageItem::Ellipse;
+			break;
+		default:
+			itemType  = (int) PageItem::Polygon;
+			frameType = (int) PageItem::Unspecified;
+			break;
+		}
+		break;
+	case modeDrawLine:
+		itemType  = (int) PageItem::Line;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	case modeDrawLatex:
+		itemType  = (int) PageItem::LatexFrame;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	case modeDrawImage:
+		itemType  = (int) PageItem::ImageFrame;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	case modeDrawText:
+		itemType  = (int) PageItem::TextFrame;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	case modeDrawRegularPolygon:
+		itemType  = (int) PageItem::RegularPolygon;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	case modeDrawArc:
+		itemType  = (int) PageItem::Arc;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	case modeDrawSpiral:
+		itemType  = (int) PageItem::Spiral;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	case modeInsertPDFButton:
+	case modeInsertPDFRadioButton:
+	case modeInsertPDFTextfield:
+	case modeInsertPDFCheckbox:
+	case modeInsertPDFCombobox:
+	case modeInsertPDFListbox:
+	case modeInsertPDFTextAnnotation:
+	case modeInsertPDFLinkAnnotation:
+		itemType  = (int) PageItem::TextFrame;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	case modeDrawTable2:
+		itemType  = (int) PageItem::Table;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	case modeInsertPDF3DAnnotation:
+		itemType  = (int) PageItem::OSGFrame;
+		frameType = (int) PageItem::Unspecified;
+		break;
+	}
+}
+
+PageItem* CreateMode::doCreateNewObject()
+{
+	int z = -1;
+	double rot, len;
+
+	double wSize = canvasCurrCoord.x() - createObjectPos.x();
+	double hSize = canvasCurrCoord.y() - createObjectPos.y();
+	bool   skipOneClick = (modifiers == Qt::ShiftModifier);
+	if ((createObjectMode == modeDrawLine) || (createObjectMode == modeDrawTable2) ||
+		(createObjectMode == modeInsertPDFButton) || (createObjectMode == modeInsertPDFTextfield) ||
+		(createObjectMode == modeInsertPDFTextfield) || (createObjectMode == modeInsertPDFCheckbox) ||
+		(createObjectMode == modeInsertPDFCombobox) || (createObjectMode == modeInsertPDFListbox) ||
+		(createObjectMode == modeInsertPDFTextAnnotation) || (createObjectMode == modeInsertPDFLinkAnnotation) ||
+		(createObjectMode == modeInsertPDF3DAnnotation) || (createObjectMode == modeInsertPDFRadioButton))
+	{
+		skipOneClick = false;
+	}
+	if (!skipOneClick)
+	{
+		if ((!m_view->moveTimerElapsed()) || ((fabs(wSize) < 2.0) && (fabs(hSize) < 2.0)))
+		{
+			if (!doOneClick(createObjectPos, canvasCurrCoord))
+			{
+				return nullptr;
+			}
+		}
+	}
+
+	wSize = canvasCurrCoord.x() - createObjectPos.x();
+	hSize = canvasCurrCoord.y() - createObjectPos.y();
+	//Lock Height to Width for Control Modifier for final item creation
+	if (createObjectMode != modeDrawLine)
+	{
+		if (modifiers == Qt::ControlModifier)
+			hSize = wSize;
+	}
+
+	PageItem *newObject = nullptr, *currItem = nullptr;
+	// FIXME for modeDrawLine
+	QRectF createObjectRect(createObjectPos.x(), createObjectPos.y(), wSize, hSize);
+	if (createObjectMode != modeDrawLine)
+	{
+		createObjectRect = createObjectRect.normalized();
+		if (modifiers == Qt::ControlModifier)
+		{
+			//bottom right and upper left are ok
+			//upper right
+			if (canvasCurrCoord.y() < createObjectPos.y() && createObjectPos.x()<canvasCurrCoord.x())
+				createObjectRect.translate(0.0, -createObjectRect.height());
+			//bottom left
+			if (canvasCurrCoord.x()<createObjectPos.x() && canvasCurrCoord.y()>createObjectPos.y())
+				createObjectRect.translate(0.0, createObjectRect.height());
+		}
+	}
+	double Rxp  = createObjectRect.x();
+	double Ryp  = createObjectRect.y();
+	double Rxpd = createObjectRect.width();
+	double Rypd = createObjectRect.height();
+
+	switch (createObjectMode)
+	{
+	case modeDrawShapes:
+		switch (createObjectSubMode)
+		{
+			case 0:
+				if (modifiers == Qt::ShiftModifier)
+					z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
+				else
+					z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
+				m_doc->Items->at(z)->FrameType = 0;
+				break;
+			case 1:
+				if (modifiers == Qt::ShiftModifier)
+					z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
+				else
+					z = m_doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
+				m_doc->Items->at(z)->FrameType = 1;
+				break;
+			default:
+				if (modifiers == Qt::ShiftModifier)
+					z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
+				else
+					z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().shapeLineColor);
+				m_doc->Items->at(z)->SetFrameShape(m_doc->ValCount, m_doc->ShapeValues);
+				m_doc->adjustItemSize(m_doc->Items->at(z));
+				m_doc->setRedrawBounding(m_doc->Items->at(z));
+				m_doc->Items->at(z)->FrameType = createObjectSubMode + 2;
+				break;
+		}
+		break;
+	case modeDrawLine:
+		Rxp = createObjectPos.x();
+		Ryp = createObjectPos.y();
+		m_doc->ApplyGuides(&Rxp, &Ryp);
+		m_doc->ApplyGuides(&Rxp, &Ryp,true);
+		rot = xy2Deg(Rxpd, Rypd);
+		if (rot < 0.0) 
+			rot += 360;
+		len = qMax(0.01, distance(Rxpd, Rypd));
+		z = m_doc->itemAdd(PageItem::Line, PageItem::Unspecified, Rxp, Ryp, len, 1, m_doc->itemToolPrefs().lineWidth, CommonStrings::None, m_doc->itemToolPrefs().lineColor);
+		m_doc->Items->at(z)->setRotation(rot);
+		m_doc->Items->at(z)->setRedrawBounding();
+		break;
+	case modeDrawLatex:
+		if (modifiers == Qt::ShiftModifier)
+			z = m_doc->itemAddArea(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
+		else
+			z = m_doc->itemAdd(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
+		break;
+	case modeDrawImage:
+		if (modifiers == Qt::ShiftModifier)
+			z = m_doc->itemAddArea(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
+		else
+			z = m_doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
+		break;
+	case modeDrawText:
+		if (modifiers == Qt::ShiftModifier)
+			z = m_doc->itemAddArea(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().textFont);
+		else
+			z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().textFont);
+		break;
+	case modeDrawRegularPolygon:
+		if (modifiers == Qt::ShiftModifier)
+			z = m_doc->itemAddArea(PageItem::RegularPolygon, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().lineColor);
+		else
+			z = m_doc->itemAdd(PageItem::RegularPolygon, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().lineColor);
+		break;
+	case modeDrawArc:
+		if (modifiers == Qt::ShiftModifier)
+			z = m_doc->itemAddArea(PageItem::Arc, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().lineColor);
+		else
+			z = m_doc->itemAdd(PageItem::Arc, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().shapeFillColor, m_doc->itemToolPrefs().lineColor);
+		m_doc->setRedrawBounding(m_doc->Items->at(z));
+		break;
+	case modeDrawSpiral:
+		if (modifiers == Qt::ShiftModifier)
+			z = m_doc->itemAddArea(PageItem::Spiral, PageItem::Unspecified, Rxp, Ryp, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().lineColor);
+		else
+			z = m_doc->itemAdd(PageItem::Spiral, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().lineColor);
+		m_doc->adjustItemSize(m_doc->Items->at(z));
+		m_doc->setRedrawBounding(m_doc->Items->at(z));
+		break;
+	case modeInsertPDFButton:
+	case modeInsertPDFRadioButton:
+	case modeInsertPDFTextfield:
+	case modeInsertPDFCheckbox:
+	case modeInsertPDFCombobox:
+	case modeInsertPDFListbox:
+	case modeInsertPDFTextAnnotation:
+	case modeInsertPDFLinkAnnotation:
+		z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_doc->itemToolPrefs().textColor);
+		currItem = m_doc->Items->at(z);
+		currItem->setIsAnnotation(true);
+		currItem->AutoName = false;
+		switch (m_doc->appMode)
+		{
+		case modeInsertPDFButton:
+			currItem->annotation().setType(Annotation::Button);
+			currItem->annotation().setFlag(Annotation::Flag_PushButton);
+			currItem->setItemName( CommonStrings::itemName_PushButton + QString("%1").arg(m_doc->TotalItems));
+			break;
+		case modeInsertPDFRadioButton:
+			currItem->annotation().setType(Annotation::RadioButton);
+			currItem->annotation().setFlag(Annotation::Flag_Radio | Annotation::Flag_NoToggleToOff);
+			currItem->setItemName( CommonStrings::itemName_RadioButton + QString("%1").arg(m_doc->TotalItems));
+			break;
+		case modeInsertPDFTextfield:
+			currItem->annotation().setType(Annotation::Textfield);
+			currItem->setItemName( CommonStrings::itemName_TextField + QString("%1").arg(m_doc->TotalItems));
+			break;
+		case modeInsertPDFCheckbox:
+			currItem->annotation().setType(Annotation::Checkbox);
+			currItem->setItemName( CommonStrings::itemName_CheckBox + QString("%1").arg(m_doc->TotalItems));
+			break;
+		case modeInsertPDFCombobox:
+			currItem->annotation().setType(Annotation::Combobox);
+			currItem->annotation().setFlag(Annotation::Flag_Combo);
+			currItem->setItemName( CommonStrings::itemName_ComboBox + QString("%1").arg(m_doc->TotalItems));
+			break;
+		case modeInsertPDFListbox:
+			currItem->annotation().setType(Annotation::Listbox);
+			currItem->setItemName( CommonStrings::itemName_ListBox + QString("%1").arg(m_doc->TotalItems));
+			break;
+		case modeInsertPDFTextAnnotation:
+			currItem->annotation().setType(Annotation::Text);
+			currItem->setItemName( CommonStrings::itemName_TextAnnotation + QString("%1").arg(m_doc->TotalItems));
+			break;
+		case modeInsertPDFLinkAnnotation:
+			currItem->annotation().setType(Annotation::Link);
+			currItem->annotation().setZiel(m_doc->currentPage()->pageNr());
+			currItem->annotation().setAction("0 0");
+			currItem->setItemName( CommonStrings::itemName_LinkAnnotation + QString("%1").arg(m_doc->TotalItems));
+			currItem->setTextFlowMode(PageItem::TextFlowDisabled);
+			break;
+		}
+		break;
+	case modeDrawTable2:
+		// TODO: Figure out what these conditions actually do.
+		if ((m_doc->m_Selection->isEmpty()) && (m_view->HaveSelRect) && (!m_view->MidButt))
+		{
+			m_view->HaveSelRect = false;
+			// Calculate table rectangle.
+			FRect tableRect = adjustedRect(canvasPressCoord, canvasCurrCoord);
+			if (tableRect.width() < 6 || tableRect.height() < 6)
+			{
+				// Ignore tiny tables.
+				m_view->requestMode(submodePaintingDone);
+				break;
+			}
+			// Show table insert dialog.
+		//	qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+			InsertTable *dia = new InsertTable(m_view, static_cast<int>(tableRect.height()/6), static_cast<int>(tableRect.width()/6));
+			if (!dia->exec())
+			{
+				m_view->requestMode(submodePaintingDone);
+				delete dia;
+				dia = nullptr;
+				break;
+			}
+			int numRows = dia->Rows->value();
+			int numColumns = dia->Cols->value();
+			delete dia;
+			dia = nullptr;
+			// Add the table item.
+			// TODO: This should be done in an undo transaction.
+			m_doc->dontResize = true;
+			z = m_doc->itemAdd(PageItem::Table, PageItem::Unspecified,
+						   tableRect.x(),
+						   tableRect.y(),
+						   tableRect.width(),
+						   tableRect.height(),
+						   0,                    // Unused.
+						   CommonStrings::None,  // Unused.
+						   CommonStrings::None); // Unused.
+			PageItem_Table *table = m_doc->Items->at(z)->asTable();
+			table->insertRows(0, numRows - 1);
+			table->insertColumns(0, numColumns - 1);
+			table->adjustTableToFrame();
+			table->adjustFrameToTable();
+			m_doc->dontResize = false;
+			m_doc->setRedrawBounding(table);
+		}
+		break;
+	case modeInsertPDF3DAnnotation:
+		if (modifiers == Qt::ShiftModifier)
+		{
+			z = m_doc->itemAddArea(PageItem::OSGFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
+		}
+		else
+		{
+			z = m_doc->itemAdd(PageItem::OSGFrame, PageItem::Unspecified, Rxp, Ryp, Rxpd, Rypd, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
+		}
+		currItem = m_doc->Items->at(z);
+		currItem->setIsAnnotation(true);
+		currItem->AutoName = false;
+		currItem->annotation().setType(Annotation::Annot3D);
+		currItem->setItemName( tr("3DAnnot") + QString("%1").arg(m_doc->TotalItems));
+		break;
+	}
+	if (z >= 0)
+	{
+		SetupDrawNoResize(z);
+		newObject = m_doc->Items->at(z);
+		newObject->ContourLine = newObject->PoLine.copy();
+		m_doc->setRedrawBounding(newObject);
+	}
+	return newObject;
+}
+
+bool CreateMode::doOneClick(FPoint& startPoint, FPoint& endPoint)
+{
+	bool doCreate = false;
+	double xSize, ySize;
+	int  originPoint = 0;
+	
+	if (QApplication::keyboardModifiers() & Qt::ControlModifier)
+		return true;
+
+	PrefsContext* sizes = PrefsManager::instance().prefsFile->getContext("ObjectSize");
+	bool doRemember     = sizes->getBool("Remember", true);
+
+	int lmode = (createObjectMode == modeDrawLine) ? 1 : 0;
+	if (lmode == 0)
+	{
+		xSize = sizes->getDouble("defWidth", 100.0);
+		ySize = sizes->getDouble("defHeight", 100.0);
+		originPoint = sizes->getInt("Origin", 0);
+	}
+	else
+	{
+		xSize = sizes->getDouble("defLength", 100.0);
+		ySize = sizes->getDouble("defAngle", 0.0);
+		originPoint = sizes->getInt("OriginL", 0);
+	}
+
+	if (lmode == 0)
+	{
+		if (doRemember)
+		{
+			sizes->set("defWidth", xSize);
+			sizes->set("defHeight", ySize);
+			sizes->set("Origin", originPoint);
+		}
+		endPoint.setXY(startPoint.x() + xSize, startPoint.y() + ySize);
+		switch (originPoint)
+		{
+			case 0:
+				break;
+			case 1:
+				startPoint.setX(startPoint.x() - xSize);
+				endPoint.setX(endPoint.x() - xSize);
+				break;
+			case 2:
+				startPoint.setXY(startPoint.x() - xSize / 2.0, startPoint.y() - ySize / 2.0);
+				endPoint.setXY(endPoint.x() - xSize / 2.0, endPoint.y() - ySize / 2.0);
+				break;
+			case 3:
+				startPoint.setY(startPoint.y() - ySize);
+				endPoint.setY(endPoint.y() - ySize);
+				break;
+			case 4:
+				startPoint.setXY(startPoint.x() - xSize, startPoint.y() - ySize);
+				endPoint.setXY(endPoint.x() - xSize, endPoint.y() - ySize);
+				break;
+		}
+	}
+	else
+	{
+		FPoint oldStart = startPoint;
+		if (doRemember)
+		{
+			sizes->set("defLength", xSize);
+			sizes->set("defAngle", ySize);
+			sizes->set("OriginL", originPoint);
+		}
+		double angle = -ySize * M_PI / 180.0;
+		switch (originPoint)
+		{
+			case 0:
+				endPoint = FPoint(startPoint.x() + xSize * cos(angle), startPoint.y() + xSize * sin(angle));
+				break;
+			case 1:
+				startPoint = FPoint(oldStart.x() - xSize * cos(angle), oldStart.y() - xSize * sin(angle));
+				endPoint   = oldStart;
+				break;
+			case 2:
+				startPoint = FPoint(oldStart.x() - xSize / 2.0 * cos(angle), oldStart.y() - xSize / 2.0 * sin(angle));
+				endPoint   = FPoint(oldStart.x() + xSize / 2.0 * cos(angle), oldStart.y() + xSize / 2.0 * sin(angle));
+				break;
+		}
+	}
+	sizes->set("Remember", doRemember);
+	doCreate = true;
+
+	//delete dia;
+	return doCreate;
+}
+
+FRect CreateMode::adjustedRect(const FPoint &firstPoint, const FPoint &secondPoint)
+{
+	// Lock to grid.
+	FPoint first = m_doc->ApplyGridF(firstPoint);
+	FPoint second = m_doc->ApplyGridF(secondPoint);
+
+	// Lock to guides and items.
+	double firstX = first.x();
+	double firstY = first.y();
+	m_doc->ApplyGuides(&firstX, &firstY);
+	m_doc->ApplyGuides(&firstX, &firstY,true);
+
+	double secondX = second.x();
+	double secondY = second.y();
+	m_doc->ApplyGuides(&secondX, &secondY);
+	m_doc->ApplyGuides(&secondX, &secondY,true);
+
+	// Return normalized rectangle.
+	FRect rect(firstX, firstY, secondX - firstX, secondY - firstY);
+
+	return rect.normalize();
+}
+
+// void CreateMode::setResizeCursor(int how)
+// {
+// 	switch (how)
+// 	{
+// 		case 1:
+// 		case 2:
+// 			qApp->changeOverrideCursor(QCursor(Qt::SizeFDiagCursor));
+// 			break;
+// 		case 3:
+// 		case 4:
+// 			qApp->changeOverrideCursor(QCursor(Qt::SizeBDiagCursor));
+// 			break;
+// 		case 5:
+// 		case 8:
+// 			qApp->changeOverrideCursor(QCursor(Qt::SizeVerCursor));
+// 			break;
+// 		case 6:
+// 		case 7:
+// 			qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
+// 			break;
+// 		default:
+// 			qApp->changeOverrideCursor(QCursor(Qt::SizeAllCursor));
+// 			break;
+// 	}
+// }
+
diff --git a/scribus/canvasmode_drawbezier.cpp b/scribus/canvasmode_drawbezier.cpp
index 9c9f51568..0d96156e5 100644
--- a/scribus/canvasmode_drawbezier.cpp
+++ b/scribus/canvasmode_drawbezier.cpp
@@ -1,496 +1,496 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-***************************************************************************/
-
-
-#include "canvasmode_drawbezier.h"
-
-#include <QApplication>
-#include <QButtonGroup>
-#include <QCheckBox>
-#include <QCursor>
-#include <QEvent>
-#include <QMessageBox>
-#include <QMouseEvent>
-#include <QPainterPath>
-#include <QPoint>
-#include <QRect>
-#include <QWidgetAction>
-
-
-#include "appmodes.h"
-#include "canvas.h"
-#include "fpoint.h"
-#include "fpointarray.h"
-#include "prefsmanager.h"
-#include "scribus.h"
-#include "scribusdoc.h"
-#include "scribusview.h"
-#include "selection.h"
-#include "ui/pageselector.h"
-#include "ui/scrspinbox.h"
-#include "undomanager.h"
-#include "util_math.h"
-
-BezierMode::BezierMode(ScribusView* view) : CanvasMode(view) 
-{
-}
-
-void BezierMode::drawControls(QPainter* p) 
-{
-	//
-}
-
-inline bool BezierMode::GetItem(PageItem** pi)
-{ 
-	*pi = m_doc->m_Selection->itemAt(0); 
-	return (*pi) != nullptr;
-}
-
-void BezierMode::finalizeItem(PageItem* currItem)
-{
-	if (currItem->PoLine.size() % 4 != 0)
-		currItem->PoLine.resize(currItem->PoLine.size()-2);
-	if (currItem->PoLine.size() < 4)
-	{
-		m_doc->Items->removeOne(currItem);
-		m_doc->m_Selection->removeFirst();
-	}
-	else
-	{
-		m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false);
-//		currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1)));
-		m_doc->adjustItemSize(currItem);
-		currItem->ContourLine = currItem->PoLine.copy();
-	}
-	m_view->resetMousePressed();
-	currItem->checkChanges();
-	currItem->update();
-	currItem->emitAllToGUI();
-}
-
-// the following code was moved from scribusview.cpp:
-
-void BezierMode::enterEvent(QEvent *e)
-{
-	if (!m_mouseButtonPressed)
-	{
-		setModeCursor();
-	}
-}
-
-void BezierMode::leaveEvent(QEvent *e)
-{
-}
-
-void BezierMode::activate(bool fromGesture)
-{
-//	qDebug() << "DrawBezierMode::activate" << flag;
-	CanvasMode::activate(fromGesture);
-
-	m_xp = m_yp = -1;
-	m_inItemCreation = false;
-	m_firstPoly = true;
-	setModeCursor();
-}
-
-void BezierMode::deactivate(bool forGesture)
-{
-//	qDebug() << "BezierMode::deactivate" << flag;
-//	m_view->stopDragTimer();
-
-	CanvasMode::deactivate(forGesture);
-
-	//When only one node(size=2) was created; it's not a valid line(min valid PoLine size is 6), delete it
-	PageItem* currItem = m_doc->m_Selection->itemAt(0);
-	if (currItem)
-	{
-		if (currItem->PoLine.size() % 4 != 0)
-			currItem->PoLine.resize(qMax(0, static_cast<int>(currItem->PoLine.size())-2));
-		if (currItem->PoLine.size() < 4)
-		{
-			m_view->deselectItems(false);
-			Selection tempSelection(m_doc, false);
-			tempSelection.addItem(currItem);
-			m_doc->itemSelection_DeleteItem(&tempSelection, true);
-			currItem = nullptr;
-		}
-	}
-
-	if (m_inItemCreation)
-	{
-		undoManager->setUndoEnabled(true);
-		m_inItemCreation = false;
-	}
-
-	UndoTransaction undoTrans;
-	if (currItem && UndoManager::undoEnabled())
-	{
-		undoTrans = undoManager->beginTransaction("creating");
-		ScItemState<PageItem*> *is = new ScItemState<PageItem*>("Create PageItem");
-		is->set("CREATE_ITEM");
-		is->setItem(currItem);
-		//Undo target rests with the Page for object specific undo
-		UndoObject *target = m_doc->Pages->at(0);
-		if (currItem->OwnPage > -1)
-			target = m_doc->Pages->at(currItem->OwnPage);
-		undoManager->action(target, is);
-	}
-
-	m_view->setRedrawMarkerShown(false);
-	if (!currItem)
-		return;
-
-	m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false);
-	currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1.0)));
-	m_doc->adjustItemSize(currItem);
-	currItem->ContourLine = currItem->PoLine.copy();
-	currItem->ClipEdited = true;
-	currItem->FrameType = 3;
-
-	if (undoTrans)
-	{
-		QString targetName = Um::ScratchSpace;
-		if (currItem->OwnPage > -1)
-			targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
-		undoTrans.commit(targetName, currItem->getUPixmap(), Um::Create + " " + currItem->getUName(),  "", Um::ICreate);
-	}
-}
-
-void BezierMode::keyPressEvent(QKeyEvent *e)
-{
-	commonkeyPressEvent_Default(e);
-}
-
-void BezierMode::keyReleaseEvent(QKeyEvent *e)
-{
-	commonkeyReleaseEvent(e);
-}
-
-void BezierMode::mouseDoubleClickEvent(QMouseEvent *m)
-{
-	m->accept();
-	m_mouseButtonPressed = false;
-	m_canvas->resetRenderMode();
-	mousePressEvent(m);
-	mouseReleaseEvent(m);
-	PageItem *currItem = nullptr;
-	if (m_doc->appMode == modeDrawBezierLine)
-	{
-		m_view->stopGesture();
-		undoManager->setUndoEnabled(true);
-		currItem = m_doc->m_Selection->itemAt(0);
-		if (currItem != nullptr)
-			finalizeItem(currItem);
-		if (!PrefsManager::instance().appPrefs.uiPrefs.stickyTools)
-			m_view->requestMode(modeNormal);
-		else
-			m_view->requestMode(m_doc->appMode);
-		m_doc->changed();
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+*                                                                         *
+***************************************************************************/
+
+
+#include "canvasmode_drawbezier.h"
+
+#include <QApplication>
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QCursor>
+#include <QEvent>
+#include <QMessageBox>
+#include <QMouseEvent>
+#include <QPainterPath>
+#include <QPoint>
+#include <QRect>
+#include <QWidgetAction>
+
+
+#include "appmodes.h"
+#include "canvas.h"
+#include "fpoint.h"
+#include "fpointarray.h"
+#include "prefsmanager.h"
+#include "scribus.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "selection.h"
+#include "ui/pageselector.h"
+#include "ui/scrspinbox.h"
+#include "undomanager.h"
+#include "util_math.h"
+
+BezierMode::BezierMode(ScribusView* view) : CanvasMode(view) 
+{
+}
+
+void BezierMode::drawControls(QPainter* p) 
+{
+	//
+}
+
+inline bool BezierMode::GetItem(PageItem** pi)
+{ 
+	*pi = m_doc->m_Selection->itemAt(0); 
+	return (*pi) != nullptr;
+}
+
+void BezierMode::finalizeItem(PageItem* currItem)
+{
+	if (currItem->PoLine.size() % 4 != 0)
+		currItem->PoLine.resize(currItem->PoLine.size()-2);
+	if (currItem->PoLine.size() < 4)
+	{
+		m_doc->Items->removeOne(currItem);
+		m_doc->m_Selection->removeFirst();
+	}
+	else
+	{
+		m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false);
+//		currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1)));
+		m_doc->adjustItemSize(currItem);
+		currItem->ContourLine = currItem->PoLine.copy();
+	}
+	m_view->resetMousePressed();
+	currItem->checkChanges();
+	currItem->update();
+	currItem->emitAllToGUI();
+}
+
+// the following code was moved from scribusview.cpp:
+
+void BezierMode::enterEvent(QEvent *e)
+{
+	if (!m_mouseButtonPressed)
+	{
+		setModeCursor();
+	}
+}
+
+void BezierMode::leaveEvent(QEvent *e)
+{
+}
+
+void BezierMode::activate(bool fromGesture)
+{
+//	qDebug() << "DrawBezierMode::activate" << flag;
+	CanvasMode::activate(fromGesture);
+
+	m_xp = m_yp = -1;
+	m_inItemCreation = false;
+	m_firstPoly = true;
+	setModeCursor();
+}
+
+void BezierMode::deactivate(bool forGesture)
+{
+//	qDebug() << "BezierMode::deactivate" << flag;
+//	m_view->stopDragTimer();
+
+	CanvasMode::deactivate(forGesture);
+
+	//When only one node(size=2) was created; it's not a valid line(min valid PoLine size is 6), delete it
+	PageItem* currItem = m_doc->m_Selection->itemAt(0);
+	if (currItem)
+	{
+		if (currItem->PoLine.size() % 4 != 0)
+			currItem->PoLine.resize(qMax(0, static_cast<int>(currItem->PoLine.size())-2));
+		if (currItem->PoLine.size() < 4)
+		{
+			m_view->deselectItems(false);
+			Selection tempSelection(m_doc, false);
+			tempSelection.addItem(currItem);
+			m_doc->itemSelection_DeleteItem(&tempSelection, true);
+			currItem = nullptr;
+		}
+	}
+
+	if (m_inItemCreation)
+	{
+		undoManager->setUndoEnabled(true);
+		m_inItemCreation = false;
+	}
+
+	UndoTransaction undoTrans;
+	if (currItem && UndoManager::undoEnabled())
+	{
+		undoTrans = undoManager->beginTransaction("creating");
+		ScItemState<PageItem*> *is = new ScItemState<PageItem*>("Create PageItem");
+		is->set("CREATE_ITEM");
+		is->setItem(currItem);
+		//Undo target rests with the Page for object specific undo
+		UndoObject *target = m_doc->Pages->at(0);
+		if (currItem->OwnPage > -1)
+			target = m_doc->Pages->at(currItem->OwnPage);
+		undoManager->action(target, is);
+	}
+
+	m_view->setRedrawMarkerShown(false);
+	if (!currItem)
+		return;
+
+	m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false);
+	currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1.0)));
+	m_doc->adjustItemSize(currItem);
+	currItem->ContourLine = currItem->PoLine.copy();
+	currItem->ClipEdited = true;
+	currItem->FrameType = 3;
+
+	if (undoTrans)
+	{
+		QString targetName = Um::ScratchSpace;
+		if (currItem->OwnPage > -1)
+			targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
+		undoTrans.commit(targetName, currItem->getUPixmap(), Um::Create + " " + currItem->getUName(),  "", Um::ICreate);
+	}
+}
+
+void BezierMode::keyPressEvent(QKeyEvent *e)
+{
+	commonkeyPressEvent_Default(e);
+}
+
+void BezierMode::keyReleaseEvent(QKeyEvent *e)
+{
+	commonkeyReleaseEvent(e);
+}
+
+void BezierMode::mouseDoubleClickEvent(QMouseEvent *m)
+{
+	m->accept();
+	m_mouseButtonPressed = false;
+	m_canvas->resetRenderMode();
+	mousePressEvent(m);
+	mouseReleaseEvent(m);
+	PageItem *currItem = nullptr;
+	if (m_doc->appMode == modeDrawBezierLine)
+	{
+		m_view->stopGesture();
+		undoManager->setUndoEnabled(true);
+		currItem = m_doc->m_Selection->itemAt(0);
+		if (currItem != nullptr)
+			finalizeItem(currItem);
+		if (!PrefsManager::instance().appPrefs.uiPrefs.stickyTools)
+			m_view->requestMode(modeNormal);
+		else
+			m_view->requestMode(m_doc->appMode);
+		m_doc->changed();
 		m_doc->changedPagePreview();
-		m_firstPoly = true;
-		m_inItemCreation = false;
-		m_canvas->setRenderModeUseBuffer(false);
-	}
-	m_doc->DragP = false;
-	m_doc->leaveDrag = false;
-	m_view->MidButt = false;
-	if (m_view->groupTransactionStarted())
-	{
-		for (int i = 0; i < m_doc->m_Selection->count(); ++i)
-			m_doc->m_Selection->itemAt(i)->checkChanges(true);
-		m_view->endGroupTransaction();
-	}
-	//Make sure the Zoom spinbox and page selector don't have focus if we click on the canvas
-	m_view->m_ScMW->zoomSpinBox->clearFocus();
-	m_view->m_ScMW->pageSelector->clearFocus();
-	if (m_doc->m_Selection->itemAt(0) != nullptr) // is there the old clip stored for the undo action
-	{
-		currItem = m_doc->m_Selection->itemAt(0);
-		m_doc->nodeEdit.finishTransaction(currItem);
-	}
-}
-
-
-void BezierMode::mouseMoveEvent(QMouseEvent *m)
-{
-	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	
-	PageItem *currItem;
-	m->accept();
-	m_canvas->displayCorrectedXYHUD(m->globalPosition(), mousePointDoc.x(), mousePointDoc.y());
-
-	if (commonMouseMove(m))
-		return;
-	
-	if (m_inItemCreation)
-	{
-		if (GetItem(&currItem))
-		{
-			double newX = qRound(mousePointDoc.x());
-			double newY = qRound(mousePointDoc.y());
-			
-			if (m_doc->DragP)
-				return;
-			
-			if (m_doc->appMode == modeDrawBezierLine)
-			{
-				if ((m_doc->SnapGrid) && (m_doc->OnPage(currItem) != -1))
-				{
-					newX = qRound(newX / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
-					newY = qRound(newY / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
-				}
-				m_canvas->newRedrawPolygon() << QPoint(qRound(newX - currItem->xPos()), qRound(newY - currItem->yPos()));
-				m_view->updateCanvas();
-				m_xp = newX;
-				m_yp = newY;
-			}
-		}
-		else
-		{
-			if ((m_mouseButtonPressed) && (m->buttons() & Qt::LeftButton))
-			{
-				QPoint startP = m_canvas->canvasToGlobal(QPointF(m_xp, m_yp));
-				QPoint globalPos = m->globalPosition().toPoint();
-				m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(globalPos)).normalized());
-				m_view->setRedrawMarkerShown(true);
-				m_view->HaveSelRect = true;
-				return;
-			}
-		}
-	}
-}
-
-void BezierMode::mousePressEvent(QMouseEvent *m)
-{
-	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	
-	int z;
-	double Rxp = 0;
-	double Ryp = 0;
-	double Rxpd = 0;
-	double Rypd = 0;
-	PageItem *currItem;
-	FPoint npf, npf2;
-	QTransform pm;
-
-	m_mouseButtonPressed = true;
-	m_view->HaveSelRect = false;
-	m_doc->DragP = false;
-	m_doc->leaveDrag = false;
-
-	m->accept();
-	m_view->registerMousePress(m->globalPosition());
-	m_xp = mousePointDoc.x();
-	m_yp = mousePointDoc.y();
-	Rxp = m_doc->ApplyGridF(FPoint(m_xp, m_yp)).x();
-	Rxpd = m_xp - Rxp;
-	m_xp = qRound(Rxp);
-	Ryp = m_doc->ApplyGridF(FPoint(m_xp, m_yp)).y();
-	Rypd = m_yp - Ryp;
-	m_yp = qRound(Ryp);
-	if (m->button() == Qt::MiddleButton)
-	{
-		m_view->MidButt = true;
-		if (m->modifiers() & Qt::ControlModifier)
-			m_view->DrawNew();
-		return;
-	}
-	if (m->button() == Qt::RightButton)
-	{
-		m_view->stopGesture();
-		return;
-	}
-	if (m_firstPoly)
-	{
-		selectPage(m);
-		undoManager->setUndoEnabled(false);
-		z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->itemToolPrefs().lineWidth, CommonStrings::None, m_doc->itemToolPrefs().lineColor);
-		currItem = m_doc->Items->at(z);
-		m_doc->m_Selection->clear();
-		m_doc->m_Selection->addItem(currItem);
-		m_view->setCursor(QCursor(Qt::CrossCursor));
-		m_canvas->setRenderModeFillBuffer();
-		m_inItemCreation = true;
-	}
-	currItem = m_doc->m_Selection->itemAt(0);
-	pm = currItem->getTransform();
-	npf = m_doc->ApplyGridF(mousePointDoc).transformPoint(pm, true);
-	currItem->PoLine.addPoint(npf);
-	npf2 = getMinClipF(&currItem->PoLine);
-	if (npf2.x() < 0)
-	{
-		currItem->PoLine.translate(-npf2.x(), 0);
-		m_doc->moveItem(npf2.x(), 0, currItem);
-	}
-	if (npf2.y() < 0)
-	{
-		currItem->PoLine.translate(0, -npf2.y());
-		m_doc->moveItem(0, npf2.y(), currItem);
-	}
-	m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false, false);
-	currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2, 1.0)));
-	m_canvas->newRedrawPolygon();
-//	undoManager->setUndoEnabled(false);
-}
-
-
-
-void BezierMode::mouseReleaseEvent(QMouseEvent *m)
-{
-	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-
-	PageItem *currItem;
-	m_mouseButtonPressed = false;
-	m_canvas->resetRenderMode();
-	m->accept();
-	m_canvas->setRenderModeUseBuffer(false);
-	if ((m_doc->appMode == modeDrawBezierLine) && (m->button() == Qt::LeftButton))
-	{
-		m_canvas->setRenderModeUseBuffer(true);
-		currItem = m_doc->m_Selection->itemAt(0);
-		currItem->ClipEdited = true;
-		currItem->FrameType = 3;
-		QTransform pm = currItem->getTransform();
-		FPoint npf = m_doc->ApplyGridF(mousePointDoc).transformPoint(pm, true);
-		currItem->PoLine.addPoint(npf);
-		bool ssiz = currItem->Sizing;
-		currItem->Sizing = true;
-		if ((currItem->PoLine.size() % 4 == 0) && (currItem->PoLine.size() > 3))
-		{
-			FPoint lxy(currItem->PoLine.point(currItem->PoLine.size()-2));
-			FPoint lk(currItem->PoLine.point(currItem->PoLine.size()-1));
-			double dx = lxy.x() - lk.x();
-			double dy = lxy.y() - lk.y();
-			lk.setX(lk.x() + dx*2);
-			lk.setY(lk.y() + dy*2);
-			currItem->PoLine.addPoint(lxy);
-			currItem->PoLine.addPoint(lk);
-		}
-		FPoint np2(getMinClipF(&currItem->PoLine));
-		if (np2.x() < 0)
-		{
-			currItem->PoLine.translate(-np2.x(), 0);
-			m_doc->moveItem(np2.x(), 0, currItem);
-		}
-		if (np2.y() < 0)
-		{
-			currItem->PoLine.translate(0, -np2.y());
-			m_doc->moveItem(0, np2.y(), currItem);
-		}
-		if (m_firstPoly)
-		{
-			m_firstPoly = false;
-			currItem->Sizing = ssiz;
-		}
-		else
-		{
-			m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false, false);
-			m_doc->adjustItemSize(currItem);
-			currItem->Sizing = ssiz;
-			currItem->ContourLine = currItem->PoLine.copy();
-			m_canvas->setRenderModeUseBuffer(false);
-			currItem->update();
-		}
-		m_canvas->setRenderModeFillBuffer();
-		int newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
-		int newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
-		m_canvas->newRedrawPolygon() << QPoint(newX - qRound(currItem->xPos()), newY - qRound(currItem->yPos()));
-		m_view->updateCanvas();
-	}
-	if ((m_doc->appMode == modeDrawBezierLine) && (m->button() == Qt::RightButton))
-	{
-		undoManager->setUndoEnabled(true);
-		currItem = m_doc->m_Selection->itemAt(0);
-		if (currItem != nullptr)
-		{
-			finalizeItem(currItem);
-		}
-		
-		if (!PrefsManager::instance().appPrefs.uiPrefs.stickyTools)
-		{
-//			qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-			m_view->requestMode(modeNormal);
-//			m_view->requestMode(submodePaintingDone);
-		}
-		else
-			m_view->requestMode(m_doc->appMode);
-		m_doc->changed();
+		m_firstPoly = true;
+		m_inItemCreation = false;
+		m_canvas->setRenderModeUseBuffer(false);
+	}
+	m_doc->DragP = false;
+	m_doc->leaveDrag = false;
+	m_view->MidButt = false;
+	if (m_view->groupTransactionStarted())
+	{
+		for (int i = 0; i < m_doc->m_Selection->count(); ++i)
+			m_doc->m_Selection->itemAt(i)->checkChanges(true);
+		m_view->endGroupTransaction();
+	}
+	//Make sure the Zoom spinbox and page selector don't have focus if we click on the canvas
+	m_view->m_ScMW->zoomSpinBox->clearFocus();
+	m_view->m_ScMW->pageSelector->clearFocus();
+	if (m_doc->m_Selection->itemAt(0) != nullptr) // is there the old clip stored for the undo action
+	{
+		currItem = m_doc->m_Selection->itemAt(0);
+		m_doc->nodeEdit.finishTransaction(currItem);
+	}
+}
+
+
+void BezierMode::mouseMoveEvent(QMouseEvent *m)
+{
+	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+	
+	PageItem *currItem;
+	m->accept();
+	m_canvas->displayCorrectedXYHUD(m->globalPosition(), mousePointDoc.x(), mousePointDoc.y());
+
+	if (commonMouseMove(m))
+		return;
+	
+	if (m_inItemCreation)
+	{
+		if (GetItem(&currItem))
+		{
+			double newX = qRound(mousePointDoc.x());
+			double newY = qRound(mousePointDoc.y());
+			
+			if (m_doc->DragP)
+				return;
+			
+			if (m_doc->appMode == modeDrawBezierLine)
+			{
+				if ((m_doc->guidesPrefs().gridSnapping) && (m_doc->OnPage(currItem) != -1))
+				{
+					newX = qRound(newX / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
+					newY = qRound(newY / m_doc->guidesPrefs().minorGridSpacing) * m_doc->guidesPrefs().minorGridSpacing;
+				}
+				m_canvas->newRedrawPolygon() << QPoint(qRound(newX - currItem->xPos()), qRound(newY - currItem->yPos()));
+				m_view->updateCanvas();
+				m_xp = newX;
+				m_yp = newY;
+			}
+		}
+		else
+		{
+			if ((m_mouseButtonPressed) && (m->buttons() & Qt::LeftButton))
+			{
+				QPoint startP = m_canvas->canvasToGlobal(QPointF(m_xp, m_yp));
+				QPoint globalPos = m->globalPosition().toPoint();
+				m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(globalPos)).normalized());
+				m_view->setRedrawMarkerShown(true);
+				m_view->HaveSelRect = true;
+				return;
+			}
+		}
+	}
+}
+
+void BezierMode::mousePressEvent(QMouseEvent *m)
+{
+	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+	
+	int z;
+	double Rxp = 0;
+	double Ryp = 0;
+	double Rxpd = 0;
+	double Rypd = 0;
+	PageItem *currItem;
+	FPoint npf, npf2;
+	QTransform pm;
+
+	m_mouseButtonPressed = true;
+	m_view->HaveSelRect = false;
+	m_doc->DragP = false;
+	m_doc->leaveDrag = false;
+
+	m->accept();
+	m_view->registerMousePress(m->globalPosition());
+	m_xp = mousePointDoc.x();
+	m_yp = mousePointDoc.y();
+	Rxp = m_doc->ApplyGridF(FPoint(m_xp, m_yp)).x();
+	Rxpd = m_xp - Rxp;
+	m_xp = qRound(Rxp);
+	Ryp = m_doc->ApplyGridF(FPoint(m_xp, m_yp)).y();
+	Rypd = m_yp - Ryp;
+	m_yp = qRound(Ryp);
+	if (m->button() == Qt::MiddleButton)
+	{
+		m_view->MidButt = true;
+		if (m->modifiers() & Qt::ControlModifier)
+			m_view->DrawNew();
+		return;
+	}
+	if (m->button() == Qt::RightButton)
+	{
+		m_view->stopGesture();
+		return;
+	}
+	if (m_firstPoly)
+	{
+		selectPage(m);
+		undoManager->setUndoEnabled(false);
+		z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->itemToolPrefs().lineWidth, CommonStrings::None, m_doc->itemToolPrefs().lineColor);
+		currItem = m_doc->Items->at(z);
+		m_doc->m_Selection->clear();
+		m_doc->m_Selection->addItem(currItem);
+		m_view->setCursor(QCursor(Qt::CrossCursor));
+		m_canvas->setRenderModeFillBuffer();
+		m_inItemCreation = true;
+	}
+	currItem = m_doc->m_Selection->itemAt(0);
+	pm = currItem->getTransform();
+	npf = m_doc->ApplyGridF(mousePointDoc).transformPoint(pm, true);
+	currItem->PoLine.addPoint(npf);
+	npf2 = getMinClipF(&currItem->PoLine);
+	if (npf2.x() < 0)
+	{
+		currItem->PoLine.translate(-npf2.x(), 0);
+		m_doc->moveItem(npf2.x(), 0, currItem);
+	}
+	if (npf2.y() < 0)
+	{
+		currItem->PoLine.translate(0, -npf2.y());
+		m_doc->moveItem(0, npf2.y(), currItem);
+	}
+	m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false, false);
+	currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2, 1.0)));
+	m_canvas->newRedrawPolygon();
+//	undoManager->setUndoEnabled(false);
+}
+
+
+
+void BezierMode::mouseReleaseEvent(QMouseEvent *m)
+{
+	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+
+	PageItem *currItem;
+	m_mouseButtonPressed = false;
+	m_canvas->resetRenderMode();
+	m->accept();
+	m_canvas->setRenderModeUseBuffer(false);
+	if ((m_doc->appMode == modeDrawBezierLine) && (m->button() == Qt::LeftButton))
+	{
+		m_canvas->setRenderModeUseBuffer(true);
+		currItem = m_doc->m_Selection->itemAt(0);
+		currItem->ClipEdited = true;
+		currItem->FrameType = 3;
+		QTransform pm = currItem->getTransform();
+		FPoint npf = m_doc->ApplyGridF(mousePointDoc).transformPoint(pm, true);
+		currItem->PoLine.addPoint(npf);
+		bool ssiz = currItem->Sizing;
+		currItem->Sizing = true;
+		if ((currItem->PoLine.size() % 4 == 0) && (currItem->PoLine.size() > 3))
+		{
+			FPoint lxy(currItem->PoLine.point(currItem->PoLine.size()-2));
+			FPoint lk(currItem->PoLine.point(currItem->PoLine.size()-1));
+			double dx = lxy.x() - lk.x();
+			double dy = lxy.y() - lk.y();
+			lk.setX(lk.x() + dx*2);
+			lk.setY(lk.y() + dy*2);
+			currItem->PoLine.addPoint(lxy);
+			currItem->PoLine.addPoint(lk);
+		}
+		FPoint np2(getMinClipF(&currItem->PoLine));
+		if (np2.x() < 0)
+		{
+			currItem->PoLine.translate(-np2.x(), 0);
+			m_doc->moveItem(np2.x(), 0, currItem);
+		}
+		if (np2.y() < 0)
+		{
+			currItem->PoLine.translate(0, -np2.y());
+			m_doc->moveItem(0, np2.y(), currItem);
+		}
+		if (m_firstPoly)
+		{
+			m_firstPoly = false;
+			currItem->Sizing = ssiz;
+		}
+		else
+		{
+			m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false, false);
+			m_doc->adjustItemSize(currItem);
+			currItem->Sizing = ssiz;
+			currItem->ContourLine = currItem->PoLine.copy();
+			m_canvas->setRenderModeUseBuffer(false);
+			currItem->update();
+		}
+		m_canvas->setRenderModeFillBuffer();
+		int newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
+		int newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
+		m_canvas->newRedrawPolygon() << QPoint(newX - qRound(currItem->xPos()), newY - qRound(currItem->yPos()));
+		m_view->updateCanvas();
+	}
+	if ((m_doc->appMode == modeDrawBezierLine) && (m->button() == Qt::RightButton))
+	{
+		undoManager->setUndoEnabled(true);
+		currItem = m_doc->m_Selection->itemAt(0);
+		if (currItem != nullptr)
+		{
+			finalizeItem(currItem);
+		}
+		
+		if (!PrefsManager::instance().appPrefs.uiPrefs.stickyTools)
+		{
+//			qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+			m_view->requestMode(modeNormal);
+//			m_view->requestMode(submodePaintingDone);
+		}
+		else
+			m_view->requestMode(m_doc->appMode);
+		m_doc->changed();
 		m_doc->changedPagePreview();
-//		emit DocChanged();
-		m_firstPoly = true;
-		m_inItemCreation = false;
-		m_canvas->setRenderModeUseBuffer(false);
-//		m_view->updateContents();
-	}
-	m_doc->DragP = false;
-	m_doc->leaveDrag = false;
-//	m_canvas->m_viewMode.operItemResizing = false;
-	m_view->MidButt = false;
-//	m_doc->SubMode = -1;
-	if (m_view->groupTransactionStarted())
-	{
-		for (int i = 0; i < m_doc->m_Selection->count(); ++i)
-			m_doc->m_Selection->itemAt(i)->checkChanges(true);
-		m_view->endGroupTransaction();
-	}
-
-//???	for (int i = 0; i < m_doc->m_Selection->count(); ++i)
-//???		m_doc->m_Selection->itemAt(i)->checkChanges(true);
-
-//	//Commit drag created items to undo manager.
-//	if (m_doc->m_Selection->itemAt(0) != nullptr)
-//	{
-//		m_doc->itemAddCommit(m_doc->m_Selection->itemAt(0)->ItemNr);
-//	}
-	//Make sure the Zoom spinbox and page selector don't have focus if we click on the canvas
-	m_view->m_ScMW->zoomSpinBox->clearFocus();
-	m_view->m_ScMW->pageSelector->clearFocus();
-	if (m_doc->m_Selection->itemAt(0) != nullptr) // is there the old clip stored for the undo action
-	{
-		currItem = m_doc->m_Selection->itemAt(0);
-		m_doc->nodeEdit.finishTransaction(currItem);
-	}
-}
-
-
-
-void BezierMode::selectPage(QMouseEvent *m)
-{
-	m_mouseButtonPressed = true;
-	FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	m_xp = mousePointDoc.x();
-	m_yp = mousePointDoc.y();
-	m_doc->nodeEdit.deselect();
-	m_view->deselectItems(false);
-
-	if (m_doc->masterPageMode())
-		return;
-
-	int i = m_doc->OnPage(m_xp, m_yp);
-	if (i < 0)
-		return;
-
-	uint docCurrPageNo = m_doc->currentPageNumber();
-	uint j = static_cast<uint>(i);
-	if (docCurrPageNo != j)
-	{
-		m_doc->setCurrentPage(m_doc->Pages->at(j));
-		m_view->m_ScMW->slotSetCurrentPage(j);
-		m_view->DrawNew();
-	}
-}
-
-
-
+//		emit DocChanged();
+		m_firstPoly = true;
+		m_inItemCreation = false;
+		m_canvas->setRenderModeUseBuffer(false);
+//		m_view->updateContents();
+	}
+	m_doc->DragP = false;
+	m_doc->leaveDrag = false;
+//	m_canvas->m_viewMode.operItemResizing = false;
+	m_view->MidButt = false;
+//	m_doc->SubMode = -1;
+	if (m_view->groupTransactionStarted())
+	{
+		for (int i = 0; i < m_doc->m_Selection->count(); ++i)
+			m_doc->m_Selection->itemAt(i)->checkChanges(true);
+		m_view->endGroupTransaction();
+	}
+
+//???	for (int i = 0; i < m_doc->m_Selection->count(); ++i)
+//???		m_doc->m_Selection->itemAt(i)->checkChanges(true);
+
+//	//Commit drag created items to undo manager.
+//	if (m_doc->m_Selection->itemAt(0) != nullptr)
+//	{
+//		m_doc->itemAddCommit(m_doc->m_Selection->itemAt(0)->ItemNr);
+//	}
+	//Make sure the Zoom spinbox and page selector don't have focus if we click on the canvas
+	m_view->m_ScMW->zoomSpinBox->clearFocus();
+	m_view->m_ScMW->pageSelector->clearFocus();
+	if (m_doc->m_Selection->itemAt(0) != nullptr) // is there the old clip stored for the undo action
+	{
+		currItem = m_doc->m_Selection->itemAt(0);
+		m_doc->nodeEdit.finishTransaction(currItem);
+	}
+}
+
+
+
+void BezierMode::selectPage(QMouseEvent *m)
+{
+	m_mouseButtonPressed = true;
+	FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+	m_xp = mousePointDoc.x();
+	m_yp = mousePointDoc.y();
+	m_doc->nodeEdit.deselect();
+	m_view->deselectItems(false);
+
+	if (m_doc->masterPageMode())
+		return;
+
+	int i = m_doc->OnPage(m_xp, m_yp);
+	if (i < 0)
+		return;
+
+	uint docCurrPageNo = m_doc->currentPageNumber();
+	uint j = static_cast<uint>(i);
+	if (docCurrPageNo != j)
+	{
+		m_doc->setCurrentPage(m_doc->Pages->at(j));
+		m_view->m_ScMW->slotSetCurrentPage(j);
+		m_view->DrawNew();
+	}
+}
+
+
+
diff --git a/scribus/canvasmode_edit.cpp b/scribus/canvasmode_edit.cpp
index 0bba8be85..a21a8e4a8 100644
--- a/scribus/canvasmode_edit.cpp
+++ b/scribus/canvasmode_edit.cpp
@@ -1,149 +1,149 @@
-/*
- For general Scribus (>=1.3.2) copyright and licensing information please refer
- to the COPYING file provided with the program. Following this notice may exist
- a copyright and/or license notice that predates the release of Scribus 1.3.2
- for which a new license (GPL+exception) is in place.
- */
-/***************************************************************************
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-***************************************************************************/
-
-
-#include "canvasmode_edit.h"
-
-#include <QApplication>
-#include <QButtonGroup>
-#include <QCheckBox>
-#include <QCursor>
-#include <QDebug>
-#include <QEvent>
-#include <QMessageBox>
-#include <QMouseEvent>
-#include <QPainterPath>
-#include <QPoint>
-#include <QPointF>
-#include <QRect>
-#include <QTimer>
-#include <QWidgetAction>
-
-#include "appmodes.h"
-#include "canvas.h"
-#include "fpoint.h"
-#include "hyphenator.h"
-#include "iconmanager.h"
-#include "pageitem_noteframe.h"
-#include "pageitem_textframe.h"
-#include "scmimedata.h"
-#include "scribus.h"
-#include "scribusdoc.h"
-#include "scribusview.h"
-#include "selection.h"
-#include "ui/contextmenu.h"
-#include "ui/hruler.h"
-#include "ui/pageselector.h"
-#include "ui/scrspinbox.h"
-#include "undomanager.h"
-#include "util_math.h"
-
-
-CanvasMode_Edit::CanvasMode_Edit(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW) 
-{
-	m_blinker = new QTimer(view);
-	connect(m_blinker, SIGNAL(timeout()), this, SLOT(blinkTextCursor()));
-	connect(view->horizRuler, SIGNAL(MarkerMoved(double,double)), this, SLOT(rulerPreview(double,double)));
-}
-
-inline bool CanvasMode_Edit::GetItem(PageItem** pi)
-{ 
-	*pi = m_doc->m_Selection->itemAt(0); 
-	return (*pi) != nullptr;
-}
-
-
-void CanvasMode_Edit::blinkTextCursor()
-{
-	PageItem* currItem;
-	if (m_doc->appMode == modeEdit && GetItem(&currItem))
-	{
-		QRectF brect(0, 0, currItem->width(), currItem->height());
-		QTransform m = currItem->getTransform();
-		brect = m.mapRect(brect);
-		m_canvas->update(QRectF(m_canvas->canvasToLocal(brect.topLeft()), QSizeF(brect.width(),brect.height())*m_canvas->scale()).toRect());
-	}
-}
-
-void CanvasMode_Edit::keyPressEvent(QKeyEvent *e)
-{
-	if (m_keyRepeat)
-		return;
-	m_keyRepeat = true;
-	e->accept();
-
-	if (e->key() == Qt::Key_Escape)
-	{
-		// Go back to normal mode.
-		m_view->requestMode(modeNormal);
-		m_keyRepeat = false;
-		return;
-	}
-
-	PageItem* currItem;
-	if (!GetItem(&currItem))
-	{
-		m_keyRepeat = false;
-		return;
-	}
-
-	if (currItem->isImageFrame() && !currItem->locked())
-	{
-		currItem->handleModeEditKey(e, m_keyRepeat);
-	}
-	if (currItem->isTextFrame())
-	{
-		bool oldKeyRepeat = m_keyRepeat;
-
-		m_cursorVisible = true;
-		switch (e->key())
-		{
-			case Qt::Key_PageUp:
-			case Qt::Key_PageDown:
-			case Qt::Key_Up:
-			case Qt::Key_Down:
-			case Qt::Key_Home:
-			case Qt::Key_End:
-				m_longCursorTime = true;
-				break;
-			default:
-				m_longCursorTime = false;
-				break;
-		}
-		blinkTextCursor();
-		if (!currItem->isTextFrame() || (currItem->isAutoNoteFrame() && currItem->asNoteFrame()->notesList().isEmpty()))
-			m_ScMW->slotDocCh(false);
-		currItem->handleModeEditKey(e, m_keyRepeat);
-		if (currItem->isAutoNoteFrame() && currItem->asNoteFrame()->notesList().isEmpty())
-		{
-			PageItem_NoteFrame* noteFrame = currItem->asNoteFrame();
-			if (!noteFrame->isEndNotesFrame() && noteFrame->masterFrame())
-			{
-				PageItem_TextFrame* masterFrame = noteFrame->masterFrame();
-				masterFrame->invalidateLayout(false);
-				masterFrame->updateLayout();
-			}
-			else if (!noteFrame->isEndNotesFrame() && !noteFrame->masterFrame())
-				qDebug() << "Broken note frame without master frame detected";
-		}
-		m_keyRepeat = oldKeyRepeat;
-		m_doc->regionsChanged()->update(QRectF());
-	}
-	m_keyRepeat = false;
-}
-
+/*
+ For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+ */
+/***************************************************************************
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+*                                                                         *
+***************************************************************************/
+
+
+#include "canvasmode_edit.h"
+
+#include <QApplication>
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QCursor>
+#include <QDebug>
+#include <QEvent>
+#include <QMessageBox>
+#include <QMouseEvent>
+#include <QPainterPath>
+#include <QPoint>
+#include <QPointF>
+#include <QRect>
+#include <QTimer>
+#include <QWidgetAction>
+
+#include "appmodes.h"
+#include "canvas.h"
+#include "fpoint.h"
+#include "hyphenator.h"
+#include "iconmanager.h"
+#include "pageitem_noteframe.h"
+#include "pageitem_textframe.h"
+#include "scmimedata.h"
+#include "scribus.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "selection.h"
+#include "ui/contextmenu.h"
+#include "ui/hruler.h"
+#include "ui/pageselector.h"
+#include "ui/scrspinbox.h"
+#include "undomanager.h"
+#include "util_math.h"
+
+
+CanvasMode_Edit::CanvasMode_Edit(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW) 
+{
+	m_blinker = new QTimer(view);
+	connect(m_blinker, SIGNAL(timeout()), this, SLOT(blinkTextCursor()));
+	connect(view->horizRuler, SIGNAL(MarkerMoved(double,double)), this, SLOT(rulerPreview(double,double)));
+}
+
+inline bool CanvasMode_Edit::GetItem(PageItem** pi)
+{ 
+	*pi = m_doc->m_Selection->itemAt(0); 
+	return (*pi) != nullptr;
+}
+
+
+void CanvasMode_Edit::blinkTextCursor()
+{
+	PageItem* currItem;
+	if (m_doc->appMode == modeEdit && GetItem(&currItem))
+	{
+		QRectF brect(0, 0, currItem->width(), currItem->height());
+		QTransform m = currItem->getTransform();
+		brect = m.mapRect(brect);
+		m_canvas->update(QRectF(m_canvas->canvasToLocal(brect.topLeft()), QSizeF(brect.width(),brect.height())*m_canvas->scale()).toRect());
+	}
+}
+
+void CanvasMode_Edit::keyPressEvent(QKeyEvent *e)
+{
+	if (m_keyRepeat)
+		return;
+	m_keyRepeat = true;
+	e->accept();
+
+	if (e->key() == Qt::Key_Escape)
+	{
+		// Go back to normal mode.
+		m_view->requestMode(modeNormal);
+		m_keyRepeat = false;
+		return;
+	}
+
+	PageItem* currItem;
+	if (!GetItem(&currItem))
+	{
+		m_keyRepeat = false;
+		return;
+	}
+
+	if (currItem->isImageFrame() && !currItem->locked())
+	{
+		currItem->handleModeEditKey(e, m_keyRepeat);
+	}
+	if (currItem->isTextFrame())
+	{
+		bool oldKeyRepeat = m_keyRepeat;
+
+		m_cursorVisible = true;
+		switch (e->key())
+		{
+			case Qt::Key_PageUp:
+			case Qt::Key_PageDown:
+			case Qt::Key_Up:
+			case Qt::Key_Down:
+			case Qt::Key_Home:
+			case Qt::Key_End:
+				m_longCursorTime = true;
+				break;
+			default:
+				m_longCursorTime = false;
+				break;
+		}
+		blinkTextCursor();
+		if (!currItem->isTextFrame() || (currItem->isAutoNoteFrame() && currItem->asNoteFrame()->notesList().isEmpty()))
+			m_ScMW->slotDocCh(false);
+		currItem->handleModeEditKey(e, m_keyRepeat);
+		if (currItem->isAutoNoteFrame() && currItem->asNoteFrame()->notesList().isEmpty())
+		{
+			PageItem_NoteFrame* noteFrame = currItem->asNoteFrame();
+			if (!noteFrame->isEndNotesFrame() && noteFrame->masterFrame())
+			{
+				PageItem_TextFrame* masterFrame = noteFrame->masterFrame();
+				masterFrame->invalidateLayout(false);
+				masterFrame->updateLayout();
+			}
+			else if (!noteFrame->isEndNotesFrame() && !noteFrame->masterFrame())
+				qDebug() << "Broken note frame without master frame detected";
+		}
+		m_keyRepeat = oldKeyRepeat;
+		m_doc->regionsChanged()->update(QRectF());
+	}
+	m_keyRepeat = false;
+}
+
 void CanvasMode_Edit::keyReleaseEvent(QKeyEvent *e)
 {
 	PageItem* currItem;
@@ -151,7 +151,7 @@ void CanvasMode_Edit::keyReleaseEvent(QKeyEvent *e)
 	{
 		return;
 	}
-
+
 	if (currItem->isImageFrame() && !currItem->locked())
 	{
 		switch (e->key())
@@ -166,7 +166,7 @@ void CanvasMode_Edit::keyReleaseEvent(QKeyEvent *e)
 				break;
 		}
 	}
-
+
 	if (currItem->isTextFrame())
 	{
 		m_doc->changedPagePreview();
@@ -176,934 +176,934 @@ void CanvasMode_Edit::keyReleaseEvent(QKeyEvent *e)
 
 
 
-void CanvasMode_Edit::rulerPreview(double base, double xp)
-{
-	PageItem* currItem;
-	if (m_doc->appMode == modeEdit && GetItem(&currItem))
-	{
-		QTransform mm = currItem->getTransform();
-		QPointF itPos = mm.map(QPointF(0, currItem->yPos()));
-		QPoint oldP = m_canvas->canvasToLocal(QPointF(mRulerGuide, itPos.y()));
-		mRulerGuide = base + xp;
-		QPoint p = m_canvas->canvasToLocal(QPointF(mRulerGuide, itPos.y() + currItem->height() * mm.m22()));
-		m_canvas->update(QRect(oldP.x() - 2, oldP.y(), p.x() + 2, p.y()));
-	}
-}
-
-
-void CanvasMode_Edit::drawControls(QPainter* p)
-{
-	commonDrawControls(p, false);
-	PageItem* currItem;
-	if (GetItem(&currItem))
-	{
-		QPen pp(Qt::blue, 1.0 / m_canvas->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
-		pp.setCosmetic(true);
-		PageItem_TextFrame* textframe = currItem->asTextFrame();
-		if (textframe)
-		{
-			if (mRulerGuide >= 0)
-			{
-				QTransform mm = currItem->getTransform();
-				QPointF itPos = mm.map(QPointF(0, currItem->yPos()));
-				p->save();
-				p->setTransform(mm, true);
-				p->setPen(QPen(Qt::blue, 1.0 / m_canvas->scale(), Qt::DashLine, Qt::FlatCap, Qt::MiterJoin));
-				p->setClipRect(QRectF(0.0, 0.0, currItem->width(), currItem->height()));
-				p->setBrush(Qt::NoBrush);
-				p->setRenderHint(QPainter::Antialiasing);
-				p->drawLine(mRulerGuide - itPos.x(), 0, mRulerGuide - itPos.x(), currItem->height() * mm.m22());
-				p->restore();
-			}
-			drawTextCursor(p, textframe);
-		}
-		else if (currItem->isImageFrame())
-		{
-			QTransform mm = currItem->getTransform();
-			p->save();
-			p->setTransform(mm, true);
-			p->setClipRect(QRectF(0.0, 0.0, currItem->width(), currItem->height()));
-			p->setPen(pp);
-			p->setBrush(QColor(0,0,255,10));
-			p->setRenderHint(QPainter::Antialiasing);
-			if (currItem->imageFlippedH())
-			{
-				p->translate(currItem->width(), 0);
-				p->scale(-1.0, 1.0);
-			}
-			if (currItem->imageFlippedV())
-			{
-				p->translate(0, currItem->height());
-				p->scale(1.0, -1.0);
-			}
-			p->translate(currItem->imageXOffset()*currItem->imageXScale(), currItem->imageYOffset()*currItem->imageYScale());
-			p->rotate(currItem->imageRotation());
-			p->drawRect(0, 0, currItem->OrigW*currItem->imageXScale(), currItem->OrigH*currItem->imageYScale());
-			p->translate(currItem->OrigW*currItem->imageXScale() / 2, currItem->OrigH*currItem->imageYScale() / 2);
-			p->scale(1.0 / m_canvas->scale(), 1.0 / m_canvas->scale());
-			QPen pps(Qt::blue, 1.0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
-			pps.setCosmetic(true);
-			p->setPen(pps);
-			p->drawLine(-10, 0, 10, 0);
-			p->drawLine(0, -10, 0, 10);
-			p->setBrush(QColor(0,0,255,70));
-			p->drawEllipse(QPointF(0.0, 0.0), 10.0, 10.0);
-			p->restore();
-		}
-	}
-}
-
-
-void CanvasMode_Edit::drawTextCursor ( QPainter *p, PageItem_TextFrame* textframe )
-{
-	if ((!m_longCursorTime && m_blinkTime.elapsed() > QApplication::cursorFlashTime() / 2 ) ||
-		(m_longCursorTime && m_blinkTime.elapsed() > QApplication::cursorFlashTime() )
-		)
-	{
-		m_cursorVisible = !m_cursorVisible;
-		m_blinkTime.restart();
-		m_longCursorTime = false;
-	}
-	if ( m_cursorVisible )
-	{
-		commonDrawTextCursor(p, textframe, QPointF());
-	}
-}
-
-void CanvasMode_Edit::enterEvent(QEvent *e)
-{
-	if (!m_canvas->m_viewMode.m_MouseButtonPressed)
-	{
-		setModeCursor();
-	}
-}
-
-void CanvasMode_Edit::leaveEvent(QEvent *e)
-{
-}
-
-void CanvasMode_Edit::activate(bool fromGesture)
-{
-	CanvasMode::activate(fromGesture);
-
-	m_canvas->m_viewMode.m_MouseButtonPressed = false;
-	m_canvas->resetRenderMode();
-	m_doc->DragP = false;
-	m_doc->leaveDrag = false;
-	m_canvas->m_viewMode.operItemMoving = false;
-	m_canvas->m_viewMode.operItemResizing = false;
-	m_view->MidButt = false;
-	Mxp = Myp = -1;
-	Dxp = Dyp = -1;
-	SeRx = SeRy = -1;
-	oldCp = Cp = -1;
-	frameResizeHandle = -1;
-	setModeCursor();
-	if (fromGesture)
-	{
-		m_view->update();
-	}
-	mRulerGuide = -1;
-	PageItem * it(nullptr);
-	if (GetItem(&it))
-	{
-		if (it->isTextFrame())
-		{
-			m_canvas->setupEditHRuler(it, true);
-			if (m_doc->appMode == modeEdit)
-			{
-				m_blinker->start(200);
-				m_blinkTime.start();
-				m_cursorVisible = true;
-				blinkTextCursor();
-			}
-		}
-	}
-}
-
-void CanvasMode_Edit::deactivate(bool forGesture)
-{
-	m_view->setRedrawMarkerShown(false);
-	if (!forGesture)
-	{
-		mRulerGuide = -1;
-		m_blinker->stop();
-	}
-	CanvasMode::deactivate(forGesture);
-}
-
-void CanvasMode_Edit::mouseDoubleClickEvent(QMouseEvent *m)
-{
-	m->accept();
-	m_canvas->m_viewMode.m_MouseButtonPressed = false;
-	m_canvas->resetRenderMode();
-	PageItem *currItem = nullptr;
-	if (GetItem(&currItem) && (m_doc->appMode == modeEdit) && currItem->isTextFrame())
-	{
-		//CB if annotation, open the annotation dialog
-		if (currItem->isAnnotation())
-		{
-		//	QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor));
-			m_view->requestMode(submodeAnnotProps);
-		}
-		//otherwise, select between the whitespace
-		else
-		{
-			if (m->modifiers() & Qt::ControlModifier)
-			{
-				int start=0, stop=0;
-
-				if (m->modifiers() & Qt::ShiftModifier)
-				{//Double click with Ctrl+Shift in a frame to select few paragraphs
-					uint oldPar = currItem->itemText.nrOfParagraph(oldCp);
-					uint newPar = currItem->itemText.nrOfParagraph();
-					if (oldPar < newPar)
-					{
-						start = currItem->itemText.startOfParagraph(oldPar);
-						stop = currItem->itemText.endOfParagraph(newPar);
-					}
-					else
-					{
-						start = currItem->itemText.startOfParagraph(newPar);
-						stop = currItem->itemText.endOfParagraph(oldPar);
-					}
-				}
-				else
-				{//Double click with Ctrl in a frame to select a paragraph
-					oldCp = currItem->itemText.cursorPosition();
-					uint nrPar = currItem->itemText.nrOfParagraph(oldCp);
-					start = currItem->itemText.startOfParagraph(nrPar);
-					stop = currItem->itemText.endOfParagraph(nrPar);
-				}
-				currItem->itemText.deselectAll();
-				currItem->itemText.extendSelection(start, stop);
-				currItem->itemText.setCursorPosition(stop);
-			}
-			else if ((currItem->itemText.cursorPosition() < currItem->itemText.length()) && (currItem->itemText.hasMark(currItem->itemText.cursorPosition())))
-			{	//invoke edit marker dialog
-				m_ScMW->slotEditMark();
-				return;
-			}
-			else
-			{	//Double click in a frame to select a word
-				oldCp = currItem->itemText.cursorPosition();
-				bool validPos = (oldCp >= 0 && oldCp < currItem->itemText.length());
-				if (validPos && currItem->itemText.hasObject(oldCp))
-				{
-					currItem->itemText.select(oldCp, 1, true);
-					InlineFrame iItem = currItem->itemText.object(oldCp);
-					m_ScMW->editInlineStart(iItem.getInlineCharID());
-				}
-				else
-				{
-					currItem->itemText.selectWord(oldCp);
-				}
-			}
-			currItem->HasSel = currItem->itemText.hasSelection();
-		}
-	}
-	else
-	{
-		mousePressEvent(m);
-		return;
-	}
-}
-
-
-void CanvasMode_Edit::mouseMoveEvent(QMouseEvent *m)
-{
-	const QPoint globalPos = m->globalPosition().toPoint();
-	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	
-	double newX, newY;
-	PageItem *currItem;
-	m->accept();
-	if (commonMouseMove(m))
-		return;
-	if (GetItem(&currItem))
-	{
-		newX = qRound(mousePointDoc.x());
-		newY = qRound(mousePointDoc.y());
-		if (m_doc->DragP)
-			return;
-		if (m_canvas->m_viewMode.m_MouseButtonPressed && (m_doc->appMode == modeEdit))
-		{
-			if (currItem->isImageFrame())
-			{
-				if (m->modifiers() & Qt::ShiftModifier)
-				{
-					m_view->setCursor(IconManager::instance().loadCursor("Rotieren2.png"));
-					QTransform p = currItem->getTransform();
-					p.translate(currItem->imageXOffset()*currItem->imageXScale(), currItem->imageYOffset()*currItem->imageYScale());
-					QPointF rotP = p.map(QPointF(0.0, 0.0));
-					double itemRotation = xy2Deg(mousePointDoc.x() - rotP.x(), mousePointDoc.y() - rotP.y());
-					currItem->setImageRotation(itemRotation);
-					m_canvas->displayRotHUD(m->globalPosition(), itemRotation);
-				}
-				else
-				{
-					m_view->setCursor(IconManager::instance().loadCursor("handc.png"));
-					QTransform mm1 = currItem->getTransform();
-					QTransform mm2 = mm1.inverted();
-					QPointF rota = mm2.map(QPointF(newX, newY)) - mm2.map(QPointF(Mxp, Myp));
-					currItem->moveImageInFrame(rota.x() / currItem->imageXScale(), rota.y() / currItem->imageYScale());
-					m_canvas->displayXYHUD(m->globalPosition(), currItem->imageXOffset() * currItem->imageXScale(), currItem->imageYOffset() * currItem->imageYScale());
-				}
-				currItem->update();
-				Mxp = newX;
-				Myp = newY;
-			}
-			if (currItem->isTextFrame())
-			{
-				int refStartSel(currItem->asTextFrame()->itemText.startOfSelection());
-				int refEndSel(currItem->asTextFrame()->itemText.endOfSelection());
-				currItem->itemText.deselectAll();
-				currItem->HasSel = false;
-				m_view->slotSetCurs(globalPos.x(), globalPos.y());
-				//Make sure we don't go here if the old cursor position was not set
-				if (oldCp!=-1 && currItem->itemText.length() > 0)
-				{
-					if (currItem->itemText.cursorPosition() < oldCp)
-					{
-						currItem->itemText.select(currItem->itemText.cursorPosition(), oldCp - currItem->itemText.cursorPosition());
-						currItem->HasSel = true;
-					}
-					if (currItem->itemText.cursorPosition() > oldCp)
-					{
-						currItem->itemText.select(oldCp, currItem->itemText.cursorPosition() - oldCp);
-						currItem->HasSel = true;
-					}
-				}
-				m_ScMW->setCopyCutEnabled(currItem->HasSel);
-				if (currItem->HasSel)
-				{
-					m_canvas->m_viewMode.operTextSelecting = true;
-					if ((refStartSel != currItem->asTextFrame()->itemText.startOfSelection()) ||
-						(refEndSel   != currItem->asTextFrame()->itemText.endOfSelection()))
-					{
-						QRectF br(currItem->getBoundingRect());
-						m_canvas->update(QRectF(m_canvas->canvasToLocal(br.topLeft()), br.size() * m_canvas->scale()).toRect());
-					}
-					// We have to call this unconditionally because slotSetCurs() doesn't know selection
-					// when it is called
-					m_doc->scMW()->setTBvals(currItem);
-				}
-			}
-		}
-		if (!m_canvas->m_viewMode.m_MouseButtonPressed)
-		{
-			if (m_doc->m_Selection->isMultipleSelection())
-			{
-				setModeCursor();
-				return;
-			}
-			for (int a = 0; a < m_doc->m_Selection->count(); ++a)
-			{
-				currItem = m_doc->m_Selection->itemAt(a);
-				if (currItem->locked())
-					break;
-				int hitTest = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
-				if (hitTest >= 0)
-				{
-					if (hitTest == Canvas::INSIDE)
-					{
-						if (currItem->isTextFrame())
-							m_view->setCursor(QCursor(Qt::IBeamCursor));
-						if (currItem->isImageFrame())
-						{
-							if (m->modifiers() & Qt::ShiftModifier)
-								m_view->setCursor(IconManager::instance().loadCursor("Rotieren2.png"));
-							else
-								m_view->setCursor(IconManager::instance().loadCursor("handc.png"));
-						}
-					}
-				}
-				else
-				{
-					m_view->setCursor(QCursor(Qt::ArrowCursor));
-				}
-			}
-		}
-	}
-	else
-	{
-		if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton))
-		{
-			newX = qRound(mousePointDoc.x());
-			newY = qRound(mousePointDoc.y());
-			SeRx = newX;
-			SeRy = newY;
-			QPoint startP = m_canvas->canvasToGlobal(QPointF(Mxp, Myp));
-			m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(globalPos)).normalized());
-			m_view->setRedrawMarkerShown(true);
-			m_view->HaveSelRect = true;
-			return;
-		}
-	}
-}
-
-void CanvasMode_Edit::mousePressEvent(QMouseEvent *m)
-{
-	if (UndoManager::undoEnabled())
-	{
-		SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
-		if (ss)
-			ss->set("ETEA", QString(""));
-		else
-		{
-			TransactionState *ts = dynamic_cast<TransactionState*>(undoManager->getLastUndo());
-			if (ts)
-				ss = dynamic_cast<SimpleState*>(ts->last());
-			if (ss)
-				ss->set("ETEA", QString(""));
-		}
-	}
-
-	const QPoint globalPos = m->globalPosition().toPoint();
-	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	
-	m_canvas->PaintSizeRect(QRect());
-	m_canvas->m_viewMode.m_MouseButtonPressed = true;
-	m_canvas->m_viewMode.operItemMoving = false;
-	m_view->HaveSelRect = false;
-	m_doc->DragP = false;
-	m_doc->leaveDrag = false;
-	m->accept();
-	m_view->registerMousePress(m->globalPosition());
-	Mxp = mousePointDoc.x();
-	Myp = mousePointDoc.y();
-	SeRx = Mxp;
-	SeRy = Myp;
-	if (m->button() == Qt::MiddleButton)
-	{
-		m_view->MidButt = true;
-		if (m->modifiers() & Qt::ControlModifier)
-			m_view->DrawNew();
-		return;
-	}
-
-	frameResizeHandle = 0;
-	int oldP = 0;
-
-	PageItem* currItem{ nullptr };
-	if (GetItem(&currItem))
-	{
-//		m_view->slotDoCurs(false);
-		if ((!currItem->locked() || currItem->isTextFrame()) && !currItem->isLine())
-		{
-			FPoint canvasPoint = m_canvas->globalToCanvas(m->globalPosition());
-			if (m_canvas->frameHitTest(QPointF(canvasPoint.x(), canvasPoint.y()), currItem) < 0)
-			{
-				m_doc->m_Selection->delaySignalsOn();
-				m_view->deselectItems(true);
-				bool wantNormal = true;
-				if (SeleItem(m))
-				{
-					currItem = m_doc->m_Selection->itemAt(0);
-					if ((currItem->isTextFrame()) || (currItem->isImageFrame()))
-					{
-						m_view->requestMode(modeEdit);
-						wantNormal = false;
-					}
-					else
-					{
-						m_view->requestMode(submodePaintingDone);
-						m_view->setCursor(QCursor(Qt::ArrowCursor));
-					}
-					if (currItem->isTextFrame())
-					{
-						m_view->slotSetCurs(globalPos.x(), globalPos.y());
-						oldCp = currItem->itemText.cursorPosition();
-					}
-				}
-				else
-				{
-					m_view->requestMode(submodePaintingDone);
-					m_view->setCursor(QCursor(Qt::ArrowCursor));
-				}
-				m_doc->m_Selection->delaySignalsOff();
-				if (wantNormal)
-				{
-					m_view->requestMode(modeNormal);
-					m_view->canvasMode()->mousePressEvent(m);
-				}
-				return;
-			}
-		}
-		oldP = currItem->itemText.cursorPosition();
-		//CB Where we set the cursor for a click in text frame
-		if (currItem->isTextFrame())
-		{
-			bool inText = m_view->slotSetCurs(globalPos.x(), globalPos.y());
-			//CB If we clicked outside a text frame to go out of edit mode and deselect the frame
-			if (!inText)
-			{
-				currItem->invalidateLayout();
-				m_view->deselectItems(true);
-				//m_view->slotDoCurs(true);
-				m_view->requestMode(modeNormal);
-				m_view->canvasMode()->mousePressEvent(m);
-				return;
-			}
-
-			if (m->button() != Qt::RightButton)
-			{
-				//currItem->asTextFrame()->deselectAll();
-				//<<CB Add in shift select to text frames
-				if (m->modifiers() & Qt::ShiftModifier)
-				{
-					if (currItem->itemText.hasSelection())
-					{
-						if (currItem->itemText.cursorPosition() < (currItem->itemText.startOfSelection() + currItem->itemText.endOfSelection()) / 2)
-						{
-							if (m->modifiers() & Qt::ControlModifier)
-								currItem->itemText.setCursorPosition(currItem->itemText.startOfParagraph());
-							oldP = currItem->itemText.startOfSelection();
-						}
-						else
-						{
-							if (m->modifiers() & Qt::ControlModifier)
-								currItem->itemText.setCursorPosition(currItem->itemText.endOfParagraph());
-							oldP = currItem->itemText.endOfSelection();
-						}
-						currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->itemText.cursorPosition());
-						oldCp = currItem->itemText.cursorPosition();
-					}
-					else
-					{
-						int dir=1;
-						if (oldCp > currItem->itemText.cursorPosition())
-							dir=-1;
-						if (m->modifiers() & Qt::ControlModifier) //no selection but Ctrl+Shift+click still select paragraphs
-						{
-							if (dir == 1)
-								currItem->itemText.setCursorPosition(currItem->itemText.endOfParagraph());
-							else
-								currItem->itemText.setCursorPosition(currItem->itemText.startOfParagraph());
-						}
-						currItem->asTextFrame()->ExpandSel(oldP);
-						oldCp = oldP;
-					}
-				}
-				else //>>CB
-				{
-					oldCp = currItem->itemText.cursorPosition();
-					currItem->itemText.deselectAll();
-					currItem->HasSel = false;
-				}
-				currItem->emitAllToGUI();
-				if (m->button() == Qt::MiddleButton)
-				{
-					m_canvas->m_viewMode.m_MouseButtonPressed = false;
-					m_view->MidButt = false;
-					QString cc;
-					cc = QApplication::clipboard()->text(QClipboard::Selection);
-					if (cc.isNull())
-						cc = QApplication::clipboard()->text(QClipboard::Clipboard);
-					if (!cc.isNull())
-					{
-						// K.I.S.S.:
-						currItem->itemText.insertChars(0, cc, true);
-						if (m_doc->docHyphenator->autoCheck())
-							m_doc->docHyphenator->slotHyphenate(currItem);
-						m_ScMW->BookMarkTxT(currItem);
-						//							m_ScMW->outlinePalette->BuildTree();
-					}
-					else
-					{
-						if (ScMimeData::clipboardHasScribusText())
-							m_ScMW->slotEditPaste();
-					}
-					currItem->update();
-				}
-			}
-		}
-		else if (!currItem->isImageFrame() || m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem) < 0)
-		{
-			m_view->deselectItems(true);
-			if (SeleItem(m))
-			{
-				currItem = m_doc->m_Selection->itemAt(0);
-				if ((currItem->isTextFrame()) || (currItem->isImageFrame()))
-				{
-					m_view->requestMode(modeEdit);
-				}
-				else
-				{
-					m_view->requestMode(submodePaintingDone);
-					m_view->setCursor(QCursor(Qt::ArrowCursor));
-				}
-			}
-			else
-			{
-				m_view->requestMode(submodePaintingDone);
-				m_view->setCursor(QCursor(Qt::ArrowCursor));
-			}
-		}
-	}
-}
-
-
-
-void CanvasMode_Edit::mouseReleaseEvent(QMouseEvent *m)
-{
-#ifdef GESTURE_FRAME_PREVIEW
-	clearPixmapCache();
-#endif // GESTURE_FRAME_PREVIEW
-	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	PageItem *currItem = nullptr;
-	m_canvas->m_viewMode.m_MouseButtonPressed = false;
-	m_canvas->resetRenderMode();
-	m->accept();
-//	m_view->stopDragTimer();
-	if ((GetItem(&currItem)) && (m->button() == Qt::RightButton) && (!m_doc->DragP))
-	{
-		createContextMenu(currItem, mousePointDoc.x(), mousePointDoc.y());
-		return;
-	}
-	if (m_view->moveTimerElapsed() && (GetItem(&currItem)))
-	{
-//		m_view->stopDragTimer();
-		m_canvas->setRenderModeUseBuffer(false);
-		if (!m_doc->m_Selection->isMultipleSelection())
-		{
-			m_doc->setRedrawBounding(currItem);
-			currItem->OwnPage = m_doc->OnPage(currItem);
-			m_canvas->m_viewMode.operItemResizing = false;
-			if (currItem->isLine())
-				m_view->updateContents();
+void CanvasMode_Edit::rulerPreview(double base, double xp)
+{
+	PageItem* currItem;
+	if (m_doc->appMode == modeEdit && GetItem(&currItem))
+	{
+		QTransform mm = currItem->getTransform();
+		QPointF itPos = mm.map(QPointF(0, currItem->yPos()));
+		QPoint oldP = m_canvas->canvasToLocal(QPointF(mRulerGuide, itPos.y()));
+		mRulerGuide = base + xp;
+		QPoint p = m_canvas->canvasToLocal(QPointF(mRulerGuide, itPos.y() + currItem->height() * mm.m22()));
+		m_canvas->update(QRect(oldP.x() - 2, oldP.y(), p.x() + 2, p.y()));
+	}
+}
+
+
+void CanvasMode_Edit::drawControls(QPainter* p)
+{
+	commonDrawControls(p, false);
+	PageItem* currItem;
+	if (GetItem(&currItem))
+	{
+		QPen pp(Qt::blue, 1.0 / m_canvas->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+		pp.setCosmetic(true);
+		PageItem_TextFrame* textframe = currItem->asTextFrame();
+		if (textframe)
+		{
+			if (mRulerGuide >= 0)
+			{
+				QTransform mm = currItem->getTransform();
+				QPointF itPos = mm.map(QPointF(0, currItem->yPos()));
+				p->save();
+				p->setTransform(mm, true);
+				p->setPen(QPen(Qt::blue, 1.0 / m_canvas->scale(), Qt::DashLine, Qt::FlatCap, Qt::MiterJoin));
+				p->setClipRect(QRectF(0.0, 0.0, currItem->width(), currItem->height()));
+				p->setBrush(Qt::NoBrush);
+				p->setRenderHint(QPainter::Antialiasing);
+				p->drawLine(mRulerGuide - itPos.x(), 0, mRulerGuide - itPos.x(), currItem->height() * mm.m22());
+				p->restore();
+			}
+			drawTextCursor(p, textframe);
+		}
+		else if (currItem->isImageFrame())
+		{
+			QTransform mm = currItem->getTransform();
+			p->save();
+			p->setTransform(mm, true);
+			p->setClipRect(QRectF(0.0, 0.0, currItem->width(), currItem->height()));
+			p->setPen(pp);
+			p->setBrush(QColor(0,0,255,10));
+			p->setRenderHint(QPainter::Antialiasing);
+			if (currItem->imageFlippedH())
+			{
+				p->translate(currItem->width(), 0);
+				p->scale(-1.0, 1.0);
+			}
+			if (currItem->imageFlippedV())
+			{
+				p->translate(0, currItem->height());
+				p->scale(1.0, -1.0);
+			}
+			p->translate(currItem->imageXOffset()*currItem->imageXScale(), currItem->imageYOffset()*currItem->imageYScale());
+			p->rotate(currItem->imageRotation());
+			p->drawRect(0, 0, currItem->OrigW*currItem->imageXScale(), currItem->OrigH*currItem->imageYScale());
+			p->translate(currItem->OrigW*currItem->imageXScale() / 2, currItem->OrigH*currItem->imageYScale() / 2);
+			p->scale(1.0 / m_canvas->scale(), 1.0 / m_canvas->scale());
+			QPen pps(Qt::blue, 1.0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+			pps.setCosmetic(true);
+			p->setPen(pps);
+			p->drawLine(-10, 0, 10, 0);
+			p->drawLine(0, -10, 0, 10);
+			p->setBrush(QColor(0,0,255,70));
+			p->drawEllipse(QPointF(0.0, 0.0), 10.0, 10.0);
+			p->restore();
+		}
+	}
+}
+
+
+void CanvasMode_Edit::drawTextCursor ( QPainter *p, PageItem_TextFrame* textframe )
+{
+	if ((!m_longCursorTime && m_blinkTime.elapsed() > QApplication::cursorFlashTime() / 2 ) ||
+		(m_longCursorTime && m_blinkTime.elapsed() > QApplication::cursorFlashTime() )
+		)
+	{
+		m_cursorVisible = !m_cursorVisible;
+		m_blinkTime.restart();
+		m_longCursorTime = false;
+	}
+	if ( m_cursorVisible )
+	{
+		commonDrawTextCursor(p, textframe, QPointF());
+	}
+}
+
+void CanvasMode_Edit::enterEvent(QEvent *e)
+{
+	if (!m_canvas->m_viewMode.m_MouseButtonPressed)
+	{
+		setModeCursor();
+	}
+}
+
+void CanvasMode_Edit::leaveEvent(QEvent *e)
+{
+}
+
+void CanvasMode_Edit::activate(bool fromGesture)
+{
+	CanvasMode::activate(fromGesture);
+
+	m_canvas->m_viewMode.m_MouseButtonPressed = false;
+	m_canvas->resetRenderMode();
+	m_doc->DragP = false;
+	m_doc->leaveDrag = false;
+	m_canvas->m_viewMode.operItemMoving = false;
+	m_canvas->m_viewMode.operItemResizing = false;
+	m_view->MidButt = false;
+	Mxp = Myp = -1;
+	Dxp = Dyp = -1;
+	SeRx = SeRy = -1;
+	oldCp = Cp = -1;
+	frameResizeHandle = -1;
+	setModeCursor();
+	if (fromGesture)
+	{
+		m_view->update();
+	}
+	mRulerGuide = -1;
+	PageItem * it(nullptr);
+	if (GetItem(&it))
+	{
+		if (it->isTextFrame())
+		{
+			m_canvas->setupEditHRuler(it, true);
+			if (m_doc->appMode == modeEdit)
+			{
+				m_blinker->start(200);
+				m_blinkTime.start();
+				m_cursorVisible = true;
+				blinkTextCursor();
+			}
+		}
+	}
+}
+
+void CanvasMode_Edit::deactivate(bool forGesture)
+{
+	m_view->setRedrawMarkerShown(false);
+	if (!forGesture)
+	{
+		mRulerGuide = -1;
+		m_blinker->stop();
+	}
+	CanvasMode::deactivate(forGesture);
+}
+
+void CanvasMode_Edit::mouseDoubleClickEvent(QMouseEvent *m)
+{
+	m->accept();
+	m_canvas->m_viewMode.m_MouseButtonPressed = false;
+	m_canvas->resetRenderMode();
+	PageItem *currItem = nullptr;
+	if (GetItem(&currItem) && (m_doc->appMode == modeEdit) && currItem->isTextFrame())
+	{
+		//CB if annotation, open the annotation dialog
+		if (currItem->isAnnotation())
+		{
+		//	QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor));
+			m_view->requestMode(submodeAnnotProps);
+		}
+		//otherwise, select between the whitespace
+		else
+		{
+			if (m->modifiers() & Qt::ControlModifier)
+			{
+				int start=0, stop=0;
+
+				if (m->modifiers() & Qt::ShiftModifier)
+				{//Double click with Ctrl+Shift in a frame to select few paragraphs
+					uint oldPar = currItem->itemText.nrOfParagraph(oldCp);
+					uint newPar = currItem->itemText.nrOfParagraph();
+					if (oldPar < newPar)
+					{
+						start = currItem->itemText.startOfParagraph(oldPar);
+						stop = currItem->itemText.endOfParagraph(newPar);
+					}
+					else
+					{
+						start = currItem->itemText.startOfParagraph(newPar);
+						stop = currItem->itemText.endOfParagraph(oldPar);
+					}
+				}
+				else
+				{//Double click with Ctrl in a frame to select a paragraph
+					oldCp = currItem->itemText.cursorPosition();
+					uint nrPar = currItem->itemText.nrOfParagraph(oldCp);
+					start = currItem->itemText.startOfParagraph(nrPar);
+					stop = currItem->itemText.endOfParagraph(nrPar);
+				}
+				currItem->itemText.deselectAll();
+				currItem->itemText.extendSelection(start, stop);
+				currItem->itemText.setCursorPosition(stop);
+			}
+			else if ((currItem->itemText.cursorPosition() < currItem->itemText.length()) && (currItem->itemText.hasMark(currItem->itemText.cursorPosition())))
+			{	//invoke edit marker dialog
+				m_ScMW->slotEditMark();
+				return;
+			}
+			else
+			{	//Double click in a frame to select a word
+				oldCp = currItem->itemText.cursorPosition();
+				bool validPos = (oldCp >= 0 && oldCp < currItem->itemText.length());
+				if (validPos && currItem->itemText.hasObject(oldCp))
+				{
+					currItem->itemText.select(oldCp, 1, true);
+					InlineFrame iItem = currItem->itemText.object(oldCp);
+					m_ScMW->editInlineStart(iItem.getInlineCharID());
+				}
+				else
+				{
+					currItem->itemText.selectWord(oldCp);
+				}
+			}
+			currItem->HasSel = currItem->itemText.hasSelection();
+		}
+	}
+	else
+	{
+		mousePressEvent(m);
+		return;
+	}
+}
+
+
+void CanvasMode_Edit::mouseMoveEvent(QMouseEvent *m)
+{
+	const QPoint globalPos = m->globalPosition().toPoint();
+	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+
+	double newX, newY;
+	PageItem *currItem;
+	m->accept();
+	if (commonMouseMove(m))
+		return;
+	if (GetItem(&currItem))
+	{
+		newX = qRound(mousePointDoc.x());
+		newY = qRound(mousePointDoc.y());
+		if (m_doc->DragP)
+			return;
+		if (m_canvas->m_viewMode.m_MouseButtonPressed && (m_doc->appMode == modeEdit))
+		{
+			if (currItem->isImageFrame())
+			{
+				if (m->modifiers() & Qt::ShiftModifier)
+				{
+					m_view->setCursor(IconManager::instance().loadCursor("Rotieren2.png"));
+					QTransform p = currItem->getTransform();
+					p.translate(currItem->imageXOffset()*currItem->imageXScale(), currItem->imageYOffset()*currItem->imageYScale());
+					QPointF rotP = p.map(QPointF(0.0, 0.0));
+					double itemRotation = xy2Deg(mousePointDoc.x() - rotP.x(), mousePointDoc.y() - rotP.y());
+					currItem->setImageRotation(itemRotation);
+					m_canvas->displayRotHUD(m->globalPosition(), itemRotation);
+				}
+				else
+				{
+					m_view->setCursor(IconManager::instance().loadCursor("handc.png"));
+					QTransform mm1 = currItem->getTransform();
+					QTransform mm2 = mm1.inverted();
+					QPointF rota = mm2.map(QPointF(newX, newY)) - mm2.map(QPointF(Mxp, Myp));
+					currItem->moveImageInFrame(rota.x() / currItem->imageXScale(), rota.y() / currItem->imageYScale());
+					m_canvas->displayXYHUD(m->globalPosition(), currItem->imageXOffset() * currItem->imageXScale(), currItem->imageYOffset() * currItem->imageYScale());
+				}
+				currItem->update();
+				Mxp = newX;
+				Myp = newY;
+			}
+			if (currItem->isTextFrame())
+			{
+				int refStartSel(currItem->asTextFrame()->itemText.startOfSelection());
+				int refEndSel(currItem->asTextFrame()->itemText.endOfSelection());
+				currItem->itemText.deselectAll();
+				currItem->HasSel = false;
+				m_view->slotSetCurs(globalPos.x(), globalPos.y());
+				//Make sure we don't go here if the old cursor position was not set
+				if (oldCp!=-1 && currItem->itemText.length() > 0)
+				{
+					if (currItem->itemText.cursorPosition() < oldCp)
+					{
+						currItem->itemText.select(currItem->itemText.cursorPosition(), oldCp - currItem->itemText.cursorPosition());
+						currItem->HasSel = true;
+					}
+					if (currItem->itemText.cursorPosition() > oldCp)
+					{
+						currItem->itemText.select(oldCp, currItem->itemText.cursorPosition() - oldCp);
+						currItem->HasSel = true;
+					}
+				}
+				m_ScMW->setCopyCutEnabled(currItem->HasSel);
+				if (currItem->HasSel)
+				{
+					m_canvas->m_viewMode.operTextSelecting = true;
+					if ((refStartSel != currItem->asTextFrame()->itemText.startOfSelection()) ||
+						(refEndSel   != currItem->asTextFrame()->itemText.endOfSelection()))
+					{
+						QRectF br(currItem->getBoundingRect());
+						m_canvas->update(QRectF(m_canvas->canvasToLocal(br.topLeft()), br.size() * m_canvas->scale()).toRect());
+					}
+					// We have to call this unconditionally because slotSetCurs() doesn't know selection
+					// when it is called
+					m_doc->scMW()->setTBvals(currItem);
+				}
+			}
+		}
+		if (!m_canvas->m_viewMode.m_MouseButtonPressed)
+		{
+			if (m_doc->m_Selection->isMultipleSelection())
+			{
+				setModeCursor();
+				return;
+			}
+			for (int a = 0; a < m_doc->m_Selection->count(); ++a)
+			{
+				currItem = m_doc->m_Selection->itemAt(a);
+				if (currItem->locked())
+					break;
+				int hitTest = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
+				if (hitTest >= 0)
+				{
+					if (hitTest == Canvas::INSIDE)
+					{
+						if (currItem->isTextFrame())
+							m_view->setCursor(QCursor(Qt::IBeamCursor));
+						if (currItem->isImageFrame())
+						{
+							if (m->modifiers() & Qt::ShiftModifier)
+								m_view->setCursor(IconManager::instance().loadCursor("Rotieren2.png"));
+							else
+								m_view->setCursor(IconManager::instance().loadCursor("handc.png"));
+						}
+					}
+				}
+				else
+				{
+					m_view->setCursor(QCursor(Qt::ArrowCursor));
+				}
+			}
+		}
+	}
+	else
+	{
+		if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton))
+		{
+			newX = qRound(mousePointDoc.x());
+			newY = qRound(mousePointDoc.y());
+			SeRx = newX;
+			SeRy = newY;
+			QPoint startP = m_canvas->canvasToGlobal(QPointF(Mxp, Myp));
+			m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(globalPos)).normalized());
+			m_view->setRedrawMarkerShown(true);
+			m_view->HaveSelRect = true;
+			return;
+		}
+	}
+}
+
+void CanvasMode_Edit::mousePressEvent(QMouseEvent *m)
+{
+	if (UndoManager::undoEnabled())
+	{
+		SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
+		if (ss)
+			ss->set("ETEA", QString(""));
+		else
+		{
+			TransactionState *ts = dynamic_cast<TransactionState*>(undoManager->getLastUndo());
+			if (ts)
+				ss = dynamic_cast<SimpleState*>(ts->last());
+			if (ss)
+				ss->set("ETEA", QString(""));
+		}
+	}
+
+	const QPoint globalPos = m->globalPosition().toPoint();
+	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+
+	m_canvas->PaintSizeRect(QRect());
+	m_canvas->m_viewMode.m_MouseButtonPressed = true;
+	m_canvas->m_viewMode.operItemMoving = false;
+	m_view->HaveSelRect = false;
+	m_doc->DragP = false;
+	m_doc->leaveDrag = false;
+	m->accept();
+	m_view->registerMousePress(m->globalPosition());
+	Mxp = mousePointDoc.x();
+	Myp = mousePointDoc.y();
+	SeRx = Mxp;
+	SeRy = Myp;
+	if (m->button() == Qt::MiddleButton)
+	{
+		m_view->MidButt = true;
+		if (m->modifiers() & Qt::ControlModifier)
+			m_view->DrawNew();
+		return;
+	}
+
+	frameResizeHandle = 0;
+	int oldP = 0;
+
+	PageItem* currItem{ nullptr };
+	if (GetItem(&currItem))
+	{
+//		m_view->slotDoCurs(false);
+		if ((!currItem->locked() || currItem->isTextFrame()) && !currItem->isLine())
+		{
+			FPoint canvasPoint = m_canvas->globalToCanvas(m->globalPosition());
+			if (m_canvas->frameHitTest(QPointF(canvasPoint.x(), canvasPoint.y()), currItem) < 0)
+			{
+				m_doc->m_Selection->delaySignalsOn();
+				m_view->deselectItems(true);
+				bool wantNormal = true;
+				if (SeleItem(m))
+				{
+					currItem = m_doc->m_Selection->itemAt(0);
+					if ((currItem->isTextFrame()) || (currItem->isImageFrame()))
+					{
+						m_view->requestMode(modeEdit);
+						wantNormal = false;
+					}
+					else
+					{
+						m_view->requestMode(submodePaintingDone);
+						m_view->setCursor(QCursor(Qt::ArrowCursor));
+					}
+					if (currItem->isTextFrame())
+					{
+						m_view->slotSetCurs(globalPos.x(), globalPos.y());
+						oldCp = currItem->itemText.cursorPosition();
+					}
+				}
+				else
+				{
+					m_view->requestMode(submodePaintingDone);
+					m_view->setCursor(QCursor(Qt::ArrowCursor));
+				}
+				m_doc->m_Selection->delaySignalsOff();
+				if (wantNormal)
+				{
+					m_view->requestMode(modeNormal);
+					m_view->canvasMode()->mousePressEvent(m);
+				}
+				return;
+			}
+		}
+		oldP = currItem->itemText.cursorPosition();
+		//CB Where we set the cursor for a click in text frame
+		if (currItem->isTextFrame())
+		{
+			bool inText = m_view->slotSetCurs(globalPos.x(), globalPos.y());
+			//CB If we clicked outside a text frame to go out of edit mode and deselect the frame
+			if (!inText)
+			{
+				currItem->invalidateLayout();
+				m_view->deselectItems(true);
+				//m_view->slotDoCurs(true);
+				m_view->requestMode(modeNormal);
+				m_view->canvasMode()->mousePressEvent(m);
+				return;
+			}
+
+			if (m->button() != Qt::RightButton)
+			{
+				//currItem->asTextFrame()->deselectAll();
+				//<<CB Add in shift select to text frames
+				if (m->modifiers() & Qt::ShiftModifier)
+				{
+					if (currItem->itemText.hasSelection())
+					{
+						if (currItem->itemText.cursorPosition() < (currItem->itemText.startOfSelection() + currItem->itemText.endOfSelection()) / 2)
+						{
+							if (m->modifiers() & Qt::ControlModifier)
+								currItem->itemText.setCursorPosition(currItem->itemText.startOfParagraph());
+							oldP = currItem->itemText.startOfSelection();
+						}
+						else
+						{
+							if (m->modifiers() & Qt::ControlModifier)
+								currItem->itemText.setCursorPosition(currItem->itemText.endOfParagraph());
+							oldP = currItem->itemText.endOfSelection();
+						}
+						currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->itemText.cursorPosition());
+						oldCp = currItem->itemText.cursorPosition();
+					}
+					else
+					{
+						int dir=1;
+						if (oldCp > currItem->itemText.cursorPosition())
+							dir=-1;
+						if (m->modifiers() & Qt::ControlModifier) //no selection but Ctrl+Shift+click still select paragraphs
+						{
+							if (dir == 1)
+								currItem->itemText.setCursorPosition(currItem->itemText.endOfParagraph());
+							else
+								currItem->itemText.setCursorPosition(currItem->itemText.startOfParagraph());
+						}
+						currItem->asTextFrame()->ExpandSel(oldP);
+						oldCp = oldP;
+					}
+				}
+				else //>>CB
+				{
+					oldCp = currItem->itemText.cursorPosition();
+					currItem->itemText.deselectAll();
+					currItem->HasSel = false;
+				}
+				currItem->emitAllToGUI();
+				if (m->button() == Qt::MiddleButton)
+				{
+					m_canvas->m_viewMode.m_MouseButtonPressed = false;
+					m_view->MidButt = false;
+					QString cc;
+					cc = QApplication::clipboard()->text(QClipboard::Selection);
+					if (cc.isNull())
+						cc = QApplication::clipboard()->text(QClipboard::Clipboard);
+					if (!cc.isNull())
+					{
+						// K.I.S.S.:
+						currItem->itemText.insertChars(0, cc, true);
+						if (m_doc->docHyphenator->autoCheck())
+							m_doc->docHyphenator->slotHyphenate(currItem);
+						m_ScMW->BookMarkTxT(currItem);
+						//							m_ScMW->outlinePalette->BuildTree();
+					}
+					else
+					{
+						if (ScMimeData::clipboardHasScribusText())
+							m_ScMW->slotEditPaste();
+					}
+					currItem->update();
+				}
+			}
+		}
+		else if (!currItem->isImageFrame() || m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem) < 0)
+		{
+			m_view->deselectItems(true);
+			if (SeleItem(m))
+			{
+				currItem = m_doc->m_Selection->itemAt(0);
+				if ((currItem->isTextFrame()) || (currItem->isImageFrame()))
+				{
+					m_view->requestMode(modeEdit);
+				}
+				else
+				{
+					m_view->requestMode(submodePaintingDone);
+					m_view->setCursor(QCursor(Qt::ArrowCursor));
+				}
+			}
+			else
+			{
+				m_view->requestMode(submodePaintingDone);
+				m_view->setCursor(QCursor(Qt::ArrowCursor));
+			}
+		}
+	}
+}
+
+
+
+void CanvasMode_Edit::mouseReleaseEvent(QMouseEvent *m)
+{
+#ifdef GESTURE_FRAME_PREVIEW
+	clearPixmapCache();
+#endif // GESTURE_FRAME_PREVIEW
+	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+	PageItem *currItem = nullptr;
+	m_canvas->m_viewMode.m_MouseButtonPressed = false;
+	m_canvas->resetRenderMode();
+	m->accept();
+//	m_view->stopDragTimer();
+	if ((GetItem(&currItem)) && (m->button() == Qt::RightButton) && (!m_doc->DragP))
+	{
+		createContextMenu(currItem, mousePointDoc.x(), mousePointDoc.y());
+		return;
+	}
+	if (m_view->moveTimerElapsed() && (GetItem(&currItem)))
+	{
+//		m_view->stopDragTimer();
+		m_canvas->setRenderModeUseBuffer(false);
+		if (!m_doc->m_Selection->isMultipleSelection())
+		{
+			m_doc->setRedrawBounding(currItem);
+			currItem->OwnPage = m_doc->OnPage(currItem);
+			m_canvas->m_viewMode.operItemResizing = false;
+			if (currItem->isLine())
+				m_view->updateContents();
 			if (currItem->isImageFrame())
 				m_doc->changedPagePreview();
-		}
-		if (m_canvas->m_viewMode.operItemMoving)
-		{
-			m_view->updatesOn(false);
-			if (m_doc->m_Selection->isMultipleSelection())
-			{
-				if (!m_view->groupTransactionStarted())
-				{
-					m_view->startGroupTransaction(Um::Move, "", Um::IMove);
-				}
-				double gx, gy, gh, gw;
-				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
-				double nx = gx;
-				double ny = gy;
-				if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
-				{
-					FPoint npx = m_doc->ApplyGridF(FPoint(gx, gy));
-					FPoint npw = m_doc->ApplyGridF(FPoint(gx + gw, gy + gh));
-					if ((fabs(gx - npx.x())) > (fabs((gx + gw) - npw.x())))
-						nx = npw.x() - gw;
-					else
-						nx = npx.x();
-					if ((fabs(gy - npx.y())) > (fabs((gy + gh) - npw.y())))
-						ny = npw.y() - gh;
-					else
-						ny = npx.y();
-				}
-				m_doc->moveGroup(nx - gx, ny - gy);
-				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
-				nx = gx + gw;
-				ny = gy + gh;
-				if (m_doc->ApplyGuides(&nx, &ny) || m_doc->ApplyGuides(&nx,&ny,true))
-					m_doc->moveGroup(nx - (gx + gw), ny - (gy + gh));
-				m_doc->m_Selection->setGroupRect();
-			}
-			else
-			{
-				currItem = m_doc->m_Selection->itemAt(0);
-				if (m_doc->SnapGrid)
-				{
-					double nx = currItem->xPos();
-					double ny = currItem->yPos();
-					if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
-					{
-						double gx, gy, gh, gw;
-						m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
-						FPoint npx = m_doc->ApplyGridF(FPoint(gx, gy));
-						FPoint npw = m_doc->ApplyGridF(FPoint(gx + gw, gy + gh));
-						if ((fabs(gx - npx.x())) > (fabs((gx + gw) - npw.x())))
-							nx = npw.x() - gw;
-						else
-							nx = npx.x();
-						if ((fabs(gy - npx.y())) > (fabs((gy + gh) - npw.y())))
-							ny = npw.y() - gh;
-						else
-							ny = npx.y();
-					}
-					m_doc->moveItem(nx-currItem->xPos(), ny-currItem->yPos(), currItem);
-				}
-				else
-					m_doc->moveItem(0, 0, currItem);
-			}
-			m_canvas->m_viewMode.operItemMoving = false;
-			if (m_doc->m_Selection->isMultipleSelection())
-			{
-				double gx, gy, gh, gw;
-				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
-				FPoint maxSize(gx + gw + m_doc->scratch()->right(), gy + gh + m_doc->scratch()->bottom());
-				FPoint minSize(gx - m_doc->scratch()->left(), gy - m_doc->scratch()->top());
-				m_doc->adjustCanvas(minSize, maxSize);
-			}
-			m_doc->setRedrawBounding(currItem);
-			currItem->OwnPage = m_doc->OnPage(currItem);
-			if (currItem->OwnPage != -1)
-			{
-				m_doc->setCurrentPage(m_doc->Pages->at(currItem->OwnPage));
-				m_view->m_ScMW->slotSetCurrentPage(currItem->OwnPage);
-			}
-			//CB done with emitAllToGUI
-			//emit HaveSel();
-			//EmitValues(currItem);
-			//CB need this for? a moved item will send its new data with the new xpos/ypos emits
-			//CB TODO And what if we have dragged to a new page. Items X&Y are not updated anyway now
-			//currItem->emitAllToGUI();
-			m_view->updatesOn(true);
-			m_view->updateContents();
+		}
+		if (m_canvas->m_viewMode.operItemMoving)
+		{
+			m_view->updatesOn(false);
+			if (m_doc->m_Selection->isMultipleSelection())
+			{
+				if (!m_view->groupTransactionStarted())
+				{
+					m_view->startGroupTransaction(Um::Move, "", Um::IMove);
+				}
+				double gx, gy, gh, gw;
+				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+				double nx = gx;
+				double ny = gy;
+				if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
+				{
+					FPoint npx = m_doc->ApplyGridF(FPoint(gx, gy));
+					FPoint npw = m_doc->ApplyGridF(FPoint(gx + gw, gy + gh));
+					if ((fabs(gx - npx.x())) > (fabs((gx + gw) - npw.x())))
+						nx = npw.x() - gw;
+					else
+						nx = npx.x();
+					if ((fabs(gy - npx.y())) > (fabs((gy + gh) - npw.y())))
+						ny = npw.y() - gh;
+					else
+						ny = npx.y();
+				}
+				m_doc->moveGroup(nx - gx, ny - gy);
+				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+				nx = gx + gw;
+				ny = gy + gh;
+				if (m_doc->ApplyGuides(&nx, &ny) || m_doc->ApplyGuides(&nx,&ny,true))
+					m_doc->moveGroup(nx - (gx + gw), ny - (gy + gh));
+				m_doc->m_Selection->setGroupRect();
+			}
+			else
+			{
+				currItem = m_doc->m_Selection->itemAt(0);
+				if (m_doc->guidesPrefs().gridSnapping)
+				{
+					double nx = currItem->xPos();
+					double ny = currItem->yPos();
+					if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
+					{
+						double gx, gy, gh, gw;
+						m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+						FPoint npx = m_doc->ApplyGridF(FPoint(gx, gy));
+						FPoint npw = m_doc->ApplyGridF(FPoint(gx + gw, gy + gh));
+						if ((fabs(gx - npx.x())) > (fabs((gx + gw) - npw.x())))
+							nx = npw.x() - gw;
+						else
+							nx = npx.x();
+						if ((fabs(gy - npx.y())) > (fabs((gy + gh) - npw.y())))
+							ny = npw.y() - gh;
+						else
+							ny = npx.y();
+					}
+					m_doc->moveItem(nx-currItem->xPos(), ny-currItem->yPos(), currItem);
+				}
+				else
+					m_doc->moveItem(0, 0, currItem);
+			}
+			m_canvas->m_viewMode.operItemMoving = false;
+			if (m_doc->m_Selection->isMultipleSelection())
+			{
+				double gx, gy, gh, gw;
+				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+				FPoint maxSize(gx + gw + m_doc->scratch()->right(), gy + gh + m_doc->scratch()->bottom());
+				FPoint minSize(gx - m_doc->scratch()->left(), gy - m_doc->scratch()->top());
+				m_doc->adjustCanvas(minSize, maxSize);
+			}
+			m_doc->setRedrawBounding(currItem);
+			currItem->OwnPage = m_doc->OnPage(currItem);
+			if (currItem->OwnPage != -1)
+			{
+				m_doc->setCurrentPage(m_doc->Pages->at(currItem->OwnPage));
+				m_view->m_ScMW->slotSetCurrentPage(currItem->OwnPage);
+			}
+			//CB done with emitAllToGUI
+			//emit HaveSel();
+			//EmitValues(currItem);
+			//CB need this for? a moved item will send its new data with the new xpos/ypos emits
+			//CB TODO And what if we have dragged to a new page. Items X&Y are not updated anyway now
+			//currItem->emitAllToGUI();
+			m_view->updatesOn(true);
+			m_view->updateContents();
 			m_doc->changedPagePreview();
-		}
-	}
-	//CB Drag selection performed here
-	if ((m_doc->m_Selection->isEmpty()) && (m_view->HaveSelRect) && (!m_view->MidButt))
-	{
-		QRectF Sele = QRectF(Dxp, Dyp, SeRx-Dxp, SeRy-Dyp).normalized();
-		if (!m_doc->masterPageMode())
-		{
-			uint docPagesCount = m_doc->Pages->count();
-			uint docCurrPageNo = m_doc->currentPageNumber();
-			for (uint i = 0; i < docPagesCount; ++i)
-			{
-				if (QRectF(m_doc->Pages->at(i)->xOffset(), m_doc->Pages->at(i)->yOffset(), m_doc->Pages->at(i)->width(), m_doc->Pages->at(i)->height()).intersects(Sele))
-				{
-					if (docCurrPageNo != i)
-					{
-						m_doc->setCurrentPage(m_doc->Pages->at(i));
-						m_view->m_ScMW->slotSetCurrentPage(i);
-					}
-					break;
-				}
-			}
-			m_view->setRulerPos(m_view->contentsX(), m_view->contentsY());
-		}
-		int docItemCount = m_doc->Items->count();
-		if (docItemCount != 0)
-		{
-			m_doc->m_Selection->delaySignalsOn();
-			for (int a = 0; a < docItemCount; ++a)
-			{
-				PageItem* docItem = m_doc->Items->at(a);
-				QTransform p;
-				m_canvas->Transform(docItem, p);
-				QRegion apr = QRegion(docItem->Clip * p);
-				QRect apr2(docItem->getRedrawBounding(1.0));
-				if ((m_doc->masterPageMode()) && (docItem->OnMasterPage != m_doc->currentPage()->pageName()))
-					continue;
-				if (((Sele.contains(apr.boundingRect())) || (Sele.contains(apr2))) && m_doc->canSelectItemOnLayer(docItem->m_layerID))
-				{
-					bool redrawSelection = false;
-					m_view->selectItemByNumber(a, redrawSelection);
-				}
-			}
-			m_doc->m_Selection->delaySignalsOff();
-			if (m_doc->m_Selection->count() > 1)
-			{
-				double x, y, w, h;
-				m_doc->m_Selection->getGroupRect(&x, &y, &w, &h);
-				m_view->getGroupRectScreen(&x, &y, &w, &h);
-			}
-		}
-		m_view->HaveSelRect = false;
-		m_view->setRedrawMarkerShown(false);
-		m_view->updateContents();
-	}
-	if (GetItem(&currItem))
-	{
-		if (m_doc->m_Selection->count() > 1)
-		{
-			double x, y, w, h;
-			m_doc->m_Selection->getGroupRect(&x, &y, &w, &h);
-			m_canvas->m_viewMode.operItemMoving = false;
-			m_canvas->m_viewMode.operItemResizing = false;
-			m_view->updateContents(QRect(static_cast<int>(x-5), static_cast<int>(y-5), static_cast<int>(w+10), static_cast<int>(h+10)));
-		}
-		/*else
-			currItem->emitAllToGUI();*/
-	}
-	m_canvas->setRenderModeUseBuffer(false);
-	m_doc->DragP = false;
-	m_doc->leaveDrag = false;
-	m_canvas->m_viewMode.operItemMoving = false;
-	m_canvas->m_viewMode.operItemResizing = false;
-	m_view->MidButt = false;
-	if (m_view->groupTransactionStarted())
-	{
-		for (int i = 0; i < m_doc->m_Selection->count(); ++i)
-			m_doc->m_Selection->itemAt(i)->checkChanges(true);
-		m_view->endGroupTransaction();
-	}
-	for (int i = 0; i < m_doc->m_Selection->count(); ++i)
-		m_doc->m_Selection->itemAt(i)->checkChanges(true);
-	//Commit drag created items to undo manager.
-	if (m_doc->m_Selection->itemAt(0) != nullptr)
-	{
-		m_doc->itemAddCommit(m_doc->m_Selection->itemAt(0));
-	}
-	//Make sure the Zoom spinbox and page selector don't have focus if we click on the canvas
-	m_view->m_ScMW->zoomSpinBox->clearFocus();
-	m_view->m_ScMW->pageSelector->clearFocus();
-	if (m_doc->m_Selection->itemAt(0) != nullptr) // is there the old clip stored for the undo action
-	{
-		currItem = m_doc->m_Selection->itemAt(0);
-		m_doc->nodeEdit.finishTransaction(currItem);
-	}
-	if (GetItem(&currItem) && currItem->isTextFrame())
-		m_ScMW->setCopyCutEnabled(currItem->itemText.hasSelection());
-}
-
-//CB-->Doc/Fix
-bool CanvasMode_Edit::SeleItem(QMouseEvent *m)
-{
-	const unsigned SELECT_IN_GROUP = Qt::AltModifier;
-	const unsigned SELECT_MULTIPLE = Qt::ShiftModifier;
-	const unsigned SELECT_BENEATH = Qt::ControlModifier;
-
-	m_canvas->m_viewMode.m_MouseButtonPressed = true;
-
-	FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
-	Mxp = mousePointDoc.x();
-	Myp = mousePointDoc.y();
-	int MxpS = static_cast<int>(mousePointDoc.x());
-	int MypS = static_cast<int>(mousePointDoc.y());
-	//QRectF mpo(Mxp - grabRadius, Myp - grabRadius, grabRadius * 2, grabRadius * 2);
-
-	m_doc->nodeEdit.deselect();
-	if (!m_doc->masterPageMode())
-	{
-		int pgNum = -1;
-		int docPageCount = static_cast<int>(m_doc->Pages->count() - 1);
-		MarginStruct pageBleeds;
-		bool drawBleed = false;
-		if (!m_doc->bleeds()->isNull() && m_doc->guidesPrefs().showBleed)
-			drawBleed = true;
-		for (int a = docPageCount; a > -1; a--)
-		{
-			if (drawBleed)
-				m_doc->getBleeds(a, pageBleeds);
-			int x = static_cast<int>(m_doc->Pages->at(a)->xOffset() - pageBleeds.left());
-			int y = static_cast<int>(m_doc->Pages->at(a)->yOffset() - pageBleeds.top());
-			int w = static_cast<int>(m_doc->Pages->at(a)->width() + pageBleeds.left() + pageBleeds.right());
-			int h = static_cast<int>(m_doc->Pages->at(a)->height() + pageBleeds.bottom() + pageBleeds.top());
-			if (QRect(x, y, w, h).contains(MxpS, MypS))
-			{
-				pgNum = static_cast<int>(a);
-				if (drawBleed)  // check again if its really on the correct page
-				{
-					for (int a2 = docPageCount; a2 > -1; a2--)
-					{
-						int xn = static_cast<int>(m_doc->Pages->at(a2)->xOffset());
-						int yn = static_cast<int>(m_doc->Pages->at(a2)->yOffset());
-						int wn = static_cast<int>(m_doc->Pages->at(a2)->width());
-						int hn = static_cast<int>(m_doc->Pages->at(a2)->height());
-						if (QRect(xn, yn, wn, hn).contains(MxpS, MypS))
-						{
-							pgNum = static_cast<int>(a2);
-							break;
-						}
-					}
-				}
-				break;
-			}
-		}
-		if (pgNum >= 0)
-		{
-			if (m_doc->currentPageNumber() != pgNum)
-			{
-				m_doc->setCurrentPage(m_doc->Pages->at(pgNum));
-				m_view->m_ScMW->slotSetCurrentPage(pgNum);
-				m_view->DrawNew();
-			}
-		}
-		m_view->setRulerPos(m_view->contentsX(), m_view->contentsY());
-	}
-	
-	PageItem* currItem = nullptr;
-	if ((m->modifiers() & SELECT_BENEATH) != 0)
-	{
-		for (int i = 0; i < m_doc->m_Selection->count(); ++i)
-		{
-			if (m_canvas->frameHitTest(QPointF(mousePointDoc.x(), mousePointDoc.y()), m_doc->m_Selection->itemAt(i)) >= 0)
-			{
-				currItem = m_doc->m_Selection->itemAt(i);
-				m_doc->m_Selection->removeItem(currItem);
-				break;
-			}
-		}
-	}
-	else if ( (m->modifiers() & SELECT_MULTIPLE) == Qt::NoModifier)
-	{
-		m_view->deselectItems(false);
-	}
-	currItem = m_canvas->itemUnderCursor(m->globalPosition(), currItem, (m->modifiers() & SELECT_IN_GROUP));
-	if (currItem)
-	{
-		m_doc->m_Selection->delaySignalsOn();
-		if (m_doc->m_Selection->containsItem(currItem))
-		{
-			m_doc->m_Selection->removeItem(currItem);
-		}
-		else
-		{
-			//CB: If we have a selection but the user clicks with control on another item that is not below the current
-			//then clear and select the new item
-			if ((m->modifiers() == SELECT_BENEATH) && m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem) >= 0)
-				m_doc->m_Selection->clear();
-			//CB: #7186: This was prependItem, does not seem to need to be anymore with current select code
-			m_doc->m_Selection->addItem(currItem);
-			if ( (m->modifiers() & SELECT_IN_GROUP) && (!currItem->isGroup()))
-			{
-				currItem->isSingleSel = true;
-			}
-		}
-		m_canvas->update();
-		m_doc->m_Selection->delaySignalsOff();
-		if (m_doc->m_Selection->count() > 1)
-		{
-			double x, y, w, h;
-			m_doc->m_Selection->getGroupRect(&x, &y, &w, &h);
-			m_view->getGroupRectScreen(&x, &y, &w, &h);
-		}
-		if (m_doc->m_Selection->count() == 1)
-		{
-			frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
-			if ((frameResizeHandle == Canvas::INSIDE) && (!currItem->locked()))
-				m_view->setCursor(QCursor(Qt::SizeAllCursor));
-		}
-		else
-		{
-			m_view->setCursor(QCursor(Qt::SizeAllCursor));
-			m_canvas->m_viewMode.operItemResizing = false;
-		}
-		return true;
-	}
-	m_doc->m_Selection->connectItemToGUI();
-	if ( !(m->modifiers() & SELECT_MULTIPLE))
-		m_view->deselectItems(true);
-	return false;
-}
-
-void CanvasMode_Edit::createContextMenu(PageItem* currItem, double mx, double my)
-{
-	ContextMenu* cmen = nullptr;
-	m_view->setCursor(QCursor(Qt::ArrowCursor));
-	m_view->setObjectUndoMode();
-	Mxp = mx;
-	Myp = my;
-	if (currItem != nullptr)
-		cmen = new ContextMenu(*(m_doc->m_Selection), m_ScMW, m_doc);
-	else
-		cmen = new ContextMenu(m_ScMW, m_doc, mx, my);
-	if (cmen)
-		cmen->exec(QCursor::pos());
-	m_view->setGlobalUndoMode();
-	delete cmen;
-}
+		}
+	}
+	//CB Drag selection performed here
+	if ((m_doc->m_Selection->isEmpty()) && (m_view->HaveSelRect) && (!m_view->MidButt))
+	{
+		QRectF Sele = QRectF(Dxp, Dyp, SeRx-Dxp, SeRy-Dyp).normalized();
+		if (!m_doc->masterPageMode())
+		{
+			uint docPagesCount = m_doc->Pages->count();
+			uint docCurrPageNo = m_doc->currentPageNumber();
+			for (uint i = 0; i < docPagesCount; ++i)
+			{
+				if (QRectF(m_doc->Pages->at(i)->xOffset(), m_doc->Pages->at(i)->yOffset(), m_doc->Pages->at(i)->width(), m_doc->Pages->at(i)->height()).intersects(Sele))
+				{
+					if (docCurrPageNo != i)
+					{
+						m_doc->setCurrentPage(m_doc->Pages->at(i));
+						m_view->m_ScMW->slotSetCurrentPage(i);
+					}
+					break;
+				}
+			}
+			m_view->setRulerPos(m_view->contentsX(), m_view->contentsY());
+		}
+		int docItemCount = m_doc->Items->count();
+		if (docItemCount != 0)
+		{
+			m_doc->m_Selection->delaySignalsOn();
+			for (int a = 0; a < docItemCount; ++a)
+			{
+				PageItem* docItem = m_doc->Items->at(a);
+				QTransform p;
+				m_canvas->Transform(docItem, p);
+				QRegion apr = QRegion(docItem->Clip * p);
+				QRect apr2(docItem->getRedrawBounding(1.0));
+				if ((m_doc->masterPageMode()) && (docItem->OnMasterPage != m_doc->currentPage()->pageName()))
+					continue;
+				if (((Sele.contains(apr.boundingRect())) || (Sele.contains(apr2))) && m_doc->canSelectItemOnLayer(docItem->m_layerID))
+				{
+					bool redrawSelection = false;
+					m_view->selectItemByNumber(a, redrawSelection);
+				}
+			}
+			m_doc->m_Selection->delaySignalsOff();
+			if (m_doc->m_Selection->count() > 1)
+			{
+				double x, y, w, h;
+				m_doc->m_Selection->getGroupRect(&x, &y, &w, &h);
+				m_view->getGroupRectScreen(&x, &y, &w, &h);
+			}
+		}
+		m_view->HaveSelRect = false;
+		m_view->setRedrawMarkerShown(false);
+		m_view->updateContents();
+	}
+	if (GetItem(&currItem))
+	{
+		if (m_doc->m_Selection->count() > 1)
+		{
+			double x, y, w, h;
+			m_doc->m_Selection->getGroupRect(&x, &y, &w, &h);
+			m_canvas->m_viewMode.operItemMoving = false;
+			m_canvas->m_viewMode.operItemResizing = false;
+			m_view->updateContents(QRect(static_cast<int>(x-5), static_cast<int>(y-5), static_cast<int>(w+10), static_cast<int>(h+10)));
+		}
+		/*else
+			currItem->emitAllToGUI();*/
+	}
+	m_canvas->setRenderModeUseBuffer(false);
+	m_doc->DragP = false;
+	m_doc->leaveDrag = false;
+	m_canvas->m_viewMode.operItemMoving = false;
+	m_canvas->m_viewMode.operItemResizing = false;
+	m_view->MidButt = false;
+	if (m_view->groupTransactionStarted())
+	{
+		for (int i = 0; i < m_doc->m_Selection->count(); ++i)
+			m_doc->m_Selection->itemAt(i)->checkChanges(true);
+		m_view->endGroupTransaction();
+	}
+	for (int i = 0; i < m_doc->m_Selection->count(); ++i)
+		m_doc->m_Selection->itemAt(i)->checkChanges(true);
+	//Commit drag created items to undo manager.
+	if (m_doc->m_Selection->itemAt(0) != nullptr)
+	{
+		m_doc->itemAddCommit(m_doc->m_Selection->itemAt(0));
+	}
+	//Make sure the Zoom spinbox and page selector don't have focus if we click on the canvas
+	m_view->m_ScMW->zoomSpinBox->clearFocus();
+	m_view->m_ScMW->pageSelector->clearFocus();
+	if (m_doc->m_Selection->itemAt(0) != nullptr) // is there the old clip stored for the undo action
+	{
+		currItem = m_doc->m_Selection->itemAt(0);
+		m_doc->nodeEdit.finishTransaction(currItem);
+	}
+	if (GetItem(&currItem) && currItem->isTextFrame())
+		m_ScMW->setCopyCutEnabled(currItem->itemText.hasSelection());
+}
+
+//CB-->Doc/Fix
+bool CanvasMode_Edit::SeleItem(QMouseEvent *m)
+{
+	const unsigned SELECT_IN_GROUP = Qt::AltModifier;
+	const unsigned SELECT_MULTIPLE = Qt::ShiftModifier;
+	const unsigned SELECT_BENEATH = Qt::ControlModifier;
+
+	m_canvas->m_viewMode.m_MouseButtonPressed = true;
+
+	FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
+	Mxp = mousePointDoc.x();
+	Myp = mousePointDoc.y();
+	int MxpS = static_cast<int>(mousePointDoc.x());
+	int MypS = static_cast<int>(mousePointDoc.y());
+	//QRectF mpo(Mxp - grabRadius, Myp - grabRadius, grabRadius * 2, grabRadius * 2);
+
+	m_doc->nodeEdit.deselect();
+	if (!m_doc->masterPageMode())
+	{
+		int pgNum = -1;
+		int docPageCount = static_cast<int>(m_doc->Pages->count() - 1);
+		MarginStruct pageBleeds;
+		bool drawBleed = false;
+		if (!m_doc->bleeds()->isNull() && m_doc->guidesPrefs().showBleed)
+			drawBleed = true;
+		for (int a = docPageCount; a > -1; a--)
+		{
+			if (drawBleed)
+				m_doc->getBleeds(a, pageBleeds);
+			int x = static_cast<int>(m_doc->Pages->at(a)->xOffset() - pageBleeds.left());
+			int y = static_cast<int>(m_doc->Pages->at(a)->yOffset() - pageBleeds.top());
+			int w = static_cast<int>(m_doc->Pages->at(a)->width() + pageBleeds.left() + pageBleeds.right());
+			int h = static_cast<int>(m_doc->Pages->at(a)->height() + pageBleeds.bottom() + pageBleeds.top());
+			if (QRect(x, y, w, h).contains(MxpS, MypS))
+			{
+				pgNum = static_cast<int>(a);
+				if (drawBleed)  // check again if its really on the correct page
+				{
+					for (int a2 = docPageCount; a2 > -1; a2--)
+					{
+						int xn = static_cast<int>(m_doc->Pages->at(a2)->xOffset());
+						int yn = static_cast<int>(m_doc->Pages->at(a2)->yOffset());
+						int wn = static_cast<int>(m_doc->Pages->at(a2)->width());
+						int hn = static_cast<int>(m_doc->Pages->at(a2)->height());
+						if (QRect(xn, yn, wn, hn).contains(MxpS, MypS))
+						{
+							pgNum = static_cast<int>(a2);
+							break;
+						}
+					}
+				}
+				break;
+			}
+		}
+		if (pgNum >= 0)
+		{
+			if (m_doc->currentPageNumber() != pgNum)
+			{
+				m_doc->setCurrentPage(m_doc->Pages->at(pgNum));
+				m_view->m_ScMW->slotSetCurrentPage(pgNum);
+				m_view->DrawNew();
+			}
+		}
+		m_view->setRulerPos(m_view->contentsX(), m_view->contentsY());
+	}
+
+	PageItem* currItem = nullptr;
+	if ((m->modifiers() & SELECT_BENEATH) != 0)
+	{
+		for (int i = 0; i < m_doc->m_Selection->count(); ++i)
+		{
+			if (m_canvas->frameHitTest(QPointF(mousePointDoc.x(), mousePointDoc.y()), m_doc->m_Selection->itemAt(i)) >= 0)
+			{
+				currItem = m_doc->m_Selection->itemAt(i);
+				m_doc->m_Selection->removeItem(currItem);
+				break;
+			}
+		}
+	}
+	else if ( (m->modifiers() & SELECT_MULTIPLE) == Qt::NoModifier)
+	{
+		m_view->deselectItems(false);
+	}
+	currItem = m_canvas->itemUnderCursor(m->globalPosition(), currItem, (m->modifiers() & SELECT_IN_GROUP));
+	if (currItem)
+	{
+		m_doc->m_Selection->delaySignalsOn();
+		if (m_doc->m_Selection->containsItem(currItem))
+		{
+			m_doc->m_Selection->removeItem(currItem);
+		}
+		else
+		{
+			//CB: If we have a selection but the user clicks with control on another item that is not below the current
+			//then clear and select the new item
+			if ((m->modifiers() == SELECT_BENEATH) && m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem) >= 0)
+				m_doc->m_Selection->clear();
+			//CB: #7186: This was prependItem, does not seem to need to be anymore with current select code
+			m_doc->m_Selection->addItem(currItem);
+			if ( (m->modifiers() & SELECT_IN_GROUP) && (!currItem->isGroup()))
+			{
+				currItem->isSingleSel = true;
+			}
+		}
+		m_canvas->update();
+		m_doc->m_Selection->delaySignalsOff();
+		if (m_doc->m_Selection->count() > 1)
+		{
+			double x, y, w, h;
+			m_doc->m_Selection->getGroupRect(&x, &y, &w, &h);
+			m_view->getGroupRectScreen(&x, &y, &w, &h);
+		}
+		if (m_doc->m_Selection->count() == 1)
+		{
+			frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
+			if ((frameResizeHandle == Canvas::INSIDE) && (!currItem->locked()))
+				m_view->setCursor(QCursor(Qt::SizeAllCursor));
+		}
+		else
+		{
+			m_view->setCursor(QCursor(Qt::SizeAllCursor));
+			m_canvas->m_viewMode.operItemResizing = false;
+		}
+		return true;
+	}
+	m_doc->m_Selection->connectItemToGUI();
+	if ( !(m->modifiers() & SELECT_MULTIPLE))
+		m_view->deselectItems(true);
+	return false;
+}
+
+void CanvasMode_Edit::createContextMenu(PageItem* currItem, double mx, double my)
+{
+	ContextMenu* cmen = nullptr;
+	m_view->setCursor(QCursor(Qt::ArrowCursor));
+	m_view->setObjectUndoMode();
+	Mxp = mx;
+	Myp = my;
+	if (currItem != nullptr)
+		cmen = new ContextMenu(*(m_doc->m_Selection), m_ScMW, m_doc);
+	else
+		cmen = new ContextMenu(m_ScMW, m_doc, mx, my);
+	if (cmen)
+		cmen->exec(QCursor::pos());
+	m_view->setGlobalUndoMode();
+	delete cmen;
+}
diff --git a/scribus/canvasmode_normal.cpp b/scribus/canvasmode_normal.cpp
index 35f5713f5..fa0365776 100644
--- a/scribus/canvasmode_normal.cpp
+++ b/scribus/canvasmode_normal.cpp
@@ -551,7 +551,7 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
 							gw = fabs(startPoint.x() - endPoint.x());
 							gh = fabs(startPoint.y() - endPoint.y());
 						}
-						if (m_doc->SnapGuides)
+						if (m_doc->guidesPrefs().guidesSnapping)
 						{
 							double nx = gx + m_objectDeltaPos.x();
 							double ny = gy + m_objectDeltaPos.y();
@@ -570,7 +570,7 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
 								m_objectDeltaPos += FPoint(nx - nxo, ny - nyo);
 							}
 						}
-						if (m_doc->SnapElement)
+						if (m_doc->guidesPrefs().elementsSnapping)
 						{
 							xSnap = 0;
 							ySnap = 0;
@@ -594,7 +594,7 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
 									xSnap = nx;
 							}
 						}
-						if (m_doc->SnapGrid)
+						if (m_doc->guidesPrefs().gridSnapping)
 						{
 							double gx, gy, gh, gw, gxo, gyo;
 							m_doc->m_Selection->getVisualGroupRect(&gx, &gy, &gw, &gh);
@@ -627,7 +627,7 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
 						dY += m_dragConstrainInitPtY-qRound(gy);
 					}
 					m_objectDeltaPos.setXY(dX, dY);
-					if (m_doc->SnapGuides)
+					if (m_doc->guidesPrefs().guidesSnapping)
 					{
 						double nx = gx + m_objectDeltaPos.x();
 						double ny = gy + m_objectDeltaPos.y();
@@ -646,7 +646,7 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
 							m_objectDeltaPos += FPoint(nx-nxo, ny-nyo);
 						}
 					}
-					if (m_doc->SnapElement)
+					if (m_doc->guidesPrefs().elementsSnapping)
 					{
 						xSnap = 0;
 						ySnap = 0;
@@ -670,7 +670,7 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
 								xSnap = nx;
 						}
 					}
-					if (m_doc->SnapGrid)
+					if (m_doc->guidesPrefs().gridSnapping)
 					{
 						double gx, gy, gh, gw, gxo, gyo;
 						m_doc->m_Selection->getVisualGroupRect(&gx, &gy, &gw, &gh);
@@ -1053,7 +1053,7 @@ void CanvasMode_Normal::mouseReleaseEvent(QMouseEvent *m)
 			{
 				currItem = m_doc->m_Selection->itemAt(0);
 				m_doc->moveItem(m_objectDeltaPos.x(), m_objectDeltaPos.y(), currItem);
-				if (m_doc->SnapGrid)
+				if (m_doc->guidesPrefs().gridSnapping)
 				{
 					double nx = currItem->xPos();
 					double ny = currItem->yPos();
@@ -1824,12 +1824,7 @@ void CanvasMode_Normal::importToPage()
 		PrefsManager::instance().prefsFile->getContext("dirs")->set("pastefile", fileName.left(fileName.lastIndexOf("/")));
 		m_doc->setLoading(true);
 		QFileInfo fi(fileName);
-		bool savedAlignGrid = m_doc->SnapGrid;
-		bool savedAlignGuides = m_doc->SnapGuides;
-		bool savedAlignElement = m_doc->SnapElement;
-		m_doc->SnapElement = false;
-		m_doc->SnapGrid = false;
-		m_doc->SnapGuides = false;
+		const auto snappingStash = m_doc->disableSnapping();
 		if (fi.suffix().toLower() == "sce")
 			m_ScMW->slotElemRead(fileName, pastePoint.x(), pastePoint.y(), true, false, m_doc, m_doc->view());
 		else
@@ -1870,9 +1865,7 @@ void CanvasMode_Normal::importToPage()
 			m_doc->moveGroup(pastePoint.x() - x2, pastePoint.y() - y2);
 			m_ScMW->requestUpdate(reqColorsUpdate | reqSymbolsUpdate | reqLineStylesUpdate | reqTextStylesUpdate);
 		}
-		m_doc->SnapGrid = savedAlignGrid;
-		m_doc->SnapGuides = savedAlignGuides;
-		m_doc->SnapElement = savedAlignElement;
+		m_doc->restoreSnapping(snappingStash);
 		m_doc->setLoading(false);
 		m_doc->view()->DrawNew();
 		if (m_doc->m_Selection->count() > 0)
diff --git a/scribus/fileloader.cpp b/scribus/fileloader.cpp
index e76ca686b..f511edf1c 100644
--- a/scribus/fileloader.cpp
+++ b/scribus/fileloader.cpp
@@ -209,9 +209,14 @@ bool FileLoader::loadFile(ScribusDoc* currDoc)
 	currDoc->guidesPrefs().layerMarkersShown = m_prefsManager.appPrefs.guidesPrefs.layerMarkersShown;
 	currDoc->guidesPrefs().gridShown = m_prefsManager.appPrefs.guidesPrefs.gridShown;
 	currDoc->guidesPrefs().guidesShown = m_prefsManager.appPrefs.guidesPrefs.guidesShown;
+
+	currDoc->guidesPrefs().guidesSnapping = m_prefsManager.appPrefs.guidesPrefs.guidesSnapping;
+	currDoc->guidesPrefs().gridSnapping = m_prefsManager.appPrefs.guidesPrefs.gridSnapping;
+	currDoc->guidesPrefs().elementsSnapping = m_prefsManager.appPrefs.guidesPrefs.elementsSnapping;
 	currDoc->guidesPrefs().colBordersShown = m_prefsManager.appPrefs.guidesPrefs.colBordersShown;
 	currDoc->guidesPrefs().baselineGridShown = m_prefsManager.appPrefs.guidesPrefs.baselineGridShown;
 	currDoc->guidesPrefs().linkShown = m_prefsManager.appPrefs.guidesPrefs.linkShown;
+
 	currDoc->itemToolPrefs().polyCorners = m_prefsManager.appPrefs.itemToolPrefs.polyCorners;
 	currDoc->itemToolPrefs().polyFactor = m_prefsManager.appPrefs.itemToolPrefs.polyFactor;
 	currDoc->itemToolPrefs().polyRotation = m_prefsManager.appPrefs.itemToolPrefs.polyRotation;
diff --git a/scribus/pageitem.cpp b/scribus/pageitem.cpp
index 7cddb5f91..18c8fe36b 100644
--- a/scribus/pageitem.cpp
+++ b/scribus/pageitem.cpp
@@ -4832,12 +4832,7 @@ void PageItem::restore(UndoState *state, bool isUndo)
 		return;
 	}
 
-	bool SnapGridBackup = m_Doc->SnapGrid;
-	bool SnapGuidesBackup = m_Doc->SnapGuides;
-	bool SnapElementBackup = m_Doc->SnapElement;
-	m_Doc->SnapElement = false;
-	m_Doc->SnapGrid = false;
-	m_Doc->SnapGuides = false;
+	const auto snappingStash = m_Doc->disableSnapping();
 	bool oldMPMode = m_Doc->masterPageMode();
 	m_Doc->setMasterPageMode(!OnMasterPage.isEmpty());
 	ScPage *oldCurrentPage = m_Doc->currentPage();
@@ -5097,9 +5092,7 @@ void PageItem::restore(UndoState *state, bool isUndo)
 	if (!OnMasterPage.isEmpty())
 		m_Doc->setCurrentPage(oldCurrentPage);
 	m_Doc->setMasterPageMode(oldMPMode);
-	m_Doc->SnapElement = SnapElementBackup;
-	m_Doc->SnapGrid = SnapGridBackup;
-	m_Doc->SnapGuides = SnapGuidesBackup;
+	m_Doc->restoreSnapping(snappingStash);
 	if (state->transactionCode == 0 || state->transactionCode == 2)
 		this->update();
 }
diff --git a/scribus/plugins/fileloader/scribus12format/scribus12format.cpp b/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
index b7a6620ad..83b9f999e 100644
--- a/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
+++ b/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
@@ -906,8 +906,8 @@ bool Scribus12Format::loadFile(const QString& fileName, const FileFormat & /* fm
 		m_Doc->setHyphAutomatic(static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt()));
 		m_Doc->setHyphAutoCheck(static_cast<bool>(dc.attribute("AUTOCHECK", "0").toInt()));
 		m_Doc->GuideLock = static_cast<bool>(dc.attribute("GUIDELOCK", "0").toInt());
-		m_Doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt());
-		m_Doc->SnapGrid  = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt());
+		m_Doc->guidesPrefs().gridSnapping = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt());
+		m_Doc->guidesPrefs().guidesSnapping = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt());
 		m_Doc->guidesPrefs().minorGridSpacing = ScCLocale::toDoubleC(dc.attribute("MINGRID"), prefsManager.appPrefs.guidesPrefs.minorGridSpacing);
 		m_Doc->guidesPrefs().majorGridSpacing = ScCLocale::toDoubleC(dc.attribute("MAJGRID"), prefsManager.appPrefs.guidesPrefs.majorGridSpacing);
 		m_Doc->itemToolPrefs().lineStartArrow = 0;
diff --git a/scribus/plugins/fileloader/scribus134format/scribus134format.cpp b/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
index 64b0448ca..a9e0d424b 100644
--- a/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
+++ b/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
@@ -940,8 +940,8 @@ void Scribus134Format::readDocAttributes(ScribusDoc* doc, ScXmlStreamAttributes&
 	
 	m_Doc->rulerXoffset = attrs.valueAsDouble("rulerXoffset", 0.0);
 	m_Doc->rulerYoffset = attrs.valueAsDouble("rulerYoffset", 0.0);
-	m_Doc->SnapGuides   = attrs.valueAsBool("SnapToGuides", false);
-	m_Doc->SnapGrid     = attrs.valueAsBool("SnapToGrid", false);
+	m_Doc->guidesPrefs().gridSnapping = attrs.valueAsBool("SnapToGrid", false);
+	m_Doc->guidesPrefs().guidesSnapping = attrs.valueAsBool("SnapToGuides", false);
 	
 	m_Doc->setAutoSave(attrs.valueAsBool("AutoSave", false));
 	m_Doc->setAutoSaveTime(attrs.valueAsInt("AutoSaveTime", 600000));
@@ -2210,11 +2210,8 @@ bool Scribus134Format::readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, c
 	pat.yoffset = attrs.valueAsDouble("yoffset", 0.0);
 	
 	uint itemCount1 = m_Doc->Items->count();
-	bool savedAlignGrid = m_Doc->SnapGrid;
-	bool savedAlignGuides = m_Doc->SnapGuides;
+	const auto snappingStash = m_Doc->disableSnapping();
 	bool savedMasterPageMode = m_Doc->masterPageMode();
-	m_Doc->SnapGrid  = false;
-	m_Doc->SnapGuides = false;
 
 	QString tagName = reader.nameAsString();
 	while (!reader.atEnd() && !reader.hasError())
@@ -2263,8 +2260,7 @@ bool Scribus134Format::readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, c
 		}
 	}
 
-	doc->SnapGrid   = savedAlignGrid;
-	doc->SnapGuides = savedAlignGuides;
+	doc->restoreSnapping(snappingStash);
 	if (!success)
 	{
 		doc->setMasterPageMode(savedMasterPageMode);
diff --git a/scribus/plugins/fileloader/scribus13format/scribus13format.cpp b/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
index c9a9171b1..cb76631c7 100644
--- a/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
+++ b/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
@@ -385,8 +385,8 @@ bool Scribus13Format::loadFile(const QString & fileName, const FileFormat & /* f
 		m_Doc->guidesPrefs().rulersShown = static_cast<bool>(dc.attribute("showrulers", "1").toInt());
 		m_Doc->rulerXoffset = ScCLocale::toDoubleC(dc.attribute("rulerXoffset"), 0.0);
 		m_Doc->rulerYoffset = ScCLocale::toDoubleC(dc.attribute("rulerYoffset"), 0.0);
-		m_Doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt());
-		m_Doc->SnapGrid  = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt());
+		m_Doc->guidesPrefs().guidesSnapping = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt());
+		m_Doc->guidesPrefs().gridSnapping = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt());
 		m_Doc->itemToolPrefs().polyCorners = dc.attribute("POLYC", "4").toInt();
 		m_Doc->itemToolPrefs().polyFactor = ScCLocale::toDoubleC(dc.attribute("POLYF"), 0.5);
 		m_Doc->itemToolPrefs().polyRotation = ScCLocale::toDoubleC(dc.attribute("POLYR"), 0.0);
diff --git a/scribus/plugins/fileloader/scribus150format/scribus150format.cpp b/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
index 58c3ee80f..8a51b9284 100644
--- a/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
+++ b/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
@@ -2462,9 +2462,9 @@ void Scribus150Format::readDocAttributes(ScribusDoc* doc, const ScXmlStreamAttri
 
 	m_Doc->rulerXoffset = attrs.valueAsDouble("rulerXoffset", 0.0);
 	m_Doc->rulerYoffset = attrs.valueAsDouble("rulerYoffset", 0.0);
-	m_Doc->SnapGuides   = attrs.valueAsBool("SnapToGuides", false);
-	m_Doc->SnapElement  = attrs.valueAsBool("SnapToElement", false);
-	m_Doc->SnapGrid     = attrs.valueAsBool("SnapToGrid", false);
+	m_Doc->guidesPrefs().gridSnapping = attrs.valueAsBool("SnapToGrid", false);
+	m_Doc->guidesPrefs().guidesSnapping = attrs.valueAsBool("SnapToGuides", false);
+	m_Doc->guidesPrefs().elementsSnapping = attrs.valueAsBool("SnapToElement", false);
 
 	m_Doc->setAutoSave(attrs.valueAsBool("AutoSave", false));
 	m_Doc->setAutoSaveTime(attrs.valueAsInt("AutoSaveTime", 600000));
@@ -4616,13 +4616,8 @@ bool Scribus150Format::readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, c
 	readObjectParams.itemKind = PageItem::PatternItem;
 	readObjectParams.loadingPage = false;
 
-	bool savedAlignGrid = m_Doc->SnapGrid;
-	bool savedAlignGuides = m_Doc->SnapGuides;
-	bool savedAlignElement = m_Doc->SnapElement;
+	const auto snappingStash = m_Doc->disableSnapping();
 	bool savedMasterPageMode = m_Doc->masterPageMode();
-	m_Doc->SnapGrid  = false;
-	m_Doc->SnapGuides = false;
-	m_Doc->SnapElement = false;
 
 	m_Doc->setMasterPageMode(false);
 	int itemCount1 = m_Doc->Items->count();
@@ -4685,9 +4680,7 @@ bool Scribus150Format::readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, c
 		}
 	}
 
-	doc->SnapGrid   = savedAlignGrid;
-	doc->SnapGuides = savedAlignGuides;
-	doc->SnapElement = savedAlignElement;
+	doc->restoreSnapping(snappingStash);
 	if (!success)
 	{
 		doc->setMasterPageMode(savedMasterPageMode);
diff --git a/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp b/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
index 9a029ec25..ad0a4a059 100644
--- a/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
+++ b/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
@@ -406,9 +406,9 @@ bool Scribus150Format::saveFile(const QString & fileName, const FileFormat & /*
 	docu.writeAttribute("AUTOMATIC", static_cast<int>(m_Doc->hyphAutomatic()));
 	docu.writeAttribute("AUTOCHECK", static_cast<int>(m_Doc->hyphAutoCheck()));
 	docu.writeAttribute("GUIDELOCK", static_cast<int>(m_Doc->GuideLock));
-	docu.writeAttribute("SnapToGuides", static_cast<int>(m_Doc->SnapGuides));
-	docu.writeAttribute("SnapToGrid", static_cast<int>(m_Doc->SnapGrid));
-	docu.writeAttribute("SnapToElement", static_cast<int>(m_Doc->SnapElement));
+	docu.writeAttribute("SnapToGuides", static_cast<int>(m_Doc->guidesPrefs().guidesSnapping));
+	docu.writeAttribute("SnapToGrid", static_cast<int>(m_Doc->guidesPrefs().gridSnapping));
+	docu.writeAttribute("SnapToElement", static_cast<int>(m_Doc->guidesPrefs().elementsSnapping));
 	docu.writeAttribute("MINGRID", m_Doc->guidesPrefs().minorGridSpacing);
 	docu.writeAttribute("MAJGRID", m_Doc->guidesPrefs().majorGridSpacing);
 	docu.writeAttribute("SHOWGRID", static_cast<int>(m_Doc->guidesPrefs().gridShown));
diff --git a/scribus/plugins/fileloader/scribus170format/scribus170format.cpp b/scribus/plugins/fileloader/scribus170format/scribus170format.cpp
index 6e5b01600..71b196f83 100644
--- a/scribus/plugins/fileloader/scribus170format/scribus170format.cpp
+++ b/scribus/plugins/fileloader/scribus170format/scribus170format.cpp
@@ -2468,9 +2468,10 @@ void Scribus170Format::readDocAttributes(ScribusDoc* doc, const ScXmlStreamAttri
 
 	m_Doc->rulerXoffset = attrs.valueAsDouble("rulerXoffset", 0.0);
 	m_Doc->rulerYoffset = attrs.valueAsDouble("rulerYoffset", 0.0);
-	m_Doc->SnapGuides   = attrs.valueAsBool("SnapToGuides", false);
-	m_Doc->SnapElement  = attrs.valueAsBool("SnapToElement", false);
-	m_Doc->SnapGrid     = attrs.valueAsBool("SnapToGrid", false);
+
+	m_Doc->guidesPrefs().gridSnapping = attrs.valueAsBool("SnapToGrid", false);
+	m_Doc->guidesPrefs().guidesSnapping = attrs.valueAsBool("SnapToGuides", false);
+	m_Doc->guidesPrefs().elementsSnapping = attrs.valueAsBool("SnapToElement", false);
 
 	m_Doc->setAutoSave(attrs.valueAsBool("AutoSave", false));
 	m_Doc->setAutoSaveTime(attrs.valueAsInt("AutoSaveTime", 600000));
@@ -4764,13 +4765,8 @@ bool Scribus170Format::readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, c
 	readObjectParams.itemKind = PageItem::PatternItem;
 	readObjectParams.loadingPage = false;
 
-	bool savedAlignGrid = m_Doc->SnapGrid;
-	bool savedAlignGuides = m_Doc->SnapGuides;
-	bool savedAlignElement = m_Doc->SnapElement;
 	bool savedMasterPageMode = m_Doc->masterPageMode();
-	m_Doc->SnapGrid  = false;
-	m_Doc->SnapGuides = false;
-	m_Doc->SnapElement = false;
+	const auto snappingStash = m_Doc->disableSnapping();
 
 	m_Doc->setMasterPageMode(false);
 	int itemCount1 = m_Doc->Items->count();
@@ -4833,9 +4829,7 @@ bool Scribus170Format::readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, c
 		}
 	}
 
-	doc->SnapGrid   = savedAlignGrid;
-	doc->SnapGuides = savedAlignGuides;
-	doc->SnapElement = savedAlignElement;
+	doc->restoreSnapping(snappingStash);
 	if (!success)
 	{
 		doc->setMasterPageMode(savedMasterPageMode);
diff --git a/scribus/plugins/fileloader/scribus170format/scribus170format_save.cpp b/scribus/plugins/fileloader/scribus170format/scribus170format_save.cpp
index 5e02269a0..dd4b202a4 100644
--- a/scribus/plugins/fileloader/scribus170format/scribus170format_save.cpp
+++ b/scribus/plugins/fileloader/scribus170format/scribus170format_save.cpp
@@ -406,9 +406,9 @@ bool Scribus170Format::saveFile(const QString & fileName, const FileFormat & /*
 	docu.writeAttribute("AUTOMATIC", static_cast<int>(m_Doc->hyphAutomatic()));
 	docu.writeAttribute("AUTOCHECK", static_cast<int>(m_Doc->hyphAutoCheck()));
 	docu.writeAttribute("GUIDELOCK", static_cast<int>(m_Doc->GuideLock));
-	docu.writeAttribute("SnapToGuides", static_cast<int>(m_Doc->SnapGuides));
-	docu.writeAttribute("SnapToGrid", static_cast<int>(m_Doc->SnapGrid));
-	docu.writeAttribute("SnapToElement", static_cast<int>(m_Doc->SnapElement));
+	docu.writeAttribute("SnapToGuides", static_cast<int>(m_Doc->guidesPrefs().guidesSnapping));
+	docu.writeAttribute("SnapToGrid", static_cast<int>(m_Doc->guidesPrefs().gridSnapping));
+	docu.writeAttribute("SnapToElement", static_cast<int>(m_Doc->guidesPrefs().elementsSnapping));
 	docu.writeAttribute("MINGRID", m_Doc->guidesPrefs().minorGridSpacing);
 	docu.writeAttribute("MAJGRID", m_Doc->guidesPrefs().majorGridSpacing);
 	docu.writeAttribute("SHOWGRID", static_cast<int>(m_Doc->guidesPrefs().gridShown));
diff --git a/scribus/prefsmanager.cpp b/scribus/prefsmanager.cpp
index 13cd7af9e..d2e6632c4 100644
--- a/scribus/prefsmanager.cpp
+++ b/scribus/prefsmanager.cpp
@@ -204,6 +204,9 @@ void PrefsManager::initDefaults()
 	appPrefs.guidesPrefs.rulerMode = true;
 	appPrefs.guidesPrefs.grabRadius = 4;
 	appPrefs.guidesPrefs.guideRad = 10;
+	appPrefs.guidesPrefs.guidesSnapping = true;
+	appPrefs.guidesPrefs.gridSnapping = false;
+	appPrefs.guidesPrefs.elementsSnapping = false;
 	appPrefs.guidesPrefs.minorGridSpacing = 20;
 	appPrefs.guidesPrefs.majorGridSpacing = 100;
 	appPrefs.guidesPrefs.minorGridColor = QColor(Qt::green);
@@ -1425,6 +1428,9 @@ bool PrefsManager::writePref(const QString& filePath)
 	deGuides.setAttribute("MarginColor", appPrefs.guidesPrefs.marginColor.name());
 	deGuides.setAttribute("BaselineGridColor", appPrefs.guidesPrefs.baselineGridColor.name());
 	deGuides.setAttribute("ObjectToGuideSnapRadius", ScCLocale::toQStringC(appPrefs.guidesPrefs.guideRad));
+	deGuides.setAttribute("SnapGuides", static_cast<int>(appPrefs.guidesPrefs.guidesSnapping));
+	deGuides.setAttribute("SnapGrid", static_cast<int>(appPrefs.guidesPrefs.gridSnapping));
+	deGuides.setAttribute("SnapElement", static_cast<int>(appPrefs.guidesPrefs.elementsSnapping));
 	QString renderStack;
 	int renderStackCount = appPrefs.guidesPrefs.renderStackOrder.count();
 	for (int r = 0; r < renderStackCount; r++)
@@ -2181,6 +2187,12 @@ bool PrefsManager::readPref(const QString& filePath)
 				appPrefs.guidesPrefs.guideRad = ScCLocale::toDoubleC(dc.attribute("GuideZ"), 10.0);
 			if (dc.hasAttribute("ObjectToGuideSnapRadius"))
 				appPrefs.guidesPrefs.guideRad = ScCLocale::toDoubleC(dc.attribute("ObjectToGuideSnapRadius"), 10.0);
+			if (dc.hasAttribute("SnapGuides"))
+				appPrefs.guidesPrefs.guidesSnapping = static_cast<bool>(dc.attribute("SnapGuides", "1").toInt());
+			if (dc.hasAttribute("SnapGrid"))
+				appPrefs.guidesPrefs.gridSnapping = static_cast<bool>(dc.attribute("SnapGrid", "0").toInt());
+			if (dc.hasAttribute("SnapElement"))
+				appPrefs.guidesPrefs.elementsSnapping = static_cast<bool>(dc.attribute("SnapElement", "0").toInt());
 			if (dc.hasAttribute("BaseC")) // legacy < 1.7.x
 				appPrefs.guidesPrefs.baselineGridColor = QColor(dc.attribute("BaseC", "#c0c0c0"));
 			if (dc.hasAttribute("BaselineGridColor"))
diff --git a/scribus/prefsstructs.h b/scribus/prefsstructs.h
index 9e8d23c89..a9f36d912 100644
--- a/scribus/prefsstructs.h
+++ b/scribus/prefsstructs.h
@@ -199,6 +199,10 @@ struct GuidesPrefs
 	double valueBaselineGrid; //! Baseline grid spacing
 	double offsetBaselineGrid; //! Offset of first line of baseline grid from top of page
 
+	bool guidesSnapping;
+	bool gridSnapping;
+	bool elementsSnapping;
+
 	bool showPic;
 	bool showControls;
 	bool showBleed;
diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
index 72a42b959..b9d04b04d 100644
--- a/scribus/scribus.cpp
+++ b/scribus/scribus.cpp
@@ -1,6 +1,6 @@
 /*
 For general Scribus (>=1.3.2) copyright and licensing information please refer
-to the COPYING file provided with the program. Following this notice may exist
+// to the COPYING file provided with the program. Following this notice may exist
 a copyright and/or license notice that predates the release of Scribus 1.3.2
 for which a new license (GPL+exception) is in place.
 */
@@ -1225,9 +1225,9 @@ void ScribusMainWindow::initMenuBar()
 	scrMenuMgr->addMenuItemString("pageManageGuides", "Page");
 	scrMenuMgr->addMenuItemString("pageManageProperties", "Page");
 	scrMenuMgr->addMenuItemString("SEPARATOR", "Page");
-	scrMenuMgr->addMenuItemString("viewSnapToGrid", "Page");
-	scrMenuMgr->addMenuItemString("viewSnapToGuides", "Page");
-	scrMenuMgr->addMenuItemString("viewSnapToElements", "Page");
+	scrMenuMgr->addMenuItemString("pageSnapToGrid", "Page");
+	scrMenuMgr->addMenuItemString("pageSnapToGuides", "Page");
+	scrMenuMgr->addMenuItemString("pageSnapToElements", "Page");
 
 	//View menu
 	scrMenuMgr->createMenu("View", ActionManager::defaultMenuNameEntryTranslated("View"));
@@ -2973,19 +2973,12 @@ void ScribusMainWindow::doPasteRecent(const QString& data)
 			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;
-		bool savedAlignGuides = doc->SnapGuides;
-		bool savedAlignElement = doc->SnapElement;
-		doc->SnapGrid = false;
-		doc->SnapGuides = false;
-		doc->SnapElement = false;
+		const auto snappingStash = doc->disableSnapping();
 		if ((view->dragX == 0.0) && (view->dragY == 0.0))
 			slotElemRead(data, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), true, true, doc, view);
 		else
 			slotElemRead(data, view->dragX, view->dragY, true, false, doc, view);
-		doc->SnapGrid = savedAlignGrid;
-		doc->SnapGuides = savedAlignGuides;
-		doc->SnapElement = savedAlignElement;
+		doc->restoreSnapping(snappingStash);
 		Selection tmpSelection(this, false);
 		tmpSelection.copy(*doc->m_Selection, true);
 		for (int i = docItemCount; i < doc->Items->count(); ++i)
@@ -4663,26 +4656,19 @@ void ScribusMainWindow::slotEditPaste()
 		}
 		else if (ScMimeData::clipboardHasScribusElem() || ScMimeData::clipboardHasScribusFragment())
 		{
-			bool savedAlignGrid = doc->SnapGrid;
-			bool savedAlignGuides = doc->SnapGuides;
-			bool savedAlignElement = doc->SnapElement;
 			int ac = doc->Items->count();
 			bool isGroup = false;
 			double gx, gy, gh, gw;
 			FPoint minSize = doc->minCanvasCoordinate;
 			FPoint maxSize = doc->maxCanvasCoordinate;
-			doc->SnapGrid = false;
-			doc->SnapGuides = false;
-			doc->SnapElement = false;
+			const auto snappingStash = doc->disableSnapping();
 			// HACK #6541 : undo does not handle text modification => do not record embedded item creation
 			// if embedded item is deleted, undo system will not be aware of its deletion => crash - JG
 			m_undoManager->setUndoEnabled(false);
 			QString buffer  = ScMimeData::clipboardScribusElem();
 			slotElemRead(buffer, 0, 0, false, true, doc, view);
 
-			doc->SnapGrid = savedAlignGrid;
-			doc->SnapGuides = savedAlignGuides;
-			doc->SnapElement = savedAlignElement;
+			doc->restoreSnapping(snappingStash);
 			Selection tempSelection(*doc->m_Selection);
 			doc->m_Selection->clear();
 			if (doc->Items->count() - ac > 1)
@@ -4729,14 +4715,9 @@ void ScribusMainWindow::slotEditPaste()
 		}
 		else if (ScMimeData::clipboardHasKnownData())
 		{
-			bool savedAlignGrid = doc->SnapGrid;
-			bool savedAlignGuides = doc->SnapGuides;
-			bool savedAlignElement = doc->SnapElement;
 			FPoint minSize = doc->minCanvasCoordinate;
 			FPoint maxSize = doc->maxCanvasCoordinate;
-			doc->SnapGrid = false;
-			doc->SnapGuides = false;
-			doc->SnapElement = false;
+			const auto snappingStash = doc->disableSnapping();
 			QString ext = ScMimeData::clipboardKnownDataExt();
 			QByteArray bitsBits = ScMimeData::clipboardKnownDataData();
 			double x0 = (view->contentsX() / view->scale()) + ((view->visibleWidth() / 2.0) / view->scale());
@@ -4748,9 +4729,8 @@ void ScribusMainWindow::slotEditPaste()
 				double y = (view->contentsY() / view->scale()) + ((view->visibleHeight() / 2.0) / view->scale()) - (retObj->height() / 2.0);
 				retObj->setTextFlowMode(PageItem::TextFlowUsesBoundingBox);
 				retObj->setXYPos(x, y, true);
-				doc->SnapGrid = savedAlignGrid;
-				doc->SnapGuides = savedAlignGuides;
-				doc->SnapElement = savedAlignElement;
+				// TODO: stash is not restored if retObj is nullptr!
+				doc->restoreSnapping(snappingStash);
 				Selection tempSelection(*doc->m_Selection);
 				doc->m_Selection->clear();
 				doc->m_Selection->delaySignalsOn();
@@ -4812,12 +4792,7 @@ void ScribusMainWindow::slotEditPaste()
 	{
 		view->deselectItems(true);
 		int docItemCount = doc->Items->count();
-		bool savedAlignGrid = doc->SnapGrid;
-		bool savedAlignGuides = doc->SnapGuides;
-		bool savedAlignElement = doc->SnapElement;
-		doc->SnapGrid = false;
-		doc->SnapGuides = false;
-		doc->SnapElement = false;
+		const auto snappingStash = doc->disableSnapping();
 		if (internalCopy)
 			slotElemRead(internalCopyBuffer, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
 		else
@@ -4826,9 +4801,7 @@ void ScribusMainWindow::slotEditPaste()
 			slotElemRead(buffer, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
 		}
 
-		doc->SnapGrid = savedAlignGrid;
-		doc->SnapGuides = savedAlignGuides;
-		doc->SnapElement = savedAlignElement;
+		doc->restoreSnapping(snappingStash);
 		doc->m_Selection->delaySignalsOn();
 		for (int i = docItemCount; i < doc->Items->count(); ++i)
 		{
@@ -5774,15 +5747,16 @@ void ScribusMainWindow::toggleSnapGrid()
 {
 	if (!doc)
 		return;
-	doc->SnapGrid = !doc->SnapGrid;
+	doc->guidesPrefs().gridSnapping = !doc->guidesPrefs().gridSnapping;
 	slotDocCh();
 }
 
 void ScribusMainWindow::toggleSnapGuides()
 {
+    // TODO: disable the menu entry when no doc
 	if (!doc)
 		return;
-	doc->SnapGuides = !doc->SnapGuides;
+	doc->guidesPrefs().guidesSnapping = !doc->guidesPrefs().guidesSnapping;
 	slotDocCh();
 }
 
@@ -5790,13 +5764,13 @@ void ScribusMainWindow::toggleSnapElements()
 {
 	if (!doc)
 		return;
-	doc->SnapElement = !doc->SnapElement;
+	doc->guidesPrefs().elementsSnapping = !doc->guidesPrefs().elementsSnapping;
 	slotDocCh();
 }
 
 void ScribusMainWindow::SetSnapElements(bool b)
 {
-	if (doc && doc->SnapElement != b)
+	if (doc && doc->guidesPrefs().elementsSnapping != b)
 		toggleSnapElements();
 }
 
@@ -8908,22 +8882,15 @@ void ScribusMainWindow::PutToInline(const QString& buffer)
 	if (!HaveDoc)
 		return;
 	Selection tempSelection(*doc->m_Selection);
-	bool savedAlignGrid = doc->SnapGrid;
-	bool savedAlignGuides = doc->SnapGuides;
-	bool savedAlignElement = doc->SnapElement;
 	int ac = doc->Items->count();
 	bool isGroup = false;
 	double gx, gy, gh, gw;
 	FPoint minSize = doc->minCanvasCoordinate;
 	FPoint maxSize = doc->maxCanvasCoordinate;
-	doc->SnapGrid  = false;
-	doc->SnapGuides = false;
-	doc->SnapElement = false;
+	const auto snappingStash = doc->disableSnapping();
 	m_undoManager->setUndoEnabled(false);
 	slotElemRead(buffer, 0, 0, false, true, doc, view);
-	doc->SnapGrid  = savedAlignGrid;
-	doc->SnapGuides = savedAlignGuides;
-	doc->SnapElement = savedAlignElement;
+	doc->restoreSnapping(snappingStash);
 	doc->m_Selection->clear();
 	if (doc->Items->count() - ac > 1)
 		isGroup = true;
@@ -8967,25 +8934,18 @@ void ScribusMainWindow::PutToInline()
 	if (!HaveDoc)
 		return;
 	Selection tempSelection(*doc->m_Selection);
-	bool savedAlignGrid = doc->SnapGrid;
-	bool savedAlignGuides = doc->SnapGuides;
-	bool savedAlignElement = doc->SnapElement;
 	int ac = doc->Items->count();
 	bool isGroup = false;
 	double gx, gy, gh, gw;
 	FPoint minSize = doc->minCanvasCoordinate;
 	FPoint maxSize = doc->maxCanvasCoordinate;
-	doc->SnapGrid  = false;
-	doc->SnapGuides = false;
-	doc->SnapElement = false;
+	const auto snappingStash = doc->disableSnapping();
 	m_undoManager->setUndoEnabled(false);
 	internalCopy = true;
 	slotEditCopy();
 	slotElemRead(internalCopyBuffer, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
 	internalCopy = false;
-	doc->SnapGrid  = savedAlignGrid;
-	doc->SnapGuides = savedAlignGuides;
-	doc->SnapElement = savedAlignElement;
+	doc->restoreSnapping(snappingStash);
 	doc->m_Selection->clear();
 	if (doc->Items->count() - ac > 1)
 		isGroup = true;
@@ -9033,23 +8993,16 @@ void ScribusMainWindow::PutToPatterns()
 	patternName = patternName.trimmed().simplified().replace(" ", "_");
 	patternName = doc->getUniquePatternName(patternName);
 
-	bool savedAlignGrid = doc->SnapGrid;
-	bool savedAlignGuides = doc->SnapGuides;
-	bool savedAlignElement = doc->SnapElement;
 	int ac = doc->Items->count();
 	FPoint minSize = doc->minCanvasCoordinate;
 	FPoint maxSize = doc->maxCanvasCoordinate;
-	doc->SnapGrid  = false;
-	doc->SnapGuides = false;
-	doc->SnapElement = false;
+	const auto snappingStash = doc->disableSnapping();
 	m_undoManager->setUndoEnabled(false);
 	internalCopy = true;
 	slotEditCopy();
 	slotElemRead(internalCopyBuffer, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
 	internalCopy = false;
-	doc->SnapGrid  = savedAlignGrid;
-	doc->SnapGuides = savedAlignGuides;
-	doc->SnapElement = savedAlignElement;
+	doc->restoreSnapping(snappingStash);
 	doc->m_Selection->clear();
 	view->deselectItems(true);
 	PageItem* currItem;
diff --git a/scribus/scribusdoc.cpp b/scribus/scribusdoc.cpp
index d001330b4..942ee0a34 100644
--- a/scribus/scribusdoc.cpp
+++ b/scribus/scribusdoc.cpp
@@ -2495,6 +2495,24 @@ void ScribusDoc::addSymbols()
 	symNewFrame.addQuadPoint(1.67188, 6.0625, 1.67188, 6.0625, 1.75, 6.20312, 1.75, 6.20312);
 }
 
+std::bitset<3> ScribusDoc::disableSnapping()
+{
+	std::bitset<3> stash;
+	stash[0] = m_docPrefsData.guidesPrefs.guidesSnapping;
+	stash[1] = m_docPrefsData.guidesPrefs.gridSnapping;
+	stash[2] = m_docPrefsData.guidesPrefs.elementsSnapping;
+	m_docPrefsData.guidesPrefs.guidesSnapping = false;
+	m_docPrefsData.guidesPrefs.gridSnapping = false;
+	m_docPrefsData.guidesPrefs.elementsSnapping = false;
+	return stash;
+}
+
+void ScribusDoc::restoreSnapping(std::bitset<3> stash)
+{
+	m_docPrefsData.guidesPrefs.guidesSnapping = stash.test(0);
+	m_docPrefsData.guidesPrefs.gridSnapping = stash.test(1);
+	m_docPrefsData.guidesPrefs.elementsSnapping = stash.test(2);
+}
 
 ScPage* ScribusDoc::addPage(int pageNumber, const QString& masterPageName, bool addAutoFrame)
 {
@@ -7207,12 +7225,7 @@ void ScribusDoc::copyPage(int pageNumberToCopy, int existingPage, int whereToIns
 			if (Layers.count() != 0)
 			{
 				int currActiveLayer = activeLayer();
-				bool savedAlignGrid   = this->SnapGrid;
-				bool savedAlignGuides = this->SnapGuides;
-				bool savedAlignElement = this->SnapElement;
-				this->SnapGrid   = false;
-				this->SnapGuides = false;
-				this->SnapElement = false;
+				const auto snappingStash = disableSnapping();
 				for (auto it = Layers.begin(); it != Layers.end(); ++it)
 				{
 					if ((lcount < itemBuffer.count()) && !itemBuffer[lcount].isEmpty())
@@ -7223,9 +7236,7 @@ void ScribusDoc::copyPage(int pageNumberToCopy, int existingPage, int whereToIns
 					}
 					lcount++;
 				}
-				this->SnapGrid   = savedAlignGrid;
-				this->SnapGuides = savedAlignGuides;
-				this->SnapElement = savedAlignElement;
+				restoreSnapping(snappingStash);
 				setActiveLayer(currActiveLayer);
 			}
 		}
@@ -10792,12 +10803,7 @@ void ScribusDoc::itemSelection_Transform(int nrOfCopies, const QTransform& matri
 	else
 	{
 		QList<PageItem*> Elements;
-		bool savedAlignGrid = SnapGrid;
-		bool savedAlignGuides = SnapGuides;
-		bool savedAlignElement = SnapElement;
-		SnapGrid  = false;
-		SnapGuides = false;
-		SnapElement = false;
+		const auto snappingStash = disableSnapping();
 		DoDrawing = false;
 		view()->updatesOn(false);
 		m_Selection->delaySignalsOn();
@@ -10917,9 +10923,7 @@ void ScribusDoc::itemSelection_Transform(int nrOfCopies, const QTransform& matri
 		}
 		m_Selection->setGroupRect();
 		setRotationMode (rotBack);
-		SnapGrid  = savedAlignGrid;
-		SnapGuides = savedAlignGuides;
-		SnapElement = savedAlignElement;
+		restoreSnapping(snappingStash);
 		DoDrawing = true;
 		m_Selection->delaySignalsOff();
 		view()->updatesOn(true);
@@ -13705,7 +13709,7 @@ void ScribusDoc::setCurrentPage(ScPage *newPage)
 QPoint ScribusDoc::ApplyGrid(const QPoint& in)
 {
 	int onp = OnPage(in.x(), in.y());
-	if (!SnapGrid || (onp == -1))
+	if (!m_docPrefsData.guidesPrefs.gridSnapping || (onp == -1))
 		return in;
 
 	QPoint np;
@@ -13721,7 +13725,7 @@ QPoint ScribusDoc::ApplyGrid(const QPoint& in)
 FPoint ScribusDoc::ApplyGridF(const FPoint& in)
 {
 	int onp = OnPage(in.x(), in.y());
-	if (!SnapGrid || (onp == -1))
+	if (!m_docPrefsData.guidesPrefs.gridSnapping || (onp == -1))
 		return in;
 
 	FPoint np;
@@ -13736,7 +13740,7 @@ FPoint ScribusDoc::ApplyGridF(const FPoint& in)
 QRectF ScribusDoc::ApplyGridF(const QRectF& in)
 {
 	QRectF nr(in);
-	if (!SnapGrid)
+	if (!m_docPrefsData.guidesPrefs.gridSnapping)
 		return nr;
 
 	bool   onPage = false;
@@ -13822,12 +13826,7 @@ void ScribusDoc::itemSelection_Duplicate(double shiftX, double shiftY, Selection
 	Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection;
 	assert(itemSelection != nullptr);
 
-	bool savedAlignGrid = this->SnapGrid;
-	bool savedAlignGuides = this->SnapGuides;
-	bool savedAlignElement = this->SnapElement;
-	this->SnapGrid  = false;
-	this->SnapGuides = false;
-	this->SnapElement = false;
+	const auto snappingStash = disableSnapping();
 
 	UndoTransaction trans;
 	if (UndoManager::undoEnabled())
@@ -13854,9 +13853,7 @@ void ScribusDoc::itemSelection_Duplicate(double shiftX, double shiftY, Selection
 	if (trans)
 		trans.commit();
 
-	this->SnapGrid  = savedAlignGrid;
-	this->SnapGuides = savedAlignGuides;
-	this->SnapElement = savedAlignElement;
+	restoreSnapping(snappingStash);
 
 	regionsChanged()->update(QRectF());
 }
@@ -14568,8 +14565,7 @@ bool ScribusDoc::ApplyGuides(double *x, double *y, bool elementSnap)
 		return ret;
 	const ScPage* page = Pages->at(pg);
 
-	//	if ((SnapGuides) && (m_SnapCounter > 1))
-	if ((SnapGuides && !elementSnap) || (SnapElement && elementSnap))
+	if ((m_docPrefsData.guidesPrefs.guidesSnapping && !elementSnap) || (m_docPrefsData.guidesPrefs.elementsSnapping && elementSnap))
 	{
 		if (!elementSnap)
 			getClosestGuides(*x, *y, &xout, &yout, page);
diff --git a/scribus/scribusdoc.h b/scribus/scribusdoc.h
index 49955ec29..5fa4b40eb 100644
--- a/scribus/scribusdoc.h
+++ b/scribus/scribusdoc.h
@@ -26,6 +26,7 @@ for which a new license (GPL+exception) is in place.
 #ifdef HAVE_CONFIG_H
 #include "scconfig.h"
 #endif
+#include <bitset>
 // include files for QT
 #include <QColor>
 #include <QFont>
@@ -232,6 +233,8 @@ public:
 
 	TypoPrefs& typographicPrefs() { return m_docPrefsData.typoPrefs; }
 	GuidesPrefs& guidesPrefs() { return m_docPrefsData.guidesPrefs; }
+	std::bitset<3> disableSnapping();
+	void restoreSnapping(std::bitset<3> stash);
 	ItemToolPrefs& itemToolPrefs() { return m_docPrefsData.itemToolPrefs; }
 	OperatorToolPrefs& opToolPrefs() { return m_docPrefsData.opToolPrefs; }
 	ColorPrefs& colorPrefs() { return m_docPrefsData.colorPrefs; }
@@ -1337,9 +1340,6 @@ public: // Public attributes
 	int Last {0};
 	int viewCount {0};
 	int viewID {0};
-	bool SnapGrid {false};
-	bool SnapGuides {false};
-	bool SnapElement {false};
 	bool GuideLock {false};
 	bool dontResize {false};
 	/** \brief Minimum and Maximum Points of Document */
diff --git a/scribus/scribusview.cpp b/scribus/scribusview.cpp
index da91920ee..bcf65834c 100644
--- a/scribus/scribusview.cpp
+++ b/scribus/scribusview.cpp
@@ -1161,7 +1161,7 @@ void ScribusView::contentsDropEvent(QDropEvent *e)
 			m_doc->m_Selection->connectItemToGUI();
 			currItem = m_doc->m_Selection->itemAt(0);
 			currItem->m_layerID = m_doc->activeLayer();
-			if (m_doc->SnapGrid)
+			if (m_doc->guidesPrefs().gridSnapping)
 			{
 				double nx = currItem->xPos();
 				double ny = currItem->yPos();
@@ -1758,7 +1758,7 @@ void ScribusView::PasteToPage()
 	else if (newObjects.count() == 1)
 	{
 		PageItem *currItem = newObjects.itemAt(0);
-		if (m_doc->SnapGrid)
+		if (m_doc->guidesPrefs().gridSnapping)
 		{
 			double nx = currItem->xPos();
 			double ny = currItem->yPos();
diff --git a/scribus/ui/colorsandfills.cpp b/scribus/ui/colorsandfills.cpp
index d96273615..692c64156 100644
--- a/scribus/ui/colorsandfills.cpp
+++ b/scribus/ui/colorsandfills.cpp
@@ -1301,12 +1301,7 @@ void ColorsAndFillsDialog::loadVectors(const QString& data)
 	QString patNam = fi.baseName().trimmed().simplified().replace(" ", "_");
 	uint ac = m_doc->Items->count();
 	uint ap = m_doc->docPatterns.count();
-	bool savedAlignGrid = m_doc->SnapGrid;
-	bool savedAlignGuides = m_doc->SnapGuides;
-	bool savedAlignElement = m_doc->SnapElement;
-	m_doc->SnapGrid = false;
-	m_doc->SnapGuides = false;
-	m_doc->SnapElement = false;
+	const auto snappingStash = m_doc->disableSnapping();
 	if (fi.suffix().toLower() == "sce")
 	{
 		ScriXmlDoc ss;
@@ -1327,9 +1322,7 @@ void ColorsAndFillsDialog::loadVectors(const QString& data)
 			}
 		}
 	}
-	m_doc->SnapGrid = savedAlignGrid;
-	m_doc->SnapGuides = savedAlignGuides;
-	m_doc->SnapElement = savedAlignElement;
+	m_doc->restoreSnapping(snappingStash);
 	uint ae = m_doc->Items->count();
 	if (ac != ae)
 	{
diff --git a/scribus/ui/contextmenu.cpp b/scribus/ui/contextmenu.cpp
index ab38576b8..5f8fbf3dc 100644
--- a/scribus/ui/contextmenu.cpp
+++ b/scribus/ui/contextmenu.cpp
@@ -599,9 +599,9 @@ void ContextMenu::createMenuItems_NoSelection(double mx, double my)
 	addAction(m_ScMW->scrActions["viewShowRulers"]);
 	addAction(m_ScMW->scrActions["viewRulerMode"]);
 	addSeparator();
-	addAction(m_ScMW->scrActions["viewSnapToGrid"]);
-	addAction(m_ScMW->scrActions["viewSnapToGuides"]);
-	addAction(m_ScMW->scrActions["viewSnapToElements"]);
+	addAction(m_ScMW->scrActions["pageSnapToGrid"]);
+	addAction(m_ScMW->scrActions["pageSnapToGuides"]);
+	addAction(m_ScMW->scrActions["pageSnapToElements"]);
 	
 	onAPage = (m_doc->OnPage(mx, my) != -1);
 	if (onAPage)
diff --git a/scribus/ui/prefs_guides.cpp b/scribus/ui/prefs_guides.cpp
index f0253c354..859666760 100644
--- a/scribus/ui/prefs_guides.cpp
+++ b/scribus/ui/prefs_guides.cpp
@@ -28,6 +28,9 @@ Prefs_Guides::Prefs_Guides(QWidget* parent, ScribusDoc* doc)
 	buttonUp->setEnabled(false);
 	buttonDown->setIcon(IconManager::instance().loadIcon("16/go-down.png"));
 	buttonDown->setEnabled(false);
+	// when a document is open, use the page menu to set the snapping
+	if (doc)
+		tabWidget->removeTab(tabWidget->indexOf(tabSnapping));
 
 	QString pxSuffix = QString(" %1").arg(CommonStrings::trStrPX);
 	guideSnapDistanceSpinBox->setSuffix(pxSuffix);
@@ -148,6 +151,10 @@ void Prefs_Guides::restoreDefaults(struct ApplicationPrefs *prefsData)
 	visibilityGridCheckBox->setChecked(prefsData->guidesPrefs.gridShown);
 	visibilityBaselineGridCheckBox->setChecked(prefsData->guidesPrefs.baselineGridShown);
 
+	snappingGuidesCheckBox->setChecked(prefsData->guidesPrefs.guidesSnapping);
+	snappingGridCheckBox->setChecked(prefsData->guidesPrefs.gridSnapping);
+	snappingElementCheckBox->setChecked(prefsData->guidesPrefs.elementsSnapping);
+
 	gridTypeCombo->setCurrentIndex(prefsData->guidesPrefs.gridType);
 	majorGridSpacingSpinBox->setValue(prefsData->guidesPrefs.majorGridSpacing * unitRatio);
 	minorGridSpacingSpinBox->setValue(prefsData->guidesPrefs.minorGridSpacing * unitRatio);
@@ -197,6 +204,9 @@ void Prefs_Guides::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
 	prefsData->guidesPrefs.minorGridSpacing = minorGridSpacingSpinBox->value() / unitRatio;
 	prefsData->guidesPrefs.valueBaselineGrid = baselineGridSpacingSpinBox->value();
 	prefsData->guidesPrefs.offsetBaselineGrid = baselineGridOffsetSpinBox->value();
+	prefsData->guidesPrefs.guidesSnapping = snappingGuidesCheckBox->isChecked();
+	prefsData->guidesPrefs.gridSnapping = snappingGridCheckBox->isChecked();
+	prefsData->guidesPrefs.elementsSnapping = snappingElementCheckBox->isChecked();
 	prefsData->guidesPrefs.guideColor = colorGuides;
 	prefsData->guidesPrefs.marginColor = colorMargin;
 	prefsData->guidesPrefs.majorGridColor = colorMajorGrid;
diff --git a/scribus/ui/prefs_guidesbase.ui b/scribus/ui/prefs_guidesbase.ui
index c1608e96a..296876261 100644
--- a/scribus/ui/prefs_guidesbase.ui
+++ b/scribus/ui/prefs_guidesbase.ui
@@ -28,7 +28,6 @@
      <property name="font">
       <font>
        <pointsize>14</pointsize>
-       <weight>75</weight>
        <bold>true</bold>
       </font>
      </property>
@@ -40,7 +39,7 @@
    <item>
     <widget class="Line" name="line">
      <property name="orientation">
-      <enum>Qt::Horizontal</enum>
+      <enum>Qt::Orientation::Horizontal</enum>
      </property>
     </widget>
    </item>
@@ -58,7 +57,6 @@
         <widget class="QLabel" name="label_2">
          <property name="font">
           <font>
-           <weight>75</weight>
            <bold>true</bold>
           </font>
          </property>
@@ -70,7 +68,7 @@
        <item>
         <widget class="Line" name="line_3">
          <property name="orientation">
-          <enum>Qt::Horizontal</enum>
+          <enum>Qt::Orientation::Horizontal</enum>
          </property>
         </widget>
        </item>
@@ -85,10 +83,10 @@
             </size>
            </property>
            <property name="dragDropMode">
-            <enum>QAbstractItemView::NoDragDrop</enum>
+            <enum>QAbstractItemView::DragDropMode::NoDragDrop</enum>
            </property>
            <property name="layoutMode">
-            <enum>QListView::SinglePass</enum>
+            <enum>QListView::LayoutMode::SinglePass</enum>
            </property>
           </widget>
          </item>
@@ -97,7 +95,7 @@
            <item>
             <spacer name="verticalSpacer_5">
              <property name="orientation">
-              <enum>Qt::Vertical</enum>
+              <enum>Qt::Orientation::Vertical</enum>
              </property>
              <property name="sizeHint" stdset="0">
               <size>
@@ -110,7 +108,7 @@
            <item>
             <layout class="QVBoxLayout" name="verticalLayout">
              <property name="sizeConstraint">
-              <enum>QLayout::SetMinimumSize</enum>
+              <enum>QLayout::SizeConstraint::SetMinimumSize</enum>
              </property>
              <item>
               <widget class="QPushButton" name="buttonUp">
@@ -149,7 +147,7 @@
            <item>
             <spacer name="verticalSpacer_6">
              <property name="orientation">
-              <enum>Qt::Vertical</enum>
+              <enum>Qt::Orientation::Vertical</enum>
              </property>
              <property name="sizeHint" stdset="0">
               <size>
@@ -210,10 +208,10 @@
            <item>
             <spacer name="verticalSpacer_3">
              <property name="orientation">
-              <enum>Qt::Vertical</enum>
+              <enum>Qt::Orientation::Vertical</enum>
              </property>
              <property name="sizeType">
-              <enum>QSizePolicy::Expanding</enum>
+              <enum>QSizePolicy::Policy::Expanding</enum>
              </property>
              <property name="sizeHint" stdset="0">
               <size>
@@ -228,7 +226,7 @@
          <item>
           <spacer name="horizontalSpacer">
            <property name="orientation">
-            <enum>Qt::Horizontal</enum>
+            <enum>Qt::Orientation::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
@@ -243,10 +241,10 @@
        <item>
         <spacer name="verticalSpacer_4">
          <property name="orientation">
-          <enum>Qt::Vertical</enum>
+          <enum>Qt::Orientation::Vertical</enum>
          </property>
          <property name="sizeType">
-          <enum>QSizePolicy::Fixed</enum>
+          <enum>QSizePolicy::Policy::Fixed</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
@@ -260,7 +258,6 @@
         <widget class="QLabel" name="label_7">
          <property name="font">
           <font>
-           <weight>75</weight>
            <bold>true</bold>
           </font>
          </property>
@@ -272,7 +269,7 @@
        <item>
         <widget class="Line" name="line_2">
          <property name="orientation">
-          <enum>Qt::Horizontal</enum>
+          <enum>Qt::Orientation::Horizontal</enum>
          </property>
         </widget>
        </item>
@@ -329,7 +326,7 @@
          <item>
           <spacer name="horizontalSpacer_2">
            <property name="orientation">
-            <enum>Qt::Horizontal</enum>
+            <enum>Qt::Orientation::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
@@ -344,7 +341,7 @@
        <item>
         <spacer name="verticalSpacer">
          <property name="orientation">
-          <enum>Qt::Vertical</enum>
+          <enum>Qt::Orientation::Vertical</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
@@ -427,7 +424,7 @@
          <item>
           <spacer name="horizontalSpacer_3">
            <property name="orientation">
-            <enum>Qt::Horizontal</enum>
+            <enum>Qt::Orientation::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
@@ -442,7 +439,48 @@
        <item>
         <spacer name="verticalSpacer_2">
          <property name="orientation">
-          <enum>Qt::Vertical</enum>
+          <enum>Qt::Orientation::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="tabSnapping">
+      <attribute name="title">
+       <string>Snapping</string>
+      </attribute>
+      <layout class="QVBoxLayout" name="verticalLayout_8">
+       <item>
+        <widget class="QCheckBox" name="snappingGuidesCheckBox">
+         <property name="text">
+          <string>Guides</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QCheckBox" name="snappingGridCheckBox">
+         <property name="text">
+          <string>Page Grid</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QCheckBox" name="snappingElementCheckBox">
+         <property name="text">
+          <string>Items</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer_7">
+         <property name="orientation">
+          <enum>Qt::Orientation::Vertical</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
@@ -462,7 +500,7 @@
        <item>
         <layout class="QFormLayout" name="formLayout_2">
          <property name="fieldGrowthPolicy">
-          <enum>QFormLayout::FieldsStayAtSizeHint</enum>
+          <enum>QFormLayout::FieldGrowthPolicy::FieldsStayAtSizeHint</enum>
          </property>
          <item row="0" column="0">
           <widget class="QLabel" name="label_15">
diff --git a/scribus/ui/viewtoolbar.cpp b/scribus/ui/viewtoolbar.cpp
index e45e6cc45..f85ba0f06 100644
--- a/scribus/ui/viewtoolbar.cpp
+++ b/scribus/ui/viewtoolbar.cpp
@@ -56,9 +56,9 @@ ViewToolBar::ViewToolBar(ScribusMainWindow* parent) : ScToolBar( tr("View Tools"
 	addAction(parent->scrActions["viewEditInPreview"]);
 	addWidget(visualMenu);
 	addSeparator();
-	addAction(parent->scrActions["viewSnapToGrid"]);
-	addAction(parent->scrActions["viewSnapToGuides"]);
-	addAction(parent->scrActions["viewSnapToElements"]);
+	addAction(parent->scrActions["pageSnapToGrid"]);
+	addAction(parent->scrActions["pageSnapToGuides"]);
+	addAction(parent->scrActions["pageSnapToElements"]);
 
 	languageChange();
 
snap-to-guides.diff (237,237 bytes)   

Issue History

Date Modified Username Field Change
2017-08-18 15:10 utnik New Issue
2017-08-18 16:28 jghali Note Added: 0044341
2017-08-18 16:46 utnik Note Added: 0044342
2017-08-19 17:30 ale Note Added: 0044344
2025-01-25 19:02 ale Note Added: 0051940
2025-01-25 19:06 ale Note Added: 0051941
2025-01-26 21:10 ale Note Added: 0051950
2025-01-26 21:10 ale File Added: prefs-snapping.png
2025-01-27 22:30 ale Note Added: 0051954
2025-01-30 10:50 ale Note Added: 0051958
2025-01-30 10:50 ale File Added: snap-to-guides.diff
2025-01-30 10:50 ale Summary 'snap to guides' should be enabled by default. (maybe 'snap to items' too…) => [PATCH] 'snap to guides' should be enabled by default. (maybe 'snap to items' too…)
2025-01-30 10:50 ale Patch No => Yes