summaryrefslogtreecommitdiffstats
path: root/tests/manual/qcursor
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/qcursor')
-rw-r--r--tests/manual/qcursor/allcursors/allcursors.pro16
-rw-r--r--tests/manual/qcursor/allcursors/main.cpp13
-rw-r--r--tests/manual/qcursor/allcursors/mainwindow.cpp43
-rw-r--r--tests/manual/qcursor/allcursors/mainwindow.h28
-rw-r--r--tests/manual/qcursor/allcursors/mainwindow.ui210
-rw-r--r--tests/manual/qcursor/grab_override/data/monkey_on_64x64.pngbin0 -> 3479 bytes
-rw-r--r--tests/manual/qcursor/grab_override/grab_override.pro18
-rw-r--r--tests/manual/qcursor/grab_override/images.qrc6
-rw-r--r--tests/manual/qcursor/grab_override/main.cpp13
-rw-r--r--tests/manual/qcursor/grab_override/mainwindow.cpp100
-rw-r--r--tests/manual/qcursor/grab_override/mainwindow.h35
-rw-r--r--tests/manual/qcursor/grab_override/mainwindow.ui97
-rw-r--r--tests/manual/qcursor/qcursor.pro3
13 files changed, 582 insertions, 0 deletions
diff --git a/tests/manual/qcursor/allcursors/allcursors.pro b/tests/manual/qcursor/allcursors/allcursors.pro
new file mode 100644
index 0000000..8e7da30
--- /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 0000000..9fb7510
--- /dev/null
+++ b/tests/manual/qcursor/allcursors/main.cpp
@@ -0,0 +1,13 @@
+#include <QtGui/QApplication>
+#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 0000000..0046ddb
--- /dev/null
+++ b/tests/manual/qcursor/allcursors/mainwindow.cpp
@@ -0,0 +1,43 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QTimer>
+#include <QBitmap>
+#include <QImage>
+#include <QPainter>
+#include <QKeyEvent>
+#include <QPoint>
+
+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 0000000..e5c731c
--- /dev/null
+++ b/tests/manual/qcursor/allcursors/mainwindow.h
@@ -0,0 +1,28 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QtGui/QMainWindow>
+
+class QTimer;
+
+namespace Ui
+{
+ class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private:
+ void keyPressEvent(QKeyEvent* event);
+
+private:
+ 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 0000000..55ff78c
--- /dev/null
+++ b/tests/manual/qcursor/allcursors/mainwindow.ui
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>240</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Arrow</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_2">
+ <property name="cursor">
+ <cursorShape>UpArrowCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>up arrow</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="label_3">
+ <property name="cursor">
+ <cursorShape>CrossCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>cross</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="cursor">
+ <cursorShape>WaitCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>wait</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_5">
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>ibeam</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QLabel" name="label_6">
+ <property name="cursor">
+ <cursorShape>SizeVerCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>sizever</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="cursor">
+ <cursorShape>SizeHorCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>sizehor</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="label_8">
+ <property name="cursor">
+ <cursorShape>SizeFDiagCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>sizebdiag</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLabel" name="label_9">
+ <property name="cursor">
+ <cursorShape>SizeBDiagCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>sizefdiag</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_10">
+ <property name="cursor">
+ <cursorShape>SizeAllCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>sizeall</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLabel" name="label_11">
+ <property name="cursor">
+ <cursorShape>BlankCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>blank</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QLabel" name="label_12">
+ <property name="cursor">
+ <cursorShape>SplitVCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>splitv</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_13">
+ <property name="cursor">
+ <cursorShape>SplitHCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>splith</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="label_14">
+ <property name="cursor">
+ <cursorShape>PointingHandCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>pointhand</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QLabel" name="label_15">
+ <property name="cursor">
+ <cursorShape>ForbiddenCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>forbidden</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_16">
+ <property name="cursor">
+ <cursorShape>WhatsThisCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>whatsthis</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLabel" name="label_19">
+ <property name="cursor">
+ <cursorShape>BusyCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>busy</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_17">
+ <property name="cursor">
+ <cursorShape>OpenHandCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>openhand</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QLabel" name="label_18">
+ <property name="cursor">
+ <cursorShape>ClosedHandCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>closehand</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
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 0000000..990f604
--- /dev/null
+++ b/tests/manual/qcursor/grab_override/data/monkey_on_64x64.png
Binary files 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 0000000..c0f69be
--- /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 0000000..1d0cb92
--- /dev/null
+++ b/tests/manual/qcursor/grab_override/images.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+ <qresource prefix="/">
+ <file>data/monkey_on_64x64.png</file>
+ </qresource>
+</RCC>
diff --git a/tests/manual/qcursor/grab_override/main.cpp b/tests/manual/qcursor/grab_override/main.cpp
new file mode 100644
index 0000000..9fb7510
--- /dev/null
+++ b/tests/manual/qcursor/grab_override/main.cpp
@@ -0,0 +1,13 @@
+#include <QtGui/QApplication>
+#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 0000000..27dd0e7
--- /dev/null
+++ b/tests/manual/qcursor/grab_override/mainwindow.cpp
@@ -0,0 +1,100 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QTimer>
+#include <QBitmap>
+#include <QImage>
+#include <QPainter>
+#include <QKeyEvent>
+
+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 0000000..0b1f694
--- /dev/null
+++ b/tests/manual/qcursor/grab_override/mainwindow.h
@@ -0,0 +1,35 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QtGui/QMainWindow>
+
+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 0000000..bf35536
--- /dev/null
+++ b/tests/manual/qcursor/grab_override/mainwindow.ui
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>240</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QSplitter" name="splitter_2">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="midLineWidth">
+ <number>1</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QLabel" name="label">
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="text">
+ <string>Custom</string>
+ </property>
+ </widget>
+ <widget class="QSplitter" name="splitter">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="midLineWidth">
+ <number>1</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QLabel" name="label_2">
+ <property name="cursor">
+ <cursorShape>ForbiddenCursor</cursorShape>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="text">
+ <string>Forbidden</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_3">
+ <property name="cursor">
+ <cursorShape>WaitCursor</cursorShape>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="text">
+ <string>Wait</string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>240</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/manual/qcursor/qcursor.pro b/tests/manual/qcursor/qcursor.pro
new file mode 100644
index 0000000..af082a4
--- /dev/null
+++ b/tests/manual/qcursor/qcursor.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+
+SUBDIRS = allcursors grab_override