]> rtime.felk.cvut.cz Git - coffee/qtwebbrowser.git/blob - src/appengine.h
Clean up the application after integration for b2qt
[coffee/qtwebbrowser.git] / src / appengine.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtBrowser project.
7 **
8 ** $QT_BEGIN_LICENSE:GPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 2 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.GPLv2 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU General Public License version 2 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 3.0 as published by the Free Software
28 ** Foundation and appearing in the file LICENSE.GPL included in the
29 ** packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 3.0 requirements will be
31 ** met: http://www.gnu.org/copyleft/gpl.html.
32 **
33 **
34 ** $QT_END_LICENSE$
35 **
36 ****************************************************************************/
37
38 #ifndef APPENGINE_H
39 #define APPENGINE_H
40
41 #include <QtCore/QEvent>
42 #include <QtCore/QFileInfo>
43 #include <QtCore/QSettings>
44 #include <QtCore/QUrl>
45 #include <QtGui/QColor>
46 #include <QtQuick/QQuickItemGrabResult>
47
48 namespace utils {
49 inline bool isTouchEvent(const QEvent* event)
50 {
51     switch (event->type()) {
52     case QEvent::TouchBegin:
53     case QEvent::TouchUpdate:
54     case QEvent::TouchEnd:
55         return true;
56     default:
57         return false;
58     }
59 }
60
61 inline bool isMouseEvent(const QEvent* event)
62 {
63     switch (event->type()) {
64     case QEvent::MouseButtonPress:
65     case QEvent::MouseMove:
66     case QEvent::MouseButtonRelease:
67     case QEvent::MouseButtonDblClick:
68         return true;
69     default:
70         return false;
71     }
72 }
73
74 }
75
76 class AppEngine : public QObject {
77     Q_OBJECT
78
79     Q_PROPERTY(QString settingsPath READ settingsPath FINAL CONSTANT)
80     Q_PROPERTY(QString initialUrl READ initialUrl FINAL CONSTANT)
81
82 public:
83     AppEngine(QObject *parent = 0);
84
85     QString settingsPath();
86     QString initialUrl() const;
87
88     Q_INVOKABLE bool isUrl(const QString& userInput);
89     Q_INVOKABLE QUrl fromUserInput(const QString& userInput);
90     Q_INVOKABLE QString domainFromString(const QString& urlString);
91     Q_INVOKABLE QString fallbackColor();
92     Q_INVOKABLE QString restoreSetting(const QString &name, const QString &defaultValue = QString());
93     Q_INVOKABLE void saveSetting(const QString &name, const QString &value);
94
95 private:
96     QSettings m_settings;
97     QString m_initialUrl;
98 };
99
100 #endif // APPENGINE_H