diff options
author | chudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-26 20:26:44 +0000 |
---|---|---|
committer | chudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-26 20:26:44 +0000 |
commit | a1226319b72df0fb4c8a9a6aae5e493a4e3527cb (patch) | |
tree | 8933edcc25852fda9251e52d9b2aff7033342f0f /debugger | |
parent | 7eed1393835c043a2457a7caa0f3ee6ecbc80f60 (diff) |
Key Shortcuts for Zooming. Refactored some event propogation.
Review URL: https://codereview.appspot.com/6452052
git-svn-id: http://skia.googlecode.com/svn/trunk@4794 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'debugger')
-rw-r--r-- | debugger/QT/SkCanvasWidget.cpp | 12 | ||||
-rw-r--r-- | debugger/QT/SkCanvasWidget.h | 11 | ||||
-rw-r--r-- | debugger/QT/SkDebuggerGUI.cpp | 17 | ||||
-rw-r--r-- | debugger/QT/SkDebuggerGUI.h | 3 | ||||
-rw-r--r-- | debugger/QT/moc_SkCanvasWidget.cpp | 11 |
5 files changed, 43 insertions, 11 deletions
diff --git a/debugger/QT/SkCanvasWidget.cpp b/debugger/QT/SkCanvasWidget.cpp index 8384fb11cf..ec6c0c8159 100644 --- a/debugger/QT/SkCanvasWidget.cpp +++ b/debugger/QT/SkCanvasWidget.cpp @@ -110,15 +110,15 @@ void SkCanvasWidget::updateWidgetTransform(TransformType type) { } } -void SkCanvasWidget::wheelEvent(QWheelEvent* event) { - fScaleFactor += event->delta()/120; +void SkCanvasWidget::zoom(float zoomIncrement) { + fScaleFactor += zoomIncrement; /* The range of the fScaleFactor crosses over the range -1,0,1 frequently. - * Based on the code below, -1 and 1 both scale the image to it's original - * size we do the following to never have a registered wheel scroll - * not effect the fScaleFactor. */ + * Based on the code below, -1 and 1 both scale the image to it's original + * size we do the following to never have a registered wheel scroll + * not effect the fScaleFactor. */ if (fScaleFactor == 0) { - fScaleFactor += (event->delta()/120) * 2; + fScaleFactor = 2 * zoomIncrement; } emit scaleFactorChanged(fScaleFactor); updateWidgetTransform(kScale); diff --git a/debugger/QT/SkCanvasWidget.h b/debugger/QT/SkCanvasWidget.h index 2ea7329af5..a73ffc8463 100644 --- a/debugger/QT/SkCanvasWidget.h +++ b/debugger/QT/SkCanvasWidget.h @@ -100,13 +100,18 @@ public: return &fRasterWidget; } - + void zoom(float zoomIncrement); signals: void scaleFactorChanged(float newScaleFactor); void commandChanged(int newCommand); void hitChanged(int hit); +private slots: + void keyZoom(int zoomIncrement) { + zoom(zoomIncrement); + } + private: QHBoxLayout fHorizontalLayout; SkRasterWidget fRasterWidget; @@ -132,7 +137,9 @@ private: void mouseDoubleClickEvent(QMouseEvent* event); - void wheelEvent(QWheelEvent* event); + void wheelEvent(QWheelEvent* event) { + zoom(event->delta()/120); + } }; diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp index 131386c120..823fffc54e 100644 --- a/debugger/QT/SkDebuggerGUI.cpp +++ b/debugger/QT/SkDebuggerGUI.cpp @@ -28,6 +28,9 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : , fActionShowDeletes(this) , fActionStepBack(this) , fActionStepForward(this) + , fActionZoomIn(this) + , fActionZoomOut(this) + , fMapper(this) , fCentralWidget(this) , fFilter(&fCentralWidget) , fContainerLayout(&fCentralWidget) @@ -76,6 +79,13 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float))); connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget, SLOT(updateCommand(int))); + fMapper.setMapping(&fActionZoomIn, 1); + fMapper.setMapping(&fActionZoomOut, -1); + + connect(&fActionZoomIn, SIGNAL(triggered()), &fMapper, SLOT(map())); + connect(&fActionZoomOut, SIGNAL(triggered()), &fMapper, SLOT(map())); + connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(keyZoom(int))); + fInspectorWidget.setDisabled(true); fMenuEdit.setDisabled(true); fMenuNavigate.setDisabled(true); @@ -413,6 +423,11 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) { fActionStepForward.setIcon(stepForward); fActionStepForward.setText("Step Forward"); + fActionZoomIn.setShortcut(QKeySequence(tr("Ctrl+="))); + fActionZoomIn.setText("Zoom In"); + fActionZoomOut.setShortcut(QKeySequence(tr("Ctrl+-"))); + fActionZoomOut.setText("Zoom Out"); + fListWidget.setItemDelegate(new SkListWidget(&fListWidget)); fListWidget.setObjectName(QString::fromUtf8("listWidget")); fListWidget.setMaximumWidth(250); @@ -501,6 +516,8 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) { fMenuView.setTitle("View"); fMenuView.addAction(&fActionBreakpoint); fMenuView.addAction(&fActionShowDeletes); + fMenuView.addAction(&fActionZoomIn); + fMenuView.addAction(&fActionZoomOut); fMenuWindows.setTitle("Window"); fMenuWindows.addAction(&fActionInspector); diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h index 072e58bc28..fcbf3b7855 100644 --- a/debugger/QT/SkDebuggerGUI.h +++ b/debugger/QT/SkDebuggerGUI.h @@ -202,6 +202,9 @@ private: QAction fActionShowDeletes; QAction fActionStepBack; QAction fActionStepForward; + QAction fActionZoomIn; + QAction fActionZoomOut; + QSignalMapper fMapper; QWidget fCentralWidget; QComboBox fFilter; diff --git a/debugger/QT/moc_SkCanvasWidget.cpp b/debugger/QT/moc_SkCanvasWidget.cpp index 098b3bb745..8164def960 100644 --- a/debugger/QT/moc_SkCanvasWidget.cpp +++ b/debugger/QT/moc_SkCanvasWidget.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'SkCanvasWidget.h' ** -** Created: Wed Jul 11 15:15:07 2012 +** Created: Thu Jul 26 15:56:26 2012 ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2) ** ** WARNING! All changes made in this file will be lost! @@ -23,7 +23,7 @@ static const uint qt_meta_data_SkCanvasWidget[] = { 4, // revision 0, // classname 0, 0, // classinfo - 3, 14, // methods + 4, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -35,6 +35,9 @@ static const uint qt_meta_data_SkCanvasWidget[] = { 68, 57, 15, 15, 0x05, 92, 88, 15, 15, 0x05, + // slots: signature, parameters, type, tag, flags + 122, 108, 15, 15, 0x08, + 0 // eod }; @@ -42,6 +45,7 @@ static const char qt_meta_stringdata_SkCanvasWidget[] = { "SkCanvasWidget\0\0newScaleFactor\0" "scaleFactorChanged(float)\0newCommand\0" "commandChanged(int)\0hit\0hitChanged(int)\0" + "zoomIncrement\0keyZoom(int)\0" }; const QMetaObject SkCanvasWidget::staticMetaObject = { @@ -76,9 +80,10 @@ int SkCanvasWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) case 0: scaleFactorChanged((*reinterpret_cast< float(*)>(_a[1]))); break; case 1: commandChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: hitChanged((*reinterpret_cast< int(*)>(_a[1]))); break; + case 3: keyZoom((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } - _id -= 3; + _id -= 4; } return _id; } |