+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-//! \file TranslationTextEdit.cpp
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
-
-#include <QtGui>
-#include "TranslationTextEdit.h"
-#include "TranslationWidget.h"
-
-TranslationTextEdit::TranslationTextEdit(QWidget *parent) :
- QWebView(parent)
-{
- realParent = qobject_cast<TranslationWidget*>(parent);
- searchSelectedAction = new QAction(tr("Search"), this);
- copySelectedAction = new QAction(tr("Copy"), this);
- selectAllAction = new QAction(tr("Select All"), this);
- setAcceptDrops(false);
-
- #ifdef Q_WS_MAEMO_5
- installEventFilter(this);
- property("kineticScroller").value<QAbstractKineticScroller*>()->
- setEnabled(true);
- #endif
-
-
- connect(searchSelectedAction, SIGNAL(triggered()),
- this, SIGNAL(search()));
- connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection()));
-}
-
-void TranslationTextEdit::wheelEvent(QWheelEvent *e) {
- if(e->modifiers() & Qt::ControlModifier) {
- if(e->delta()>0) {
- zoomIn();
- }
- else {
- zoomOut();
- }
- e->ignore();
- }
- else {
- QWebView::wheelEvent(e);
- }
-}
-
-bool TranslationTextEdit::eventFilter(QObject *, QEvent *e) {
- switch (e->type()) {
- case QEvent::MouseButtonPress:
- if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
- mousePressed = true;
- break;
- case QEvent::MouseButtonRelease:
- if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
- mousePressed = false;
- break;
- case QEvent::MouseMove:
- if (mousePressed)
- return true;
- default:
- break;
- }
- return false;
-}
-
-
-void TranslationTextEdit::contextMenuEvent(QContextMenuEvent *e) {
- QMenu *menu = new QMenu;
- if(selectedText().isEmpty())
- searchSelectedAction->setEnabled(false);
- else
- searchSelectedAction->setEnabled(true);
-
- menu->addAction(searchSelectedAction);
- menu->addSeparator();
- menu->addAction(pageAction(QWebPage::Copy));
- menu->addAction(pageAction(QWebPage::SelectAll));
-
- menu->exec(e->globalPos());
- delete menu;
-
- e->ignore();
-}
-
-
-void TranslationTextEdit::zoomIn() {
- if(zoomFactor() >= 3)
- return;
- setZoomFactor(zoomFactor()*1.05);
- realParent->updateZoom(zoomFactor());
-
-}
-
-void TranslationTextEdit::zoomOut() {
- if(zoomFactor() <= 0.5)
- return;
- setZoomFactor(zoomFactor()*0.95);
- realParent->updateZoom(zoomFactor());
-}
-
-void TranslationTextEdit::copy() {
- pageAction(QWebPage::Copy)->trigger();
-}
-
-void TranslationTextEdit::selection() {
- if(selectedText().size())
- Q_EMIT copyAvailable(true);
- else
- Q_EMIT copyAvailable(false);
-}
-
-
-void TranslationTextEdit::selectAll() {
- pageAction(QWebPage::SelectAll)->trigger();
-}
-
-
-
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-//! \file TranslationTextEdit.h
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
-
-#ifndef TRANSLATIONTEXTEDIT_H
-#define TRANSLATIONTEXTEDIT_H
-
-#include <QTextEdit>
-#include <QAction>
-#include <QWebView>
-#include <QEvent>
-
-class TranslationWidget;
-
-class TranslationTextEdit : public QWebView
-{
- Q_OBJECT
-public:
- explicit TranslationTextEdit(QWidget *parent = 0);
-
-public Q_SLOTS:
- void zoomIn();
- void zoomOut();
- void copy();
- void selection();
- void selectAll();
-
-Q_SIGNALS:
- void search();
- void copyAvailable(bool);
-
-protected:
- void contextMenuEvent(QContextMenuEvent *);
- void wheelEvent(QWheelEvent *);
-
-private:
- QAction* searchSelectedAction;
- QAction* copySelectedAction;
- QAction* selectAllAction;
- TranslationWidget* realParent;
- bool mousePressed;
- bool eventFilter(QObject *, QEvent *);
-
-};
-
-#endif // TRANSLATIONTEXTEDIT_H
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//! \file TranslationView.cpp
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+
+#include <QtGui>
+#include "TranslationView.h"
+#include "TranslationWidget.h"
+
+TranslationView::TranslationView(QWidget *parent) :
+ QWebView(parent)
+{
+ realParent = qobject_cast<TranslationWidget*>(parent);
+ searchSelectedAction = new QAction(tr("Search"), this);
+ copySelectedAction = new QAction(tr("Copy"), this);
+ selectAllAction = new QAction(tr("Select All"), this);
+ setAcceptDrops(false);
+
+ #ifdef Q_WS_MAEMO_5
+ installEventFilter(this);
+ property("kineticScroller").value<QAbstractKineticScroller*>()->
+ setEnabled(true);
+ #endif
+
+
+ connect(searchSelectedAction, SIGNAL(triggered()),
+ this, SIGNAL(search()));
+ connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection()));
+}
+
+void TranslationView::wheelEvent(QWheelEvent *e) {
+ if(e->modifiers() & Qt::ControlModifier) {
+ if(e->delta()>0) {
+ zoomIn();
+ }
+ else {
+ zoomOut();
+ }
+ e->ignore();
+ }
+ else {
+ QWebView::wheelEvent(e);
+ }
+}
+
+bool TranslationView::eventFilter(QObject *, QEvent *e) {
+ switch (e->type()) {
+ case QEvent::MouseButtonPress:
+ if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
+ mousePressed = true;
+ break;
+ case QEvent::MouseButtonRelease:
+ if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
+ mousePressed = false;
+ break;
+ case QEvent::MouseMove:
+ if (mousePressed)
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+
+void TranslationView::contextMenuEvent(QContextMenuEvent *e) {
+ QMenu *menu = new QMenu;
+ if(selectedText().isEmpty())
+ searchSelectedAction->setEnabled(false);
+ else
+ searchSelectedAction->setEnabled(true);
+
+ menu->addAction(searchSelectedAction);
+ menu->addSeparator();
+ menu->addAction(pageAction(QWebPage::Copy));
+ menu->addAction(pageAction(QWebPage::SelectAll));
+
+ menu->exec(e->globalPos());
+ delete menu;
+
+ e->ignore();
+}
+
+
+void TranslationView::zoomIn() {
+ if(zoomFactor() >= 3)
+ return;
+ setZoomFactor(zoomFactor()*1.05);
+ realParent->updateZoom(zoomFactor());
+
+}
+
+void TranslationView::zoomOut() {
+ if(zoomFactor() <= 0.5)
+ return;
+ setZoomFactor(zoomFactor()*0.95);
+ realParent->updateZoom(zoomFactor());
+}
+
+void TranslationView::copy() {
+ pageAction(QWebPage::Copy)->trigger();
+}
+
+void TranslationView::selection() {
+ if(selectedText().size())
+ Q_EMIT copyAvailable(true);
+ else
+ Q_EMIT copyAvailable(false);
+}
+
+
+void TranslationView::selectAll() {
+ pageAction(QWebPage::SelectAll)->trigger();
+}
+
+
+
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//! \file TranslationView.h
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+
+#ifndef TRANSLATIONVIEW_H
+#define TRANSLATIONVIEW_H
+
+#include <QTextEdit>
+#include <QAction>
+#include <QWebView>
+#include <QEvent>
+
+class TranslationWidget;
+
+class TranslationView : public QWebView
+{
+ Q_OBJECT
+public:
+ explicit TranslationView(QWidget *parent = 0);
+
+public Q_SLOTS:
+ void zoomIn();
+ void zoomOut();
+ void copy();
+ void selection();
+ void selectAll();
+
+Q_SIGNALS:
+ void search();
+ void copyAvailable(bool);
+
+protected:
+ void contextMenuEvent(QContextMenuEvent *);
+ void wheelEvent(QWheelEvent *);
+
+private:
+ QAction* searchSelectedAction;
+ QAction* copySelectedAction;
+ QAction* selectAllAction;
+ TranslationWidget* realParent;
+ bool mousePressed;
+ bool eventFilter(QObject *, QEvent *);
+
+};
+
+#endif // TRANSLATIONVIEW_H
void TranslationWidget::initializeUI() {
- webkit = new TranslationTextEdit(this);
+ webkit = new TranslationView(this);
Settings* set = guiinterface->settings();
qreal fac = set->value("zoom").toFloat();
if(!fac)
#include "../backbone/backbone.h"
#include <QtXml>
#include <QXmlQuery>
-#include "TranslationTextEdit.h"
+#include "TranslationView.h"
#include <QPropertyAnimation>
#include "../../include/GUIInterface.h"
QString XslConversion(QString translation);
QToolButton* zoomInToolButton;
QToolButton* zoomOutToolButton;
- TranslationTextEdit *webkit;
+ TranslationView *webkit;
QString xslt;
#ifdef Q_WS_MAEMO_5
gui/BookmarksWidget.cpp \
gui/WelcomeScreenWidget.cpp \
gui/AboutWidget.cpp \
- gui/TranslationTextEdit.cpp \
+ gui/TranslationView.cpp \
gui/DBusAdapter.cpp \
gui/NotifyManager.cpp \
gui/SpinBox.cpp
gui/BookmarksWidget.h \
gui/WelcomeScreenWidget.h \
../include/Notify.h \
- gui/TranslationTextEdit.h \
+ gui/TranslationView.h \
../include/AccentsNormalizer.h \
../include/DictDialog.h \
gui/DBusAdapter.h \