Changeset 561 for trunk/examples/widgets/tablet
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/examples/widgets/tablet/main.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/examples/widgets/tablet/mainwindow.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 170 170 alphaChannelGroup->addAction(alphaChannelTiltAction); 171 171 alphaChannelGroup->addAction(noAlphaChannelAction); 172 connect(alphaChannelGroup, SIGNAL(triggered(QAction 173 this, SLOT(alphaActionTriggered(QAction 172 connect(alphaChannelGroup, SIGNAL(triggered(QAction*)), 173 this, SLOT(alphaActionTriggered(QAction*))); 174 174 175 175 //! [9] … … 192 192 colorSaturationGroup->addAction(colorSaturationPressureAction); 193 193 colorSaturationGroup->addAction(noColorSaturationAction); 194 connect(colorSaturationGroup, SIGNAL(triggered(QAction 195 this, SLOT(saturationActionTriggered(QAction 194 connect(colorSaturationGroup, SIGNAL(triggered(QAction*)), 195 this, SLOT(saturationActionTriggered(QAction*))); 196 196 197 197 lineWidthPressureAction = new QAction(tr("&Pressure"), this); … … 209 209 lineWidthGroup->addAction(lineWidthTiltAction); 210 210 lineWidthGroup->addAction(lineWidthFixedAction); 211 connect(lineWidthGroup, SIGNAL(triggered(QAction 212 this, SLOT(lineWidthActionTriggered(QAction 211 connect(lineWidthGroup, SIGNAL(triggered(QAction*)), 212 this, SLOT(lineWidthActionTriggered(QAction*))); 213 213 214 214 exitAction = new QAction(tr("E&xit"), this); 215 exitAction->setShortcut (tr("Ctrl+X"));215 exitAction->setShortcuts(QKeySequence::Quit); 216 216 connect(exitAction, SIGNAL(triggered()), 217 217 this, SLOT(close())); 218 218 219 219 loadAction = new QAction(tr("&Open..."), this); 220 loadAction->setShortcut (tr("Ctrl+O"));220 loadAction->setShortcuts(QKeySequence::Open); 221 221 connect(loadAction, SIGNAL(triggered()), 222 222 this, SLOT(loadAct())); 223 223 224 224 saveAction = new QAction(tr("&Save As..."), this); 225 saveAction->setShortcut (tr("Ctrl+S"));225 saveAction->setShortcuts(QKeySequence::SaveAs); 226 226 connect(saveAction, SIGNAL(triggered()), 227 227 this, SLOT(saveAct())); -
trunk/examples/widgets/tablet/mainwindow.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/examples/widgets/tablet/tablet.pro
r2 r561 12 12 sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/tablet 13 13 INSTALLS += target sources 14 15 symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) -
trunk/examples/widgets/tablet/tabletapplication.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/examples/widgets/tablet/tabletapplication.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/examples/widgets/tablet/tabletcanvas.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 51 51 myBrush = QBrush(); 52 52 myPen = QPen(); 53 init Image();53 initPixmap(); 54 54 setAutoFillBackground(true); 55 55 deviceDown = false; … … 61 61 } 62 62 63 void TabletCanvas::init Image()64 { 65 Q Image newImage = QImage(width(), height(), QImage::Format_ARGB32);66 QPainter painter(&newImage);67 painter.fillRect(0, 0, newImage.width(), newImage.height(), Qt::white);68 if (! image.isNull())69 painter.draw Image(0, 0, image);63 void TabletCanvas::initPixmap() 64 { 65 QPixmap newPixmap = QPixmap(width(), height()); 66 newPixmap.fill(Qt::white); 67 QPainter painter(&newPixmap); 68 if (!pixmap.isNull()) 69 painter.drawPixmap(0, 0, pixmap); 70 70 painter.end(); 71 image = newImage;71 pixmap = newPixmap; 72 72 } 73 73 //! [0] … … 76 76 bool TabletCanvas::saveImage(const QString &file) 77 77 { 78 return image.save(file);78 return pixmap.save(file); 79 79 } 80 80 //! [1] … … 83 83 bool TabletCanvas::loadImage(const QString &file) 84 84 { 85 bool success = image.load(file);85 bool success = pixmap.load(file); 86 86 87 87 if (success) { … … 99 99 switch (event->type()) { 100 100 case QEvent::TabletPress: 101 if (!deviceDown) 101 if (!deviceDown) { 102 102 deviceDown = true; 103 polyLine[0] = polyLine[1] = polyLine[2] = event->pos(); 104 } 103 105 break; 104 106 case QEvent::TabletRelease: … … 113 115 if (deviceDown) { 114 116 updateBrush(event); 115 QPainter painter(& image);116 paint Image(painter, event);117 QPainter painter(&pixmap); 118 paintPixmap(painter, event); 117 119 } 118 120 break; … … 128 130 { 129 131 QPainter painter(this); 130 painter.draw Image(QPoint(0, 0), image);132 painter.drawPixmap(0, 0, pixmap); 131 133 } 132 134 //! [4] 133 135 134 136 //! [5] 135 void TabletCanvas::paint Image(QPainter &painter, QTabletEvent *event)137 void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event) 136 138 { 137 139 QPoint brushAdjust(10, 10); 138 140 139 141 switch (myTabletDevice) { 140 case QTabletEvent::Stylus:141 painter.setBrush(myBrush);142 painter.setPen(myPen);143 painter.drawLine(polyLine[1], event->pos());144 break;145 142 case QTabletEvent::Airbrush: 146 143 myBrush.setColor(myColor); … … 157 154 case QTabletEvent::FourDMouse: 158 155 case QTabletEvent::RotationStylus: 159 qWarning("This input device is not supported by the example."); 160 break; 161 default: 162 qWarning("Unknown tablet device."); 156 { 157 const QString error(tr("This input device is not supported by the example.")); 158 #ifndef QT_NO_STATUSTIP 159 QStatusTipEvent status(error); 160 QApplication::sendEvent(this, &status); 161 #else 162 qWarning() << error; 163 #endif 164 } 165 break; 166 default: 167 { 168 const QString error(tr("Unknown tablet device - treating as stylus")); 169 #ifndef QT_NO_STATUSTIP 170 QStatusTipEvent status(error); 171 QApplication::sendEvent(this, &status); 172 #else 173 qWarning() << error; 174 #endif 175 } 176 // FALL-THROUGH 177 case QTabletEvent::Stylus: 178 painter.setBrush(myBrush); 179 painter.setPen(myPen); 180 painter.drawLine(polyLine[1], event->pos()); 181 break; 163 182 } 164 183 } … … 251 270 //! [11] 252 271 253 void TabletCanvas::resizeEvent(QResizeEvent * event)254 { 255 init Image();272 void TabletCanvas::resizeEvent(QResizeEvent *) 273 { 274 initPixmap(); 256 275 polyLine[0] = polyLine[1] = polyLine[2] = QPoint(); 257 276 } -
trunk/examples/widgets/tablet/tabletcanvas.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 44 44 45 45 #include <QWidget> 46 #include <Q Image>46 #include <QPixmap> 47 47 #include <QPoint> 48 48 #include <QTabletEvent> … … 93 93 94 94 private: 95 void init Image();96 void paint Image(QPainter &painter, QTabletEvent *event);95 void initPixmap(); 96 void paintPixmap(QPainter &painter, QTabletEvent *event); 97 97 Qt::BrushStyle brushPattern(qreal value); 98 98 void updateBrush(QTabletEvent *event); … … 105 105 QColor myColor; 106 106 107 Q Image image;107 QPixmap pixmap; 108 108 QBrush myBrush; 109 109 QPen myPen;
Note:
See TracChangeset
for help on using the changeset viewer.