2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
3 * Copyright (C) 2010 University of Szeged
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef MiniBrowserApplication_h
30 #define MiniBrowserApplication_h
34 #include <QStringList>
36 #include <QGuiApplication>
37 #include <QTouchEvent>
39 #include <qpa/qwindowsysteminterface.h>
43 class WindowOptions : public QObject {
45 Q_PROPERTY(bool printLoadedUrls READ printLoadedUrls)
46 Q_PROPERTY(bool startMaximized READ startMaximized)
47 Q_PROPERTY(bool touchMockingEnabled READ touchMockingEnabled WRITE setTouchMockingEnabled NOTIFY touchMockingEnabledChanged)
50 WindowOptions(QObject* parent = 0)
52 , m_printLoadedUrls(false)
53 , m_startMaximized(false)
54 , m_touchMockingEnabled(true)
55 , m_windowSize(QSize(980, 735))
59 void setPrintLoadedUrls(bool enabled) { m_printLoadedUrls = enabled; }
60 bool printLoadedUrls() const { return m_printLoadedUrls; }
61 void setStartMaximized(bool enabled) { m_startMaximized = enabled; }
62 bool startMaximized() const { return m_startMaximized; }
63 void setStartFullScreen(bool enabled) { m_startFullScreen = enabled; }
64 bool startFullScreen() const { return m_startFullScreen; }
65 void setRequestedWindowSize(const QSize& size) { m_windowSize = size; }
66 QSize requestedWindowSize() const { return m_windowSize; }
67 void setUserAgent(const QString& userAgent) { m_userAgent = userAgent; }
68 QString userAgent() const { return m_userAgent; }
69 bool touchMockingEnabled() const { return m_touchMockingEnabled; }
70 void setTouchMockingEnabled(bool enabled)
72 if (enabled != m_touchMockingEnabled) {
73 m_touchMockingEnabled = enabled;
74 emit touchMockingEnabledChanged();
79 void touchMockingEnabledChanged();
82 bool m_printLoadedUrls;
83 bool m_startMaximized;
84 bool m_startFullScreen;
85 bool m_touchMockingEnabled;
90 class MiniBrowserApplication : public QGuiApplication {
94 MiniBrowserApplication(int& argc, char** argv);
95 QStringList urls() const { return m_urls; }
96 bool isRobotized() const { return m_isRobotized; }
97 int robotTimeout() const { return m_robotTimeoutSeconds; }
98 int robotExtraTime() const { return m_robotExtraTimeSeconds; }
99 WindowOptions* windowOptions() { return &m_windowOptions; }
101 virtual bool notify(QObject*, QEvent*);
104 void updateTouchPoint(const QMouseEvent*, QTouchEvent::TouchPoint, Qt::MouseButton);
105 bool sendTouchEvent(BrowserWindow*, QEvent::Type, ulong timestamp);
106 void handleUserOptions();
109 bool m_realTouchEventReceived;
110 int m_pendingFakeTouchEventCount;
112 int m_robotTimeoutSeconds;
113 int m_robotExtraTimeSeconds;
116 QHash<int, QTouchEvent::TouchPoint> m_touchPoints;
117 QSet<int> m_heldTouchPoints;
119 WindowOptions m_windowOptions;
120 bool m_holdingControl;
123 QML_DECLARE_TYPE(WindowOptions);