--- /dev/null
+<RCC>
+ <qresource prefix="/icons">
+ <file>48x48/edit-select-all.png</file>
+ <file>logo/mdictionary.png</file>
+ <file>96x96/staroff.png</file>
+ <file>96x96/staron.png</file>
+ </qresource>
+</RCC>
dh_testroot
dh_clean -k
dh_installdirs
- cd builddir && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/$(APPNAME) install
+ cd builddir && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/$(APPNAME) install
./rename-plugins "$(CURDIR)/debian/$(APPNAME)/usr/lib/mdictionary"
# Build architecture-independent files here.
binary-indep: build install
../includes/Notify.h \
gui/TranslationTextEdit.h
-FORMS += gui/MainWindow.ui
+FORMS +=
-RESOURCES += gui/gui.qrc
+RESOURCES += \
+ ../../../data/icons/gui.qrc
unix {
# VARIABLES
isEmpty(PREFIX):PREFIX = /usr
QString infoNote, licenseNote, comarchNote;
infoNote = "<center><h2><u>mDictionary</u></h2></center>";
comarchNote = "<center>Meamo/Meego Mulitlingual Dictionary</center>";
- comarchNote += "<center>Copyright 2006-2010, Comarch S.A. <br />";
+ comarchNote += "<center>Copyright 2006-2010, Comarch S.A. <br>";
comarchNote += "<a href=\"http://mdictionary.garage.maemo.org\">http://mdictionary.garage.maemo.org</a></center>";
- licenseNote = "<br><p><font size=\"small\">This program is free software: you can redistribute it and/or modify\n"
- "it under the terms of the GNU General Public License as published by\n"
- "the Free Software Foundation, either version 3 of the License, or\n"
- "(at your option) any later version.<br />"
- "This program is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
- "GNU General Public License for more details.<br />"
- "You should have received a copy of the GNU General Public License\n"
- "along with this program. If not, see"
- "<<a href=\"http://www.gnu.org/licenses/\">"
- "http://www.gnu.org/licenses/</a>>."
- "</p></font>";
+ licenseNote = QString("<br><p><font size=\"small\">This program is free software: you can redistribute it and/or modify\n")+
+ QString("it under the terms of the GNU General Public License as published by\n")+
+ QString("the Free Software Foundation, either version 3 of the License, or\n")+
+ QString("(at your option) any later version.<br>")+
+ QString("This program is distributed in the hope that it will be useful,\n")+
+ QString("but WITHOUT ANY WARRANTY; without even the implied warranty of\n")+
+ QString("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n")+
+ QString("GNU General Public License for more details.<br>") +
+ QString("You should have received a copy of the GNU General Public License<br>") +
+ QString("along with this program. If not, see") +
+ QString("<<a href=\"http://www.gnu.org/licenses/\">") +
+ QString("http://www.gnu.org/licenses/</a>>.") +
+ QString("</p></font>");
setWindowTitle(tr("About"));
- mainLayout = new QVBoxLayout(this);
+ mainLayout = new QVBoxLayout;
#ifndef Q_WS_MAEMO_5
- scrollLayout = new QVBoxLayout(this);
- scroll = new QScrollArea(this);
+ scrollLayout = new QVBoxLayout;
+ scroll = new QScrollArea;
w = new QWidget(this);
#endif
- imageLabel = new QLabel(this);
- mainLabel = new QLabel(this);
- licenseLabel = new QLabel(this);
+ imageLabel = new QLabel;
+ mainLabel = new QLabel;
+ licenseLabel = new QLabel;
- mainLayout->addWidget(imageLabel, 0, Qt::AlignHCenter);
- mainLayout->addWidget(mainLabel, 0, Qt::AlignHCenter);
- mainLayout->addWidget(licenseLabel, 0, Qt::AlignHCenter);
- QImage img(":/icons/mdictionary.png");
+ QImage img(":/icons/logo/mdictionary.png");
imageLabel->setPixmap(QPixmap::fromImage(img));
- imageLabel->resize(imageLabel->pixmap()->size());
imageLabel->setMinimumSize(imageLabel->pixmap()->size());
mainLabel->setText(infoNote + comarchNote);
mainLabel->setOpenExternalLinks(true);
+ mainLabel->setMinimumSize(mainLabel->sizeHint());
+
- licenseLabel->setText(licenseNote);
licenseLabel->setWordWrap(true);
+ licenseLabel->setText(licenseNote);
licenseLabel->setOpenExternalLinks(true);
+ licenseLabel->setMinimumSize(licenseLabel->sizeHint());
- #ifndef Q_WS_MAEMO_5
- w->setLayout(mainLayout);
- scroll->setWidget(w);
- scrollLayout->addWidget(scroll, 0, Qt::AlignHCenter);
- this->setLayout(scrollLayout);
- #endif
+ mainLayout->addWidget(imageLabel, 0, Qt::AlignHCenter);
+ mainLayout->addWidget(mainLabel, 0, Qt::AlignHCenter);
+ mainLayout->addWidget(licenseLabel, 0, Qt::AlignHCenter);
- #ifdef Q_WS_MAEMO_5
+
+ #ifndef Q_WS_MAEMO_5
+ w->setLayout(mainLayout);
+ scroll->setWidget(w);
+ scrollLayout->addWidget(scroll, 0, Qt::AlignHCenter);
+ this->setLayout(scrollLayout);
+ this->resize(img.width()*1.65, img.height()*2.60);
+ #else
setLayout(mainLayout);
- mainLayout->addSpacing(20);
#endif
-
- this->resize(img.width()*1.65, img.height()*2.60);
}
MainWindow::MainWindow(Backbone *backbone, QWidget *parent):
- GUIInterface(parent),
- ui(new Ui::MainWindow) {
+ GUIInterface(parent) {
this->backbone = backbone;
+
initializeUI();
connectBackbone();
connectMenu();
connectBookmarksWidget();
-
-
setExactSearch(false);
setWindowTitle("mDictionary");
}
MainWindow::~MainWindow() {
- delete ui;
+
}
void MainWindow::initializeUI() {
- ui->setupUi(this);
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow);
#endif
- searchBarWidget = new SearchBarWidget;
-
- wordListWidget = new WordListWidget;
-
//translationWidget is antoher stacked window, so we don't add it to layout
//only create it with this widget as parent
translationWidget = new TranslationWidget(this);
+
+ mainLayout = new QVBoxLayout;
+ QWidget* w = new QWidget;
+ w->setLayout(mainLayout);
+ setCentralWidget(w);
+ menuBar = new QMenuBar;
+ setMenuBar(menuBar);
+
+ searchBarWidget = new SearchBarWidget;
+
+ wordListWidget = new WordListWidget;
+
welcomeScreenWidget = new WelcomeScreenWidget;
#ifdef Q_WS_MAEMO_5
//At start we set widget as welcome screen widget
- ui->centralWidget->layout()->addWidget(welcomeScreenWidget);
- QVBoxLayout* vl = (QVBoxLayout*)(ui->centralWidget->layout());
- vl->addWidget(searchBarWidget, 0, Qt::AlignBottom);
+ mainLayout->addWidget(welcomeScreenWidget);
+ mainLayout->addWidget(searchBarWidget, 0, Qt::AlignBottom);
#else
translationWidget->hide();
//we add to splitter word list and welcome screen
splitter->addWidget(wordListWidget);
splitter->addWidget(welcomeScreenWidget);
splitter->setStretchFactor(1, 150);
- ui->centralWidget->layout()->addWidget(splitter);
- ui->centralWidget->layout()->addWidget(searchBarWidget);
+ mainLayout->addWidget(splitter);
+ mainLayout->addWidget(searchBarWidget);
#endif
-
dictManagerWidget = new DictManagerWidget(this);
dictManagerWidget->hide();
aboutWidget = new AboutWidget(this);
aboutWidget->hide();
-
//creating menus
#ifdef Q_WS_MAEMO_5
menuWidget->addSubMenu(tr("Dictionaries"), dictManagerWidget);
menuWidget->addSubMenu(tr("Bookmarks"), bookmarksWidget);
menuWidget->addSubMenu(tr("About"), aboutWidget);
- ui->menuBar->addAction(menuWidget);
+ menuBar->addAction(menuWidget);
#else
- dictionariesAction = ui->menuBar->addAction(tr("Dictionaries"));
+ dictionariesAction = menuBar->addAction(tr("Dictionaries"));
connect(dictionariesAction, SIGNAL(triggered()),
dictManagerWidget, SLOT(show()));
- settingsAction = ui->menuBar->addAction(tr("Settings"));
+ settingsAction = menuBar->addAction(tr("Settings"));
connect(settingsAction, SIGNAL(triggered()),
settingsWidget, SLOT(show()));
- QMenu* m = ui->menuBar->addMenu(tr("Bookmarks"));
+ QMenu* m = menuBar->addMenu(tr("Bookmarks"));
bookmarksShowAllAction = new QAction(tr("Show all"), m);
bookmarksRemoveAllAction = new QAction(tr("Remove all"), m);
m->addAction(bookmarksShowAllAction);
m->addAction(bookmarksRemoveAllAction);
- aboutAction = ui->menuBar->addAction(tr("About"));
+ aboutAction = menuBar->addAction(tr("About"));
connect(aboutAction, SIGNAL(triggered()),
aboutWidget, SLOT(show()));
#endif
-
}
void MainWindow::closeEvent(QCloseEvent *event) {
#ifdef Q_WS_MAEMO_5
//switch welcome screen with word list
if(!wordListWidget->isVisible()) {
- int i = ui->centralWidget->layout()->indexOf(welcomeScreenWidget);
- QBoxLayout* l = (QBoxLayout*)(ui->centralWidget->layout());
+ int i = mainLayout->indexOf(welcomeScreenWidget);
+ QBoxLayout* l = (QBoxLayout*)(mainLayout);
l->removeWidget(welcomeScreenWidget);
welcomeScreenWidget->deleteLater();
l->insertWidget(0, wordListWidget);
#ifndef Q_WS_MAEMO_5
//switch welcome screen with translation widget
if(!translationWidget->isVisible()) {
- QBoxLayout* l = (QBoxLayout*)(ui->centralWidget->layout());
+ QBoxLayout* l = (QBoxLayout*)(mainLayout);
QSplitter* s = (QSplitter*)((QWidgetItem*)(l->itemAt(0))->widget());
s->insertWidget(1,translationWidget);
s->setStretchFactor(1, 150);
void MainWindow::addToHistory(QList<Translation *> trans) {
if(trans.count() > 0) {
backbone->history()->add(trans[0]->key());
- translationWidget->setWindowTitle(trans[0]->key());
}
}
void MainWindow::disableMenu() {
#ifdef Q_WS_MAEMO_5
- if(ui->menuBar->actions().contains(menuWidget)) {
- ui->menuBar->removeAction(menuWidget);
+ if(menuBar->actions().contains(menuWidget)) {
+ menuBar->removeAction(menuWidget);
}
#else
- ui->menuBar->setEnabled(false);
+ menuBar->setEnabled(false);
#endif
}
void MainWindow::enableMenu() {
#ifdef Q_WS_MAEMO_5
- if(!ui->menuBar->actions().contains(menuWidget)) {
- ui->menuBar->addAction(menuWidget);
+ if(!menuBar->actions().contains(menuWidget)) {
+ menuBar->addAction(menuWidget);
}
#else
- ui->menuBar->setEnabled(true);
+ menuBar->setEnabled(true);
#endif
}
#include "WelcomeScreenWidget.h"
#include "AboutWidget.h"
-namespace Ui {
- class MainWindow;
-}
//! Implements interface for GUI
/*!
private:
Backbone* backbone;
- Ui::MainWindow *ui;
void initializeUI();
-
SearchBarWidget* searchBarWidget;
QWidget* translationWidget;
QWidget* wordListWidget;
BookmarksWidget* bookmarksWidget;
QWidget* welcomeScreenWidget;
AboutWidget* aboutWidget;
+ QVBoxLayout* mainLayout;
+ QMenuBar* menuBar;
#ifndef Q_WS_MAEMO_5
QSplitter* splitter;
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>MainWindow</string>
- </property>
- <widget class="QWidget" name="centralWidget">
- <property name="autoFillBackground">
- <bool>false</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout"/>
- </widget>
- <widget class="QMenuBar" name="menuBar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>23</height>
- </rect>
- </property>
- </widget>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
clearSearchWordToolButton->sizeHint().height()*2);
#endif
- fullScreenToolButton = new QToolButton();
+ /*fullScreenToolButton = new QToolButton();
#ifdef Q_WS_MAEMO_5
fullScreenToolButton->setIcon(
generateIcon(QIcon::fromTheme("general_fullsize")));
fullScreenToolButton->setMinimumSize(
fullScreenToolButton->sizeHint().height()*2,
fullScreenToolButton->sizeHint().height()*2);
- #endif
+ #endif*/
searchingProgressBar = new QProgressBar();
horizontalLayout->addWidget(historyPrevToolButton);
horizontalLayout->addWidget(historyShowToolButton);
horizontalLayout->addWidget(historyNextToolButton);
- horizontalLayout->addWidget(fullScreenToolButton);
+ // horizontalLayout->addWidget(fullScreenToolButton);
//adding clear toolButton to textEdit with right alignment
lineEditLayout->addWidget(clearSearchWordToolButton, 0,
verticalLayout->addWidget(searchInBookmarksCheckBox);
+ settings = 0;
+
#ifndef Q_WS_MAEMO_5
setMinimumWidth(250);
setMaximumWidth(250);
void SettingsWidget::showEvent(QShowEvent *e) {
- settings = guiInterface->settings();
+ settings = guiInterface->settings();
- historySizeSpinBox->setValue(
+ historySizeSpinBox->setValue(
settings->value("history_size").toInt());
searchResultSizeSpinBox->setValue(
}
void SettingsWidget::hideEvent(QHideEvent *e) {
- Settings* newSettings = new Settings;
- newSettings->setValue("history_size",
- QString::number(historySizeSpinBox->value()));
- newSettings->setValue("search_limit",
- QString::number(searchResultSizeSpinBox->value()));
-
- if(searchInDictionariesCheckBox->isChecked())
- newSettings->setValue("search_dictionaries", "true");
- else
- newSettings->setValue("search_dictionaries", "false");
+ QDialog::hideEvent(e);
- if(searchInBookmarksCheckBox->isChecked())
- newSettings->setValue("search_bookmarks", "true");
- else
- newSettings->setValue("search_bookmarks", "false");
-
- //setting new settings only if their are different that old ones
- QString key;
- foreach(key, newSettings->keys()) {
- if(settings->value(key) != newSettings->value(key)) {
- guiInterface->setSettings(newSettings);
- break;
+ if(settings) {
+ Settings* newSettings = new Settings;
+ newSettings->setValue("history_size",
+ QString::number(historySizeSpinBox->value()));
+ newSettings->setValue("search_limit",
+ QString::number(
+ searchResultSizeSpinBox->value()));
+
+ if(searchInDictionariesCheckBox->isChecked())
+ newSettings->setValue("search_dictionaries", "true");
+ else
+ newSettings->setValue("search_dictionaries", "false");
+
+ if(searchInBookmarksCheckBox->isChecked())
+ newSettings->setValue("search_bookmarks", "true");
+ else
+ newSettings->setValue("search_bookmarks", "false");
+
+ //setting new settings only if their are different that old ones
+ QString key;
+ foreach(key, newSettings->keys()) {
+ if(settings->value(key) != newSettings->value(key)) {
+ guiInterface->setSettings(newSettings);
+ break;
+ }
}
- }
- QDialog::hideEvent(e);
+ delete settings;
+ settings = 0;
+ }
}
TranslationWidget::TranslationWidget(QWidget *parent):
QScrollArea(parent) {
+ qDebug()<<parent;
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow);
+ setWindowFlags(windowFlags() | Qt::Window);
#endif
- setWindowFlags(windowFlags() | Qt::Window);
+
initializeUI();
- //Q_INIT_RESOURCE(xslt);
- setWindowTitle(tr("Translation"));
+
+ setWindowTitle("mDictionary");
connect(textEdit, SIGNAL(search()),
- this, SLOT(searchSelected()));
+ this, SLOT(searchSelected()));
}
QScrollArea::show();
}
+
void TranslationWidget::show(QStringList translations) {
showMaximized();
}
- trans=tr("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") + tr("\n <ar>") + trans + tr("\n </ar>");
+ trans=QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") +
+ QString("\n <ar>") + trans + QString("\n </ar>");
// trans.replace("&","&");
trans=XslConversion(trans);
qDebug()<<trans;
verticalLayout = new QVBoxLayout(w);
verticalLayout->addWidget(textEdit);
- textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
+ #ifndef Q_WS_MAEMO_5
+ textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ #endif
this->setWidget(w);
this->setWidgetResizable(true);
-
#ifdef Q_WS_MAEMO_5
zoomInButton = new QToolButton(this);
zoomInButton->setIcon(QIcon::fromTheme("pdf_zoomin"));
zoomOutButton->setMinimumSize(zoomOutButton->sizeHint());
selectAllButton = new QToolButton(this);
- selectAllButton->setIcon(QIcon::fromTheme("pdf_zoomout"));
+ selectAllButton->setIcon(QIcon(":/icons/48x48/edit-select-all.png"));
selectAllButton->setMinimumSize(selectAllButton->sizeHint());
copyButton = new QToolButton(this);
searchButton->setEnabled(false);
showButtonsButton = new QToolButton(this);
- showButtonsButton->setArrowType(Qt::UpArrow);
+ showButtonsButton->setIcon(QIcon::fromTheme("general_sent"));
showButtonsButton->setMinimumSize(searchButton->sizeHint());
connect(zoomInButton, SIGNAL(clicked()),
buttonsAnimation->start();
buttonsVisible = true;
- showButtonsButton->setArrowType(Qt::DownArrow);
+ showButtonsButton->setIcon(QIcon::fromTheme("general_received"));
}
else if(buttonsVisible) {
buttonsAnimation->setDirection(QAbstractAnimation::Backward);
buttonsAnimation->start();
buttonsVisible = false;
- showButtonsButton->setArrowType(Qt::UpArrow);
+ showButtonsButton->setIcon(QIcon::fromTheme("general_sent"));
}
}
1);
}
+void TranslationWidget::hideEvent(QHideEvent* e) {
+ if(buttonsVisible)
+ showButtons();
+
+ QScrollArea::hideEvent(e);
+}
+
void TranslationWidget::keyPressEvent(QKeyEvent* event) {
switch (event->key()) {
case Qt::Key_F7:
protected:
#ifdef Q_WS_MAEMO_5
void keyPressEvent(QKeyEvent *);
+ void hideEvent(QHideEvent *);
#endif
private Q_SLOTS:
mainLayout->addWidget(mainLabel, 0, Qt::AlignCenter);
mainLayout->addStretch(0);
- QImage img(":/icons/mdictionary.png");
+ QImage img(":/icons/logo/mdictionary.png");
imageLabel->setPixmap(QPixmap::fromImage(img));
imageLabel->resize(imageLabel->pixmap()->size());
QProxyStyle()
{
//load pixmap from resources
- starPixmapOn = QPixmap(":/icons/staron.png");
- starPixmapOff = QPixmap(":/icons/staroff.png");
+ starPixmapOn = QPixmap(":/icons/96x96/staron.png");
+ starPixmapOff = QPixmap(":/icons/96x96/staroff.png");
}
void WordListWidget::showSearchResults(
QHash<QString, QList<Translation *> > result) {
- model->clear();
- searchResult.clear();
+ clear();
+ qDebug()<<searchResult.count();
+ searchResult = result;
+
model->setColumnCount(2);
model->setRowCount(result.count());
- searchResult = result;
int row=0;
QHash<QString, QList<Translation*> >::iterator i;
- for(i = result.begin(); i != result.end(); i++) {
+ for(i = searchResult.begin(); i != searchResult.end(); i++) {
addWord(i.key(), row++);
}
void WordListWidget::wordClicked(QModelIndex index) {
//we're getting translation based on data in index
+ qDebug()<<searchResult[index.data().toString()].at(0)->dictionaryInfo();
emit showTranslation(
searchResult[index.data().toString()]);
}
}
void WordListWidget::resizeColumns() {
- setColumnWidth(0, viewport()->width() -checkBoxWidth - 20);
+ setColumnWidth(0, viewport()->width() -checkBoxWidth);
setColumnWidth(1, checkBoxWidth);
}
void WordListWidget::unlockList() {
setEnabled(true);
}
+
+void WordListWidget::clear() {
+ model->clear();
+ qDebug()<<"asdasdas";
+
+ /* QHash<QString, QList<Translation*> >::iterator i;
+ for(i = searchResult.begin(); i != searchResult.end(); i++) {
+ Translation*t;
+ foreach(t, i.value()) {
+ delete t;
+ }
+ }*/
+ searchResult.clear();
+}
//! Signal is emitted only when star was clicked.
void wordChecked(QModelIndex index);
+ void clear();
+
private:
//! Adds word to model. Row is row in the model
void addWord(QString word, int row);
+++ /dev/null
-<RCC>
- <qresource prefix="/icons">
- <file>staroff.png</file>
- <file>staron.png</file>
- <file>mdictionary.png</file>
- </qresource>
-</RCC>
qRegisterMetaType<Translation*>("Translation*");
qRegisterMetaType<QList<Translation*> >("QList<Translation*>");
- Backbone* backbone = new Backbone;
- MainWindow* w = new MainWindow(backbone);
- w->show();
+ Backbone backbone;
+ MainWindow w(&backbone);
+ w.show();
if(search.count() > 0) {
- w->setExactSearch(true);
- w->searchExact(search[0]);
+ w.setExactSearch(true);
+ w.searchExact(search[0]);
}
return a.exec();