setWindowFlags(windowFlags() | Qt::Window);
initializeUI();
-
+ //Q_INIT_RESOURCE(xslt);
setWindowTitle(tr("Translation"));
+
+ connect(textEdit, SIGNAL(search()),
+ this, SLOT(searchSelected()));
+
}
emit updateSize();
}
+QString TranslationWidget::XslConversion(QString translation)
+{
+ QXmlQuery myQuery(QXmlQuery::XSLT20);
+ myQuery.setFocus(translation);
+// qDebug()<<translation;
+ QFile file(":/xsl/xsl.xsl");
+ if(!file.open(QFile::ReadOnly)){
+ qDebug()<<"can't open a xslt file";
+ return translation;
+ }
+ QString xslt;
+ xslt=file.readAll();
+ myQuery.setQuery(xslt);
+ QString result("");
+ myQuery.evaluateTo(&result);
+ return result;
+}
+
+void TranslationWidget::initializeUI() {
+
+ zoomInToolButton = new QToolButton;
+ zoomInToolButton->setIcon(QIcon::fromTheme("pdf_zoomin"));
+
+ zoomOutToolButton = new QToolButton;
+ zoomOutToolButton->setIcon(QIcon::fromTheme("pdf_zoomout"));
+ #ifdef Q_WS_MAEMO_5
+ void TranslationWidget::initButtons() {
+
+ int x = width() - showButtonsButton->sizeHint().width();
+ int y = height() - showButtonsButton->sizeHint().height();
+
+ showButtonsButton->move(QPoint(x,y));
+ showButtonsButton->show();
+ showButtonsButton->setCheckable(true);
+ //==================================================================
+
+ x = width() - zoomOutButton->sizeHint().width();
+ y = height() - 2*zoomOutButton->sizeHint().height();
+ zoomOutButton->move(QPoint(x, height()));
+
+ zoomOutButtonAnimation =
+ new QPropertyAnimation(zoomOutButton, "pos", this);
+
+ zoomOutButtonAnimation->setStartValue(QPoint(x, height()));
+ zoomOutButtonAnimation->setEndValue(QPoint(x,y));
+ zoomOutButtonAnimation->setDuration(200);
+ zoomOutButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+ //==================================================================
+ x = width() - zoomInButton->sizeHint().width();
+ y = height() - 3*zoomInButton->sizeHint().height();
+ zoomInButton->move(QPoint(x, height()));
+
+ zoomInButtonAnimation =
+ new QPropertyAnimation(zoomInButton, "pos", this);
+
+ zoomInButtonAnimation->setStartValue(QPoint(x, height()));
+ zoomInButtonAnimation->setEndValue(QPoint(x,y));
+ zoomInButtonAnimation->setDuration(400);
+ zoomInButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+ //==================================================================
+ x = 0;
+ y = height() - copyButton->sizeHint().height();
+
+ copyButton->move(QPoint(x, height()));
+
+ copyButtonAnimation =
+ new QPropertyAnimation(copyButton, "pos", this);
+
+ copyButtonAnimation->setStartValue(QPoint(x, height()));
+ copyButtonAnimation->setEndValue(QPoint(x,y));
+ copyButtonAnimation->setDuration(200);
+ copyButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+ //==================================================================
+ x = 0;
+ y = height() - 2*copyButton->sizeHint().height();
+
+ selectAllButton->move(QPoint(x, height()));
+
+ selectAllButtonAnimation =
+ new QPropertyAnimation(selectAllButton, "pos", this);
+
+ selectAllButtonAnimation->setStartValue(QPoint(x, height()));
+ selectAllButtonAnimation->setEndValue(QPoint(x,y));
+ selectAllButtonAnimation->setDuration(400);
+ selectAllButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+ //==================================================================
+ x = 0;
+ y = height() - 3*copyButton->sizeHint().height();
+
+ searchButton->move(QPoint(x, height()));
+
+ searchButtonAnimation =
+ new QPropertyAnimation(searchButton, "pos", this);
+
+ searchButtonAnimation->setStartValue(QPoint(x, height()));
+ searchButtonAnimation->setEndValue(QPoint(x,y));
+ searchButtonAnimation->setDuration(600);
+ searchButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+ //==================================================================
+
+ buttonsAnimation = new QParallelAnimationGroup(this);
+ buttonsAnimation->addAnimation(zoomInButtonAnimation);
+ buttonsAnimation->addAnimation(zoomOutButtonAnimation);
+ buttonsAnimation->addAnimation(selectAllButtonAnimation);
+ buttonsAnimation->addAnimation(copyButtonAnimation);
+ buttonsAnimation->addAnimation(searchButtonAnimation);
+ buttonsInitialized = true;
+ buttonsVisible = false;
+
+ connect(showButtonsButton, SIGNAL(toggled(bool)),
+ this, SLOT(showButtons(bool)));
+ }
+ #endif
- // horizontalLayout = new QHBoxLayout;
- //horizontalLayout->addWidget(zoomInToolButton);
- // horizontalLayout->addWidget(zoomOutToolButton);
+ void TranslationWidget::initializeUI() {
- textEdit = new QTextEdit;
+ textEdit = new TranslationTextEdit;
textEdit->setReadOnly(true);
resizer = new TranslationWidgetAutoResizer(textEdit);
#include <QtGui>
#include "../backbone/backbone.h"
#include "TranslationWidgetAutoResizer.h"
+#include <QtXml>
+#include <QXmlQuery>
+ #include "TranslationTextEdit.h"
+ #include <QPropertyAnimation>
//! Displays translation of word found in dictionaries
/*!
//! Request to show translation of word list passed as parameter.
void show(QStringList);
+ protected:
+ #ifdef Q_WS_MAEMO_5
+ void keyPressEvent(QKeyEvent *);
+ #endif
+
+ private Q_SLOTS:
+ void searchSelected();
+ #ifdef Q_WS_MAEMO_5
+ void showButtons(bool);
+ #endif
private:
+ QString XslConversion(QString translation);
- QTextEdit *textEdit;
+ QToolButton* zoomInToolButton;
+ QToolButton* zoomOutToolButton;
+ TranslationTextEdit *textEdit;
#ifdef Q_WS_MAEMO_5
- QToolButton* fullScreenButton;
- QToolButton* backButton;
+ QToolButton* zoomInButton;
+ QToolButton* zoomOutButton;
+ QToolButton* selectAllButton;
+ QToolButton* copyButton;
+ QToolButton* searchButton;
+ QToolButton* showButtonsButton;
+
+ QPropertyAnimation* zoomInButtonAnimation;
+ QPropertyAnimation* zoomOutButtonAnimation;
+ QPropertyAnimation* copyButtonAnimation;
+ QPropertyAnimation* selectAllButtonAnimation;
+ QPropertyAnimation* searchButtonAnimation;
+ QAnimationGroup* buttonsAnimation;
+
+ void initButtons();
+ bool buttonsInitialized;
+ bool buttonsVisible;
+
+ void grabZoomKeys(bool);
#endif
QVBoxLayout *verticalLayout;
QHBoxLayout* horizontalLayout;