1/*
2 * Copyright (C) 2012 Intel Corporation. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB.  If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#ifndef WebColorChooserProxyQt_h
22#define WebColorChooserProxyQt_h
23
24#include "IntRect.h"
25#include "WebColorChooserProxy.h"
26#include <QtCore/QObject>
27#include <wtf/OwnPtr.h>
28
29QT_BEGIN_NAMESPACE
30class QQmlComponent;
31class QQmlContext;
32class QQuickItem;
33QT_END_NAMESPACE
34
35class QQuickWebView;
36
37namespace WebCore {
38class Color;
39}
40
41namespace WebKit {
42
43class WebColorChooserProxyQt : public QObject, public WebColorChooserProxy {
44    Q_OBJECT
45
46public:
47    static PassRefPtr<WebColorChooserProxy> create(WebColorChooserProxy::Client* client, QQuickWebView* webView, const WebCore::Color& initialColor, const WebCore::IntRect& elementRect)
48    {
49        return adoptRef(new WebColorChooserProxyQt(client, webView, initialColor, elementRect));
50    }
51    ~WebColorChooserProxyQt();
52
53    virtual void setSelectedColor(const WebCore::Color&);
54
55public Q_SLOTS:
56    virtual void endChooser();
57
58private Q_SLOTS:
59    void notifyColorSelected(const QColor&);
60
61private:
62    WebColorChooserProxyQt(WebColorChooserProxy::Client*, QQuickWebView*, const WebCore::Color&, const WebCore::IntRect&);
63
64    void createItem(QObject*);
65    void createContext(QQmlComponent*, QObject*);
66
67    OwnPtr<QQmlContext> m_context;
68    OwnPtr<QQuickItem> m_colorChooser;
69
70    QQuickWebView* m_webView;
71};
72
73} // namespace WebKit
74
75#endif // WebColorChooserProxyQt_h
76