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);
38 setWindowTitle(tr("Translation"));
42 void TranslationWidget::show() {
46 void TranslationWidget::show(QStringList translations) {
54 foreach(t, translations) {
58 textEdit->setPlainText(trans);
60 textEdit->repaint(this->rect());
67 void TranslationWidget::initializeUI() {
69 zoomInToolButton = new QToolButton;
70 zoomInToolButton->setIcon(QIcon::fromTheme("pdf_zoomin"));
72 zoomOutToolButton = new QToolButton;
73 zoomOutToolButton->setIcon(QIcon::fromTheme("pdf_zoomout"));
75 // horizontalLayout = new QHBoxLayout;
76 //horizontalLayout->addWidget(zoomInToolButton);
77 // horizontalLayout->addWidget(zoomOutToolButton);
79 textEdit = new QTextEdit;
80 textEdit->setReadOnly(true);
82 resizer = new TranslationWidgetAutoResizer(textEdit);
83 connect(this, SIGNAL(updateSize()),
84 resizer, SLOT(textEditChanged()));
86 QWidget*w = new QWidget;
87 verticalLayout = new QVBoxLayout(w);
88 verticalLayout->addWidget(textEdit);
90 textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
91 textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
95 this->setWidgetResizable(true);
97 connect(zoomInToolButton, SIGNAL(clicked()),
98 textEdit, SLOT(zoomIn()));
100 connect(zoomInToolButton, SIGNAL(clicked()),
101 this, SIGNAL(updateSize()));
103 connect(zoomOutToolButton, SIGNAL(clicked()),
104 textEdit, SLOT(zoomOut()));
106 connect(zoomInToolButton, SIGNAL(clicked()),
107 this, SIGNAL(updateSize()));
109 /* #ifdef Q_WS_MAEMO_5
110 fullScreenButton = new QToolButton(this);
111 fullScreenButton->setIcon(QIcon::fromTheme("general_fullsize"));
112 fullScreenButton->setMinimumSize(fullScreenButton->sizeHint());
113 int x = QApplication::desktop()->screenGeometry(this).width() -
114 fullScreenButton->sizeHint().width();
115 int y = QApplication::desktop()->screenGeometry(this).height() -
116 fullScreenButton->sizeHint().height();
117 fullScreenButton->move(QPoint(x,y));
118 fullScreenButton->show();
119 fullScreenButton->setWindowOpacity(0.5);
122 backButton = new QToolButton(this);
123 backButton->setIcon(QIcon::fromTheme("general_overlay_back"));
124 backButton->setMinimumSize(fullScreenButton->sizeHint());
125 x = QApplication::desktop()->screenGeometry(this).width() -
126 backButton->sizeHint().width();
128 backButton->move(QPoint(x,y));
130 backButton->setWindowOpacity(0.5);
132 connect(backButton, SIGNAL(clicked()),