X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmdictionary%2Fgui%2FTranslationView.cpp;h=84efd21a7584b8b392355302cf756d86338da93f;hb=cb312e2582ca127874eb31ddac520f3c227d21fa;hp=351ed6b8b5131a5648983a7e09c43c2cd6c0c910;hpb=12cf9b5c58f197de505342631ced6fe0a79978cd;p=mdictionary diff --git a/src/mdictionary/gui/TranslationView.cpp b/src/mdictionary/gui/TranslationView.cpp index 351ed6b..84efd21 100644 --- a/src/mdictionary/gui/TranslationView.cpp +++ b/src/mdictionary/gui/TranslationView.cpp @@ -41,6 +41,14 @@ TranslationView::TranslationView(QWidget *parent) : QWebView(parent) { 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(parent); @@ -63,7 +71,20 @@ TranslationView::TranslationView(QWidget *parent) : QWebView(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(); @@ -76,9 +97,12 @@ void TranslationView::wheelEvent(QWheelEvent *e) { 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(e)->button() == Qt::LeftButton) @@ -95,10 +119,13 @@ bool TranslationView::eventFilter(QObject *, QEvent *e) { 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); @@ -114,38 +141,53 @@ void TranslationView::contextMenuEvent(QContextMenuEvent *e) { 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 }