From bd5096d012327d4acb44449464cb00c488450cc5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 17:05:41 +0100 Subject: Add the QtMain windows library to the CMake files. Change-Id: Iff8b9bdd4b069721103e1cd5854e56b6116d7549 Reviewed-by: Andreas Holzammer Reviewed-by: Oswald Buddenhagen Reviewed-by: Alexander Neundorf Reviewed-by: Stephen Kelly --- tests/manual/cmake/CMakeLists.txt | 1 + tests/manual/cmake/pass8/CMakeLists.txt | 20 ++++++++++++ tests/manual/cmake/pass8/myobject.cpp | 54 +++++++++++++++++++++++++++++++ tests/manual/cmake/pass8/myobject.h | 57 +++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 tests/manual/cmake/pass8/CMakeLists.txt create mode 100644 tests/manual/cmake/pass8/myobject.cpp create mode 100644 tests/manual/cmake/pass8/myobject.h (limited to 'tests/manual') diff --git a/tests/manual/cmake/CMakeLists.txt b/tests/manual/cmake/CMakeLists.txt index 930936a7b5..2d0164a47b 100644 --- a/tests/manual/cmake/CMakeLists.txt +++ b/tests/manual/cmake/CMakeLists.txt @@ -88,3 +88,4 @@ expect_fail(fail4) expect_fail(fail5) expect_pass("pass(needsquoting)6") expect_pass(pass7) +expect_pass(pass8) diff --git a/tests/manual/cmake/pass8/CMakeLists.txt b/tests/manual/cmake/pass8/CMakeLists.txt new file mode 100644 index 0000000000..735b1bd26e --- /dev/null +++ b/tests/manual/cmake/pass8/CMakeLists.txt @@ -0,0 +1,20 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass8) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) + +add_definitions(${Qt5Core_DEFINITIONS}) + +qt5_wrap_cpp(moc_files myobject.h) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +# On non-windows, the WIN32 is harmless, and Qt5Core_QTMAIN_LIBRARIES is empty. +# We test that it is harmless on those, and test that it builds on Windows. +# It wouldn't build if WIN32 is used and Qt5Core_QTMAIN_LIBRARIES is empty. +add_executable(myobject WIN32 myobject.cpp ${moc_files} ) +target_link_libraries(myobject ${Qt5Core_LIBRARIES} ${Qt5Core_QTMAIN_LIBRARIES}) diff --git a/tests/manual/cmake/pass8/myobject.cpp b/tests/manual/cmake/pass8/myobject.cpp new file mode 100644 index 0000000000..b6287b2540 --- /dev/null +++ b/tests/manual/cmake/pass8/myobject.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "myobject.h" + +MyObject::MyObject(QObject *parent) + : QObject(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyObject myObject; + return 0; +} diff --git a/tests/manual/cmake/pass8/myobject.h b/tests/manual/cmake/pass8/myobject.h new file mode 100644 index 0000000000..71a65ee801 --- /dev/null +++ b/tests/manual/cmake/pass8/myobject.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif -- cgit v1.2.3 From d91cf1e53b450483d92c50965fd3c33ab1da4300 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 21 Feb 2012 16:09:30 +0100 Subject: clean up qmake-generated projects remove "header" and assignmets which are defaults or bogus, reorder some assignments. Change-Id: I67403872168c890ca3b696753ceb01c605d19be7 Reviewed-by: Rohan McGovern --- tests/manual/gestures/graphicsview/graphicsview.pro | 9 --------- tests/manual/lance/lance.pro | 1 - tests/manual/qgraphicslayout/flicker/flicker.pro | 6 ------ .../qhttpnetworkconnection/qhttpnetworkconnection.pro | 3 --- tests/manual/qimagereader/qimagereader.pro | 7 ------- tests/manual/qlocale/qlocale.pro | 6 ------ tests/manual/qnetworkaccessmanager/qget/qget.pro | 1 - .../qnetworkconfigurationmanager.pro | 3 --- tests/manual/qnetworkreply/qnetworkreply.pro | 3 --- .../qtabletevent/device_information/qtabletevent.pro | 16 ++++------------ .../qtabletevent/event_compression/event_compression.pro | 2 -- tests/manual/qwidget_zorder/qwidget_zorder.pro | 5 ----- tests/manual/repaint/mainwindow/mainwindow.pro | 13 ------------- tests/manual/repaint/scrollarea/scrollarea.pro | 13 ------------- tests/manual/repaint/splitter/splitter.pro | 13 ------------- tests/manual/repaint/tableview/tableview.pro | 6 ------ tests/manual/repaint/task141091/task141091.pro | 11 +---------- tests/manual/repaint/toplevel/toplevel.pro | 12 ------------ tests/manual/repaint/widget/widget.pro | 13 ------------- tests/manual/socketengine/socketengine.pro | 3 --- 20 files changed, 5 insertions(+), 141 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/gestures/graphicsview/graphicsview.pro b/tests/manual/gestures/graphicsview/graphicsview.pro index a40c323eb3..c5f6fe0764 100644 --- a/tests/manual/gestures/graphicsview/graphicsview.pro +++ b/tests/manual/gestures/graphicsview/graphicsview.pro @@ -1,12 +1,3 @@ -# ##################################################################### -# Automatically generated by qmake (2.01a) Mon Sep 7 13:26:43 2009 -# ##################################################################### -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp \ imageitem.cpp \ gestures.cpp \ diff --git a/tests/manual/lance/lance.pro b/tests/manual/lance/lance.pro index 7eee7ec2de..e24d3f2fa3 100644 --- a/tests/manual/lance/lance.pro +++ b/tests/manual/lance/lance.pro @@ -4,7 +4,6 @@ TEMPLATE = app INCLUDEPATH += . $$LANCELOT_DIR QT += core-private gui-private -# Input HEADERS += widgets.h \ interactivewidget.h \ $$LANCELOT_DIR/paintcommands.h diff --git a/tests/manual/qgraphicslayout/flicker/flicker.pro b/tests/manual/qgraphicslayout/flicker/flicker.pro index 323a30f7bf..2e09826022 100644 --- a/tests/manual/qgraphicslayout/flicker/flicker.pro +++ b/tests/manual/qgraphicslayout/flicker/flicker.pro @@ -1,8 +1,2 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += window.h SOURCES += main.cpp window.cpp diff --git a/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro index d73124c8f9..fd21007793 100644 --- a/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -1,13 +1,10 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qhttpnetworkconnection -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/manual/qimagereader/qimagereader.pro b/tests/manual/qimagereader/qimagereader.pro index b8293b9552..28dcadcbfa 100644 --- a/tests/manual/qimagereader/qimagereader.pro +++ b/tests/manual/qimagereader/qimagereader.pro @@ -1,8 +1 @@ - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp diff --git a/tests/manual/qlocale/qlocale.pro b/tests/manual/qlocale/qlocale.pro index e9f17f4f9f..4eaddedcf0 100644 --- a/tests/manual/qlocale/qlocale.pro +++ b/tests/manual/qlocale/qlocale.pro @@ -1,8 +1,2 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += currency.h calendar.h dateformats.h numberformats.h languages.h window.h miscellaneous.h info.h SOURCES += currency.cpp main.cpp calendar.cpp dateformats.cpp numberformats.cpp languages.cpp window.cpp miscellaneous.cpp info.cpp diff --git a/tests/manual/qnetworkaccessmanager/qget/qget.pro b/tests/manual/qnetworkaccessmanager/qget/qget.pro index 341f772b51..1f2b497171 100644 --- a/tests/manual/qnetworkaccessmanager/qget/qget.pro +++ b/tests/manual/qnetworkaccessmanager/qget/qget.pro @@ -2,6 +2,5 @@ TEMPLATE = app QT = core network CONFIG += console -# Input SOURCES += qget.cpp HEADERS += qget.h diff --git a/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro b/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro index 613fcd85e4..7ad271ce46 100644 --- a/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro +++ b/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro @@ -1,13 +1,10 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qnetworkconfigurationmanager -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/manual/qnetworkreply/qnetworkreply.pro b/tests/manual/qnetworkreply/qnetworkreply.pro index 479a1e63bc..17f48c6544 100644 --- a/tests/manual/qnetworkreply/qnetworkreply.pro +++ b/tests/manual/qnetworkreply/qnetworkreply.pro @@ -1,13 +1,10 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qnetworkreply -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/manual/qtabletevent/device_information/qtabletevent.pro b/tests/manual/qtabletevent/device_information/qtabletevent.pro index e0ed549004..8251d73094 100644 --- a/tests/manual/qtabletevent/device_information/qtabletevent.pro +++ b/tests/manual/qtabletevent/device_information/qtabletevent.pro @@ -1,13 +1,5 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Mon Aug 10 17:02:09 2009 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp\ +SOURCES += \ + main.cpp \ tabletwidget.cpp -HEADERS += tabletwidget.h +HEADERS += \ + tabletwidget.h diff --git a/tests/manual/qtabletevent/event_compression/event_compression.pro b/tests/manual/qtabletevent/event_compression/event_compression.pro index 273fd6c1b0..fd2521e44f 100644 --- a/tests/manual/qtabletevent/event_compression/event_compression.pro +++ b/tests/manual/qtabletevent/event_compression/event_compression.pro @@ -1,7 +1,5 @@ -TEMPLATE = app QT += testlib -# Input SOURCES += main.cpp \ mousestatwidget.cpp HEADERS += mousestatwidget.h diff --git a/tests/manual/qwidget_zorder/qwidget_zorder.pro b/tests/manual/qwidget_zorder/qwidget_zorder.pro index 5526f9161f..28dcadcbfa 100644 --- a/tests/manual/qwidget_zorder/qwidget_zorder.pro +++ b/tests/manual/qwidget_zorder/qwidget_zorder.pro @@ -1,6 +1 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp diff --git a/tests/manual/repaint/mainwindow/mainwindow.pro b/tests/manual/repaint/mainwindow/mainwindow.pro index c269d57eff..db6b2d280c 100644 --- a/tests/manual/repaint/mainwindow/mainwindow.pro +++ b/tests/manual/repaint/mainwindow/mainwindow.pro @@ -1,15 +1,2 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Nov 8 15:46:28 2006 -###################################################################### - -TEMPLATE = app -TARGET = mainwindow -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/scrollarea/scrollarea.pro b/tests/manual/repaint/scrollarea/scrollarea.pro index e1a40ad6ad..db6b2d280c 100644 --- a/tests/manual/repaint/scrollarea/scrollarea.pro +++ b/tests/manual/repaint/scrollarea/scrollarea.pro @@ -1,15 +1,2 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Nov 8 15:28:57 2006 -###################################################################### - -TEMPLATE = app -TARGET = scrollarea -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/splitter/splitter.pro b/tests/manual/repaint/splitter/splitter.pro index 0afc0630ba..db6b2d280c 100644 --- a/tests/manual/repaint/splitter/splitter.pro +++ b/tests/manual/repaint/splitter/splitter.pro @@ -1,15 +1,2 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Nov 8 15:39:53 2006 -###################################################################### - -TEMPLATE = app -TARGET = splitter -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/tableview/tableview.pro b/tests/manual/repaint/tableview/tableview.pro index 4fccf4abc9..4097c95739 100644 --- a/tests/manual/repaint/tableview/tableview.pro +++ b/tests/manual/repaint/tableview/tableview.pro @@ -1,8 +1,2 @@ HEADERS +=../shared/shared.h -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp diff --git a/tests/manual/repaint/task141091/task141091.pro b/tests/manual/repaint/task141091/task141091.pro index db89bd35b8..82ead4b6c2 100644 --- a/tests/manual/repaint/task141091/task141091.pro +++ b/tests/manual/repaint/task141091/task141091.pro @@ -1,12 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue Mar 6 13:44:00 2007 -###################################################################### +CONFIG += console -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . -CONFIG+=console - -# Input SOURCES += main.cpp diff --git a/tests/manual/repaint/toplevel/toplevel.pro b/tests/manual/repaint/toplevel/toplevel.pro index 568ea8e062..c2cc19f67d 100644 --- a/tests/manual/repaint/toplevel/toplevel.pro +++ b/tests/manual/repaint/toplevel/toplevel.pro @@ -1,16 +1,4 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue Nov 7 10:15:42 2006 -###################################################################### - -TEMPLATE = app -TARGET = toplevel -DEPENDPATH += . -INCLUDEPATH += . CONFIG += console -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/widget/widget.pro b/tests/manual/repaint/widget/widget.pro index c9d8f872e8..db6b2d280c 100644 --- a/tests/manual/repaint/widget/widget.pro +++ b/tests/manual/repaint/widget/widget.pro @@ -1,15 +1,2 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue Nov 7 11:16:05 2006 -###################################################################### - -TEMPLATE = app -TARGET = widget -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/socketengine/socketengine.pro b/tests/manual/socketengine/socketengine.pro index 24523e9ca4..808502c22a 100644 --- a/tests/manual/socketengine/socketengine.pro +++ b/tests/manual/socketengine/socketengine.pro @@ -1,13 +1,10 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_socketengine -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += main.cpp -- cgit v1.2.3 From 5a2efb490bc3549ef42420a0dafcf22072785e0d Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Mon, 9 Jan 2012 11:25:40 +0100 Subject: QWheelEvent high-resolution delta support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support pixel-based deltas as well as sending dx and dy values in the same event. Keep source and behavior compatibility with Qt 4. New API: QPoint pixelDelta() const QPoint angleDelta() const Deprecate delta() and orientation(). Both pixel-based deltas and combined updates are necessary for smooth trackpad-based scrolling on OS X. Qt 4 compatible behavior is achieved by sending an extra wheel event in cases where the initial event has a combined dx and dy update. This extra event sends dx in delta() and orientation(), with pixelDelta() and angleDelta() set to null. Modify the Cocoa implementation to provide pixel deltas. It is expected that not all platforms can provide these. Angle deltas will always be available. Change-Id: I20c10f0df338ddcd6a3f7a4d40949ed5ae3b4795 Reviewed-by: Morten Johan Sørvig --- tests/manual/cocoa/wheelevent/main.cpp | 59 +++++++ tests/manual/cocoa/wheelevent/wheelevent.pro | 6 + tests/manual/cocoa/wheelevent/window.cpp | 240 +++++++++++++++++++++++++++ tests/manual/cocoa/wheelevent/window.h | 76 +++++++++ 4 files changed, 381 insertions(+) create mode 100644 tests/manual/cocoa/wheelevent/main.cpp create mode 100644 tests/manual/cocoa/wheelevent/wheelevent.pro create mode 100644 tests/manual/cocoa/wheelevent/window.cpp create mode 100644 tests/manual/cocoa/wheelevent/window.h (limited to 'tests/manual') diff --git a/tests/manual/cocoa/wheelevent/main.cpp b/tests/manual/cocoa/wheelevent/main.cpp new file mode 100644 index 0000000000..979498991d --- /dev/null +++ b/tests/manual/cocoa/wheelevent/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "window.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + Window window; + window.show(); + + + return app.exec(); +} + + + diff --git a/tests/manual/cocoa/wheelevent/wheelevent.pro b/tests/manual/cocoa/wheelevent/wheelevent.pro new file mode 100644 index 0000000000..6eca6d48cf --- /dev/null +++ b/tests/manual/cocoa/wheelevent/wheelevent.pro @@ -0,0 +1,6 @@ +TEMPLATE = app + +HEADERS += window.h +SOURCES += window.cpp main.cpp + +QT += core gui gui-private core-private diff --git a/tests/manual/cocoa/wheelevent/window.cpp b/tests/manual/cocoa/wheelevent/window.cpp new file mode 100644 index 0000000000..b305b057bf --- /dev/null +++ b/tests/manual/cocoa/wheelevent/window.cpp @@ -0,0 +1,240 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "window.h" + +#include + +#include +#include +#include + +static int colorIndexId = 0; + +QColor colorTable[] = +{ + QColor("#f09f8f"), + QColor("#a2bff2"), + QColor("#c0ef8f") +}; + +Window::Window(QScreen *screen) + : QWindow(screen) + , m_backgroundColorIndex(colorIndexId++) +{ + initialize(); +} + +Window::Window(QWindow *parent) + : QWindow(parent) + , m_backgroundColorIndex(colorIndexId++) +{ + initialize(); +} + +void Window::initialize() +{ + if (parent()) + setGeometry(QRect(160, 120, 320, 240)); + else { + setGeometry(QRect(10, 10, 640, 480)); + + setSizeIncrement(QSize(10, 10)); + setBaseSize(QSize(640, 480)); + setMinimumSize(QSize(240, 160)); + setMaximumSize(QSize(800, 600)); + } + + create(); + m_backingStore = new QBackingStore(this); + + m_image = QImage(geometry().size(), QImage::Format_RGB32); + m_image.fill(colorTable[m_backgroundColorIndex % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); + + m_lastPos = QPoint(-1, -1); + m_renderTimer = 0; +} + +void Window::mousePressEvent(QMouseEvent *event) +{ + m_lastPos = event->pos(); +} + +void Window::mouseMoveEvent(QMouseEvent *event) +{ + if (m_lastPos != QPoint(-1, -1)) { + QPainter p(&m_image); + p.setRenderHint(QPainter::Antialiasing); + p.drawLine(m_lastPos, event->pos()); + m_lastPos = event->pos(); + } + + scheduleRender(); +} + +void Window::wheelEvent(QWheelEvent *event) +{ + qDebug() << "wheelEvent delta" << event->delta() << "orientation" << event->orientation(); + qDebug() << "wheelEvent pixelDelta" << event->pixelDelta(); + qDebug() << "wheelEvent angleDelta" << event->angleDelta(); + + const bool useQt4API = false; + + if (useQt4API) { + if (event->orientation() == Qt::Horizontal) + scrollOffset.setX(scrollOffset.x() + event->delta()); + else + scrollOffset.setY(scrollOffset.y() + event->delta()); + scheduleRender(); + } else { + if (!event->pixelDelta().isNull()) { + scrollOffset += event->pixelDelta(); + scheduleRender(); + } + } +} + +void Window::mouseReleaseEvent(QMouseEvent *event) +{ + if (m_lastPos != QPoint(-1, -1)) { + QPainter p(&m_image); + p.setRenderHint(QPainter::Antialiasing); + p.drawLine(m_lastPos, event->pos()); + m_lastPos = QPoint(-1, -1); + } + + scheduleRender(); +} + +void Window::exposeEvent(QExposeEvent *) +{ + scheduleRender(); +} + +void Window::resizeEvent(QResizeEvent *) +{ + QImage old = m_image; + + //qDebug() << "Window::resizeEvent" << width << height; + + int width = qMax(geometry().width(), old.width()); + int height = qMax(geometry().height(), old.height()); + + if (width > old.width() || height > old.height()) { + m_image = QImage(width, height, QImage::Format_RGB32); + m_image.fill(colorTable[(m_backgroundColorIndex) % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); + + QPainter p(&m_image); + p.drawImage(0, 0, old); + } + + render(); +} + +void Window::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Backspace: + m_text.chop(1); + break; + case Qt::Key_Enter: + case Qt::Key_Return: + m_text.append('\n'); + break; + default: + m_text.append(event->text()); + break; + } + scheduleRender(); +} + +void Window::scheduleRender() +{ + if (!m_renderTimer) + m_renderTimer = startTimer(1); +} + +void Window::timerEvent(QTimerEvent *) +{ + render(); + killTimer(m_renderTimer); + m_renderTimer = 0; +} + +void Window::render() +{ + QRect rect(QPoint(), geometry().size()); + + m_backingStore->resize(rect.size()); + + m_backingStore->beginPaint(rect); + + QPaintDevice *device = m_backingStore->paintDevice(); + + QPainter p(device); + p.drawImage(0, 0, m_image); + + QFont font; + font.setPixelSize(32); + + p.setFont(font); + p.drawText(rect, 0, m_text); + + // draw grid: + int gridSpace = 80; + + for (int y = 0; y < geometry().height() + gridSpace; y+= gridSpace) { + int offset = scrollOffset.y() % gridSpace; + //int color = ((y + offset) %255);// + scrollOffset.y()) % 255); + p.drawLine(0, y + offset, geometry().width(), y + offset); + //p.setBrush(QColor(color,0, 0)); + //p.fillRect(0, y + offset, geometry().width(), gridSpace,QColor(color,0, 0)); + } + + for (int x = 0; x < geometry().width() + gridSpace; x+= gridSpace) { + p.drawLine(x + scrollOffset.x() % gridSpace, 0, x + scrollOffset.x() % gridSpace, geometry().height()); + } + + m_backingStore->endPaint(); + m_backingStore->flush(rect); +} + + diff --git a/tests/manual/cocoa/wheelevent/window.h b/tests/manual/cocoa/wheelevent/window.h new file mode 100644 index 0000000000..523c9f3dc9 --- /dev/null +++ b/tests/manual/cocoa/wheelevent/window.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class Window : public QWindow +{ +public: + Window(QWindow *parent = 0); + Window(QScreen *screen); + +protected: + void mousePressEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + void mouseReleaseEvent(QMouseEvent *); + void wheelEvent(QWheelEvent *event); + + void keyPressEvent(QKeyEvent *); + + void exposeEvent(QExposeEvent *); + void resizeEvent(QResizeEvent *); + + void timerEvent(QTimerEvent *); + +private: + void render(); + void scheduleRender(); + void initialize(); + + QString m_text; + QImage m_image; + QPoint m_lastPos; + int m_backgroundColorIndex; + QBackingStore *m_backingStore; + int m_renderTimer; + QPoint scrollOffset; +}; -- cgit v1.2.3