view->setAlignment(Qt::AlignCenter);
view->show();
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(this, SIGNAL(setUrl(QVariant)),
+ rootObject, SLOT(setUrl(QVariant)));
#else
realParent = qobject_cast<TranslationWidget*>(parent);
#endif
}
+void TranslationView::setHtml(QString htmlString){
+ QString url = QDir::homePath() + "/.mdictionary/" + "html.html";
+ QFile file(url);
+ if(file.open(QIODevice::WriteOnly | QIODevice::Text)){
+ QByteArray array = htmlString.toUtf8();
+ file.write(array);
+ file.close();
+ emit setUrl(url);
+ }
+}
+
void TranslationView::wheelEvent(QWheelEvent *e) {
+#ifndef Q_WS_MAEMO_5
+#else
if(e->modifiers() & Qt::ControlModifier) {
if(e->delta()>0) {
zoomIn();
else {
QWebView::wheelEvent(e);
}
+#endif
}
bool TranslationView::eventFilter(QObject *, QEvent *e) {
+#ifndef Q_WS_MAEMO_5
+#else
switch (e->type()) {
case QEvent::MouseButtonPress:
if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
break;
}
return false;
+#endif
}
void TranslationView::contextMenuEvent(QContextMenuEvent *e) {
+#ifndef Q_WS_MAEMO_5
+#else
QMenu *menu = new QMenu;
if(selectedText().isEmpty())
searchSelectedAction->setEnabled(false);
delete menu;
e->ignore();
+#endif
}
void TranslationView::zoomIn() {
+#ifndef Q_WS_MAEMO_5
+#else
if(zoomFactor() >= 3)
return;
setZoomFactor(zoomFactor()*1.05);
realParent->updateZoom(zoomFactor());
-
+#endif
}
void TranslationView::zoomOut() {
+#ifndef Q_WS_MAEMO_5
+#else
if(zoomFactor() <= 0.5)
return;
setZoomFactor(zoomFactor()*0.95);
realParent->updateZoom(zoomFactor());
+#endif
}
void TranslationView::copy() {
+#ifndef Q_WS_MAEMO_5
+#else
pageAction(QWebPage::Copy)->trigger();
+#endif
}
void TranslationView::selection() {
+#ifndef Q_WS_MAEMO_5
+#else
if(selectedText().size())
Q_EMIT copyAvailable(true);
else
Q_EMIT copyAvailable(false);
+#endif
}
void TranslationView::selectAll() {
+#ifndef Q_WS_MAEMO_5
+#else
pageAction(QWebPage::SelectAll)->trigger();
+#endif
}