1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
22 //Created by Mateusz Półrola
24 #include "TranslationWidget.h"
25 #include "TranslationWidgetAutoResizer.h"
28 TranslationWidget::TranslationWidget(QWidget *parent):
32 setAttribute(Qt::WA_Maemo5StackedWindow);
34 setWindowFlags(windowFlags() | Qt::Window);
37 //Q_INIT_RESOURCE(xslt);
38 setWindowTitle(tr("Translation"));
42 void TranslationWidget::show() {
46 void TranslationWidget::show(QStringList translations) {
53 foreach(t, translations) {
58 trans=tr("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>") + tr("\n <ar>") + trans + tr("\n </ar>");
60 trans=XslConversion(trans);
61 textEdit->insertHtml(trans);
62 // textEdit->setPlainText(trans);
64 textEdit->repaint(this->rect());
71 QString TranslationWidget::XslConversion(QString translation)
73 QXmlQuery myQuery(QXmlQuery::XSLT20);
74 myQuery.setFocus(translation);
75 // qDebug()<<translation;
76 QFile file(":/xsl/xsl.xsl");
77 if(!file.open(QFile::ReadOnly)){
78 qDebug()<<"can't open a xslt file";
83 myQuery.setQuery(xslt);
85 myQuery.evaluateTo(&result);
89 void TranslationWidget::initializeUI() {
91 zoomInToolButton = new QToolButton;
92 zoomInToolButton->setIcon(QIcon::fromTheme("pdf_zoomin"));
94 zoomOutToolButton = new QToolButton;
95 zoomOutToolButton->setIcon(QIcon::fromTheme("pdf_zoomout"));
97 // horizontalLayout = new QHBoxLayout;
98 //horizontalLayout->addWidget(zoomInToolButton);
99 // horizontalLayout->addWidget(zoomOutToolButton);
101 textEdit = new QTextEdit;
102 textEdit->setReadOnly(true);
104 resizer = new TranslationWidgetAutoResizer(textEdit);
105 connect(this, SIGNAL(updateSize()),
106 resizer, SLOT(textEditChanged()));
108 QWidget*w = new QWidget;
109 verticalLayout = new QVBoxLayout(w);
110 //verticalLayout->addLayout(horizontalLayout);
111 verticalLayout->addWidget(textEdit);
114 this->setWidgetResizable(true);
116 connect(zoomInToolButton, SIGNAL(clicked()),
117 textEdit, SLOT(zoomIn()));
119 connect(zoomInToolButton, SIGNAL(clicked()),
120 this, SIGNAL(updateSize()));
122 connect(zoomOutToolButton, SIGNAL(clicked()),
123 textEdit, SLOT(zoomOut()));
125 connect(zoomInToolButton, SIGNAL(clicked()),
126 this, SIGNAL(updateSize()));