summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets/tablet/tabletcanvas.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@theqtcompany.com>2015-07-31 11:57:48 +0200
committerShawn Rutledge <shawn.rutledge@theqtcompany.com>2016-01-28 19:17:08 +0000
commite6de387ea0d2bf479caf7216f206ff35241faa3b (patch)
tree70fb2efc79c994ac1c36bda407a33d68b40b80aa /examples/widgets/widgets/tablet/tabletcanvas.h
parent910f719bd111813f37278b67d07f9d12cb03a4ff (diff)
Polish the Tablet example
- Introduce Qt 5 signal-slot connection syntax. - Merge MainWindow::createMenus()/createActions() into MainWindow::createMenus(), removing the need to store the actions as member variables. Use QMenu::addAction() for brevity. - For actions in QActionGroups, carry the Valuator enum in QAction::data so that the slot to handle the selection does not need to compare the QAction pointer itself. - Use a non-modal QColorDialog, so that the user can change colors more easily while drawing. - Choose saner shortcut keys: control-Q should not override the default usage for quitting the application, and using shortcuts for About dialogs is anyway dubious. - Improve the example documentation. Change-Id: I57aaf5f5b885c13a953482dbcc41275dd3d6bff4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com>
Diffstat (limited to 'examples/widgets/widgets/tablet/tabletcanvas.h')
-rw-r--r--examples/widgets/widgets/tablet/tabletcanvas.h46
1 files changed, 21 insertions, 25 deletions
diff --git a/examples/widgets/widgets/tablet/tabletcanvas.h b/examples/widgets/widgets/tablet/tabletcanvas.h
index a7335dbaf0..6044884d32 100644
--- a/examples/widgets/widgets/tablet/tabletcanvas.h
+++ b/examples/widgets/widgets/tablet/tabletcanvas.h
@@ -61,27 +61,26 @@ class TabletCanvas : public QWidget
Q_OBJECT
public:
- enum AlphaChannelType { AlphaPressure, AlphaTangentialPressure, AlphaTilt, NoAlpha };
- enum ColorSaturationType { SaturationVTilt, SaturationHTilt,
- SaturationPressure, NoSaturation };
- enum LineWidthType { LineWidthPressure, LineWidthTilt, NoLineWidth };
+ enum Valuator { PressureValuator, TangentialPressureValuator,
+ TiltValuator, VTiltValuator, HTiltValuator, NoValuator };
+ Q_ENUM(Valuator)
TabletCanvas();
bool saveImage(const QString &file);
bool loadImage(const QString &file);
- void setAlphaChannelType(AlphaChannelType type)
- { alphaChannelType = type; }
- void setColorSaturationType(ColorSaturationType type)
- { colorSaturationType = type; }
- void setLineWidthType(LineWidthType type)
- { lineWidthType = type; }
- void setColor(const QColor &color)
- { myColor = color; }
+ void setAlphaChannelValuator(Valuator type)
+ { m_alphaChannelValuator = type; }
+ void setColorSaturationValuator(Valuator type)
+ { m_colorSaturationValuator = type; }
+ void setLineWidthType(Valuator type)
+ { m_lineWidthValuator = type; }
+ void setColor(const QColor &c)
+ { if (c.isValid()) m_color = c; }
QColor color() const
- { return myColor; }
+ { return m_color; }
void setTabletDevice(QTabletEvent *event)
- { myTabletDevice = event->device(); updateCursor(event); }
+ { updateCursor(event); }
int maximum(int a, int b)
{ return a > b ? a : b; }
@@ -97,17 +96,14 @@ private:
void updateBrush(const QTabletEvent *event);
void updateCursor(const QTabletEvent *event);
- AlphaChannelType alphaChannelType;
- ColorSaturationType colorSaturationType;
- LineWidthType lineWidthType;
- QTabletEvent::PointerType pointerType;
- QTabletEvent::TabletDevice myTabletDevice;
- QColor myColor;
-
- QPixmap pixmap;
- QBrush myBrush;
- QPen myPen;
- bool deviceDown;
+ Valuator m_alphaChannelValuator;
+ Valuator m_colorSaturationValuator;
+ Valuator m_lineWidthValuator;
+ QColor m_color;
+ QPixmap m_pixmap;
+ QBrush m_brush;
+ QPen m_pen;
+ bool m_deviceDown;
struct Point {
QPointF pos;