summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@sosco.com>2009-09-15 12:12:08 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2009-09-15 14:05:53 (GMT)
commit56cec4cf9a8b04c979ced28cab89ce6232d4184a (patch)
treea9701f13161810d1e9bfbf7ef9cd8430a77580be /tests/manual
parentf42f5c457b3368adb4c92e521dc56969f138bdd3 (diff)
downloadQt-56cec4cf9a8b04c979ced28cab89ce6232d4184a.zip
Qt-56cec4cf9a8b04c979ced28cab89ce6232d4184a.tar.gz
Qt-56cec4cf9a8b04c979ced28cab89ce6232d4184a.tar.bz2
QCursor support for Symbian OS
Reviewed-By: Jason Barron Reviewed-By: Alessandro Portale Summary: QT_NO_CURSOR is now not defined for symbian builds Existing QCursor APIs are all supported New public API, QApplication::setNavigationMode, to allow the navigation mode to be set. I.E. on an S60 3.2 phone, some applications will want a virtual mouse cursor (web browser), while others are designed for keypad navigation. Symbian HAL is used for detecting input capabilities. Fix DND, code cleanup & comment QCursor visibility now uses a refcount, and is called from DND and the setNavigationMode so they are both simpler and don't interfere with each other. QApplication::setNavigationMode New public API for configuring cursor/keypad navi style. This links in with ongoing work on the 4-way keypad navi branch, but 2-way and 4-way modes both act as 2-way mode until that is integrated Some of the demos/examples have cursor switched on (those that were not usable with keypad) Virtual mouse support for non touch, non mouse phones (tested on N78) add *.d and .metadata (carbide debug file / workspace dir) to .gitignore System pointers are unavailable when using sprite workaround, so the system cursor shapes are compiled into qtgui as resources. MAC port does this also for shapes that aren't standard on the MAC. Refactor Drag'n'Drop to use QCursor Add test case to check all system cursor shapes Simply a mainwindow containing a label widget for each cursor shape, with the cursor property set appropriately QCursor(QBitmap,QBitmap) supported Fixed problem with the image & mask being inverted when using the QCursor constructor that takes two mono bitmaps. add .make.cache files to .gitignore Correct implementation of QApplication::setOverrideCursor QApplication::restoreOverrideCursor and QApplication::setOverrideCursor are now working correctly on Symbian platform. Performance will be slower compared with other platforms, because the Symbian window server has a cursor associated with each native window. Add test case for custom cursors Create a pixmap cursor and associate it with a widget. No changes to production code, since test passed 1st time ;) Add manual test for QCursor Make cursor independent of construction order Updated to work around window server issue where contruction order affects what cursor is displayed in child windows. Also changed to effectiveWinId following review comments Also fixed a problem which would make qcursor not link if configured with QT_NO_CURSOR Moved some multiply declared extern functions from cpp to _p.h files Implemented Symbian versions of the cursor functions. Merged in work I'd done based on tower. Fill in bits of stub functions based on windows port Removed QT_NO_CURSOR from list of config options forced on symbian Recompiled configure.exe Added stub functions for the missing functions in s60 port
Diffstat (limited to 'tests/manual')
-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