From: jakub Date: Thu, 23 Dec 2010 11:46:53 +0000 (+0100) Subject: qml X-Git-Url: http://vcs.maemo.org/git/?p=mdictionary;a=commitdiff_plain;h=12cf9b5c58f197de505342631ced6fe0a79978cd qml --- diff --git a/src/mdictionary/gui/TranslationView.cpp b/src/mdictionary/gui/TranslationView.cpp index 7e9cd8c..351ed6b 100644 --- a/src/mdictionary/gui/TranslationView.cpp +++ b/src/mdictionary/gui/TranslationView.cpp @@ -29,9 +29,20 @@ #include "TranslationView.h" #include "TranslationWidget.h" -TranslationView::TranslationView(QWidget *parent) : - QWebView(parent) -{ + + +TranslationView::TranslationView(QWidget *parent) : QWebView(parent) { + +#ifndef Q_WS_MAEMO_5 + + view= new QDeclarativeView(); + view->setSource(QUrl("src/mdictionary/qml/TranslationView.qml")); + view->setResizeMode(QDeclarativeView::SizeRootObjectToView); + view->setAlignment(Qt::AlignCenter); + view->show(); + +#else + realParent = qobject_cast(parent); searchSelectedAction = new QAction(tr("Search"), this); copySelectedAction = new QAction(tr("Copy"), this); @@ -48,6 +59,8 @@ TranslationView::TranslationView(QWidget *parent) : connect(searchSelectedAction, SIGNAL(triggered()), this, SIGNAL(search())); connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection())); + +#endif } void TranslationView::wheelEvent(QWheelEvent *e) { diff --git a/src/mdictionary/gui/TranslationView.h b/src/mdictionary/gui/TranslationView.h index c3768dc..7db495d 100644 --- a/src/mdictionary/gui/TranslationView.h +++ b/src/mdictionary/gui/TranslationView.h @@ -32,6 +32,8 @@ #include #include #include +#include +#include class TranslationWidget; @@ -57,6 +59,9 @@ protected: void wheelEvent(QWheelEvent *); private: + QVBoxLayout* mainLayout; + QDeclarativeView *view; + QAction* searchSelectedAction; QAction* copySelectedAction; QAction* selectAllAction; diff --git a/src/mdictionary/qml/TranslationView.qml b/src/mdictionary/qml/TranslationView.qml new file mode 100644 index 0000000..d020be1 --- /dev/null +++ b/src/mdictionary/qml/TranslationView.qml @@ -0,0 +1,47 @@ +import Qt 4.7 +import QtWebKit 1.0 + +Rectangle { + id: rectangle1 + width: 500 + height: 500 + + + + WebView { + id: web_view1 + anchors.fill: parent + url: "http://kokos.pl/" + + onDoubleClick: { + console.log(clickX,clickY); + heuristicZoom(clickX,clickY,2) + } + /* onZoomTo: { + console.log(zoom); + scale=zoom;x=width/2-centerX; + y=height/2-centerY + } + */ + } + + Button { + id: button1 + textInButton: "test" + width: 200; + height: 30; + x: 41 + y: 28 + onClicked: web_view1.scale=web_view1.scale*1.05; + } + + Button { + id: button2 + textInButton: "test2" + width: 200; + height: 30; + x: 41 + y: 68 + onClicked: web_view1.scale=web_view1.scale*.95; + } +}