diff options
Diffstat (limited to 'tests/manual')
47 files changed, 1213 insertions, 1465 deletions
diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index 6826312880..c85fc439e9 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -90,7 +90,7 @@ void BearerEx::showConfigurations() font.setUnderline(true); listItem->setFont(font); listItem->setText(" UserChoice"); - listItem->setData(Qt::UserRole, qVariantFromValue(defaultConfig)); + listItem->setData(Qt::UserRole, QVariant::fromValue(defaultConfig)); listWidget->addItem(listItem); } @@ -121,7 +121,7 @@ void BearerEx::showConfigurations() listItem->setFont(font); } listItem->setText(text); - listItem->setData(Qt::UserRole, qVariantFromValue(configurations[i])); + listItem->setData(Qt::UserRole, QVariant::fromValue(configurations[i])); listWidget->addItem(listItem); } } @@ -143,7 +143,7 @@ void BearerEx::on_showDetailsButton_clicked() return; } - QNetworkConfiguration networkConfiguration = qVariantValue<QNetworkConfiguration>(item->data(Qt::UserRole)); + QNetworkConfiguration networkConfiguration = qvariant_cast<QNetworkConfiguration>(item->data(Qt::UserRole)); DetailedInfoDialog infoDialog(&networkConfiguration,this); infoDialog.exec(); } @@ -154,7 +154,7 @@ void BearerEx::on_createSessionButton_clicked() if (!item) { return; } - QNetworkConfiguration networkConfiguration = qVariantValue<QNetworkConfiguration>(item->data(Qt::UserRole)); + QNetworkConfiguration networkConfiguration = qvariant_cast<QNetworkConfiguration>(item->data(Qt::UserRole)); int newTabIndex = mainTabWidget->count(); SessionTab* newTab = new SessionTab(&networkConfiguration,&m_NetworkConfigurationManager,eventListWidget,newTabIndex-1); QString label = QString("S")+QString::number(newTabIndex-1); diff --git a/tests/manual/cmake/CMakeLists.txt b/tests/manual/cmake/CMakeLists.txt deleted file mode 100644 index f7b16946c1..0000000000 --- a/tests/manual/cmake/CMakeLists.txt +++ /dev/null @@ -1,93 +0,0 @@ - -# This is an automatic test for the CMake configuration files. -# To run it, -# 1) mkdir build # Create a build directory -# 2) cd build -# 3) cmake .. # Run cmake on this directory. -# 4) ctest # Run ctest -# -# The expected output is something like: -# -# Start 1: pass1 -# 1/7 Test #1: pass1 ............................ Passed 4.25 sec -# Start 2: pass2 -# 2/7 Test #2: pass2 ............................ Passed 2.00 sec -# Start 3: pass3 -# 3/7 Test #3: pass3 ............................ Passed 2.85 sec -# Start 4: fail4 -# 4/7 Test #4: fail4 ............................ Passed 1.88 sec -# Start 5: fail5 -# 5/7 Test #5: fail5 ............................ Passed 1.36 sec -# Start 6: pass_needsquoting_6 -# 6/7 Test #6: pass_needsquoting_6 .............. Passed 2.88 sec -# Start 7: pass7 -# 7/7 Test #7: pass7 ............................ Passed 0.93 sec -# -# Note that if Qt is not installed, or if it is installed to a -# non-standard prefix, the environment variable CMAKE_PREFIX_PATH -# needs to be set to the installation prefix or build prefix of Qt -# before running these tests. - -cmake_minimum_required(VERSION 2.8) - -project(qmake_cmake_files) - -enable_testing() - -macro(expect_pass _dir) - string(REPLACE "(" "_" testname "${_dir}") - string(REPLACE ")" "_" testname "${testname}") - add_test(${testname} ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" - "${CMAKE_CURRENT_BINARY_DIR}/${_dir}" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - ) -endmacro() - -macro(expect_fail _dir) - string(REPLACE "(" "_" testname "${_dir}") - string(REPLACE ")" "_" testname "${testname}") - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}") - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}") - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/CMakeLists.txt" - " - cmake_minimum_required(VERSION 2.8) - project(${_dir}_build) - - try_compile(Result \${CMAKE_CURRENT_BINARY_DIR}/${_dir} - \${CMAKE_CURRENT_SOURCE_DIR}/${_dir} - ${_dir} - OUTPUT_VARIABLE Out - ) - message(\"\${Out}\") - if (Result) - message(SEND_ERROR \"Succeeded build which should fail\") - endif() - " - ) - add_test(${testname} ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}" - "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/build" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - ) -endmacro() - -if(${CMAKE_VERSION} VERSION_GREATER 2.8.7) - # Requires CMAKE_AUTOMOC function in CMake 2.8.7 - expect_pass(pass1) -else() - message("CMake version older than 2.8.7. Not running test \"pass1\"") -endif() -expect_pass(pass2) -# Modules do not currently find their own dependencies. -# expect_pass(pass3) -expect_fail(fail4) -expect_fail(fail5) -expect_pass("pass(needsquoting)6") -expect_pass(pass7) -expect_pass(pass8) -expect_pass(pass9) diff --git a/tests/manual/cmake/fail4/CMakeLists.txt b/tests/manual/cmake/fail4/CMakeLists.txt deleted file mode 100644 index fdf90e17a7..0000000000 --- a/tests/manual/cmake/fail4/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(pass4) - -find_package(Qt5Core REQUIRED) - -include_directories(${Qt5Core_INCLUDE_DIRS}) - -add_definitions(${Qt5Core_DEFINITIONS}) - -qt5_wrap_cpp(moc_files myobject.h) - -# Test options. The -binary option generates a binary to dlopen instead of -# a source file to compile. The compiler will consider it garbage when used -# in the add_executable call. -qt5_add_resources(rcc_files "pass4.qrc" OPTIONS -binary) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") - -add_executable(myobject myobject.cpp ${moc_files} ${rcc_files}) -target_link_libraries(myobject ${Qt5Core_LIBRARIES}) diff --git a/tests/manual/cmake/fail4/myobject.cpp b/tests/manual/cmake/fail4/myobject.cpp deleted file mode 100644 index 292a76e569..0000000000 --- a/tests/manual/cmake/fail4/myobject.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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/fail4/myobject.h b/tests/manual/cmake/fail4/myobject.h deleted file mode 100644 index cd8765d03f..0000000000 --- a/tests/manual/cmake/fail4/myobject.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 <QObject> - -class MyObject : public QObject -{ - Q_OBJECT -public: - MyObject(QObject *parent = 0); - -signals: - void someSignal(); -}; - -#endif diff --git a/tests/manual/cmake/fail4/pass4.qrc b/tests/manual/cmake/fail4/pass4.qrc deleted file mode 100644 index 00a17f541f..0000000000 --- a/tests/manual/cmake/fail4/pass4.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/"> - <file>resource_file.txt</file> -</qresource> -</RCC> - diff --git a/tests/manual/cmake/fail4/resource_file.txt b/tests/manual/cmake/fail4/resource_file.txt deleted file mode 100644 index 2c604a4f18..0000000000 --- a/tests/manual/cmake/fail4/resource_file.txt +++ /dev/null @@ -1 +0,0 @@ -Ken sent me. diff --git a/tests/manual/cmake/fail5/CMakeLists.txt b/tests/manual/cmake/fail5/CMakeLists.txt deleted file mode 100644 index 962314c818..0000000000 --- a/tests/manual/cmake/fail5/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(pass5) - -find_package(Qt5Core REQUIRED) - -include_directories(${Qt5Core_INCLUDE_DIRS}) - -add_definitions(${Qt5Core_DEFINITIONS}) - -# Test options. The -i option removes the include "myobject.h" from the moc file -# causing a compile failure. -> Options work -qt5_wrap_cpp(moc_files myobject.h OPTIONS -i) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") - -add_executable(myobject myobject.cpp ${moc_files}) -target_link_libraries(myobject ${Qt5Core_LIBRARIES}) diff --git a/tests/manual/cmake/fail5/myobject.cpp b/tests/manual/cmake/fail5/myobject.cpp deleted file mode 100644 index 292a76e569..0000000000 --- a/tests/manual/cmake/fail5/myobject.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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/fail5/myobject.h b/tests/manual/cmake/fail5/myobject.h deleted file mode 100644 index cd8765d03f..0000000000 --- a/tests/manual/cmake/fail5/myobject.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 <QObject> - -class MyObject : public QObject -{ - Q_OBJECT -public: - MyObject(QObject *parent = 0); - -signals: - void someSignal(); -}; - -#endif diff --git a/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt b/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt deleted file mode 100644 index 7b9561c588..0000000000 --- a/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project("pass(needsquoting)6") - -find_package(Qt5Core REQUIRED) -find_package(Qt5Gui REQUIRED) -find_package(Qt5Widgets REQUIRED) - -include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) - -add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -qt5_wrap_cpp(moc_files mywidget.h) -qt5_wrap_ui(ui_files mywidget.ui) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") - -add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files}) -target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Core_LIBRARIES}) diff --git a/tests/manual/cmake/pass(needsquoting)6/mywidget.cpp b/tests/manual/cmake/pass(needsquoting)6/mywidget.cpp deleted file mode 100644 index 7f8923810d..0000000000 --- a/tests/manual/cmake/pass(needsquoting)6/mywidget.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 "mywidget.h" -#include "ui_mywidget.h" - -MyWidget::MyWidget(QWidget *parent) - : QWidget(parent) -{ - emit someSignal(); -} - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - MyWidget myWidget; - return 0; -} diff --git a/tests/manual/cmake/pass(needsquoting)6/mywidget.h b/tests/manual/cmake/pass(needsquoting)6/mywidget.h deleted file mode 100644 index 11968e6454..0000000000 --- a/tests/manual/cmake/pass(needsquoting)6/mywidget.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 MYWIDGET_H -#define MYWIDGET_H - -#include <QWidget> - -namespace Ui -{ -class MyWidget; -} - -class MyWidget : public QWidget -{ - Q_OBJECT -public: - MyWidget(QWidget *parent = 0); - -signals: - void someSignal(); - -private: - Ui::MyWidget *ui; -}; - -#endif diff --git a/tests/manual/cmake/pass(needsquoting)6/mywidget.ui b/tests/manual/cmake/pass(needsquoting)6/mywidget.ui deleted file mode 100644 index ac42ac4dc2..0000000000 --- a/tests/manual/cmake/pass(needsquoting)6/mywidget.ui +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Form</class> - <widget class="QWidget" name="Form"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="pushButton"> - <property name="text"> - <string>PushButton</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit"/> - </item> - <item> - <widget class="QTextEdit" name="textEdit"/> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/tests/manual/cmake/pass1/CMakeLists.txt b/tests/manual/cmake/pass1/CMakeLists.txt deleted file mode 100644 index 970ca33078..0000000000 --- a/tests/manual/cmake/pass1/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(pass1) - -set(CMAKE_AUTOMOC ON) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -macro(qt5_use_package _target _package) - if (NOT Qt5${_package}_FOUND) - find_package(Qt5${_package} ${ARG1}) - endif() - if (Qt5${_package}_FOUND) - # TODO: Handle public/private keywords? - target_link_libraries(${_target} ${Qt5${_package}_LIBRARIES}) - # ### Requires CMake 2.8.8: - # set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_package}_INCLUDE_DIRS}) - include_directories(${Qt5${_package}_INCLUDE_DIRS}) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_package}_COMPILE_DEFINITIONS}) - - # We can't just append to the COMPILE_FLAGS property. That creats a ';' separated list - # which breaks the compile commmand line. - # Ensure non-duplication here manually instead. - get_property(_taget_type TARGET ${_target} PROPERTY TYPE) - if ("${_taget_type}" STREQUAL "EXECUTABLE") - get_target_property(_flags ${_target} COMPILE_FLAGS) - if (_flags) - list(APPEND _flags ${Qt5${_package}_EXECUTABLE_COMPILE_FLAGS}) - list(REMOVE_DUPLICATES _flags) - else() - set(_flags ${Qt5${_package}_EXECUTABLE_COMPILE_FLAGS}) - endif() - if (_flags) - set_target_properties(${_target} PROPERTIES COMPILE_FLAGS ${_flags}) - endif() - endif() - else() - message(FATAL_ERROR "NOT FOUND: Qt5${_package}") - endif() -endmacro() - -add_executable(two two.cpp) -add_executable(three three.cpp) - -qt5_use_package(two Core) -qt5_use_package(two Test) -qt5_use_package(three Widgets) -qt5_use_package(three Gui) -qt5_use_package(three Core) -qt5_use_package(three Test) diff --git a/tests/manual/cmake/pass1/three.cpp b/tests/manual/cmake/pass1/three.cpp deleted file mode 100644 index 63bcbff480..0000000000 --- a/tests/manual/cmake/pass1/three.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 <QtTest> -#include <QWidget> - -class Three : public QObject -{ - Q_OBJECT -public: - Three(QObject *parent = 0) - { - QWidget *w = new QWidget; - w->show(); - } -}; - -QTEST_MAIN(Three) - -#include "three.moc" diff --git a/tests/manual/cmake/pass1/two.cpp b/tests/manual/cmake/pass1/two.cpp deleted file mode 100644 index 24fcd5dba4..0000000000 --- a/tests/manual/cmake/pass1/two.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 <QtTest> - -class Two : public QObject -{ - Q_OBJECT -public: - Two(QObject *parent = 0) - { - - } -}; - -QTEST_MAIN(Two) - -#include "two.moc" diff --git a/tests/manual/cmake/pass2/CMakeLists.txt b/tests/manual/cmake/pass2/CMakeLists.txt deleted file mode 100644 index c859f13fff..0000000000 --- a/tests/manual/cmake/pass2/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(pass2) - -find_package(Qt5Core REQUIRED) - -include_directories(${Qt5Core_INCLUDE_DIRS}) - -add_definitions(${Qt5Core_DEFINITIONS}) - -qt5_wrap_cpp(moc_files myobject.h) - -qt5_add_resources(rcc_files "pass2.qrc") - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") - -add_executable(myobject myobject.cpp ${moc_files} ${rcc_files}) -target_link_libraries(myobject ${Qt5Core_LIBRARIES}) diff --git a/tests/manual/cmake/pass2/myobject.cpp b/tests/manual/cmake/pass2/myobject.cpp deleted file mode 100644 index a237b00c50..0000000000 --- a/tests/manual/cmake/pass2/myobject.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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; - // Compile error if the resource file was not created. - Q_INIT_RESOURCE(pass2); - return 0; -} diff --git a/tests/manual/cmake/pass2/myobject.h b/tests/manual/cmake/pass2/myobject.h deleted file mode 100644 index cd8765d03f..0000000000 --- a/tests/manual/cmake/pass2/myobject.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 <QObject> - -class MyObject : public QObject -{ - Q_OBJECT -public: - MyObject(QObject *parent = 0); - -signals: - void someSignal(); -}; - -#endif diff --git a/tests/manual/cmake/pass2/pass2.qrc b/tests/manual/cmake/pass2/pass2.qrc deleted file mode 100644 index 00a17f541f..0000000000 --- a/tests/manual/cmake/pass2/pass2.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/"> - <file>resource_file.txt</file> -</qresource> -</RCC> - diff --git a/tests/manual/cmake/pass2/resource_file.txt b/tests/manual/cmake/pass2/resource_file.txt deleted file mode 100644 index 2c604a4f18..0000000000 --- a/tests/manual/cmake/pass2/resource_file.txt +++ /dev/null @@ -1 +0,0 @@ -Ken sent me. diff --git a/tests/manual/cmake/pass3/CMakeLists.txt b/tests/manual/cmake/pass3/CMakeLists.txt deleted file mode 100644 index 7fa6731f9b..0000000000 --- a/tests/manual/cmake/pass3/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(pass3) - -# The module finds its dependencies -find_package(Qt5Widgets REQUIRED) - -include_directories(${Qt5Widgets_INCLUDE_DIRS}) - -add_definitions(${Qt5Core_DEFINITIONS}) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -qt5_wrap_cpp(moc_files mywidget.h) -qt5_wrap_ui(ui_files mywidget.ui) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") - -add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files}) -target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES}) diff --git a/tests/manual/cmake/pass3/mywidget.cpp b/tests/manual/cmake/pass3/mywidget.cpp deleted file mode 100644 index 7f8923810d..0000000000 --- a/tests/manual/cmake/pass3/mywidget.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 "mywidget.h" -#include "ui_mywidget.h" - -MyWidget::MyWidget(QWidget *parent) - : QWidget(parent) -{ - emit someSignal(); -} - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - MyWidget myWidget; - return 0; -} diff --git a/tests/manual/cmake/pass3/mywidget.h b/tests/manual/cmake/pass3/mywidget.h deleted file mode 100644 index 11968e6454..0000000000 --- a/tests/manual/cmake/pass3/mywidget.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 MYWIDGET_H -#define MYWIDGET_H - -#include <QWidget> - -namespace Ui -{ -class MyWidget; -} - -class MyWidget : public QWidget -{ - Q_OBJECT -public: - MyWidget(QWidget *parent = 0); - -signals: - void someSignal(); - -private: - Ui::MyWidget *ui; -}; - -#endif diff --git a/tests/manual/cmake/pass3/mywidget.ui b/tests/manual/cmake/pass3/mywidget.ui deleted file mode 100644 index ac42ac4dc2..0000000000 --- a/tests/manual/cmake/pass3/mywidget.ui +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Form</class> - <widget class="QWidget" name="Form"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="pushButton"> - <property name="text"> - <string>PushButton</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit"/> - </item> - <item> - <widget class="QTextEdit" name="textEdit"/> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/tests/manual/cmake/pass7/CMakeLists.txt b/tests/manual/cmake/pass7/CMakeLists.txt deleted file mode 100644 index ecf6b3649e..0000000000 --- a/tests/manual/cmake/pass7/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(pass7) - -find_package(Qt5Core REQUIRED) - -include_directories(${Qt5Core_INCLUDE_DIRS}) -add_definitions(${Qt5Core_DEFINITIONS}) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") - -add_executable(myobject main.cpp) diff --git a/tests/manual/cmake/pass8/CMakeLists.txt b/tests/manual/cmake/pass8/CMakeLists.txt deleted file mode 100644 index 735b1bd26e..0000000000 --- a/tests/manual/cmake/pass8/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ - -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 deleted file mode 100644 index b6287b2540..0000000000 --- a/tests/manual/cmake/pass8/myobject.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 deleted file mode 100644 index 71a65ee801..0000000000 --- a/tests/manual/cmake/pass8/myobject.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 <QObject> - -class MyObject : public QObject -{ - Q_OBJECT -public: - MyObject(QObject *parent = 0); - -signals: - void someSignal(); -}; - -#endif diff --git a/tests/manual/cmake/pass9/CMakeLists.txt b/tests/manual/cmake/pass9/CMakeLists.txt deleted file mode 100644 index 6aefd37696..0000000000 --- a/tests/manual/cmake/pass9/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(pass9) - -find_package(Qt5DBus REQUIRED) - -include_directories( - ${Qt5DBus_INCLUDE_DIRS} -) - -add_definitions(${Qt5DBus_DEFINITIONS}) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(my_srcs mydbusobject.cpp) - -qt5_wrap_cpp(moc_files mydbusobject.h) - -qt5_generate_dbus_interface( - mydbusobject.h - ${CMAKE_BINARY_DIR}/org.qtProject.Tests.MyDBusObject.xml -) - -qt5_add_dbus_adaptor(my_srcs - ${CMAKE_BINARY_DIR}/org.qtProject.Tests.MyDBusObject.xml - mydbusobject.h - MyDBusObject -) - -add_executable(myobject ${my_srcs} ${moc_files}) -target_link_libraries(myobject ${Qt5DBus_LIBRARIES}) diff --git a/tests/manual/cmake/pass9/mydbusobject.cpp b/tests/manual/cmake/pass9/mydbusobject.cpp deleted file mode 100644 index ee211bbe9b..0000000000 --- a/tests/manual/cmake/pass9/mydbusobject.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 "mydbusobject.h" -#include "mydbusobjectadaptor.h" - -MyDBusObject::MyDBusObject(QObject *parent) - : QObject(parent) -{ - new MyDBusObjectAdaptor(this); - emit someSignal(); -} - -int main(int argc, char **argv) -{ - MyDBusObject myDBusObject; - return 0; -} diff --git a/tests/manual/cmake/pass9/mydbusobject.h b/tests/manual/cmake/pass9/mydbusobject.h deleted file mode 100644 index dd9a023ffe..0000000000 --- a/tests/manual/cmake/pass9/mydbusobject.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 MYDBUSOBJECT_H -#define MYDBUSOBJECT_H - -#include <QObject> - -class MyDBusObject : public QObject -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.qtProject.Tests.MyDBusObject") -public: - MyDBusObject(QObject *parent = 0); - -signals: - void someSignal(); -}; - -#endif diff --git a/tests/manual/keypadnavigation/main.cpp b/tests/manual/keypadnavigation/main.cpp index 964d46faf6..ad53c9f655 100644 --- a/tests/manual/keypadnavigation/main.cpp +++ b/tests/manual/keypadnavigation/main.cpp @@ -142,7 +142,7 @@ protected slots: QFontDialog::getFont(0, this); break; case DialogQuestion: - QMessageBox::question(this, QLatin1String("question"), QLatin1String("¿Hola, que tal?")); + QMessageBox::question(this, QLatin1String("question"), QLatin1String("\xbfHola, que tal?")); break; case DialogAboutQt: QMessageBox::aboutQt(this); diff --git a/tests/manual/lance/main.cpp b/tests/manual/lance/main.cpp index e8bb44a221..b66c0c109d 100644 --- a/tests/manual/lance/main.cpp +++ b/tests/manual/lance/main.cpp @@ -103,6 +103,7 @@ static void printHelp() " -imagewidget same as image, but with interacion...\n" #ifndef QT_NO_OPENGL " -opengl Paints the files to an OpenGL on screen\n" + " -pbuffer Paints the files to an OpenGL pbuffer\n" #endif #ifdef USE_CUSTOM_DEVICE " -customdevice Paints the files to the custom paint device\n" @@ -117,8 +118,11 @@ static void printHelp() " -grab Paints the files to an image called filename_qps.png\n" " -i Interactive mode.\n" " -v Verbose.\n" - " -bg-white No checkers background\n" - " -commands Displays all available commands\n"); + " -commands Displays all available commands\n" + " -w Width of the paintdevice\n" + " -h Height of the paintdevice\n" + " -cmp Show the reference picture\n" + " -bg-white No checkers background\n"); } static void displayCommands() diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 9df151eee1..ef72a5eec4 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -27,6 +27,7 @@ socketengine \ textrendering \ widgets/itemviews/delegate \ windowflags \ +windowgeometry \ windowmodality !contains(QT_CONFIG, openssl):!contains(QT_CONFIG, openssl-linked):SUBDIRS -= qssloptions diff --git a/tests/manual/windowflags/controllerwindow.cpp b/tests/manual/windowflags/controllerwindow.cpp index 586691a37d..1b547117d7 100644 --- a/tests/manual/windowflags/controllerwindow.cpp +++ b/tests/manual/windowflags/controllerwindow.cpp @@ -49,6 +49,7 @@ #include <QtWidgets/QHBoxLayout> #include "controllerwindow.h" +#include "controls.h" //! [0] ControllerWindow::ControllerWindow() @@ -62,7 +63,6 @@ ControllerWindow::ControllerWindow() previewDialog = new PreviewDialog; createTypeGroupBox(); - createHintsGroupBox(); quitButton = new QPushButton(tr("&Quit")); connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); @@ -71,11 +71,25 @@ ControllerWindow::ControllerWindow() bottomLayout->addStretch(); bottomLayout->addWidget(quitButton); + hintsControl = new HintControl; + hintsControl->setHints(previewWindow->windowFlags()); + connect(hintsControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview())); + + statesControl = new WindowStatesControl(WindowStatesControl::WantVisibleCheckBox); + statesControl->setStates(previewWindow->windowState()); + statesControl->setVisibleValue(true); + connect(statesControl, SIGNAL(changed()), this, SLOT(updatePreview())); + + typeControl = new TypeControl; + typeControl->setType(previewWindow->windowFlags()); + connect(typeControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview())); + QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(widgetTypeGroupBox); mainLayout->addWidget(additionalOptionsGroupBox); - mainLayout->addWidget(typeGroupBox); - mainLayout->addWidget(hintsGroupBox); + mainLayout->addWidget(typeControl); + mainLayout->addWidget(hintsControl); + mainLayout->addWidget(statesControl); mainLayout->addLayout(bottomLayout); setLayout(mainLayout); @@ -86,52 +100,7 @@ ControllerWindow::ControllerWindow() void ControllerWindow::updatePreview() { - Qt::WindowFlags flags = 0; - - if (windowRadioButton->isChecked()) { - flags = Qt::Window; - } else if (dialogRadioButton->isChecked()) { - flags = Qt::Dialog; - } else if (sheetRadioButton->isChecked()) { - flags = Qt::Sheet; - } else if (drawerRadioButton->isChecked()) { - flags = Qt::Drawer; - } else if (popupRadioButton->isChecked()) { - flags = Qt::Popup; - } else if (toolRadioButton->isChecked()) { - flags = Qt::Tool; - } else if (toolTipRadioButton->isChecked()) { - flags = Qt::ToolTip; - } else if (splashScreenRadioButton->isChecked()) { - flags = Qt::SplashScreen; - } - - if (msWindowsFixedSizeDialogCheckBox->isChecked()) - flags |= Qt::MSWindowsFixedSizeDialogHint; - if (x11BypassWindowManagerCheckBox->isChecked()) - flags |= Qt::X11BypassWindowManagerHint; - if (framelessWindowCheckBox->isChecked()) - flags |= Qt::FramelessWindowHint; - if (windowTitleCheckBox->isChecked()) - flags |= Qt::WindowTitleHint; - if (windowSystemMenuCheckBox->isChecked()) - flags |= Qt::WindowSystemMenuHint; - if (windowMinimizeButtonCheckBox->isChecked()) - flags |= Qt::WindowMinimizeButtonHint; - if (windowMaximizeButtonCheckBox->isChecked()) - flags |= Qt::WindowMaximizeButtonHint; - if (windowCloseButtonCheckBox->isChecked()) - flags |= Qt::WindowCloseButtonHint; - if (windowContextHelpButtonCheckBox->isChecked()) - flags |= Qt::WindowContextHelpButtonHint; - if (windowShadeButtonCheckBox->isChecked()) - flags |= Qt::WindowShadeButtonHint; - if (windowStaysOnTopCheckBox->isChecked()) - flags |= Qt::WindowStaysOnTopHint; - if (windowStaysOnBottomCheckBox->isChecked()) - flags |= Qt::WindowStaysOnBottomHint; - if (customizeWindowHintCheckBox->isChecked()) - flags |= Qt::CustomizeWindowHint; + const Qt::WindowFlags flags = typeControl->type() | hintsControl->hints(); previewWindow->hide(); previewDialog->hide(); @@ -165,7 +134,9 @@ void ControllerWindow::updatePreview() if (pos.y() < 0) pos.setY(0); widget->move(pos); - widget->show(); + + widget->setWindowState(statesControl->states()); + widget->setVisible(statesControl->visibleValue()); } void ControllerWindow::createTypeGroupBox() @@ -186,71 +157,10 @@ void ControllerWindow::createTypeGroupBox() l->addWidget(modalWindowCheckBox); l->addWidget(fixedSizeWindowCheckBox); additionalOptionsGroupBox->setLayout(l); - - typeGroupBox = new QGroupBox(tr("Type")); - - windowRadioButton = createRadioButton(tr("Window")); - dialogRadioButton = createRadioButton(tr("Dialog")); - sheetRadioButton = createRadioButton(tr("Sheet")); - drawerRadioButton = createRadioButton(tr("Drawer")); - popupRadioButton = createRadioButton(tr("Popup")); - toolRadioButton = createRadioButton(tr("Tool")); - toolTipRadioButton = createRadioButton(tr("Tooltip")); - splashScreenRadioButton = createRadioButton(tr("Splash screen")); - windowRadioButton->setChecked(true); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(windowRadioButton, 0, 0); - layout->addWidget(dialogRadioButton, 1, 0); - layout->addWidget(sheetRadioButton, 2, 0); - layout->addWidget(drawerRadioButton, 3, 0); - layout->addWidget(popupRadioButton, 0, 1); - layout->addWidget(toolRadioButton, 1, 1); - layout->addWidget(toolTipRadioButton, 2, 1); - layout->addWidget(splashScreenRadioButton, 3, 1); - typeGroupBox->setLayout(layout); } //! [5] //! [6] -void ControllerWindow::createHintsGroupBox() -{ - hintsGroupBox = new QGroupBox(tr("Hints")); - - msWindowsFixedSizeDialogCheckBox = - createCheckBox(tr("MS Windows fixed size dialog")); - x11BypassWindowManagerCheckBox = - createCheckBox(tr("X11 bypass window manager")); - framelessWindowCheckBox = createCheckBox(tr("Frameless window")); - windowTitleCheckBox = createCheckBox(tr("Window title")); - windowSystemMenuCheckBox = createCheckBox(tr("Window system menu")); - windowMinimizeButtonCheckBox = createCheckBox(tr("Window minimize button")); - windowMaximizeButtonCheckBox = createCheckBox(tr("Window maximize button")); - windowCloseButtonCheckBox = createCheckBox(tr("Window close button")); - windowContextHelpButtonCheckBox = - createCheckBox(tr("Window context help button")); - windowShadeButtonCheckBox = createCheckBox(tr("Window shade button")); - windowStaysOnTopCheckBox = createCheckBox(tr("Window stays on top")); - windowStaysOnBottomCheckBox = createCheckBox(tr("Window stays on bottom")); - customizeWindowHintCheckBox= createCheckBox(tr("Customize window")); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0); - layout->addWidget(x11BypassWindowManagerCheckBox, 1, 0); - layout->addWidget(framelessWindowCheckBox, 2, 0); - layout->addWidget(windowTitleCheckBox, 3, 0); - layout->addWidget(windowSystemMenuCheckBox, 4, 0); - layout->addWidget(windowMinimizeButtonCheckBox, 0, 1); - layout->addWidget(windowMaximizeButtonCheckBox, 1, 1); - layout->addWidget(windowCloseButtonCheckBox, 2, 1); - layout->addWidget(windowContextHelpButtonCheckBox, 3, 1); - layout->addWidget(windowShadeButtonCheckBox, 4, 1); - layout->addWidget(windowStaysOnTopCheckBox, 5, 1); - layout->addWidget(windowStaysOnBottomCheckBox, 6, 1); - layout->addWidget(customizeWindowHintCheckBox, 5, 0); - hintsGroupBox->setLayout(layout); -} -//! [6] //! [7] QCheckBox *ControllerWindow::createCheckBox(const QString &text) diff --git a/tests/manual/windowflags/controllerwindow.h b/tests/manual/windowflags/controllerwindow.h index 02827cffd8..5f6edbb3cb 100644 --- a/tests/manual/windowflags/controllerwindow.h +++ b/tests/manual/windowflags/controllerwindow.h @@ -42,7 +42,7 @@ #ifndef CONTROLLERWINDOW_H #define CONTROLLERWINDOW_H -#include <QWidget> +#include <QtWidgets/QWidget> #include "previewwindow.h" @@ -55,6 +55,10 @@ class QRadioButton; class QMainWindow; QT_END_NAMESPACE +class HintControl; +class WindowStatesControl; +class TypeControl; + //! [0] class ControllerWindow : public QWidget { @@ -68,47 +72,24 @@ private slots: private: void createTypeGroupBox(); - void createHintsGroupBox(); QCheckBox *createCheckBox(const QString &text); QRadioButton *createRadioButton(const QString &text); QMainWindow *parentWindow; PreviewWindow *previewWindow; PreviewDialog *previewDialog; - QGroupBox *widgetTypeGroupBox; QGroupBox *additionalOptionsGroupBox; - QGroupBox *typeGroupBox; - QGroupBox *hintsGroupBox; + TypeControl *typeControl; + HintControl *hintsControl; + WindowStatesControl *statesControl; + QPushButton *quitButton; QRadioButton *previewWidgetButton; QRadioButton *previewDialogButton; QCheckBox *modalWindowCheckBox; QCheckBox *fixedSizeWindowCheckBox; - - QRadioButton *windowRadioButton; - QRadioButton *dialogRadioButton; - QRadioButton *sheetRadioButton; - QRadioButton *drawerRadioButton; - QRadioButton *popupRadioButton; - QRadioButton *toolRadioButton; - QRadioButton *toolTipRadioButton; - QRadioButton *splashScreenRadioButton; - - QCheckBox *msWindowsFixedSizeDialogCheckBox; - QCheckBox *x11BypassWindowManagerCheckBox; - QCheckBox *framelessWindowCheckBox; - QCheckBox *windowTitleCheckBox; - QCheckBox *windowSystemMenuCheckBox; - QCheckBox *windowMinimizeButtonCheckBox; - QCheckBox *windowMaximizeButtonCheckBox; - QCheckBox *windowCloseButtonCheckBox; - QCheckBox *windowContextHelpButtonCheckBox; - QCheckBox *windowShadeButtonCheckBox; - QCheckBox *windowStaysOnTopCheckBox; - QCheckBox *windowStaysOnBottomCheckBox; - QCheckBox *customizeWindowHintCheckBox; }; //! [0] diff --git a/tests/manual/windowflags/controls.cpp b/tests/manual/windowflags/controls.cpp new file mode 100644 index 0000000000..bdd8894c0d --- /dev/null +++ b/tests/manual/windowflags/controls.cpp @@ -0,0 +1,314 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples 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 "controls.h" + +#include <QGridLayout> +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QRadioButton> +#include <QCheckBox> +#include <QRadioButton> +#include <QButtonGroup> +#include <QDebug> + +HintControl::HintControl(QWidget *parent) + : QGroupBox(tr("Hints"), parent) + , msWindowsFixedSizeDialogCheckBox(new QCheckBox(tr("MS Windows fixed size dialog"))) + , x11BypassWindowManagerCheckBox(new QCheckBox(tr("X11 bypass window manager"))) + , framelessWindowCheckBox(new QCheckBox(tr("Frameless window"))) + , windowTitleCheckBox(new QCheckBox(tr("Window title"))) + , windowSystemMenuCheckBox(new QCheckBox(tr("Window system menu"))) + , windowMinimizeButtonCheckBox(new QCheckBox(tr("Window minimize button"))) + , windowMaximizeButtonCheckBox(new QCheckBox(tr("Window maximize button"))) + , windowCloseButtonCheckBox(new QCheckBox(tr("Window close button"))) + , windowContextHelpButtonCheckBox(new QCheckBox(tr("Window context help button"))) + , windowShadeButtonCheckBox(new QCheckBox(tr("Window shade button"))) + , windowStaysOnTopCheckBox(new QCheckBox(tr("Window stays on top"))) + , windowStaysOnBottomCheckBox(new QCheckBox(tr("Window stays on bottom"))) + , customizeWindowHintCheckBox(new QCheckBox(tr("Customize window"))) +{ + connect(msWindowsFixedSizeDialogCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(x11BypassWindowManagerCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(framelessWindowCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(windowTitleCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(windowSystemMenuCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(windowMinimizeButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(windowMaximizeButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(windowCloseButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(windowContextHelpButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(windowShadeButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(windowStaysOnTopCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(windowStaysOnBottomCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(customizeWindowHintCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + QGridLayout *layout = new QGridLayout(this); + layout->setSpacing(0); + layout->setMargin(ControlLayoutMargin); + layout->addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0); + layout->addWidget(x11BypassWindowManagerCheckBox, 1, 0); + layout->addWidget(framelessWindowCheckBox, 2, 0); + layout->addWidget(windowTitleCheckBox, 3, 0); + layout->addWidget(windowSystemMenuCheckBox, 4, 0); + layout->addWidget(windowMinimizeButtonCheckBox, 0, 1); + layout->addWidget(windowMaximizeButtonCheckBox, 1, 1); + layout->addWidget(windowCloseButtonCheckBox, 2, 1); + layout->addWidget(windowContextHelpButtonCheckBox, 3, 1); + layout->addWidget(windowShadeButtonCheckBox, 4, 1); + layout->addWidget(windowStaysOnTopCheckBox, 5, 1); + layout->addWidget(windowStaysOnBottomCheckBox, 6, 1); + layout->addWidget(customizeWindowHintCheckBox, 5, 0); +} + +Qt::WindowFlags HintControl::hints() const +{ + Qt::WindowFlags flags = 0; + if (msWindowsFixedSizeDialogCheckBox->isChecked()) + flags |= Qt::MSWindowsFixedSizeDialogHint; + if (x11BypassWindowManagerCheckBox->isChecked()) + flags |= Qt::X11BypassWindowManagerHint; + if (framelessWindowCheckBox->isChecked()) + flags |= Qt::FramelessWindowHint; + if (windowTitleCheckBox->isChecked()) + flags |= Qt::WindowTitleHint; + if (windowSystemMenuCheckBox->isChecked()) + flags |= Qt::WindowSystemMenuHint; + if (windowMinimizeButtonCheckBox->isChecked()) + flags |= Qt::WindowMinimizeButtonHint; + if (windowMaximizeButtonCheckBox->isChecked()) + flags |= Qt::WindowMaximizeButtonHint; + if (windowCloseButtonCheckBox->isChecked()) + flags |= Qt::WindowCloseButtonHint; + if (windowContextHelpButtonCheckBox->isChecked()) + flags |= Qt::WindowContextHelpButtonHint; + if (windowShadeButtonCheckBox->isChecked()) + flags |= Qt::WindowShadeButtonHint; + if (windowStaysOnTopCheckBox->isChecked()) + flags |= Qt::WindowStaysOnTopHint; + if (windowStaysOnBottomCheckBox->isChecked()) + flags |= Qt::WindowStaysOnBottomHint; + if (customizeWindowHintCheckBox->isChecked()) + flags |= Qt::CustomizeWindowHint; + return flags; +} + +void HintControl::setHints(Qt::WindowFlags flags) +{ + msWindowsFixedSizeDialogCheckBox->setChecked(flags & Qt::MSWindowsFixedSizeDialogHint); + x11BypassWindowManagerCheckBox->setChecked(flags & Qt::X11BypassWindowManagerHint); + framelessWindowCheckBox->setChecked(flags & Qt::FramelessWindowHint); + windowTitleCheckBox->setChecked(flags & Qt::WindowTitleHint); + windowSystemMenuCheckBox->setChecked(flags & Qt::WindowSystemMenuHint); + windowMinimizeButtonCheckBox->setChecked(flags & Qt::WindowMinimizeButtonHint); + windowMaximizeButtonCheckBox->setChecked(flags & Qt::WindowMaximizeButtonHint); + windowCloseButtonCheckBox->setChecked(flags & Qt::WindowCloseButtonHint); + windowContextHelpButtonCheckBox->setChecked(flags & Qt::WindowContextHelpButtonHint); + windowShadeButtonCheckBox->setChecked(flags & Qt::WindowShadeButtonHint); + windowStaysOnTopCheckBox->setChecked(flags & Qt::WindowStaysOnTopHint); + windowStaysOnBottomCheckBox->setChecked(flags & Qt::WindowStaysOnBottomHint); + customizeWindowHintCheckBox->setChecked(flags & Qt::CustomizeWindowHint); +} + +void HintControl::slotCheckBoxChanged() +{ + emit changed(hints()); +} + +WindowStateControl::WindowStateControl(unsigned flags, QWidget *parent) + : QWidget(parent) + , group(new QButtonGroup) + , visibleCheckBox(0) + , restoreButton(new QRadioButton(tr("Normal"))) + , minimizeButton(0) + , maximizeButton(new QRadioButton(tr("Maximized"))) + , fullscreenButton(new QRadioButton(tr("Fullscreen"))) +{ + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setSpacing(0); + layout->setMargin(ControlLayoutMargin); + if (flags & WantVisibleCheckBox) { + visibleCheckBox = new QCheckBox(tr("Visible")); + connect(visibleCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + layout->addWidget(visibleCheckBox); + } + + group->setExclusive(true); + if (flags & WantMinimizeRadioButton) { + minimizeButton = new QRadioButton(tr("Minimized")); + group->addButton(minimizeButton, Qt::WindowMinimized); + layout->addWidget(minimizeButton); + } + group->addButton(restoreButton, Qt::WindowNoState); + layout->addWidget(restoreButton); + group->addButton(maximizeButton, Qt::WindowMaximized); + layout->addWidget(maximizeButton); + group->addButton(fullscreenButton, Qt::WindowFullScreen); + layout->addWidget(fullscreenButton); + connect(group, SIGNAL(buttonReleased(int)), this, SIGNAL(changed())); +} + +Qt::WindowState WindowStateControl::state() const +{ + return Qt::WindowState(group->checkedId()); +} + +void WindowStateControl::setState(Qt::WindowState s) +{ + group->blockSignals(true); + if (QAbstractButton *b = group->button(s)) + b->setChecked(true); + group->blockSignals(false); +} + +bool WindowStateControl::visibleValue() const +{ + return visibleCheckBox && visibleCheckBox->isChecked(); +} + +void WindowStateControl::setVisibleValue(bool v) +{ + if (visibleCheckBox) { + visibleCheckBox->blockSignals(true); + visibleCheckBox->setChecked(v); + visibleCheckBox->blockSignals(false); + } +} + +WindowStatesControl::WindowStatesControl(unsigned flags, QWidget *parent) + : QGroupBox(tr("States"), parent) + , visibleCheckBox(0) + , minimizeCheckBox(new QCheckBox(tr("Minimized"))) + , stateControl(new WindowStateControl(0)) +{ + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setSpacing(0); + layout->setMargin(ControlLayoutMargin); + if (flags & WantVisibleCheckBox) { + visibleCheckBox = new QCheckBox(tr("Visible")); + connect(visibleCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + layout->addWidget(visibleCheckBox); + } + layout->addWidget(minimizeCheckBox); + layout->addWidget(stateControl); + connect(stateControl, SIGNAL(changed()), this, SIGNAL(changed())); + connect(minimizeCheckBox, SIGNAL(clicked()), this, SIGNAL(changed())); +} + +Qt::WindowStates WindowStatesControl::states() const +{ + Qt::WindowStates s = stateControl->state(); + if (minimizeCheckBox->isChecked()) + s |= Qt::WindowMinimized; + return s; +} + +void WindowStatesControl::setStates(Qt::WindowStates s) +{ + minimizeCheckBox->blockSignals(true); + minimizeCheckBox->setChecked(s & Qt::WindowMinimized); + minimizeCheckBox->blockSignals(false); + s &= ~Qt::WindowMinimized; + stateControl->setState(Qt::WindowState(int(s))); +} + +bool WindowStatesControl::visibleValue() const +{ + return visibleCheckBox && visibleCheckBox->isChecked(); +} + +void WindowStatesControl::setVisibleValue(bool v) +{ + if (visibleCheckBox) { + visibleCheckBox->blockSignals(true); + visibleCheckBox->setChecked(v); + visibleCheckBox->blockSignals(false); + } +} + +TypeControl::TypeControl(QWidget *parent) + : QGroupBox(tr("Type"), parent) + , group(new QButtonGroup) + , windowRadioButton(new QRadioButton(tr("Window"))) + , dialogRadioButton(new QRadioButton(tr("Dialog"))) + , sheetRadioButton(new QRadioButton(tr("Sheet"))) + , drawerRadioButton(new QRadioButton(tr("Drawer"))) + , popupRadioButton(new QRadioButton(tr("Popup"))) + , toolRadioButton(new QRadioButton(tr("Tool"))) + , toolTipRadioButton(new QRadioButton(tr("Tooltip"))) + , splashScreenRadioButton(new QRadioButton(tr("Splash screen"))) +{ + group->setExclusive(true); + QGridLayout *layout = new QGridLayout(this); + layout->setSpacing(0); + layout->setMargin(ControlLayoutMargin); + group->addButton(windowRadioButton, Qt::Window); + layout->addWidget(windowRadioButton, 0, 0); + group->addButton(dialogRadioButton, Qt::Dialog); + layout->addWidget(dialogRadioButton, 1, 0); + group->addButton(sheetRadioButton, Qt::Sheet); + layout->addWidget(sheetRadioButton, 2, 0); + group->addButton(drawerRadioButton, Qt::Drawer); + layout->addWidget(drawerRadioButton, 3, 0); + group->addButton(popupRadioButton, Qt::Popup); + layout->addWidget(popupRadioButton, 0, 1); + group->addButton(toolRadioButton, Qt::Tool); + layout->addWidget(toolRadioButton, 1, 1); + group->addButton(toolTipRadioButton, Qt::ToolTip); + layout->addWidget(toolTipRadioButton, 2, 1); + group->addButton(splashScreenRadioButton, Qt::SplashScreen); + layout->addWidget(splashScreenRadioButton, 3, 1); + connect(group, SIGNAL(buttonReleased(int)), this, SLOT(slotChanged())); +} + +Qt::WindowFlags TypeControl::type() const +{ + return Qt::WindowFlags(group->checkedId()); +} + +void TypeControl::setType(Qt::WindowFlags s) +{ + if (QAbstractButton *b = group->button(s & Qt::WindowType_Mask)) + b->setChecked(true); +} + +void TypeControl::slotChanged() +{ + emit changed(type()); +} diff --git a/tests/manual/windowflags/controls.h b/tests/manual/windowflags/controls.h new file mode 100644 index 0000000000..57d9798882 --- /dev/null +++ b/tests/manual/windowflags/controls.h @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples 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 CONTROLS_H +#define CONTROLS_H + +#include <QGroupBox> + +QT_BEGIN_NAMESPACE +class QCheckBox; +class QRadioButton; +class QButtonGroup; +QT_END_NAMESPACE + +enum { ControlLayoutMargin = 4 }; + +// Control for the hint part of Qt::WindowFlags +class HintControl : public QGroupBox +{ + Q_OBJECT +public: + explicit HintControl(QWidget *parent= 0); + + Qt::WindowFlags hints() const; + void setHints(Qt::WindowFlags hints); + +signals: + void changed(Qt::WindowFlags); + +private slots: + void slotCheckBoxChanged(); + +private: + QCheckBox *msWindowsFixedSizeDialogCheckBox; + QCheckBox *x11BypassWindowManagerCheckBox; + QCheckBox *framelessWindowCheckBox; + QCheckBox *windowTitleCheckBox; + QCheckBox *windowSystemMenuCheckBox; + QCheckBox *windowMinimizeButtonCheckBox; + QCheckBox *windowMaximizeButtonCheckBox; + QCheckBox *windowCloseButtonCheckBox; + QCheckBox *windowContextHelpButtonCheckBox; + QCheckBox *windowShadeButtonCheckBox; + QCheckBox *windowStaysOnTopCheckBox; + QCheckBox *windowStaysOnBottomCheckBox; + QCheckBox *customizeWindowHintCheckBox; +}; + +// Control for the Qt::WindowState enum, optional with a "visible" QCheckbox +class WindowStateControl : public QWidget { + Q_OBJECT +public: + enum Flags { + WantVisibleCheckBox = 0x1, + WantMinimizeRadioButton = 0x2 + }; + + explicit WindowStateControl(unsigned flags, QWidget *parent= 0); + + Qt::WindowState state() const; + void setState(Qt::WindowState s); + + bool visibleValue() const; + void setVisibleValue(bool); + +signals: + void changed(); + +private: + QButtonGroup *group; + QCheckBox *visibleCheckBox; + QRadioButton *restoreButton; + QRadioButton *minimizeButton; + QRadioButton *maximizeButton; + QRadioButton *fullscreenButton; +}; + +// Control for the Qt::WindowStates flags (normal, maximized, fullscreen exclusively +// combined with minimized and optionally, with a "visible" QCheckbox) +class WindowStatesControl : public QGroupBox +{ + Q_OBJECT +public: + enum Flags { + WantVisibleCheckBox = 0x1 + }; + + explicit WindowStatesControl(unsigned flags, QWidget *parent= 0); + + Qt::WindowStates states() const; + void setStates(Qt::WindowStates s); + + bool visibleValue() const; + void setVisibleValue(bool); + +signals: + void changed(); + +private: + QCheckBox *visibleCheckBox; + QCheckBox *minimizeCheckBox; + WindowStateControl *stateControl; +}; + +// Control for the type part of Qt::WindowFlags +class TypeControl : public QGroupBox +{ + Q_OBJECT +public: + explicit TypeControl(QWidget *parent= 0); + + Qt::WindowFlags type() const; + void setType(Qt::WindowFlags); + +signals: + void changed(Qt::WindowFlags); + +private slots: + void slotChanged(); + +private: + QButtonGroup *group; + QRadioButton *windowRadioButton; + QRadioButton *dialogRadioButton; + QRadioButton *sheetRadioButton; + QRadioButton *drawerRadioButton; + QRadioButton *popupRadioButton; + QRadioButton *toolRadioButton; + QRadioButton *toolTipRadioButton; + QRadioButton *splashScreenRadioButton; +}; + +#endif // CONTROLS_H diff --git a/tests/manual/windowflags/previewwindow.cpp b/tests/manual/windowflags/previewwindow.cpp index 684d1ee1fe..ba5399dd68 100644 --- a/tests/manual/windowflags/previewwindow.cpp +++ b/tests/manual/windowflags/previewwindow.cpp @@ -107,6 +107,8 @@ PreviewWindow::PreviewWindow(QWidget *parent) showNormalButton = new QPushButton(tr("Show normal")); connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal())); + showMinimizedButton = new QPushButton(tr("Show minimized")); + connect(showMinimizedButton, SIGNAL(clicked()), this, SLOT(showMinimized())); showMaximizedButton = new QPushButton(tr("Show maximized")); connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized())); showFullScreenButton = new QPushButton(tr("Show fullscreen")); @@ -115,6 +117,7 @@ PreviewWindow::PreviewWindow(QWidget *parent) QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(textEdit); layout->addWidget(showNormalButton); + layout->addWidget(showMinimizedButton); layout->addWidget(showMaximizedButton); layout->addWidget(showFullScreenButton); layout->addWidget(closeButton); @@ -143,6 +146,8 @@ PreviewDialog::PreviewDialog(QWidget *parent) showNormalButton = new QPushButton(tr("Show normal")); connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal())); + showMinimizedButton = new QPushButton(tr("Show minimized")); + connect(showMinimizedButton, SIGNAL(clicked()), this, SLOT(showMinimized())); showMaximizedButton = new QPushButton(tr("Show maximized")); connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized())); showFullScreenButton = new QPushButton(tr("Show fullscreen")); @@ -151,6 +156,7 @@ PreviewDialog::PreviewDialog(QWidget *parent) QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(textEdit); layout->addWidget(showNormalButton); + layout->addWidget(showMinimizedButton); layout->addWidget(showMaximizedButton); layout->addWidget(showFullScreenButton); layout->addWidget(closeButton); diff --git a/tests/manual/windowflags/previewwindow.h b/tests/manual/windowflags/previewwindow.h index 42189016e1..9ff091f304 100644 --- a/tests/manual/windowflags/previewwindow.h +++ b/tests/manual/windowflags/previewwindow.h @@ -42,8 +42,8 @@ #ifndef PREVIEWWINDOW_H #define PREVIEWWINDOW_H -#include <QWidget> -#include <QDialog> +#include <QtWidgets/QWidget> +#include <QtWidgets/QDialog> QT_BEGIN_NAMESPACE class QPushButton; @@ -63,6 +63,7 @@ private: QTextEdit *textEdit; QPushButton *closeButton; QPushButton *showNormalButton; + QPushButton *showMinimizedButton; QPushButton *showMaximizedButton; QPushButton *showFullScreenButton; }; @@ -80,6 +81,7 @@ private: QTextEdit *textEdit; QPushButton *closeButton; QPushButton *showNormalButton; + QPushButton *showMinimizedButton; QPushButton *showMaximizedButton; QPushButton *showFullScreenButton; }; diff --git a/tests/manual/windowflags/windowflags.pro b/tests/manual/windowflags/windowflags.pro index 06def212b3..46e9475800 100644 --- a/tests/manual/windowflags/windowflags.pro +++ b/tests/manual/windowflags/windowflags.pro @@ -1,7 +1,12 @@ QT += widgets HEADERS = controllerwindow.h \ - previewwindow.h + previewwindow.h \ + controls.h + SOURCES = controllerwindow.cpp \ previewwindow.cpp \ - main.cpp + main.cpp \ + controls.cpp + +QT += widgets diff --git a/tests/manual/windowgeometry/controllerwidget.cpp b/tests/manual/windowgeometry/controllerwidget.cpp new file mode 100644 index 0000000000..e45b05776d --- /dev/null +++ b/tests/manual/windowgeometry/controllerwidget.cpp @@ -0,0 +1,483 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples 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 "controllerwidget.h" +#include <controls.h> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets> +# include <QWindow> +# include <QBackingStore> +# include <QPaintDevice> +# include <QPainter> +#else +# include <QtGui> +#endif + +#include <QResizeEvent> + +CoordinateControl::CoordinateControl(const QString &sep) : m_x(new QSpinBox), m_y(new QSpinBox) +{ + m_x->setMinimum(0); + m_x->setMaximum(2000); + connect(m_x, SIGNAL(valueChanged(int)), this, SLOT(spinBoxChanged())); + m_y->setMinimum(0); + m_y->setMaximum(2000); + connect(m_y, SIGNAL(valueChanged(int)), this, SLOT(spinBoxChanged())); + QHBoxLayout *l = new QHBoxLayout(this); + l->setSpacing(2); + l->addWidget(m_x); + l->addWidget(new QLabel(sep)); + l->addWidget(m_y); +} + +void CoordinateControl::setCoordinates(int x, int y) +{ + m_x->blockSignals(true); + m_y->blockSignals(true); + m_x->setValue(x); + m_y->setValue(y); + m_x->blockSignals(false); + m_y->blockSignals(false); +} + +QPair<int, int> CoordinateControl::coordinates() const +{ + return QPair<int, int>(m_x->value(), m_y->value()); +} + +void CoordinateControl::spinBoxChanged() +{ + const int x = m_x->value(); + const int y = m_y->value(); + emit pointValueChanged(QPoint(x, y)); + emit sizeValueChanged(QSize(x, y)); +} + +RectControl::RectControl() + : m_point(new CoordinateControl(QLatin1String("+"))) + , m_size(new CoordinateControl(QLatin1String("x"))) +{ + QHBoxLayout *l = new QHBoxLayout(this); + l->setSpacing(0); + l->setMargin(ControlLayoutMargin); + connect(m_point, SIGNAL(pointValueChanged(QPoint)), this, SLOT(handleChanged())); + connect(m_point, SIGNAL(pointValueChanged(QPoint)), this, SIGNAL(positionChanged(QPoint))); + l->addWidget(m_point); + l->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); + connect(m_size, SIGNAL(sizeValueChanged(QSize)), this, SLOT(handleChanged())); + connect(m_size, SIGNAL(sizeValueChanged(QSize)), this, SIGNAL(sizeChanged(QSize))); + l->addWidget(m_size); +} + +void RectControl::setRectValue(const QRect &r) +{ + m_point->setPointValue(r.topLeft()); + m_size->setSizeValue(r.size()); +} + +QRect RectControl::rectValue() const +{ + return QRect(m_point->pointValue(), m_size->sizeValue()); +} + +void RectControl::handleChanged() +{ + emit changed(rectValue()); +} + +BaseWindowControl::BaseWindowControl(QObject *w) + : m_layout(new QGridLayout(this)) + , m_object(w) + , m_geometry(new RectControl) + , m_framePosition(new CoordinateControl(QLatin1String("x"))) + , m_typeControl(new TypeControl) + , m_hintControl(new HintControl) + , m_moveEventLabel(new QLabel(tr("Move events"))) + , m_resizeEventLabel(new QLabel(tr("Resize events"))) + , m_mouseEventLabel(new QLabel(tr("Mouse events"))) + , m_moveCount(0) + , m_resizeCount(0) +{ + m_object->installEventFilter(this); + m_geometry->setTitle(tr("Geometry")); + int row = 0; + m_layout->addWidget(m_geometry, row, 0, 1, 2); + m_layout->setMargin(ControlLayoutMargin); + QGroupBox *frameGB = new QGroupBox(tr("Frame")); + QVBoxLayout *frameL = new QVBoxLayout(frameGB); + frameL->setSpacing(0); + frameL->setMargin(ControlLayoutMargin); + frameL->addWidget(m_framePosition); + m_layout->addWidget(frameGB, row, 2); + + m_layout->addWidget(m_hintControl, ++row, 0, 1, 2); + connect(m_hintControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(windowFlagsChanged())); + m_layout->addWidget(m_typeControl, row, 2); + connect(m_typeControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(windowFlagsChanged())); + + QGroupBox *eventGroupBox = new QGroupBox(tr("Events")); + QVBoxLayout *l = new QVBoxLayout(eventGroupBox); + l->setSpacing(0); + l->setMargin(ControlLayoutMargin); + l->addWidget(m_moveEventLabel); + l->addWidget(m_resizeEventLabel); + l->addWidget(m_mouseEventLabel); + m_layout->addWidget(eventGroupBox, ++row, 2); + + connect(m_geometry, SIGNAL(positionChanged(QPoint)), this, SLOT(posChanged(QPoint))); + connect(m_geometry, SIGNAL(sizeChanged(QSize)), this, SLOT(sizeChanged(QSize))); + connect(m_framePosition, SIGNAL(pointValueChanged(QPoint)), this, SLOT(framePosChanged(QPoint))); +} + +bool BaseWindowControl::eventFilter(QObject *, QEvent *e) +{ + switch (e->type()) { + case QEvent::Resize: { + const QResizeEvent *re = static_cast<const QResizeEvent *>(e); + m_resizeEventLabel->setText(tr("Resize %1x%2 (#%3)") + .arg(re->size().width()).arg(re->size().height()) + .arg(++m_resizeCount)); + refresh(); + } + break; + case QEvent::Move: { + const QMoveEvent *me = static_cast<const QMoveEvent *>(e); + m_moveEventLabel->setText(tr("Move %1,%2 (#%3)") + .arg(me->pos().x()).arg(me->pos().y()) + .arg(++m_moveCount)); + refresh(); + } + break; + case QEvent::MouseMove: { + const QMouseEvent *me = static_cast<const QMouseEvent *>(e); + const QPoint pos = me->pos(); + QPoint globalPos = objectMapToGlobal(m_object, pos); + m_mouseEventLabel->setText(tr("Mouse: %1,%2 Global: %3,%4 "). + arg(pos.x()).arg(pos.y()).arg(globalPos.x()).arg(globalPos.y())); + } + break; + case QEvent::WindowStateChange: + refresh(); + default: + break; + } + return false; +} + +void BaseWindowControl::posChanged(const QPoint &p) +{ + QRect geom = objectGeometry(m_object); + geom.moveTopLeft(p); + setObjectGeometry(m_object, geom); +} + +void BaseWindowControl::sizeChanged(const QSize &s) +{ + QRect geom = objectGeometry(m_object); + geom.setSize(s); + setObjectGeometry(m_object, geom); +} + +void BaseWindowControl::framePosChanged(const QPoint &p) +{ + setObjectFramePosition(m_object, p); +} + +void BaseWindowControl::windowFlagsChanged() +{ + const Qt::WindowFlags f = m_typeControl->type() | m_hintControl->hints(); + setObjectWindowFlags(m_object, f); +} + +void BaseWindowControl::refresh() +{ + m_geometry->setRectValue(objectGeometry(m_object)); + m_framePosition->setPointValue(objectFramePosition(m_object)); + const Qt::WindowFlags flags = objectWindowFlags(m_object); + m_typeControl->setType(flags); + m_hintControl->setHints(flags); +} + +// A control for a QWidget +class WidgetWindowControl : public BaseWindowControl +{ + Q_OBJECT +public: + explicit WidgetWindowControl(QWidget *w); + + virtual void refresh(); + +private slots: + void statesChanged(); + +private: + virtual QRect objectGeometry(const QObject *o) const + { return static_cast<const QWidget *>(o)->geometry(); } + virtual void setObjectGeometry(QObject *o, const QRect &r) const + { static_cast<QWidget *>(o)->setGeometry(r); } + virtual QPoint objectFramePosition(const QObject *o) const + { return static_cast<const QWidget *>(o)->pos(); } + virtual void setObjectFramePosition(QObject *o, const QPoint &p) const + { static_cast<QWidget *>(o)->move(p); } + virtual QPoint objectMapToGlobal(const QObject *o, const QPoint &p) const + { return static_cast<const QWidget *>(o)->mapToGlobal(p); } + virtual Qt::WindowFlags objectWindowFlags(const QObject *o) const + { return static_cast<const QWidget *>(o)->windowFlags(); } + virtual void setObjectWindowFlags(QObject *o, Qt::WindowFlags f); + + WindowStatesControl *m_statesControl; +}; + +WidgetWindowControl::WidgetWindowControl(QWidget *w ) + : BaseWindowControl(w) + , m_statesControl(new WindowStatesControl(WindowStatesControl::WantVisibleCheckBox)) +{ + setTitle(w->windowTitle()); + m_layout->addWidget(m_statesControl, 2, 0); + connect(m_statesControl, SIGNAL(changed()), this, SLOT(statesChanged())); +} + +void WidgetWindowControl::setObjectWindowFlags(QObject *o, Qt::WindowFlags f) +{ + QWidget *w = static_cast<QWidget *>(o); + const bool visible = w->isVisible(); + w->setWindowFlags(f); // hides. + if (visible) + w->show(); +} + +void WidgetWindowControl::refresh() +{ + const QWidget *w = static_cast<const QWidget *>(m_object); + m_statesControl->setVisibleValue(w->isVisible()); + m_statesControl->setStates(w->windowState()); + BaseWindowControl::refresh(); +} + +void WidgetWindowControl::statesChanged() +{ + QWidget *w = static_cast<QWidget *>(m_object); + w->setVisible(m_statesControl->visibleValue()); + w->setWindowState(m_statesControl->states()); +} + +#if QT_VERSION >= 0x050000 + +// Test window drawing diagonal lines +class Window : public QWindow +{ +public: + explicit Window(QWindow *parent = 0) + : QWindow(parent) + , m_backingStore(new QBackingStore(this)) + { + setObjectName(QStringLiteral("window")); + setWindowTitle(tr("TestWindow")); + } + +protected: + void exposeEvent(QExposeEvent *) + { render(); } + +private: + QBackingStore *m_backingStore; + void render(); +}; + +void Window::render() +{ + QRect rect(QPoint(), geometry().size()); + m_backingStore->resize(rect.size()); + m_backingStore->beginPaint(rect); + if (!rect.size().isEmpty()) { + QPaintDevice *device = m_backingStore->paintDevice(); + QPainter p(device); + p.fillRect(rect, Qt::white); + p.drawLine(0, 0, rect.width(), rect.height()); + p.drawLine(0, rect.height(), rect.width(), 0); + } + m_backingStore->endPaint(); + m_backingStore->flush(rect); +} + +// A control for a QWindow +class WindowControl : public BaseWindowControl +{ + Q_OBJECT +public: + explicit WindowControl(QWindow *w); + + virtual void refresh(); + +private slots: + void stateChanged(); + +private: + virtual QRect objectGeometry(const QObject *o) const + { return static_cast<const QWindow *>(o)->geometry(); } + virtual void setObjectGeometry(QObject *o, const QRect &r) const + { static_cast<QWindow *>(o)->setGeometry(r); } + virtual QPoint objectFramePosition(const QObject *o) const + { return static_cast<const QWindow *>(o)->framePos(); } + virtual void setObjectFramePosition(QObject *o, const QPoint &p) const + { static_cast<QWindow *>(o)->setFramePos(p); } + virtual QPoint objectMapToGlobal(const QObject *o, const QPoint &p) const + { return static_cast<const QWindow *>(o)->mapToGlobal(p); } + virtual Qt::WindowFlags objectWindowFlags(const QObject *o) const + { return static_cast<const QWindow *>(o)->windowFlags(); } + virtual void setObjectWindowFlags(QObject *o, Qt::WindowFlags f) + { static_cast<QWindow *>(o)->setWindowFlags(f); } + + WindowStateControl *m_stateControl; +}; + +WindowControl::WindowControl(QWindow *w ) + : BaseWindowControl(w) + , m_stateControl(new WindowStateControl(WindowStateControl::WantVisibleCheckBox | WindowStateControl::WantMinimizeRadioButton)) +{ + setTitle(w->windowTitle()); + QGroupBox *stateGroupBox = new QGroupBox(tr("State")); + QVBoxLayout *l = new QVBoxLayout(stateGroupBox); + l->addWidget(m_stateControl); + m_layout->addWidget(stateGroupBox, 2, 0); + connect(m_stateControl, SIGNAL(changed()), this, SLOT(stateChanged())); +} + +void WindowControl::refresh() +{ + const QWindow *w = static_cast<const QWindow *>(m_object); + BaseWindowControl::refresh(); + m_stateControl->setVisibleValue(w->isVisible()); + m_stateControl->setState(w->windowState()); +} + +void WindowControl::stateChanged() +{ + QWindow *w = static_cast<QWindow *>(m_object); + w->setVisible(m_stateControl->visibleValue()); + w->setWindowState(m_stateControl->state()); +} + +#endif + +ControllerWidget::ControllerWidget(QWidget *parent) + : QMainWindow(parent) + , m_testWidget(new QWidget) +#if QT_VERSION >= 0x050000 + , m_testWindow(new Window) +#endif +{ + QMenu *fileMenu = menuBar()->addMenu(tr("File")); + QAction *exitAction = fileMenu->addAction(tr("Exit")); + exitAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); + connect(exitAction, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); + + QString title = QLatin1String("Geometry test, (Qt "); + title += QLatin1String(QT_VERSION_STR); +#if QT_VERSION >= 0x050000 + title += QLatin1String(", "); + title += qApp->platformName(); +#endif + title += QLatin1Char(')'); + setWindowTitle(title); + + int x = 100; + int y = 100; + const QStringList args = QApplication::arguments(); + const int offsetArgIndex = args.indexOf(QLatin1String("-offset")); + if (offsetArgIndex >=0 && offsetArgIndex < args.size() - 1) { + y += args.at(offsetArgIndex + 1).toInt(); + } else { + if (QT_VERSION < 0x050000) + y += 400; + } + + move(x, y); + + x += 800; + m_testWidget->setWindowTitle(tr("TestWidget")); + m_testWidget->move(x, y); + m_testWidget->resize(200, 200); + m_testWidget->show(); + +#if QT_VERSION >= 0x050000 + x += 300; + m_testWindow->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint + | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint + | Qt::WindowTitleHint); + m_testWindow->setFramePos(QPoint(x, y)); + m_testWindow->resize(200, 200); + m_testWindow->show(); + m_testWindow->setWindowTitle(tr("TestWindow")); +#endif + + QWidget *central = new QWidget ; + QVBoxLayout *l = new QVBoxLayout(central); + + const QString labelText = tr( + "<html><head/><body><p>This example lets you control the geometry" + " of a QWidget and a QWindow (Qt 5) for testing out" + " QPA plugins.</p>" + "<p>It compiles with Qt 4 and Qt 5 for comparison.</p>" + "<p>The command line option <code>-offset <value></code> specifies" + " a vertical offset.</p></body></html>"); + + l->addWidget(new QLabel(labelText)); + + BaseWindowControl *widgetControl = new WidgetWindowControl(m_testWidget.data()); + widgetControl->refresh(); + l->addWidget(widgetControl); + +#if QT_VERSION >= 0x050000 + BaseWindowControl *windowControl = new WindowControl(m_testWindow.data()); + windowControl->refresh(); + l->addWidget(windowControl); +#endif + + setCentralWidget(central); +} + +ControllerWidget::~ControllerWidget() +{ +} + +#include "controllerwidget.moc" diff --git a/tests/manual/windowgeometry/controllerwidget.h b/tests/manual/windowgeometry/controllerwidget.h new file mode 100644 index 0000000000..9e3901be6c --- /dev/null +++ b/tests/manual/windowgeometry/controllerwidget.h @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples 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 CONTROLLERWIDGET_H +#define CONTROLLERWIDGET_H + +#include <QMainWindow> +#include <QGroupBox> +#include <QScopedPointer> + +QT_BEGIN_NAMESPACE +class QSpinBox; +class QLabel; +class QGridLayout; +QT_END_NAMESPACE + +class TypeControl; +class HintControl; + +// A control for editing points or sizes +class CoordinateControl : public QWidget +{ + Q_OBJECT + +public: + CoordinateControl(const QString &sep); + + void setPointValue(const QPoint &p) { setCoordinates(p.x(), p.y()); } + QPoint pointValue() const { const QPair<int, int> t = coordinates(); return QPoint(t.first, t.second); } + + void setSizeValue(const QSize &s) { setCoordinates(s.width(), s.height()); } + QSize sizeValue() const { const QPair<int, int> t = coordinates(); return QSize(t.first, t.second); } + +signals: + void pointValueChanged(const QPoint &p); + void sizeValueChanged(const QSize &s); + +private slots: + void spinBoxChanged(); + +private: + void setCoordinates(int x, int y); + QPair<int, int> coordinates() const; + + QSpinBox *m_x; + QSpinBox *m_y; +}; + +// A control for editing QRect +class RectControl : public QGroupBox +{ + Q_OBJECT +public: + RectControl(); + void setRectValue(const QRect &r); + QRect rectValue() const; + +signals: + void changed(const QRect &r); + void sizeChanged(const QSize &s); + void positionChanged(const QPoint &s); + +private slots: + void handleChanged(); + +private: + CoordinateControl *m_point; + CoordinateControl *m_size; +}; + +// Base class for controlling the position of a Window (QWindow or QWidget) +class BaseWindowControl : public QGroupBox +{ + Q_OBJECT + +protected: + explicit BaseWindowControl(QObject *w); + +public: + virtual bool eventFilter(QObject *, QEvent *); + virtual void refresh(); + +private slots: + void posChanged(const QPoint &); + void sizeChanged(const QSize &); + void framePosChanged(const QPoint &); + void windowFlagsChanged(); + +protected: + QGridLayout *m_layout; + QObject *m_object; + +private: + virtual QRect objectGeometry(const QObject *o) const = 0; + virtual void setObjectGeometry(QObject *o, const QRect &) const = 0; + + virtual QPoint objectFramePosition(const QObject *o) const = 0; + virtual void setObjectFramePosition(QObject *o, const QPoint &) const = 0; + + virtual Qt::WindowFlags objectWindowFlags(const QObject *o) const = 0; + virtual void setObjectWindowFlags(QObject *o, Qt::WindowFlags) = 0; + + virtual QPoint objectMapToGlobal(const QObject *o, const QPoint &) const = 0; + + RectControl *m_geometry; + CoordinateControl *m_framePosition; + TypeControl *m_typeControl; + HintControl *m_hintControl; + QLabel *m_moveEventLabel; + QLabel *m_resizeEventLabel; + QLabel *m_mouseEventLabel; + unsigned m_moveCount; + unsigned m_resizeCount; +}; + +class ControllerWidget : public QMainWindow +{ + Q_OBJECT +public: + explicit ControllerWidget(QWidget *parent = 0); + ~ControllerWidget(); + +private: + QScopedPointer<QWidget> m_testWidget; +#if QT_VERSION >= 0x050000 + QScopedPointer<QWindow> m_testWindow; +#endif +}; + +#endif // CONTROLLERWIDGET_H diff --git a/tests/manual/cmake/pass7/main.cpp b/tests/manual/windowgeometry/main.cpp index 0a6b09d877..46eeee53cf 100644 --- a/tests/manual/cmake/pass7/main.cpp +++ b/tests/manual/windowgeometry/main.cpp @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** 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. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -39,9 +39,13 @@ ** ****************************************************************************/ -#include "qplatformdefs.h" +#include <QApplication> +#include "controllerwidget.h" -int main(int argc, char **argv) +int main(int argc, char *argv[]) { - return 0; + QApplication a(argc, argv); + ControllerWidget controller; + controller.show(); + return a.exec(); } diff --git a/tests/manual/windowgeometry/windowgeometry.pro b/tests/manual/windowgeometry/windowgeometry.pro new file mode 100644 index 0000000000..44ea97ba62 --- /dev/null +++ b/tests/manual/windowgeometry/windowgeometry.pro @@ -0,0 +1,9 @@ +QT += core gui +TARGET = windowgeometry +TEMPLATE = app + +INCLUDEPATH += ../windowflags +SOURCES += $$PWD/main.cpp controllerwidget.cpp ../windowflags/controls.cpp +HEADERS += controllerwidget.h ../windowflags/controls.h + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets |