gui/MenuWidget.h \
gui/MenuTabWidget.h \
gui/DictManagerWidget.h \
- gui/DictTypeSelectDialog.h
+ gui/DictTypeSelectDialog.h \
+ gui/TranslationWidgetAutoResizer.h
FORMS += gui/MainWindow.ui
dictListWidget->clear();
dictsHash.clear();
-
+ removeDictButton->setEnabled(false);
+ settingsButton->setEnabled(false);
QHash<CommonDictInterface*, bool> dicts = backbone->getDictionaries();
void DictManagerWidget::showEvent(QShowEvent *e) {
refreshDictsList();
- removeDictButton->setEnabled(false);
- settingsButton->setEnabled(false);
QWidget::showEvent(e);
}
}
}
-void DictManagerWidget::itemSelected(QListWidgetItem *item) {
+void DictManagerWidget::itemSelected(QListWidgetItem *) {
removeDictButton->setEnabled(true);
settingsButton->setEnabled(true);
}
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(searchBarWidget, SIGNAL(enableMenu(bool)),
+ this, SLOT(enableMenu(bool)));
+
connect(wordListWidget, SIGNAL(showTranslation(QList<Translation*>)),
translationWidget, SLOT(show(QList<Translation*>)));
void MainWindow::search(QStringList words) {
emit searchWordList(words);
}
+
+void MainWindow::enableMenu(bool enabled) {
+ ui->menuBar->setVisible(enabled);
+ qDebug()<<enabled;
+}
*/
void closeEvent(QCloseEvent *);
+private Q_SLOTS:
+ void enableMenu(bool);
private:
Backbone* backbone;
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);
}
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
/*!
//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();
}
void TranslationWidget::show(QList<Translation*> translations) {
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);
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#ifndef TRANSLATIONWIDGETAUTORESIZER_H
+#define TRANSLATIONWIDGETAUTORESIZER_H
+
+#include <QtGui/qtextedit.h>
+class TranslationWidgetAutoResizer : public QObject
+{
+ Q_OBJECT
+
+public:
+ TranslationWidgetAutoResizer(QWidget *parent) :QObject(parent),
+ textEdit(qobject_cast<QTextEdit* >((parent))),
+ edit(qobject_cast<QFrame* >((parent))) {
+
+ connect(parent, SIGNAL(textChanged()), this,
+ SLOT(textEditChanged()));
+ connect(parent, SIGNAL(cursorPositionChanged()),
+ this, SLOT(textEditChanged()));
+ }
+
+private Q_SLOTS:
+ inline void textEditChanged();
+
+private:
+ QTextEdit *textEdit;
+ QFrame *edit;
+};
+
+void TranslationWidgetAutoResizer::textEditChanged() {
+ QTextDocument *doc = textEdit->document();
+
+ QSize s = doc->size().toSize();
+
+ const QRect fr = edit->frameRect();
+ const QRect cr = edit->contentsRect();
+
+ edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height()) -
+ 1));
+}
+
+#endif // TRANSLATIONWIDGETAUTORESIZER_H
connect(saveButton, SIGNAL(clicked()),
this, SLOT(accept()));
- _dicitonaryFilePath = QString();
+ _dicitonaryFilePath = plugin->settings()->value("path");
}
void XdxfSettingsDialog::selectFile() {