From 38be0d13830efd2d98281c645c3a60afe05ffece Mon Sep 17 00:00:00 2001 From: Qt by Nokia Date: Wed, 27 Apr 2011 12:05:43 +0200 Subject: Initial import from the monolithic Qt. This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12 --- tests/manual/qcursor/allcursors/allcursors.pro | 16 ++ tests/manual/qcursor/allcursors/main.cpp | 54 ++++++ tests/manual/qcursor/allcursors/mainwindow.cpp | 84 +++++++++ tests/manual/qcursor/allcursors/mainwindow.h | 68 +++++++ tests/manual/qcursor/allcursors/mainwindow.ui | 210 +++++++++++++++++++++ .../qcursor/grab_override/data/monkey_on_64x64.png | Bin 0 -> 3479 bytes .../manual/qcursor/grab_override/grab_override.pro | 18 ++ tests/manual/qcursor/grab_override/images.qrc | 6 + tests/manual/qcursor/grab_override/main.cpp | 54 ++++++ tests/manual/qcursor/grab_override/mainwindow.cpp | 141 ++++++++++++++ tests/manual/qcursor/grab_override/mainwindow.h | 76 ++++++++ tests/manual/qcursor/grab_override/mainwindow.ui | 97 ++++++++++ tests/manual/qcursor/qcursor.pro | 3 + 13 files changed, 827 insertions(+) create mode 100644 tests/manual/qcursor/allcursors/allcursors.pro create mode 100644 tests/manual/qcursor/allcursors/main.cpp create mode 100644 tests/manual/qcursor/allcursors/mainwindow.cpp create mode 100644 tests/manual/qcursor/allcursors/mainwindow.h create mode 100644 tests/manual/qcursor/allcursors/mainwindow.ui create mode 100644 tests/manual/qcursor/grab_override/data/monkey_on_64x64.png create mode 100644 tests/manual/qcursor/grab_override/grab_override.pro create mode 100644 tests/manual/qcursor/grab_override/images.qrc create mode 100644 tests/manual/qcursor/grab_override/main.cpp create mode 100644 tests/manual/qcursor/grab_override/mainwindow.cpp create mode 100644 tests/manual/qcursor/grab_override/mainwindow.h create mode 100644 tests/manual/qcursor/grab_override/mainwindow.ui create mode 100644 tests/manual/qcursor/qcursor.pro (limited to 'tests/manual/qcursor') diff --git a/tests/manual/qcursor/allcursors/allcursors.pro b/tests/manual/qcursor/allcursors/allcursors.pro new file mode 100644 index 0000000000..8e7da30752 --- /dev/null +++ b/tests/manual/qcursor/allcursors/allcursors.pro @@ -0,0 +1,16 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2009-08-05T17:13:23 +# +#------------------------------------------------- + +TARGET = tst_allcursors +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui diff --git a/tests/manual/qcursor/allcursors/main.cpp b/tests/manual/qcursor/allcursors/main.cpp new file mode 100644 index 0000000000..1cdc73ed90 --- /dev/null +++ b/tests/manual/qcursor/allcursors/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.showFullScreen(); +#ifdef QT_KEYPAD_NAVIGATION + QApplication::setNavigationMode(Qt::NavigationModeCursorForceVisible); +#endif + return a.exec(); +} diff --git a/tests/manual/qcursor/allcursors/mainwindow.cpp b/tests/manual/qcursor/allcursors/mainwindow.cpp new file mode 100644 index 0000000000..61d215fb9b --- /dev/null +++ b/tests/manual/qcursor/allcursors/mainwindow.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include +#include +#include +#include +#include +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::keyPressEvent(QKeyEvent* event) +{ + QPoint off(0, 0); + switch (event->key()) { + case Qt::Key_Up: + off.setY(-4); + break; + case Qt::Key_Down: + off.setY(4); + break; + case Qt::Key_Left: + off.setX(-4); + break; + case Qt::Key_Right: + off.setX(4); + break; + default: + return QMainWindow::keyPressEvent(event); + } + off += QCursor::pos(); + QCursor::setPos(off); +} diff --git a/tests/manual/qcursor/allcursors/mainwindow.h b/tests/manual/qcursor/allcursors/mainwindow.h new file mode 100644 index 0000000000..26e2c37796 --- /dev/null +++ b/tests/manual/qcursor/allcursors/mainwindow.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +class QTimer; + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + void keyPressEvent(QKeyEvent* event); + + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/tests/manual/qcursor/allcursors/mainwindow.ui b/tests/manual/qcursor/allcursors/mainwindow.ui new file mode 100644 index 0000000000..55ff78c605 --- /dev/null +++ b/tests/manual/qcursor/allcursors/mainwindow.ui @@ -0,0 +1,210 @@ + + + MainWindow + + + + 0 + 0 + 240 + 320 + + + + MainWindow + + + + + + + Arrow + + + + + + + UpArrowCursor + + + up arrow + + + + + + + CrossCursor + + + cross + + + + + + + WaitCursor + + + wait + + + + + + + IBeamCursor + + + ibeam + + + + + + + SizeVerCursor + + + sizever + + + + + + + SizeHorCursor + + + sizehor + + + + + + + SizeFDiagCursor + + + sizebdiag + + + + + + + SizeBDiagCursor + + + sizefdiag + + + + + + + SizeAllCursor + + + sizeall + + + + + + + BlankCursor + + + blank + + + + + + + SplitVCursor + + + splitv + + + + + + + SplitHCursor + + + splith + + + + + + + PointingHandCursor + + + pointhand + + + + + + + ForbiddenCursor + + + forbidden + + + + + + + WhatsThisCursor + + + whatsthis + + + + + + + BusyCursor + + + busy + + + + + + + OpenHandCursor + + + openhand + + + + + + + ClosedHandCursor + + + closehand + + + + + + + + + diff --git a/tests/manual/qcursor/grab_override/data/monkey_on_64x64.png b/tests/manual/qcursor/grab_override/data/monkey_on_64x64.png new file mode 100644 index 0000000000..990f604d98 Binary files /dev/null and b/tests/manual/qcursor/grab_override/data/monkey_on_64x64.png differ diff --git a/tests/manual/qcursor/grab_override/grab_override.pro b/tests/manual/qcursor/grab_override/grab_override.pro new file mode 100644 index 0000000000..c0f69be5ad --- /dev/null +++ b/tests/manual/qcursor/grab_override/grab_override.pro @@ -0,0 +1,18 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2009-08-05T17:13:23 +# +#------------------------------------------------- + +TARGET = t_cursors +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui + +RESOURCES += images.qrc diff --git a/tests/manual/qcursor/grab_override/images.qrc b/tests/manual/qcursor/grab_override/images.qrc new file mode 100644 index 0000000000..1d0cb92a15 --- /dev/null +++ b/tests/manual/qcursor/grab_override/images.qrc @@ -0,0 +1,6 @@ + + + + data/monkey_on_64x64.png + + diff --git a/tests/manual/qcursor/grab_override/main.cpp b/tests/manual/qcursor/grab_override/main.cpp new file mode 100644 index 0000000000..1cdc73ed90 --- /dev/null +++ b/tests/manual/qcursor/grab_override/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.showFullScreen(); +#ifdef QT_KEYPAD_NAVIGATION + QApplication::setNavigationMode(Qt::NavigationModeCursorForceVisible); +#endif + return a.exec(); +} diff --git a/tests/manual/qcursor/grab_override/mainwindow.cpp b/tests/manual/qcursor/grab_override/mainwindow.cpp new file mode 100644 index 0000000000..737122734a --- /dev/null +++ b/tests/manual/qcursor/grab_override/mainwindow.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include +#include +#include +#include +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), ui(new Ui::MainWindow) +{ + ui->setupUi(this); + QPixmap pix(":/data/monkey_on_64x64.png"); + + QImage mask(16, 16, QImage::Format_MonoLSB); + QImage bw(16, 16, QImage::Format_MonoLSB); + mask.fill(0); + bw.fill(0); + for (int x = 0; x < 16; x++) { + bw.setPixel(x, x, 1); + bw.setPixel(x, 15 - x, 1); + mask.setPixel(x, x, 1); + mask.setPixel(x, 15 - x, 1); + if (x > 0 && x < 15) { + mask.setPixel(x - 1, x, 1); + mask.setPixel(x + 1, x, 1); + mask.setPixel(x - 1, 15 - x, 1); + mask.setPixel(x + 1, 15 - x, 1); + } + } + + ccurs = QCursor(pix); + bcurs = QCursor(QBitmap::fromImage(bw), QBitmap::fromImage(mask)); + ui->label->setCursor(ccurs); + + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(toggleOverrideCursor())); + timer->start(2000); + + override = 0; +} + +MainWindow::~MainWindow() +{ + delete timer; + delete ui; +} + +void MainWindow::toggleOverrideCursor() +{ + switch (override) { + case 0: + QApplication::setOverrideCursor(Qt::BusyCursor); + break; + case 1: + QApplication::restoreOverrideCursor(); + break; + case 2: + ui->label->grabMouse(Qt::ForbiddenCursor); + break; + case 3: + case 5: + ui->label->releaseMouse(); + break; + case 4: + ui->label->grabMouse(); + break; + case 6: + ui->label->setCursor(bcurs); + break; + case 7: + ui->label->setCursor(ccurs); + break; + } + override = (override + 1) % 8; +} + +void MainWindow::keyPressEvent(QKeyEvent* event) +{ + QPoint off(0, 0); + switch (event->key()) { + case Qt::Key_Up: + off.setY(-4); + break; + case Qt::Key_Down: + off.setY(4); + break; + case Qt::Key_Left: + off.setX(-4); + break; + case Qt::Key_Right: + off.setX(4); + break; + default: + return QMainWindow::keyPressEvent(event); + } + off += QCursor::pos(); + QCursor::setPos(off); +} diff --git a/tests/manual/qcursor/grab_override/mainwindow.h b/tests/manual/qcursor/grab_override/mainwindow.h new file mode 100644 index 0000000000..ee135a653a --- /dev/null +++ b/tests/manual/qcursor/grab_override/mainwindow.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +class QTimer; + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private slots: + void toggleOverrideCursor(); + +private: + void keyPressEvent(QKeyEvent* event); + + Ui::MainWindow *ui; + QTimer *timer; + int override; + + QCursor ccurs; + QCursor bcurs; +}; + +#endif // MAINWINDOW_H diff --git a/tests/manual/qcursor/grab_override/mainwindow.ui b/tests/manual/qcursor/grab_override/mainwindow.ui new file mode 100644 index 0000000000..bf35536116 --- /dev/null +++ b/tests/manual/qcursor/grab_override/mainwindow.ui @@ -0,0 +1,97 @@ + + + MainWindow + + + + 0 + 0 + 240 + 320 + + + + MainWindow + + + + + + + QFrame::NoFrame + + + 1 + + + Qt::Vertical + + + + QFrame::Box + + + Custom + + + + + QFrame::NoFrame + + + 1 + + + Qt::Horizontal + + + + ForbiddenCursor + + + QFrame::Box + + + Forbidden + + + + + WaitCursor + + + QFrame::Box + + + Wait + + + + + + + + + + + 0 + 0 + 240 + 21 + + + + + + TopToolBarArea + + + false + + + + + + + + diff --git a/tests/manual/qcursor/qcursor.pro b/tests/manual/qcursor/qcursor.pro new file mode 100644 index 0000000000..af082a4b82 --- /dev/null +++ b/tests/manual/qcursor/qcursor.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS = allcursors grab_override -- cgit v1.2.3