#include "TranslationWidgetAutoResizer.h"
#include <QDebug>
-TranslationWidget::TranslationWidget(Backbone *backbone, QWidget *parent):
+TranslationWidget::TranslationWidget(QWidget *parent):
QScrollArea(parent) {
- this->backbone = backbone;
-
-
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow);
#endif
initializeUI();
- /* connect(textEdit, SIGNAL(customContextMenuRequested(QPoint)),
- this, SLOT(showContextMenu(QPoint)));*/
-
setWindowTitle(tr("Translation"));
}
QScrollArea::show();
}
-void TranslationWidget::show(QList<Translation*> translations) {
+void TranslationWidget::show(QStringList translations) {
show();
textEdit->clear();
QString trans;
- Translation* t;
+ QString t;
foreach(t, translations) {
- trans += t->toHtml() + "\n";
+ trans += t + "\n";
}
textEdit->setPlainText(trans);
- textEdit->update(this->rect());
+ textEdit->repaint(this->rect());
+ update(this->rect());
+
+ emit updateSize();
}
void TranslationWidget::initializeUI() {
- /*contextMenu = new QMenu;
- contextMenu->addAction(tr("Copy"), this, SLOT(copy()));
- contextMenu->addAction(tr("Paste"), this, SLOT(paste()));
- contextMenu->addAction(tr("Select all"), this, SLOT(selectAll()));*/
+ zoomInToolButton = new QToolButton;
+ zoomInToolButton->setIcon(QIcon::fromTheme("pdf_zoomin"));
+
+ zoomOutToolButton = new QToolButton;
+ zoomOutToolButton->setIcon(QIcon::fromTheme("pdf_zoomout"));
+
+ // horizontalLayout = new QHBoxLayout;
+ //horizontalLayout->addWidget(zoomInToolButton);
+ // horizontalLayout->addWidget(zoomOutToolButton);
textEdit = new QTextEdit;
textEdit->setReadOnly(true);
- new TranslationWidgetAutoResizer(textEdit);
+ resizer = new TranslationWidgetAutoResizer(textEdit);
+ connect(this, SIGNAL(updateSize()),
+ resizer, SLOT(textEditChanged()));
QWidget*w = new QWidget;
verticalLayout = new QVBoxLayout(w);
verticalLayout->addWidget(textEdit);
- this->setWidget(w);
- this->setWidgetResizable(true);
+ textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-}
+ this->setWidget(w);
+ this->setWidgetResizable(true);
-void TranslationWidget::showContextMenu(QPoint pos) {
- contextMenu->exec(pos);
+ connect(zoomInToolButton, SIGNAL(clicked()),
+ textEdit, SLOT(zoomIn()));
+
+ connect(zoomInToolButton, SIGNAL(clicked()),
+ this, SIGNAL(updateSize()));
+
+ connect(zoomOutToolButton, SIGNAL(clicked()),
+ textEdit, SLOT(zoomOut()));
+
+ connect(zoomInToolButton, SIGNAL(clicked()),
+ this, SIGNAL(updateSize()));
+
+ /* #ifdef Q_WS_MAEMO_5
+ fullScreenButton = new QToolButton(this);
+ fullScreenButton->setIcon(QIcon::fromTheme("general_fullsize"));
+ fullScreenButton->setMinimumSize(fullScreenButton->sizeHint());
+ int x = QApplication::desktop()->screenGeometry(this).width() -
+ fullScreenButton->sizeHint().width();
+ int y = QApplication::desktop()->screenGeometry(this).height() -
+ fullScreenButton->sizeHint().height();
+ fullScreenButton->move(QPoint(x,y));
+ fullScreenButton->show();
+ fullScreenButton->setWindowOpacity(0.5);
+
+
+ backButton = new QToolButton(this);
+ backButton->setIcon(QIcon::fromTheme("general_overlay_back"));
+ backButton->setMinimumSize(fullScreenButton->sizeHint());
+ x = QApplication::desktop()->screenGeometry(this).width() -
+ backButton->sizeHint().width();
+ y = 0;
+ backButton->move(QPoint(x,y));
+ backButton->show();
+ backButton->setWindowOpacity(0.5);
+
+ connect(backButton, SIGNAL(clicked()),
+ this, SLOT(hide()));
+ #endif*/
}