searchBarWidget = new SearchBarWidget(backbone);
wordListWidget = new WordListWidget(backbone);
translationWidget = new TranslationWidget(backbone, this);
+
+ searchBarWidget->setFocus();
menuWidget = new MenuWidget(this);
ui->menuBar->addAction(menuWidget);
+
connect(this, SIGNAL(searchWordList(QStringList)),
searchBarWidget, SLOT(searchWordList(QStringList)));
+ connect(backbone, SIGNAL(htmlReady()),
+ translationWidget, SLOT(show()));
+
+ connect(backbone, SIGNAL(htmlReady()),
+ searchBarWidget, SLOT(showIdle()));
+
+ connect(wordListWidget, SIGNAL(clicked(QModelIndex)),
+ searchBarWidget, SLOT(showBusy()));
+
+ connect(searchBarWidget, SIGNAL(enableMenu(bool)),
+ this, SLOT(enableMenu(bool)));
+
- connect(wordListWidget, SIGNAL(showTranslation(QList<Translation*>)),
- translationWidget, SLOT(show(QList<Translation*>)));
+
ui->centralWidget->layout()->addWidget(wordListWidget);
ui->centralWidget->layout()->addWidget(searchBarWidget);
void MainWindow::search(QStringList words) {
emit searchWordList(words);
}
+
+ void MainWindow::enableMenu(bool enabled) {
+ ui->menuBar->setVisible(enabled);
+ qDebug()<<enabled;
+ }
connect(searchPushButton, SIGNAL(clicked()),
this, SLOT(searchPushButtonClicked()));
+ connect(searchWordLineEdit, SIGNAL(returnPressed()),
+ this, SLOT(searchPushButtonClicked()));
+
connect(historyNextToolButton, SIGNAL(clicked()),
this, SLOT(historyNextToolButtonClicked()));
connect(backbone, SIGNAL(ready()),
this, SLOT(searchFinished()));
+ searchWordLineEdit->setFocus();
}
SearchBarWidget::~SearchBarWidget() {
verticalLayout = new QVBoxLayout();
+
searchPushButton = new QPushButton(tr("Search"));
- searchPushButton->setMinimumWidth(200);
+ searchPushButton->setMinimumWidth(150);
searchWordLineEdit = new QLineEdit();
- searchWordLineEdit->setMinimumWidth(350);
+ searchWordLineEdit->setMinimumWidth(300);
//create layout for lineEdit to have clear button on it
QHBoxLayout* lineEditLayout = new QHBoxLayout;
searchWordLineEdit->setLayout(lineEditLayout);
historyNextToolButton = new QToolButton();
historyNextToolButton->setIcon(QIcon::fromTheme("general_forward"));
- historyNextToolButton->setMaximumSize(
+ /* historyNextToolButton->setMaximumSize(
historyNextToolButton->sizeHint().width()/2,
- historyNextToolButton->sizeHint().height()/2);
+ historyNextToolButton->sizeHint().height()/2);*/
historyPrevToolButton = new QToolButton();
historyPrevToolButton->setIcon(QIcon::fromTheme("general_back"));
- historyPrevToolButton->setMaximumSize(
+ /*historyPrevToolButton->setMaximumSize(
historyPrevToolButton->sizeHint().width()/2,
- historyPrevToolButton->sizeHint().height()/2);
+ historyPrevToolButton->sizeHint().height()/2);*/
historyShowToolButton = new QToolButton();
historyShowToolButton->setIcon(QIcon::fromTheme("general_back"));
- historyShowToolButton->setMaximumSize(
+ /*historyShowToolButton->setMaximumSize(
historyShowToolButton->sizeHint().width()/2,
- historyShowToolButton->sizeHint().height()/2);
+ historyShowToolButton->sizeHint().height()/2);*/
QPixmap p = historyShowToolButton->icon().pixmap(256);
QMatrix m;
Qt::AlignRight | Qt::AlignVCenter);
verticalLayout->addLayout(horizontalLayout);
+
+
}
searchingProgressBar->hide();
searchPushButton->setText(tr("Search"));
setEnabled(true);
+ emit enableMenu(true);
_isSearching = false;
emit stopSearching();
}
searchingProgressBar->show();
searchPushButton->setText(tr("Stop"));
setEnabled(false);
+ emit enableMenu(false);
_isSearching = true;
QStringList searchWord;
searchWord << searchWordLineEdit->text();
searchingProgressBar->show();
searchPushButton->setText(tr("Stop"));
setEnabled(false);
+ emit enableMenu(false);
_isSearching = true;
emit searchForTranslations(words);
}
historyShowToolButton->setEnabled(enabled);
}
+void SearchBarWidget::showBusy() {
+ searchingProgressBar->show();
+ setEnabled(false);
+}
+
+void SearchBarWidget::showIdle() {
+ searchingProgressBar->hide();
+ setEnabled(true);
+}
void SearchBarWidget::searchFinished() {
searchingProgressBar->hide();
searchPushButton->setText(tr("Search"));
setEnabled(true);
+ emit enableMenu(true);
_isSearching = false;
}
void SearchBarWidget::historyNextToolButtonClicked() {
- CommonDictInterface*p = backbone->getPlugins()[0];
- p->dictDialog()->addNewDictionary(this);
}
void SearchBarWidget::historyPrevToolButtonClicked() {
//! Request to stop all active searchings
void stopSearching();
+ void enableMenu(bool);
+
public Q_SLOTS:
//! Enable or disable search word line edit and history buttons
/*!
void setEnabled(bool enabled = true);
void searchFinished();
void searchWordList(QStringList);
+ void showBusy();
+ void showIdle();
private Q_SLOTS:
void clearSearchWordToolButtonClicked();
//Created by Mateusz Półrola
#include "TranslationWidget.h"
+ #include "TranslationWidgetAutoResizer.h"
#include <QDebug>
TranslationWidget::TranslationWidget(Backbone *backbone, QWidget *parent):
- QWidget(parent) {
+ QScrollArea(parent) {
this->backbone = backbone;
initializeUI();
- connect(textEdit, SIGNAL(customContextMenuRequested(QPoint)),
- this, SLOT(showContextMenu(QPoint)));
+ /* connect(textEdit, SIGNAL(customContextMenuRequested(QPoint)),
+ this, SLOT(showContextMenu(QPoint)));*/
setWindowTitle(tr("Translation"));
}
void TranslationWidget::show() {
- QWidget::show();
+ QScrollArea::show();
textEdit->clear();
+ QStringList translations = backbone->htmls();
+
QString trans;
- Translation* t;
+ QString t;
foreach(t, translations) {
- trans += t->toHtml() + "\n";
+ trans += t + "\n";
}
textEdit->setPlainText(trans);
- textEdit->repaint(this->rect());
+ textEdit->update(this->rect());
}
void TranslationWidget::initializeUI() {
- contextMenu = new QMenu;
+ /*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()));
+ contextMenu->addAction(tr("Select all"), this, SLOT(selectAll()));*/
textEdit = new QTextEdit;
textEdit->setReadOnly(true);
- textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
- verticalLayout = new QVBoxLayout;
- setLayout(verticalLayout);
+ new TranslationWidgetAutoResizer(textEdit);
+
+ QWidget*w = new QWidget;
+ verticalLayout = new QVBoxLayout(w);
verticalLayout->addWidget(textEdit);
+
+ this->setWidget(w);
+ this->setWidgetResizable(true);
+
+
}
void TranslationWidget::showContextMenu(QPoint pos) {
/*!
Display many translation of word, formatted as html.
*/
- class TranslationWidget : public QWidget {
+ class TranslationWidget : public QScrollArea {
Q_OBJECT
public:
explicit TranslationWidget(Backbone* backbone, QWidget *parent = 0);
public Q_SLOTS:
//! Request to show translation of word passed as QModelIndex from word list
void show();
- void show(QList<Translation*>);
private Q_SLOTS:
void showContextMenu(QPoint pos);