Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/examples/widgets/tablet/main.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the examples of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/examples/widgets/tablet/mainwindow.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the examples of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    170170    alphaChannelGroup->addAction(alphaChannelTiltAction);
    171171    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*)));
    174174
    175175//! [9]
     
    192192    colorSaturationGroup->addAction(colorSaturationPressureAction);
    193193    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*)));
    196196
    197197    lineWidthPressureAction = new QAction(tr("&Pressure"), this);
     
    209209    lineWidthGroup->addAction(lineWidthTiltAction);
    210210    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*)));
    213213
    214214    exitAction = new QAction(tr("E&xit"), this);
    215     exitAction->setShortcut(tr("Ctrl+X"));
     215    exitAction->setShortcuts(QKeySequence::Quit);
    216216    connect(exitAction, SIGNAL(triggered()),
    217217            this, SLOT(close()));
    218218
    219219    loadAction = new QAction(tr("&Open..."), this);
    220     loadAction->setShortcut(tr("Ctrl+O"));
     220    loadAction->setShortcuts(QKeySequence::Open);
    221221    connect(loadAction, SIGNAL(triggered()),
    222222            this, SLOT(loadAct()));
    223223
    224224    saveAction = new QAction(tr("&Save As..."), this);
    225     saveAction->setShortcut(tr("Ctrl+S"));
     225    saveAction->setShortcuts(QKeySequence::SaveAs);
    226226    connect(saveAction, SIGNAL(triggered()),
    227227            this, SLOT(saveAct()));
  • trunk/examples/widgets/tablet/mainwindow.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the examples of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/examples/widgets/tablet/tablet.pro

    r2 r561  
    1212sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/tablet
    1313INSTALLS += target sources
     14
     15symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
  • trunk/examples/widgets/tablet/tabletapplication.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the examples of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/examples/widgets/tablet/tabletapplication.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the examples of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/examples/widgets/tablet/tabletcanvas.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the examples of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    5151    myBrush = QBrush();
    5252    myPen = QPen();
    53     initImage();
     53    initPixmap();
    5454    setAutoFillBackground(true);
    5555    deviceDown = false;
     
    6161}
    6262
    63 void TabletCanvas::initImage()
    64 {
    65     QImage 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.drawImage(0, 0, image);
     63void 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);
    7070    painter.end();
    71     image = newImage;
     71    pixmap = newPixmap;
    7272}
    7373//! [0]
     
    7676bool TabletCanvas::saveImage(const QString &file)
    7777{
    78     return image.save(file);
     78    return pixmap.save(file);
    7979}
    8080//! [1]
     
    8383bool TabletCanvas::loadImage(const QString &file)
    8484{
    85     bool success = image.load(file);
     85    bool success = pixmap.load(file);
    8686
    8787    if (success) {
     
    9999    switch (event->type()) {
    100100        case QEvent::TabletPress:
    101             if (!deviceDown)
     101            if (!deviceDown) {
    102102                deviceDown = true;
     103                polyLine[0] = polyLine[1] = polyLine[2] = event->pos();
     104            }
    103105            break;
    104106        case QEvent::TabletRelease:
     
    113115            if (deviceDown) {
    114116                updateBrush(event);
    115                 QPainter painter(&image);
    116                 paintImage(painter, event);
     117                QPainter painter(&pixmap);
     118                paintPixmap(painter, event);
    117119            }
    118120            break;
     
    128130{
    129131    QPainter painter(this);
    130     painter.drawImage(QPoint(0, 0), image);
     132    painter.drawPixmap(0, 0, pixmap);
    131133}
    132134//! [4]
    133135
    134136//! [5]
    135 void TabletCanvas::paintImage(QPainter &painter, QTabletEvent *event)
     137void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
    136138{
    137139    QPoint brushAdjust(10, 10);
    138140
    139141    switch (myTabletDevice) {
    140         case QTabletEvent::Stylus:
    141             painter.setBrush(myBrush);
    142             painter.setPen(myPen);
    143             painter.drawLine(polyLine[1], event->pos());
    144             break;
    145142        case QTabletEvent::Airbrush:
    146143            myBrush.setColor(myColor);
     
    157154        case QTabletEvent::FourDMouse:
    158155        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;
    163182    }
    164183}
     
    251270//! [11]
    252271
    253 void TabletCanvas::resizeEvent(QResizeEvent *event)
    254 {
    255     initImage();
     272void TabletCanvas::resizeEvent(QResizeEvent *)
     273{
     274    initPixmap();
    256275    polyLine[0] = polyLine[1] = polyLine[2] = QPoint();
    257276}
  • trunk/examples/widgets/tablet/tabletcanvas.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the examples of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4444
    4545#include <QWidget>
    46 #include <QImage>
     46#include <QPixmap>
    4747#include <QPoint>
    4848#include <QTabletEvent>
     
    9393
    9494private:
    95     void initImage();
    96     void paintImage(QPainter &painter, QTabletEvent *event);
     95    void initPixmap();
     96    void paintPixmap(QPainter &painter, QTabletEvent *event);
    9797    Qt::BrushStyle brushPattern(qreal value);
    9898    void updateBrush(QTabletEvent *event);
     
    105105    QColor myColor;
    106106
    107     QImage image;
     107    QPixmap pixmap;
    108108    QBrush myBrush;
    109109    QPen myPen;
Note: See TracChangeset for help on using the changeset viewer.