r14340 by jghali - move key even handling code common to normal and node edit canvas modes out of scribus.cpp
scribus-commit
scribus-commit at lists.scribus.net
Tue Nov 24 23:30:49 CET 2009
Revision: 14340
Author: jghali
Date: 2009-11-24T13:19:02.230579Z
Commit message: move key even handling code common to normal and node edit canvas modes out of scribus.cpp
Changeset:
M /trunk/Scribus/scribus/canvasmode_normal.cpp
M /trunk/Scribus/scribus/scribus.cpp
M /trunk/Scribus/scribus/canvasmode_nodeedit.cpp
M /trunk/Scribus/scribus/canvasmode_normal.h
M /trunk/Scribus/scribus/canvasmode.cpp
M /trunk/Scribus/scribus/canvasmode_nodeedit.h
M /trunk/Scribus/scribus/canvasmode.h
M /trunk/Scribus/scribus/scribusview.cpp
Diffs:
Index: scribus/canvasmode_nodeedit.h
===================================================================
--- scribus/canvasmode_nodeedit.h (revision 14339)
+++ scribus/canvasmode_nodeedit.h (revision 14340)
@@ -43,6 +43,11 @@
virtual void mouseMoveEvent(QMouseEvent *m);
virtual void mousePressEvent(QMouseEvent *m);
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual void keyReleaseEvent(QKeyEvent *e);
+
+ virtual bool handleKeyEvents() { return true; }
+
/**
Draws the controls for this mode
Index: scribus/canvasmode_nodeedit.cpp
===================================================================
--- scribus/canvasmode_nodeedit.cpp (revision 14339)
+++ scribus/canvasmode_nodeedit.cpp (revision 14340)
@@ -22,10 +22,6 @@
#include "canvasgesture_rectselect.h"
#include "fpoint.h"
#include "pageitem.h"
-#include "ui/pageselector.h"
-#include "ui/scrspinbox.h"
-#include "scraction.h"
-#include "ui/scrapbookpalette.h"
#include "scribus.h"
#include "scribusdoc.h"
#include "scribusview.h"
@@ -34,6 +30,8 @@
#include "undomanager.h"
#include "util_icon.h"
#include "util_math.h"
+#include "ui/pageselector.h"
+#include "ui/scrspinbox.h"
CanvasMode_NodeEdit::CanvasMode_NodeEdit(ScribusView* view) : CanvasMode(view), m_rectangleSelect(NULL)
@@ -50,8 +48,6 @@
m_ScMW = m_view->m_ScMW;
}
-
-
void CanvasMode_NodeEdit::drawControls(QPainter* p)
{
// qDebug() << "NodeEdit::drawControls";
@@ -651,8 +647,16 @@
}
}
+void CanvasMode_NodeEdit::keyPressEvent(QKeyEvent *e)
+{
+ commonkeyPressEvent_NormalNodeEdit(e);
+}
+
+void CanvasMode_NodeEdit::keyReleaseEvent(QKeyEvent *e)
+{
+ commonkeyReleaseEvent(e);
+}
-
void CanvasMode_NodeEdit::handleNodeEditPress(QMouseEvent* m, QRect)
{
FPoint npf2;
Index: scribus/canvasmode.cpp
===================================================================
--- scribus/canvasmode.cpp (revision 14339)
+++ scribus/canvasmode.cpp (revision 14340)
@@ -37,12 +37,22 @@
#ifdef GESTURE_FRAME_PREVIEW
#include "pageitempreview.h"
#endif
+#include "prefsmanager.h"
#include "selection.h"
#include "scpainter.h"
-#include "ui/scresizecursor.h"
+#include "scraction.h"
#include "scribus.h"
#include "scribusdoc.h"
#include "scribusview.h"
+#include "ui/checkdocument.h"
+#include "ui/contextmenu.h"
+#include "ui/outlinepalette.h"
+#include "ui/pageselector.h"
+#include "ui/scrapbookpalette.h"
+#include "ui/scrspinbox.h"
+#include "ui/scresizecursor.h"
+#include "undomanager.h"
+#include "units.h"
#include "util_icon.h"
#include <QPainter>
@@ -71,6 +81,9 @@
m_brush["selection-group"] = QColor(255,0,0,10);
m_brush["selection-group-inside"] = Qt::NoBrush;
m_brush["handle"] = Qt::red;
+
+ m_keyRepeat = false;
+ m_arrowKeyDown = false;
}
CanvasMode::~CanvasMode()
@@ -660,3 +673,597 @@
else
drawSelection(p);
}
+
+void CanvasMode::commonkeyPressEvent_NormalNodeEdit(QKeyEvent *e)
+{
+ int kk = e->key();
+ QString uc = e->text();
+ ScribusMainWindow* mainWindow = m_view->m_ScMW;
+ QList<QMdiSubWindow *> windows;
+
+ QMdiArea* mdiArea = mainWindow->mdiArea;
+ QMdiSubWindow* w = NULL;
+ PrefsManager* prefsManager = PrefsManager::instance();
+ OutlinePalette* outlinePalette = mainWindow->outlinePalette;
+ CheckDocument* docCheckerPalette = mainWindow->docCheckerPalette;
+ QMap<QString, QPointer<ScrAction> >& scrActions(mainWindow->scrActions);
+
+ if (m_keyRepeat)
+ return;
+ m_keyRepeat = true;
+
+ int keyMod=0;
+ if (e->modifiers() & Qt::ShiftModifier)
+ keyMod |= Qt::SHIFT;
+ if (e->modifiers() & Qt::ControlModifier)
+ keyMod |= Qt::CTRL;
+ if (e->modifiers() & Qt::AltModifier)
+ keyMod |= Qt::ALT;
+ //User presses escape and we have a doc open, and we have an item selected
+ if (kk == Qt::Key_Escape)
+ {
+ m_keyRepeat = false;
+ PageItem *currItem;
+ if (m_doc->m_Selection->count() != 0)
+ {
+ currItem = m_doc->m_Selection->itemAt(0);
+ currItem->Sizing = false;
+ if (m_doc->SubMode != -1)
+ {
+ m_view->Deselect(false);
+ m_doc->Items->removeAt(currItem->ItemNr);
+ }
+ else
+ m_view->Deselect(false);
+ m_view->cancelGroupTransaction();
+ }
+ m_doc->DragP = false;
+ m_doc->leaveDrag = false;
+ m_view->stopAllDrags();
+ m_doc->SubMode = -1;
+ m_doc->ElemToLink = NULL;
+ mainWindow->slotSelect();
+ if (m_doc->m_Selection->count() == 0)
+ mainWindow->HaveNewSel(-1);
+ prefsManager->appPrefs.uiPrefs.stickyTools = false;
+ scrActions["stickyTools"]->setChecked(false);
+ return;
+ }
+ Qt::KeyboardModifiers buttonModifiers = e->modifiers();
+ /**If we have a doc and we are not changing the page or zoom level in the status bar */
+ if ((!m_view->zoomSpinBox->hasFocus()) && (!m_view->pageSelector->hasFocus()))
+ {
+ //Show our context menu
+ QKeySequence currKeySeq = QKeySequence(kk | keyMod);
+ if (currKeySeq.matches(scrActions["viewShowContextMenu"]->shortcut()) == QKeySequence::ExactMatch)
+ {
+ ContextMenu* cmen=NULL;
+ qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+ if (m_doc->m_Selection->count() == 0)
+ {
+ //CB We should be able to get this calculated by the canvas.... it is already in m_canvas->globalToCanvas(m->globalPos());
+ FPoint fp = m_canvas->globalToCanvas(QCursor::pos());
+ cmen = new ContextMenu(mainWindow, m_doc, fp.x(), fp.y());
+ }
+ else
+ cmen = new ContextMenu(*(m_doc->m_Selection), mainWindow, m_doc);
+ if (cmen)
+ {
+ mainWindow->setUndoMode(true);
+ cmen->exec(QCursor::pos());
+ mainWindow->setUndoMode(false);
+ }
+ delete cmen;
+ }
+
+
+ /**
+ * With no item selected we can:
+ * - With space, get into panning mode (modePanning)
+ * - With PageUp, scroll up
+ * - With PageDown, scroll down
+ * - With Tab, change active document windowActivated
+ */
+
+ if (m_doc->m_Selection->count() == 0)
+ {
+ int pg;
+ int wheelVal = prefsManager->mouseWheelJump();
+ if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ wheelVal = qMax(qRound(wheelVal / 10.0), 1);
+ switch (kk)
+ {
+ case Qt::Key_Space:
+ m_keyRepeat = false;
+ if (m_doc->appMode == modePanning)
+ m_view->requestMode(modeNormal);
+ else
+ m_view->requestMode(modePanning);
+ return;
+ break;
+ case Qt::Key_PageUp:
+ if (m_doc->masterPageMode())
+ m_view->scrollBy(0, -prefsManager->mouseWheelJump());
+ else
+ {
+ pg = m_doc->currentPageNumber();
+ if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ pg--;
+ else
+ pg -= m_doc->pageSets[m_doc->currentPageLayout].Columns;
+ if (pg > -1)
+ m_view->GotoPage(pg);
+ }
+ m_keyRepeat = false;
+ return;
+ break;
+ case Qt::Key_PageDown:
+ if (m_doc->masterPageMode())
+ m_view->scrollBy(0, prefsManager->mouseWheelJump());
+ else
+ {
+ pg = m_doc->currentPageNumber();
+ if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ pg++;
+ else
+ pg += m_doc->pageSets[m_doc->currentPageLayout].Columns;
+ if (pg < static_cast<int>(m_doc->Pages->count()))
+ m_view->GotoPage(pg);
+ }
+ m_keyRepeat = false;
+ return;
+ break;
+ case Qt::Key_Left:
+ m_view->scrollBy(-wheelVal, 0);
+ m_keyRepeat = false;
+ return;
+ break;
+ case Qt::Key_Right:
+ m_view->scrollBy(wheelVal, 0);
+ m_keyRepeat = false;
+ return;
+ break;
+ case Qt::Key_Up:
+ m_view->scrollBy(0, -wheelVal);
+ m_keyRepeat = false;
+ return;
+ break;
+ case Qt::Key_Down:
+ m_view->scrollBy(0, wheelVal);
+ m_keyRepeat = false;
+ return;
+ break;
+ case Qt::Key_Tab:
+ if (buttonModifiers == Qt::ControlModifier)
+ {
+ m_keyRepeat = false;
+ windows = mdiArea->subWindowList();
+ if (windows.count() > 1)
+ {
+ for (int i = 0; i < static_cast<int>(windows.count()); ++i)
+ {
+ if (mdiArea->activeSubWindow() == windows.at(i))
+ {
+ if (i == static_cast<int>(windows.count()-1))
+ w = windows.at(0);
+ else
+ w = windows.at(i+1);
+ break;
+ }
+ }
+ outlinePalette->buildReopenVals();
+ docCheckerPalette->clearErrorList();
+ if ( w )
+ w->showNormal();
+ mainWindow->newActWin(w);
+ }
+ return;
+ }
+ break;
+ }
+ }
+ /** Now if we have an item selected
+ * - In normal mode we can:
+ * -- Use backspace or delete to delete the item
+ * -- Use itemRaise action shortcut to raise an item (actionmanager.cpp connect, no code here)
+ * -- Use itemLower action shortcut to lower an item (actionmanager.cpp connect, no code here)
+ * -- Use the arrow keys to move an item or group around for !inches:
+ With no meta, by 1.0 unit
+ Ctrl, by 10.0 units
+ Shift by 0.1 units
+ Ctrl Shift 0.01 units
+ - For inches:
+ With no meta, by 1.0 pt
+ Ctrl, by 1.0 unit
+ Shift by 0.1 units
+ Ctrl Shift 0.01 units
+ * -- Use the arrow keys to resize an item:
+ Alt right arrow, move right side outwards (expand)
+ Alt left arrow, move left side outwards (expand)
+ Alt Shift right arrow, move left side inwards (shrink)
+ Alt Shift left arrow, move right side inwards (shrink)
+ * -- In edit mode of an image frame, use the arrow keys to resize the image:
+ (flows to pageitem_imageframe for control)
+ Alt right arrow, move right side of image outwards (expand)
+ Alt left arrow, move right side inwards (shrink)
+ Alt down arrow, move bottom side downwards (expand)
+ Alt up arrow, move top side inwards (shrink)
+ */
+ if (m_doc->m_Selection->count() != 0)
+ {
+ double moveBy=1.0;
+ if (m_doc->unitIndex()!=SC_INCHES)
+ {
+ if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ moveBy=0.1;
+ else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ moveBy=10.0;
+ else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ moveBy=0.01;
+
+ moveBy/=m_doc->unitRatio();//Lets allow movement by the current doc ratio, not only points
+ }
+ else
+ {
+ if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ moveBy=0.1/m_doc->unitRatio();
+ else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ moveBy=1.0/m_doc->unitRatio();
+ else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
+ moveBy=0.01/m_doc->unitRatio();
+ }
+ bool resizing=((buttonModifiers & Qt::AltModifier) && !(buttonModifiers & Qt::ControlModifier));
+ bool resizingsmaller=(resizing && (buttonModifiers & Qt::ShiftModifier));
+ double resizeBy=1.0;
+ //CB with control locked out due to the requirement of moveby of 0.01, we cannot support
+ //resizeby 10 units unless we move to supporting modifier keys that most people dont have.
+ //if (buttonModifiers & Qt::ControlModifier)
+ // resizeBy*=10.0;
+ resizeBy/=m_doc->unitRatio();
+ if (resizingsmaller)
+ resizeBy*=-1.0;
+
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+
+ switch (kk)
+ {
+ case Qt::Key_Backspace:
+ case Qt::Key_Delete:
+ m_doc->itemSelection_DeleteItem();
+ break;
+ /* CB: Stop using inflexible hardcoded keys here, actions for lower/raise work without this
+ per note above with shortcuts.
+ case Qt::Key_PageUp:
+ if (!currItem->locked())
+ {
+ m_view->RaiseItem();
+ }
+ break;
+ case Qt::Key_PageDown:
+ if (!currItem->locked())
+ {
+ m_view->LowerItem();
+ }
+ break;
+ */
+ case Qt::Key_Left:
+ if (!currItem->locked())
+ {
+ if (!resizing)
+ {
+ if ((m_doc->appMode == modeEditClip) && (m_doc->nodeEdit.hasNodeSelected()))
+ {
+ int storedClRe = m_doc->nodeEdit.ClRe;
+ if ((m_doc->nodeEdit.SelNode.count() != 0) && (m_doc->nodeEdit.EdPoints))
+ {
+ for (int itm = 0; itm < m_doc->nodeEdit.SelNode.count(); ++itm)
+ {
+ FPoint np;
+ int clRe = m_doc->nodeEdit.SelNode.at(itm);
+ if (m_doc->nodeEdit.isContourLine)
+ np = currItem->ContourLine.point(clRe);
+ else
+ np = currItem->PoLine.point(clRe);
+ m_doc->nodeEdit.ClRe = clRe;
+ np = np - FPoint(moveBy, 0);
+ m_doc->nodeEdit.moveClipPoint(currItem, np);
+ }
+ }
+ m_doc->nodeEdit.ClRe = storedClRe;
+ }
+ 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->useRaster;
+ m_doc->SnapGuides = false;
+ m_doc->useRaster = false;
+ if (m_doc->m_Selection->count() > 1)
+ m_view->startGroupTransaction(Um::Move, "", Um::IMove);
+ m_doc->moveGroup(-moveBy, 0);
+ if (m_doc->m_Selection->count() > 1)
+ m_view->endGroupTransaction();
+ m_doc->SnapGuides = sav1;
+ m_doc->useRaster = sav2;
+ }
+ }
+ else
+ {
+ //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
+ if(m_doc->nodeEdit.isContourLine)
+ m_view->TransformPoly(10, 0, resizeBy/unitGetRatioFromIndex(m_doc->unitIndex()));
+ else
+ {
+ if (resizingsmaller)
+ {
+ currItem->Sizing = false;
+ m_doc->SizeItem(currItem->width()+resizeBy, currItem->height(), currItem->ItemNr, true);
+ }
+ else
+ {
+ m_doc->MoveItem(-resizeBy, 0, currItem, false);
+ currItem->moveImageXYOffsetBy(resizeBy/currItem->imageXScale(), 0);
+ currItem->Sizing = false;
+ m_doc->SizeItem(currItem->width()+resizeBy, currItem->height(), currItem->ItemNr, true);
+ }
+ }
+ }
+ currItem->update();
+ mainWindow->slotDocCh();
+ }
+ break;
+ case Qt::Key_Right:
+ if (!currItem->locked())
+ {
+ if (!resizing)
+ {
+ if ((m_doc->appMode == modeEditClip) && (m_doc->nodeEdit.hasNodeSelected()))
+ {
+ int storedClRe = m_doc->nodeEdit.ClRe;
+ if ((m_doc->nodeEdit.SelNode.count() != 0) && (m_doc->nodeEdit.EdPoints))
+ {
+ for (int itm = 0; itm < m_doc->nodeEdit.SelNode.count(); ++itm)
+ {
+ FPoint np;
+ int clRe = m_doc->nodeEdit.SelNode.at(itm);
+ if (m_doc->nodeEdit.isContourLine)
+ np = currItem->ContourLine.point(clRe);
+ else
+ np = currItem->PoLine.point(clRe);
+ m_doc->nodeEdit.ClRe = clRe;
+ np = np + FPoint(moveBy, 0);
+ m_doc->nodeEdit.moveClipPoint(currItem, np);
+ }
+ }
+ m_doc->nodeEdit.ClRe = storedClRe;
+ }
+ 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->useRaster;
+ m_doc->SnapGuides = false;
+ m_doc->useRaster = false;
+ if (m_doc->m_Selection->count() > 1)
+ m_view->startGroupTransaction(Um::Move, "", Um::IMove);
+ m_doc->moveGroup(moveBy, 0);
+ if (m_doc->m_Selection->count() > 1)
+ m_view->endGroupTransaction();
+ m_doc->SnapGuides = sav1;
+ m_doc->useRaster = sav2;
+ }
+ }
+ else
+ {
+ //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
+ if(m_doc->nodeEdit.isContourLine)
+ m_view->TransformPoly(11, 0, resizeBy/unitGetRatioFromIndex(m_doc->unitIndex()));
+ else
+ {
+ if (resizingsmaller)
+ {
+ m_doc->MoveItem(-resizeBy, 0, currItem, false);
+ currItem->moveImageXYOffsetBy(resizeBy/currItem->imageXScale(), 0);
+ currItem->Sizing = false;
+ m_doc->SizeItem(currItem->width()+resizeBy, currItem->height(), currItem->ItemNr, true);
+ }
+ else
+ {
+ currItem->Sizing = false;
+ m_doc->SizeItem(currItem->width()+resizeBy, currItem->height(), currItem->ItemNr, true);
+ }
+ }
+ }
+ currItem->update();
+ mainWindow->slotDocCh();
+ }
+ break;
+ case Qt::Key_Up:
+ if (!currItem->locked())
+ {
+ if (!resizing)
+ {
+ if ((m_doc->appMode == modeEditClip) && (m_doc->nodeEdit.hasNodeSelected()))
+ {
+ int storedClRe = m_doc->nodeEdit.ClRe;
+ if ((m_doc->nodeEdit.SelNode.count() != 0) && (m_doc->nodeEdit.EdPoints))
+ {
+ for (int itm = 0; itm < m_doc->nodeEdit.SelNode.count(); ++itm)
+ {
+ FPoint np;
+ int clRe = m_doc->nodeEdit.SelNode.at(itm);
+ if (m_doc->nodeEdit.isContourLine)
+ np = currItem->ContourLine.point(clRe);
+ else
+ np = currItem->PoLine.point(clRe);
+ m_doc->nodeEdit.ClRe = clRe;
+ np = np - FPoint(0, moveBy);
+ m_doc->nodeEdit.moveClipPoint(currItem, np);
+ }
+ }
+ m_doc->nodeEdit.ClRe = storedClRe;
+ }
+ 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->useRaster;
+ m_doc->SnapGuides = false;
+ m_doc->useRaster = false;
+ if (m_doc->m_Selection->count() > 1)
+ m_view->startGroupTransaction(Um::Move, "", Um::IMove);
+ m_doc->moveGroup(0, -moveBy);
+ if (m_doc->m_Selection->count() > 1)
+ m_view->endGroupTransaction();
+ m_doc->SnapGuides = sav1;
+ m_doc->useRaster = sav2;
+ }
+ }
+ else
+ {
+ //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
+ if(m_doc->nodeEdit.isContourLine)
+ m_view->TransformPoly(12, 0, resizeBy/unitGetRatioFromIndex(m_doc->unitIndex()));
+ else
+ {
+ if (resizingsmaller)
+ {
+ currItem->Sizing = false;
+ m_doc->SizeItem(currItem->width(), currItem->height()+resizeBy, currItem->ItemNr, true);
+ }
+ else
+ {
+ m_doc->MoveItem(0, -resizeBy, currItem, false);
+ currItem->moveImageXYOffsetBy(0, resizeBy/currItem->imageYScale());
+ currItem->Sizing = false;
+ m_doc->SizeItem(currItem->width(), currItem->height()+resizeBy, currItem->ItemNr, true);
+ }
+ }
+ }
+ currItem->update();
+ mainWindow->slotDocCh();
+ }
+ break;
+ case Qt::Key_Down:
+ if (!currItem->locked())
+ {
+ if (!resizing)
+ {
+ if ((m_doc->appMode == modeEditClip) && (m_doc->nodeEdit.hasNodeSelected()))
+ {
+ int storedClRe = m_doc->nodeEdit.ClRe;
+ if ((m_doc->nodeEdit.SelNode.count() != 0) && (m_doc->nodeEdit.EdPoints))
+ {
+ for (int itm = 0; itm < m_doc->nodeEdit.SelNode.count(); ++itm)
+ {
+ FPoint np;
+ int clRe = m_doc->nodeEdit.SelNode.at(itm);
+ if (m_doc->nodeEdit.isContourLine)
+ np = currItem->ContourLine.point(clRe);
+ else
+ np = currItem->PoLine.point(clRe);
+ m_doc->nodeEdit.ClRe = clRe;
+ np = np - FPoint(0, -moveBy);
+ m_doc->nodeEdit.moveClipPoint(currItem, np);
+ }
+ }
+ m_doc->nodeEdit.ClRe = storedClRe;
+ }
+ 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->useRaster;
+ m_doc->SnapGuides = false;
+ m_doc->useRaster = false;
+ if (m_doc->m_Selection->count() > 1)
+ m_view->startGroupTransaction(Um::Move, "", Um::IMove);
+ m_doc->moveGroup(0, moveBy);
+ if (m_doc->m_Selection->count() > 1)
+ m_view->endGroupTransaction();
+ m_doc->SnapGuides = sav1;
+ m_doc->useRaster = sav2;
+ }
+ }
+ else
+ {
+ //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
+ if(m_doc->nodeEdit.isContourLine)
+ m_view->TransformPoly(13, 0, resizeBy/unitGetRatioFromIndex(m_doc->unitIndex()));
+ else
+ {
+ if (resizingsmaller)
+ {
+ m_doc->MoveItem(0, -resizeBy, currItem, false);
+ currItem->moveImageXYOffsetBy(0, resizeBy/currItem->imageYScale());
+ currItem->Sizing = false;
+ m_doc->SizeItem(currItem->width(), currItem->height()+resizeBy, currItem->ItemNr, true);
+ }
+ else
+ {
+ currItem->Sizing = false;
+ m_doc->SizeItem(currItem->width(), currItem->height()+resizeBy, currItem->ItemNr, true);
+ }
+ }
+ }
+ currItem->update();
+ mainWindow->slotDocCh();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ switch(kk)
+ {
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ m_arrowKeyDown = true;
+ }
+ m_keyRepeat = false;
+}
+
+void CanvasMode::commonkeyReleaseEvent(QKeyEvent *e)
+{
+ //Exit out of panning mode if Control is release while the right mouse button is pressed
+ if ((m_doc->appMode == modePanning) && (e->key() == Qt::Key_Control) && (QApplication::mouseButtons() & Qt::RightButton))
+ m_view->requestMode(modeNormal);
+ if (m_doc->appMode == modeMagnifier)
+ qApp->changeOverrideCursor(QCursor(loadIcon("LupeZ.xpm")));
+ if (e->isAutoRepeat() || !m_arrowKeyDown)
+ return;
+ switch(e->key())
+ {
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ m_arrowKeyDown = false;
+ if ((!m_view->zoomSpinBox->hasFocus()) && (!m_view->pageSelector->hasFocus()))
+ {
+ int docSelectionCount=m_doc->m_Selection->count();
+ if ((docSelectionCount != 0) && (m_doc->appMode == modeEditClip) && (m_doc->nodeEdit.hasNodeSelected()))
+ {
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ double xposOrig = currItem->xPos();
+ double yposOrig = currItem->yPos();
+ m_doc->AdjustItemSize(currItem);
+ if (!m_doc->nodeEdit.isContourLine)
+ currItem->ContourLine.translate(xposOrig - currItem->xPos(),yposOrig - currItem->yPos());
+ currItem->update();
+ }
+ for (int i = 0; i < docSelectionCount; ++i)
+ m_doc->m_Selection->itemAt(i)->checkChanges(true);
+ if (docSelectionCount > 1 && m_view->groupTransactionStarted())
+ m_view->endGroupTransaction();
+ }
+ break;
+ }
+}
Index: scribus/canvasmode_normal.h
===================================================================
--- scribus/canvasmode_normal.h (revision 14339)
+++ scribus/canvasmode_normal.h (revision 14340)
@@ -52,6 +52,11 @@
virtual void mousePressEvent(QMouseEvent *m);
virtual void drawControls(QPainter* p);
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual void keyReleaseEvent(QKeyEvent *e);
+
+ virtual bool handleKeyEvents() { return true; }
+
private:
inline bool GetItem(PageItem** pi);
bool SeleItem(QMouseEvent *m);
@@ -63,10 +68,8 @@
FPoint m_objectDeltaPos;
bool shiftSelItems;
- bool MoveGX, MoveGY;
int frameResizeHandle;
int dragConstrainInitPtX, dragConstrainInitPtY;
- int GxM, GyM;
ScribusMainWindow* m_ScMW;
ResizeGesture* resizeGesture;
LineMove* lineMoveGesture;
Index: scribus/canvasmode.h
===================================================================
--- scribus/canvasmode.h (revision 14339)
+++ scribus/canvasmode.h (revision 14340)
@@ -100,6 +100,8 @@
virtual void keyReleaseEvent(QKeyEvent *e) {}
virtual void inputMethodEvent(QInputMethodEvent *e) {}
+ virtual bool handleKeyEvents() { return false; }
+
/**
Sets appropiate values for this canvas mode
*/
@@ -141,11 +143,16 @@
void setResizeCursor(int how, double rot = 0.0);
bool commonMouseMove(QMouseEvent *m);
void commonDrawControls(QPainter* p);
+
+ void commonkeyPressEvent_NormalNodeEdit(QKeyEvent *e);
+ void commonkeyReleaseEvent(QKeyEvent *e);
- private:
- QMap<QString,QPen> m_pen;
- QMap<QString,QBrush> m_brush;
-
+private:
+ QMap<QString,QPen> m_pen;
+ QMap<QString,QBrush> m_brush;
+
+ bool m_keyRepeat;
+ bool m_arrowKeyDown;
};
Index: scribus/scribusview.cpp
===================================================================
--- scribus/scribusview.cpp (revision 14339)
+++ scribus/scribusview.cpp (revision 14340)
@@ -3876,8 +3876,8 @@
currItem->GrTypeStroke = Buffer->GrTypeStroke;
currItem->GrStrokeStartX = Buffer->GrStrokeStartX;
currItem->GrStrokeStartY = Buffer->GrStrokeStartY;
- currItem->GrStrokeEndX = Buffer->GrStrokeEndX;
- currItem->GrStrokeEndY = Buffer->GrStrokeEndY;
+ currItem->GrStrokeEndX = Buffer->GrStrokeEndX;
+ currItem->GrStrokeEndY = Buffer->GrStrokeEndY;
currItem->GrStrokeFocalX = Buffer->GrStrokeFocalX;
currItem->GrStrokeFocalY = Buffer->GrStrokeFocalY;
currItem->GrStrokeScale = Buffer->GrStrokeScale;
@@ -4876,13 +4876,19 @@
else if (/* obj == widget() && */ event->type() == QEvent::KeyPress)
{
QKeyEvent* m = static_cast<QKeyEvent*> (event);
- m_ScMW->keyPressEvent(m);
+ if (m_canvasMode->handleKeyEvents())
+ m_canvasMode->keyPressEvent(m);
+ else
+ m_ScMW->keyPressEvent(m);
return true;
}
else if (/* obj == widget() && */ event->type() == QEvent::KeyRelease)
{
QKeyEvent* m = static_cast<QKeyEvent*> (event);
- m_ScMW->keyReleaseEvent(m);
+ if (m_canvasMode->handleKeyEvents())
+ m_canvasMode->keyReleaseEvent(m);
+ else
+ m_ScMW->keyReleaseEvent(m);
return true;
}
else if (obj == widget() && event->type() == QEvent::DragEnter)
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp (revision 14339)
+++ scribus/scribus.cpp (revision 14340)
@@ -1468,23 +1468,6 @@
/** Now if we have an item selected
* - In normal mode we can:
* -- Use backspace or delete to delete the item
- * -- Use itemRaise action shortcut to raise an item (actionmanager.cpp connect, no code here)
- * -- Use itemLower action shortcut to lower an item (actionmanager.cpp connect, no code here)
- * -- Use the arrow keys to move an item or group around for !inches:
- With no meta, by 1.0 unit
- Ctrl, by 10.0 units
- Shift by 0.1 units
- Ctrl Shift 0.01 units
- - For inches:
- With no meta, by 1.0 pt
- Ctrl, by 1.0 unit
- Shift by 0.1 units
- Ctrl Shift 0.01 units
- * -- Use the arrow keys to resize an item:
- Alt right arrow, move right side outwards (expand)
- Alt left arrow, move left side outwards (expand)
- Alt Shift right arrow, move left side inwards (shrink)
- Alt Shift left arrow, move right side inwards (shrink)
* -- In edit mode of an image frame, use the arrow keys to resize the image:
(flows to pageitem_imageframe for control)
Alt right arrow, move right side of image outwards (expand)
@@ -1494,365 +1477,14 @@
*/
if (doc->m_Selection->count() != 0)
{
- double moveBy=1.0;
- if (doc->unitIndex()!=SC_INCHES)
- {
- if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
- moveBy=0.1;
- else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
- moveBy=10.0;
- else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
- moveBy=0.01;
-
- moveBy/=doc->unitRatio();//Lets allow movement by the current doc ratio, not only points
- }
- else
- {
- if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
- moveBy=0.1/doc->unitRatio();
- else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
- moveBy=1.0/doc->unitRatio();
- else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
- moveBy=0.01/doc->unitRatio();
- }
- bool resizing=((buttonModifiers & Qt::AltModifier) && !(buttonModifiers & Qt::ControlModifier));
- bool resizingsmaller=(resizing && (buttonModifiers & Qt::ShiftModifier));
- double resizeBy=1.0;
- //CB with control locked out due to the requirement of moveby of 0.01, we cannot support
- //resizeby 10 units unless we move to supporting modifier keys that most people dont have.
- //if (buttonModifiers & Qt::ControlModifier)
- // resizeBy*=10.0;
- resizeBy/=doc->unitRatio();
- if (resizingsmaller)
- resizeBy*=-1.0;
-
-
PageItem *currItem = doc->m_Selection->itemAt(0);
- switch (doc->appMode)
+ if (doc->appMode == modeEdit)
{
- case modeNormal:
- case modeEditClip:
- switch (kk)
- {
- case Qt::Key_Backspace:
- case Qt::Key_Delete:
- doc->itemSelection_DeleteItem();
- break;
- /* CB: Stop using inflexible hardcoded keys here, actions for lower/raise work without this
- per note above with shortcuts.
- case Qt::Key_PageUp:
- if (!currItem->locked())
- {
- view->RaiseItem();
- }
- break;
- case Qt::Key_PageDown:
- if (!currItem->locked())
- {
- view->LowerItem();
- }
- break;
- */
- case Qt::Key_Left:
- if (!currItem->locked())
- {
- if (!resizing)
- {
- if ((doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
- {
- int storedClRe = doc->nodeEdit.ClRe;
- if ((doc->nodeEdit.SelNode.count() != 0) && (doc->nodeEdit.EdPoints))
- {
- for (int itm = 0; itm < doc->nodeEdit.SelNode.count(); ++itm)
- {
- FPoint np;
- int clRe = doc->nodeEdit.SelNode.at(itm);
- if (doc->nodeEdit.isContourLine)
- np = currItem->ContourLine.point(clRe);
- else
- np = currItem->PoLine.point(clRe);
- doc->nodeEdit.ClRe = clRe;
- np = np - FPoint(moveBy, 0);
- doc->nodeEdit.moveClipPoint(currItem, np);
- }
- }
- doc->nodeEdit.ClRe = storedClRe;
- }
- 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 = doc->SnapGuides;
- bool sav2 = doc->useRaster;
- doc->SnapGuides = false;
- doc->useRaster = false;
- if (doc->m_Selection->count() > 1)
- view->startGroupTransaction(Um::Move, "", Um::IMove);
- doc->moveGroup(-moveBy, 0);
- if (doc->m_Selection->count() > 1)
- view->endGroupTransaction();
- doc->SnapGuides = sav1;
- doc->useRaster = sav2;
- }
- }
- else
- {
- //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
- if(doc->nodeEdit.isContourLine)
- view->TransformPoly(10, 0, resizeBy/unitGetRatioFromIndex(doc->unitIndex()));
- else
- {
- if (resizingsmaller)
- {
- currItem->Sizing = false;
- doc->SizeItem(currItem->width()+resizeBy, currItem->height(), currItem->ItemNr, true);
- }
- else
- {
- doc->MoveItem(-resizeBy, 0, currItem, false);
- currItem->moveImageXYOffsetBy(resizeBy/currItem->imageXScale(), 0);
- currItem->Sizing = false;
- doc->SizeItem(currItem->width()+resizeBy, currItem->height(), currItem->ItemNr, true);
- }
- }
- }
- currItem->update();
- slotDocCh();
- }
- break;
- case Qt::Key_Right:
- if (!currItem->locked())
- {
- if (!resizing)
- {
- if ((doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
- {
- int storedClRe = doc->nodeEdit.ClRe;
- if ((doc->nodeEdit.SelNode.count() != 0) && (doc->nodeEdit.EdPoints))
- {
- for (int itm = 0; itm < doc->nodeEdit.SelNode.count(); ++itm)
- {
- FPoint np;
- int clRe = doc->nodeEdit.SelNode.at(itm);
- if (doc->nodeEdit.isContourLine)
- np = currItem->ContourLine.point(clRe);
- else
- np = currItem->PoLine.point(clRe);
- doc->nodeEdit.ClRe = clRe;
- np = np + FPoint(moveBy, 0);
- doc->nodeEdit.moveClipPoint(currItem, np);
- }
- }
- doc->nodeEdit.ClRe = storedClRe;
- }
- 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 = doc->SnapGuides;
- bool sav2 = doc->useRaster;
- doc->SnapGuides = false;
- doc->useRaster = false;
- if (doc->m_Selection->count() > 1)
- view->startGroupTransaction(Um::Move, "", Um::IMove);
- doc->moveGroup(moveBy, 0);
- if (doc->m_Selection->count() > 1)
- view->endGroupTransaction();
- doc->SnapGuides = sav1;
- doc->useRaster = sav2;
- }
- }
- else
- {
- //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
- if(doc->nodeEdit.isContourLine)
- view->TransformPoly(11, 0, resizeBy/unitGetRatioFromIndex(doc->unitIndex()));
- else
- {
- if (resizingsmaller)
- {
- doc->MoveItem(-resizeBy, 0, currItem, false);
- currItem->moveImageXYOffsetBy(resizeBy/currItem->imageXScale(), 0);
- currItem->Sizing = false;
- doc->SizeItem(currItem->width()+resizeBy, currItem->height(), currItem->ItemNr, true);
- }
- else
- {
- currItem->Sizing = false;
- doc->SizeItem(currItem->width()+resizeBy, currItem->height(), currItem->ItemNr, true);
- }
- }
- }
- currItem->update();
- slotDocCh();
- }
- break;
- case Qt::Key_Up:
- if (!currItem->locked())
- {
- if (!resizing)
- {
- if ((doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
- {
- int storedClRe = doc->nodeEdit.ClRe;
- if ((doc->nodeEdit.SelNode.count() != 0) && (doc->nodeEdit.EdPoints))
- {
- for (int itm = 0; itm < doc->nodeEdit.SelNode.count(); ++itm)
- {
- FPoint np;
- int clRe = doc->nodeEdit.SelNode.at(itm);
- if (doc->nodeEdit.isContourLine)
- np = currItem->ContourLine.point(clRe);
- else
- np = currItem->PoLine.point(clRe);
- doc->nodeEdit.ClRe = clRe;
- np = np - FPoint(0, moveBy);
- doc->nodeEdit.moveClipPoint(currItem, np);
- }
- }
- doc->nodeEdit.ClRe = storedClRe;
- }
- 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 = doc->SnapGuides;
- bool sav2 = doc->useRaster;
- doc->SnapGuides = false;
- doc->useRaster = false;
- if (doc->m_Selection->count() > 1)
- view->startGroupTransaction(Um::Move, "", Um::IMove);
- doc->moveGroup(0, -moveBy);
- if (doc->m_Selection->count() > 1)
- view->endGroupTransaction();
- doc->SnapGuides = sav1;
- doc->useRaster = sav2;
- }
- }
- else
- {
- //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
- if(doc->nodeEdit.isContourLine)
- view->TransformPoly(12, 0, resizeBy/unitGetRatioFromIndex(doc->unitIndex()));
- else
- {
- if (resizingsmaller)
- {
- currItem->Sizing = false;
- doc->SizeItem(currItem->width(), currItem->height()+resizeBy, currItem->ItemNr, true);
- }
- else
- {
- doc->MoveItem(0, -resizeBy, currItem, false);
- currItem->moveImageXYOffsetBy(0, resizeBy/currItem->imageYScale());
- currItem->Sizing = false;
- doc->SizeItem(currItem->width(), currItem->height()+resizeBy, currItem->ItemNr, true);
- }
- }
- }
- currItem->update();
- slotDocCh();
- }
- break;
- case Qt::Key_Down:
- if (!currItem->locked())
- {
- if (!resizing)
- {
- if ((doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
- {
- int storedClRe = doc->nodeEdit.ClRe;
- if ((doc->nodeEdit.SelNode.count() != 0) && (doc->nodeEdit.EdPoints))
- {
- for (int itm = 0; itm < doc->nodeEdit.SelNode.count(); ++itm)
- {
- FPoint np;
- int clRe = doc->nodeEdit.SelNode.at(itm);
- if (doc->nodeEdit.isContourLine)
- np = currItem->ContourLine.point(clRe);
- else
- np = currItem->PoLine.point(clRe);
- doc->nodeEdit.ClRe = clRe;
- np = np - FPoint(0, -moveBy);
- doc->nodeEdit.moveClipPoint(currItem, np);
- }
- }
- doc->nodeEdit.ClRe = storedClRe;
- }
- 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 = doc->SnapGuides;
- bool sav2 = doc->useRaster;
- doc->SnapGuides = false;
- doc->useRaster = false;
- if (doc->m_Selection->count() > 1)
- view->startGroupTransaction(Um::Move, "", Um::IMove);
- doc->moveGroup(0, moveBy);
- if (doc->m_Selection->count() > 1)
- view->endGroupTransaction();
- doc->SnapGuides = sav1;
- doc->useRaster = sav2;
- }
- }
- else
- {
- //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
- if(doc->nodeEdit.isContourLine)
- view->TransformPoly(13, 0, resizeBy/unitGetRatioFromIndex(doc->unitIndex()));
- else
- {
- if (resizingsmaller)
- {
- doc->MoveItem(0, -resizeBy, currItem, false);
- currItem->moveImageXYOffsetBy(0, resizeBy/currItem->imageYScale());
- currItem->Sizing = false;
- doc->SizeItem(currItem->width(), currItem->height()+resizeBy, currItem->ItemNr, true);
- }
- else
- {
- currItem->Sizing = false;
- doc->SizeItem(currItem->width(), currItem->height()+resizeBy, currItem->ItemNr, true);
- }
- }
- }
- currItem->update();
- slotDocCh();
- }
- break;
- default:
- break;
- }
- break;
- case modeEdit:
if (currItem->asImageFrame() && !currItem->locked())
{
currItem->handleModeEditKey(k, keyrep);
- /*
- double dX=0.0,dY=0.0;
- switch (kk)
- {
- case Qt::Key_Left:
- dX=-moveBy;
- break;
- case Qt::Key_Right:
- dX=moveBy;
- break;
- case Qt::Key_Up:
- dY=-moveBy;
- break;
- case Qt::Key_Down:
- dY=moveBy;
- break;
- }
- if (dX!=0.0 || dY!=0.0)
- {
- currItem->moveImageInFrame(dX, dY);
- currItem->update();
- }*/
}
-//FIXME:av view->oldCp = currItem->CPos;
+//FIXME:av view->oldCp = currItem->CPos;
if (currItem->itemType() == PageItem::TextFrame)
{
bool kr=keyrep;
@@ -1860,7 +1492,6 @@
keyrep=kr;
}
slotDocCh(false);
- break;
}
}
}
Index: scribus/canvasmode_normal.cpp
===================================================================
--- scribus/canvasmode_normal.cpp (revision 14339)
+++ scribus/canvasmode_normal.cpp (revision 14340)
@@ -30,23 +30,19 @@
#include <QWidgetAction>
#include <QDebug>
-#include "ui/aligndistribute.h"
#include "canvas.h"
#include "canvasgesture_linemove.h"
#include "canvasgesture_resize.h"
#include "canvasgesture_rulermove.h"
-#include "ui/contextmenu.h"
-#include "ui/customfdialog.h"
+#include "fileloader.h"
#include "fpoint.h"
#include "fpointarray.h"
#include "hyphenator.h"
-#include "ui/insertTable.h"
+#include "loadsaveplugin.h"
#include "pageitem_textframe.h"
-#include "ui/pageselector.h"
#include "prefscontext.h"
#include "prefsfile.h"
#include "prefsmanager.h"
-#include "ui/propertiespalette.h"
#include "scmimedata.h"
#include "scribus.h"
#include "scribusdoc.h"
@@ -55,24 +51,25 @@
#include "selection.h"
#include "stencilreader.h"
#include "undomanager.h"
-#include "units.h"
#include "util.h"
#include "util_icon.h"
#include "util_math.h"
-#include "loadsaveplugin.h"
-#include "fileloader.h"
+#include "ui/aligndistribute.h"
+#include "ui/contextmenu.h"
+#include "ui/customfdialog.h"
+#include "ui/insertTable.h"
+#include "ui/pageselector.h"
+#include "ui/propertiespalette.h"
#include "plugins/formatidlist.h"
CanvasMode_Normal::CanvasMode_Normal(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
{
- GxM = GyM = -1;
- MoveGX = MoveGY = false;
frameResizeHandle = -1;
shiftSelItems = false;
resizeGesture = NULL;
- lineMoveGesture = NULL;
+ lineMoveGesture = NULL;
guideMoveGesture = NULL;
m_mousePressPoint.setXY(0, 0);
m_mouseCurrentPoint.setXY(0, 0);
@@ -130,8 +127,6 @@
m_mouseCurrentPoint.setXY(0, 0);
m_mouseSavedPoint.setXY(0, 0);
m_objectDeltaPos.setXY(0,0 );
- GxM = GyM = -1;
- MoveGX = MoveGY = false;
frameResizeHandle = -1;
shiftSelItems = false;
setModeCursor();
@@ -579,7 +574,7 @@
}
else
{
- if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton) && (GyM == -1) && (GxM == -1))
+ if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton))
{
newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
@@ -608,7 +603,6 @@
m_view->HaveSelRect = false;
m_doc->DragP = false;
m_doc->leaveDrag = false;
- MoveGX = MoveGY = false;
m->accept();
m_view->registerMousePress(m->globalPos());
QRect mpo(m->x()-m_doc->guidesSettings.grabRadius, m->y()-m_doc->guidesSettings.grabRadius, m_doc->guidesSettings.grabRadius*2, m_doc->guidesSettings.grabRadius*2);
@@ -1011,6 +1005,16 @@
}
}
+void CanvasMode_Normal::keyPressEvent(QKeyEvent *e)
+{
+ commonkeyPressEvent_NormalNodeEdit(e);
+}
+
+void CanvasMode_Normal::keyReleaseEvent(QKeyEvent *e)
+{
+ commonkeyReleaseEvent(e);
+}
+
//CB-->Doc/Fix
bool CanvasMode_Normal::SeleItem(QMouseEvent *m)
{
@@ -1264,57 +1268,6 @@
// m_view->startGesture(guideMoveGesture);
guideMoveGesture->mouseSelectGuide(m);
}
-/* GxM = -1;
- GyM = -1;
- QMap<double, uint> tmpGuidesSel;
- Guides tmpGuides = m_doc->currentPage()->guides.horizontals(GuideManagerCore::Standard);
- Guides::iterator it;
- uint yg = 0;
- uint xg = 0;
- double lowX = ((m->x() - m_doc->guidesSettings.grabRad) / m_canvas->scale()) + 0*m_doc->minCanvasCoordinate.x();
- double highX = ((m->x() + m_doc->guidesSettings.grabRad) / m_canvas->scale()) + 0*m_doc->minCanvasCoordinate.x();
- double lowY = ((m->y() - m_doc->guidesSettings.grabRad) / m_canvas->scale()) + 0*m_doc->minCanvasCoordinate.y();
- double highY = ((m->y() + m_doc->guidesSettings.grabRad) / m_canvas->scale()) + 0*m_doc->minCanvasCoordinate.y();
- for (it = tmpGuides.begin(); it != tmpGuides.end(); ++it, ++yg)
- {
- if (((*it) + m_doc->currentPage()->yOffset() < highY) && ((*it)+m_doc->currentPage()->yOffset() > lowY))
- tmpGuidesSel.insert(fabs(((*it)+m_doc->currentPage()->yOffset()) - MypS), yg);
- }
- if (tmpGuidesSel.count() != 0)
- {
- GyM = tmpGuidesSel.begin().value();
- QPoint py = m_view->viewport()->mapFromGlobal(m->globalPos());
- m_view->DrHY = py.y();
- }
- tmpGuidesSel.clear();
- tmpGuides = m_doc->currentPage()->guides.verticals(GuideManagerCore::Standard);
- for (it = tmpGuides.begin(); it != tmpGuides.end(); ++it, ++xg)
- {
- if (((*it) + m_doc->currentPage()->xOffset() < highX) && ((*it)+m_doc->currentPage()->xOffset() > lowX))
- tmpGuidesSel.insert(fabs(((*it)+m_doc->currentPage()->xOffset()) - MypS), xg);
- }
- if (tmpGuidesSel.count() != 0)
- {
- GxM = tmpGuidesSel.begin().value();
- QPoint py = m_view->viewport()->mapFromGlobal(m->globalPos());
- m_view->DrVX = py.x();
- }
- if (GxM!=-1 || GyM!=-1)
- {
- if (GxM==-1)
- {
- // Horizontal Guide
- MoveGY = true;
-//FIXME:av emit signalGuideInformation(0, qRound(m_doc->currentPage()->guides.horizontal(GyM, GuideManagerCore::Standard) * 10000.0) / 10000.0);
- }
- else
- {
- // Vertical Guide
- MoveGX = true;
-//FIXME:av emit signalGuideInformation(1, qRound(m_doc->currentPage()->guides.vertical(GxM, GuideManagerCore::Standard) * 10000.0) / 10000.0);
- }
- }
- */
}
//m_doc->m_Selection->setIsGUISelection(true);
m_doc->m_Selection->connectItemToGUI();
More information about the scribus-commit
mailing list