summaryrefslogtreecommitdiffstats
path: root/src/webengine/ui_delegates_manager.h
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2016-06-13 12:38:51 +0200
committerMichal Klocek <michal.klocek@qt.io>2016-08-18 09:23:03 +0000
commitbaeb20b2e720f5c683cf3810116d827e1561c4b2 (patch)
treeabaf7c153e369c2043b46621ab78fbe42ce74421 /src/webengine/ui_delegates_manager.h
parent6534b09073791398bad99863821740e986915bff (diff)
Add Qt Quick Controls 2 support for dialogs
QtQuickControls1 does not handle embedded platforms too well. In case of eglfs platform we crash badly - only one window is supported. QtQuickControls2 on the other hand lacks the native look on desktop. Therefore on desktop platforms keep using QtQuickControls1, and on eglfs use QtQuickControls2. QtQuick.Dialogs are not implemented for QtQuickControls2, moreover required authentication dialog and prompt dialog are neither implemented in QtQuickControls1. As a workaround make new dialogs to give consistent look and feel. Replace close() with reject() signal in java script prompt dialog to unify handling between qqc1 and qqc2 [ChangeLog][QtWebEngine][General] Qt WebEngine (QML) now optionally uses Qt Quick 2 Controls to show standard dialogs. Task-number: QTBUG-53467 Task-number: QTBUG-51177 Change-Id: I42f9506357bbb82d4f04465f30a18c8013439e25 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/webengine/ui_delegates_manager.h')
-rw-r--r--src/webengine/ui_delegates_manager.h37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/webengine/ui_delegates_manager.h b/src/webengine/ui_delegates_manager.h
index 43d1e6985..b1eb65513 100644
--- a/src/webengine/ui_delegates_manager.h
+++ b/src/webengine/ui_delegates_manager.h
@@ -74,6 +74,7 @@ class QQmlContext;
class QQmlComponent;
class QQuickItem;
class QQuickWebEngineView;
+class QQmlEngine;
QT_END_NAMESPACE
namespace QtWebEngineCore {
@@ -103,27 +104,35 @@ public:
};
UIDelegatesManager(QQuickWebEngineView *);
+ virtual ~UIDelegatesManager();
- void addMenuItem(MenuItemHandler *menuItemHandler, const QString &text, const QString &iconName = QString(),
- bool enabled = true, bool checkable = false, bool checked = true);
+ virtual bool initializeImportDirs(QStringList &dirs, QQmlEngine *engine);
+ virtual void addMenuItem(MenuItemHandler *menuItemHandler, const QString &text,
+ const QString &iconName = QString(),
+ bool enabled = true,
+ bool checkable = false, bool checked = true);
void addMenuSeparator(QObject *menu);
- QObject *addMenu(QObject *parentMenu, const QString &title, const QPoint &pos = QPoint());
+ virtual QObject *addMenu(QObject *parentMenu, const QString &title,
+ const QPoint &pos = QPoint());
QQmlContext *creationContextForComponent(QQmlComponent *);
void showColorDialog(QSharedPointer<ColorChooserController>);
void showDialog(QSharedPointer<JavaScriptDialogController>);
void showDialog(QSharedPointer<AuthenticationDialogController>);
void showFilePicker(FilePickerController *controller);
- void showMessageBubble(const QRect &anchor, const QString &mainText, const QString &subText);
+ virtual void showMenu(QObject *menu);
+ void showMessageBubble(const QRect &anchor, const QString &mainText,
+ const QString &subText);
void hideMessageBubble();
void moveMessageBubble(const QRect &anchor);
void showToolTip(const QString &text);
-private:
+protected:
bool ensureComponentLoaded(ComponentType);
QQuickWebEngineView *m_view;
QScopedPointer<QQuickItem> m_messageBubbleItem;
QScopedPointer<QObject> m_toolTip;
+ QStringList m_importDirs;
FOR_EACH_COMPONENT_TYPE(MEMBER_DECLARATION, SEMICOLON_SEPARATOR)
@@ -131,6 +140,24 @@ private:
};
+// delegate manager for qtquickcontrols2 with fallback to qtquickcontrols1
+
+class UI2DelegatesManager : public UIDelegatesManager
+{
+public:
+ UI2DelegatesManager(QQuickWebEngineView *);
+ bool initializeImportDirs(QStringList &dirs, QQmlEngine *engine) override;
+ QObject *addMenu(QObject *parentMenu, const QString &title,
+ const QPoint &pos = QPoint()) override;
+ void addMenuItem(MenuItemHandler *menuItemHandler, const QString &text,
+ const QString &iconName = QString(),
+ bool enabled = true,
+ bool checkable = false, bool checked = false) override;
+ void showMenu(QObject *menu) override;
+ Q_DISABLE_COPY(UI2DelegatesManager)
+
+};
+
} // namespace QtWebEngineCore
#endif // UI_DELEGATES_MANAGER_H