<file>xsl/xsl.xsl</file>
<file>translations/en_US.qm</file>
<file>translations/pl_PL.qm</file>
+ <file>button/buttonCenter.png</file>
+ <file>button/buttonLeft.png</file>
+ <file>button/buttonR.png</file>
+ <file>button/go-previous.png</file>
+ <file>progressBar/background.png</file>
+ <file>button/buttonCenterDisabled.png</file>
+ <file>button/buttonCenterPushed.png</file>
+ <file>button/buttonRightDisabled.png</file>
+ <file>button/buttonRightPushed.png</file>
+ <file>button/buttonLeftDisabled.png</file>
+ <file>button/buttonLeftPushed.png</file>
+ <file>button/checkbox.png</file>
+ <file>button/checkboxChecked.png</file>
+ <file>button/go-next.png</file>
+ <file>button/go-show.png</file>
+ <file>button/go-clear.png</file>
+ <file>button/up_enable.png</file>
+ <file>button/down_enable.png</file>
+ <file>button/revert.png</file>
</qresource>
</RCC>
usr/lib/mdictionary/plugins/eng-thai.xdxf
usr/share/mdictionary/xdxf.png
usr/share/mdictionary/css/
+usr/share/mdictionary/qml/
usr/share/applications/hildon/mdictionary.desktop
qt \
release
-CONFIG -= debug
+#CONFIG -= debug
+CONFIG += debug
isEmpty(ENABLED_SRC):ENABLED_SRC = "mdictionary plugins desktopWidget"
isEmpty(ENABLED_PLUGINS):ENABLED_PLUGINS = "xdxf google stardict"
isEmpty(LIBS_DIR):LIBS_DIR=$$INSTALL_PREFIX/lib/mdictionary
isEmpty(PLUGINS_DIR):PLUGINS_DIR=$$INSTALL_PREFIX/lib/mdictionary/plugins
isEmpty(DOCS_DIR):DOCS_DIR=$$INSTALL_PREFIX/share/doc/mdictionary
+#isEmpty(QMLS_DIR):QMLS_DIR=$$DATA_DIR/qml
DEFINES += MDICTIONARY_VERSION=\\\"$$VERSION\\\"
DEFINES += MDICTIONARY_INSTALL_PREFIX=\\\"$$INSTALL_PREFIX\\\"
system(echo "ENABLED_SRC = $$ENABLED_SRC" >src/src.pri)
system(echo "ENABLED_PLUGINS = $$ENABLED_PLUGINS" >src/plugins/plugins.pri)
+
+OTHER_FILES +=
+
+HEADERS +=
message("Plugins directory: "$$PLUGINS_DIR)
message("Documentation directory: "$$DOCS_DIR)
+#message("Qml directory: "$$QMLS_DIR)
+
--- /dev/null
+#!/bin/bash
+
+#$1 - path to rpmbuild root
+echo 'mdictionary RPMs builder'
+cd ../..
+echo 'source compressing...'
+tar -cjf mdictionary.tar.bz2 mdictionary
+mv -u mdictionary.tar.bz2 "$1"/SOURCES/
+cp -u mdictionary/rpm/mdictionary.spec "$1"/SPECS/
+
+echo 'building...'
+rpmbuild -bb "$1"/SPECS/mdictionary.spec
+echo 'cleaning...'
+rm "$1"/SOURCES/mdictionary.tar.bz2
+rm "$1"/SPECS/mdictionary.spec
+rm -rf "$1"/BUILD/mdictionary
+rm -rf "$1"/BUILDROOT/mdictionary*
+
+if [ -d mdictionary-rpms ]
+then
+ rm -rf mdictionary-rpms
+fi
+
+mkdir mdictionary-rpms
+mv "$1"/RPMS/*/mdictionary*.rpm mdictionary-rpms/
+
+echo 'RPMs build finished!'
+
--- /dev/null
+Name: mdictionary
+Summary: Multilingual Dictionary
+Version: 2.1.0
+Release: 3
+Group: Applications/Productivity
+License: GPLv3
+Source0: %{name}.tar.bz2
+BuildArch: i386
+URL: http://mdictionary.garage.maemo.org
+Vendor: Comarch
+Packager: Marcin Kazmierczak
+Autoreq: 0
+Requires: libqtcore4 >= 4.7
+Requires: libqtgui4 >= 4.7
+Requires: libqtsql4 >= 4.7
+Requires: libqtsql4-sqlite >= 4.7
+Requires: libqtwebkit4 >= 2.0
+Requires: libqtxml4 >= 4.7
+Requires: libqtxmlpatterns4 >= 4.7
+Requires: libqtnetwork4 >= 4.7
+Requires: libqtdeclarative4 >= 4.7
+
+
+%description
+Description: %{summary}
+
+
+%package google-plugin
+Summary: Google plugin for mDictionary
+Group: Applications/Productivity
+Requires: %{name} = %{version}-%{release}
+Requires: libqtnetwork4 >= 4.7
+
+%description google-plugin
+Description: %{summary}
+
+%package stardict-plugin
+Summary: Stardict plugin for mDictionary
+Group: Applications/Productivity
+Requires: %{name} = %{version}-%{release}
+
+%description stardict-plugin
+Description: %{summary}
+
+%package devel
+Summary: mDictionary development files
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: libqtdevel >= 4.7
+Requires: libqtcore4 >= 4.7
+Requires: libqtgui4 >= 4.7
+Requires: libqtxml4 >= 4.7
+Requires: libqtxmlpatterns4 >= 4.7
+Requires: libqtsql4 >= 4.7
+Requires: libqtsql4-sqlite >= 4.7
+Requires: libqtdbus4 >= 4.7
+Requires: libqtwebkit4 >= 2.0
+Requires: libqtdeclarative4 >= 4.7
+
+%description devel
+Description: %{summary}
+
+%package doc
+Summary: mDictionary documentation
+Group: Documentation
+Requires: %{name} = %{version}-%{release}
+
+%description doc
+Description: %{summary}
+
+%package homescreen-widget
+Summary: home screen widget for mDictionary
+Group: Applications/Productivity
+Requires: %{name} = %{version}-%{release}
+Requires: qt4-homescreen-loader
+Requires: libqtdbus4 >= 4.7
+
+%description homescreen-widget
+Description: %{summary}
+
+%prep
+%setup -q -n %{name}
+
+# >> setup
+# << setup
+
+%build
+# >> build pre
+# << build pre
+
+qmake "CONFIG+=meego_css"
+
+make %{?jobs:-j%jobs}
+
+# >> build post
+# << build post
+%install
+rm -rf %{buildroot}
+# >> install pre
+# << install pre
+#%qmake_install
+make install -j4 INSTALL_ROOT=%{buildroot}
+
+# >> install post
+# << install post
+desktop-file-install --delete-original \
+ --dir %{buildroot}%{_datadir}/applications \
+ %{buildroot}%{_datadir}/applications/*.desktop
+
+
+
+%post
+/bin/touch --no-create %{_datadir}/icons/hicolor || :
+%{_bindir}/gtk-update-icon-cache \
+ --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
+
+%postun
+/bin/touch --no-create %{_datadir}/icons/hicolor || :
+%{_bindir}/gtk-update-icon-cache \
+ --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+# >> files
+/usr/share/dbus-1/*
+/usr/share/icons/*
+%dir /usr/share/mdictionary
+/usr/share/mdictionary/staron.png
+/usr/bin/mdictionary
+%dir /usr/lib/mdictionary
+%dir /usr/lib/mdictionary/plugins
+/usr/lib/mdictionary/plugins/libxdxf.so
+/usr/lib/mdictionary/plugins/eng-us.xdxf
+/usr/lib/mdictionary/plugins/eng-thai.xdxf
+/usr/share/mdictionary/xdxf.png
+/usr/share/mdictionary/css
+/usr/share/mdictionary/qml
+/usr/share/applications/mdictionary.desktop
+# << files
+
+
+%files google-plugin
+%defattr(-,root,root,-)
+# >> files mdictionary-google-plugin
+/usr/lib/mdictionary/plugins/libgoogle.so
+/usr/share/mdictionary/google.png
+# << files mdictionary-google-plugin
+
+%files stardict-plugin
+%defattr(-,root,root,-)
+# >> files mdictionary-stardict-plugin
+/usr/lib/mdictionary/plugins/libstardict.so
+/usr/share/mdictionary/stardict.png
+# << files mdictionary-stardict-plugin
+
+%files devel
+%defattr(-,root,root,-)
+# >> files mdictionary-dev
+/usr/include/*
+# << files mdictionary-dev
+
+%files doc
+%defattr(-,root,root,-)
+# >> files mdictionary-doc
+/usr/share/doc/mdictionary
+%doc AUTHORS
+# << files mdictionary-doc
+
+%files homescreen-widget
+%defattr(-,root,root,-)
+# >> files mdictionary-homescreen-widget
+/usr/lib/hildon-desktop/*
+/usr/share/applications/hildon-home/*
+# << files mdictionary-homescreen-widget
+
+
+%changelog
+* Wed Feb 16 2011 Marcin Kazmierczak <marcin.kazmierczak@comarch.com>
+
+- Create spec file for mdictionary
+
--- /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.
+
+*******************************************************************************/
+
+/*! \file ComboBoxModel.cpp
+ \brief Contains data for ComboBox QML component
+
+ \author Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+#include "ComboBoxModel.h"
+
+ComboBoxModel::ComboBoxModel(QList<QString> contents, QObject *parent) :
+ QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[ContentRole] = "content";
+ roles[NumberRole] = "number";
+ setRoleNames(roles);
+
+ setContents(contents);
+}
+
+int ComboBoxModel::rowCount(const QModelIndex &parent) const
+{
+ return _contents.count();
+}
+
+QVariant ComboBoxModel::data(const QModelIndex &index, int role) const
+{
+ if (index.row() < 0 || index.row() > _contents.count())
+ return QVariant();
+
+ QString item = _contents[index.row()];
+ if (role == ContentRole)
+ return item;
+ if (role == NumberRole)
+ return index.row();
+ return QVariant();
+}
+
+QString ComboBoxModel::selectedItem()
+{
+ return _selectedItem;
+}
+
+int ComboBoxModel::selectedIndex()
+{
+ return _selectedIndex;
+}
+
+void ComboBoxModel::setSelectedItem(QString item)
+{
+ _selectedItem = item;
+}
+
+void ComboBoxModel::setSelectedIndex(int index)
+{
+ _selectedIndex = index;
+}
+
+void ComboBoxModel::setContents(QList<QString> contents)
+{
+ foreach (QString item, contents)
+ {
+ addItem(item);
+ }
+}
+
+void ComboBoxModel::addItem(QString item)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ _contents << item;
+ endInsertRows();
+}
--- /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.
+
+*******************************************************************************/
+
+/*! \file ComboBoxModel.h
+ \brief Contains data for ComboBox QML component
+
+ \author Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+
+#ifndef COMBOBOXMODEL_H
+#define COMBOBOXMODEL_H
+
+#include <QAbstractListModel>
+#include <QList>
+#include <QHash>
+
+/*!
+ Contains a list of string values.
+ Data source for qml ComboBox
+*/
+class ComboBoxModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum ComboBoxRoles
+ {
+ ContentRole = Qt::UserRole + 1,
+ NumberRole
+ };
+
+ //! Constructor
+ /*!
+ \param contents list of elements for ComboBox
+ \param parent parent of this class.
+ */
+ explicit ComboBoxModel(QList<QString> contents, QObject *parent = 0);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+
+ QString selectedItem();
+ int selectedIndex();
+ void setSelectedItem(QString item);
+ void setSelectedIndex(int index);
+
+private:
+ void setContents(QList<QString> contents);
+ void addItem(QString item);
+ QList<QString> _contents;
+ QString _selectedItem;
+ int _selectedIndex;
+
+};
+
+#endif // COMBOBOXMODEL_H
//! \returns plugin icon
virtual QIcon* icon() = 0;
+ //! \returns plugin icon's path
+ virtual QString iconPath() = 0;
+
//! \returns empty translation object (to be fetched later) for a given key
virtual Translation* getTranslationFor(QString ) {return 0;}
QList<CommonDictInterface*> Backbone::activeDicts() {
QList<CommonDictInterface*>res;
foreach(CommonDictInterface* dict, _dicts.keys())
- if(_dicts[dict])
+ if(_dicts[dict]){
res.append(dict);
+ }
return res;
}
AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent)
{
+ setWindowTitle(tr("About"));
+
+#ifndef Q_WS_MAEMO_5
+ resize(380,450);
+
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/AboutWidget.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+
+ QGraphicsObject *rootObject = view->rootObject();
+ connect(rootObject, SIGNAL(linkClicked(QString)), this, SLOT(openUrl(QString)));
+ this->setLayout(mainLayout);
+
+#else
setModal(true);
QString infoNote, licenseNote, comarchNote;
infoNote = "<center><h2><u>mDictionary</u></h2></center>";
"<<a href=\"http://www.gnu.org/licenses/\">"
"http://www.gnu.org/licenses/</a>>."
"</p></font>");
-
- setWindowTitle(tr("About"));
mainLayout = new QVBoxLayout;
- /*on desktop we place all content in scroll area, on maemo by default all
- widgets that are in menu are placed in scroll area created by menu, so we
- don't have to do it here*/
- #ifndef Q_WS_MAEMO_5
- scrollLayout = new QVBoxLayout;
- scroll = new QScrollArea;
- w = new QWidget(this);
- #endif
-
-
imageLabel = new QLabel;
mainLabel = new QLabel;
licenseLabel = new QLabel;
mainLayout->addWidget(mainLabel, 0, Qt::AlignHCenter);
mainLayout->addWidget(licenseLabel, 0, Qt::AlignHCenter);
- //add content to scroll area, and remove fram from it
- #ifndef Q_WS_MAEMO_5
- w->setLayout(mainLayout);
- scroll->setWidget(w);
- scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- scrollLayout->addWidget(scroll, 0, Qt::AlignHCenter);
- this->setLayout(scrollLayout);
- w->setMinimumSize(img.width()*1.6, img.height()*2.45);
- scroll->setLineWidth(0);
- scroll->setMidLineWidth(0);
- scroll->setFrameStyle(QFrame::NoFrame);;
- #else
- setLayout(mainLayout);
- #endif
+ setLayout(mainLayout);
+#endif
+}
+
+
+void AboutWidget::openUrl(QString url){
+ QDesktopServices::openUrl(url);
}
#include <QDialog>
#include <QWidget>
#include <QtGui>
+#include <QDeclarativeView>
+#include <QDesktopServices>
+
#include "../../include/GUIInterface.h"
class AboutWidget : public QDialog
Q_OBJECT
public:
AboutWidget(GUIInterface *parent = 0);
+
+private slots:
+ void openUrl(QString url);
+
private:
+ QDeclarativeView *view;
QVBoxLayout* mainLayout;
+
QVBoxLayout *scrollLayout;
QLabel* mainLabel, * licenseLabel, *imageLabel;
QScrollArea* scroll;
--- /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.
+
+*******************************************************************************/
+
+/*! \file DictManagerModel.cpp
+ \brief Contains dictionaries data for qml UI
+
+ \author Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+#include "DictManagerModel.h"
+
+DictManagerModel::DictManagerModel(QHash<CommonDictInterface *, bool> dictionaries, QObject *parent) :
+ QAbstractListModel(parent)
+{
+ _currentIndex = 0;
+ QHash<int, QByteArray> roles;
+ roles[NameRole] = "name";
+ roles[IconPathRole] = "iconPath";
+ roles[IsSelectedRole] = "isSelected";
+ roles[NumberRole] = "number";
+ setRoleNames(roles);
+
+ setDictionaries(dictionaries);
+
+ connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(itemChanged()));
+}
+
+int DictManagerModel::rowCount(const QModelIndex &parent) const
+{
+ return _dictList.count();
+}
+
+void DictManagerModel::setDictionaries(QHash<CommonDictInterface *, bool> dictionaries)
+{
+ QHashIterator<CommonDictInterface *, bool> i(dictionaries);
+ while (i.hasNext()) {
+ i.next();
+ addDictionary(i.key(), i.value());
+ }
+}
+
+void DictManagerModel::clear()
+{
+ bool empty = true;
+ if (!_dictionaries.isEmpty()){
+// beginRemoveRows(QModelIndex(), 0, rowCount());
+ beginResetModel();
+ empty = false;
+ }
+ _dictionaries.clear();
+ _dictList.clear();
+
+ if (!empty){
+ endResetModel();
+ }
+}
+
+QVariant DictManagerModel::data(const QModelIndex & index, int role) const
+{
+ if (index.row() < 0 || index.row() > _dictList.count())
+ return QVariant();
+
+ CommonDictInterface* dictionary = _dictList[index.row()];
+ if (role == NameRole)
+ {
+ QString name;
+ if (dictionary->type() == "stardict") {
+ name = dictionary->name() + " (" + dictionary->type() + ")";
+ }
+ else {
+ name = dictionary->langFrom() + " - " + dictionary->langTo() +
+ " (" + dictionary->type() + " " +
+ dictionary->name() + ")";
+ }
+ return name;
+ }
+ if (role == NumberRole){
+ return index.row();
+ }
+ if (role == IconPathRole){
+ return dictionary->iconPath();
+ }
+ if (role == IsSelectedRole){
+ return _dictionaries[dictionary];
+ }
+ return QVariant();
+}
+
+bool DictManagerModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ int res = setDataPriv(index.row(), value, role);
+ if (res == 0)
+ return false;
+ if (res > 0)
+ return true;
+ return true;
+}
+
+int DictManagerModel::setDataPriv(int index, const QVariant &value, int role)
+{
+ if (index < 0 || index > _dictList.count())
+ return 0;
+
+ CommonDictInterface* dictionary = _dictList[index];
+ if (role == NameRole)
+ return 1;
+ if (role == NumberRole)
+ return 1;
+ if (role == IconPathRole)
+ return 1;
+ if (role == IsSelectedRole)
+ {
+ if (value.type() == QVariant::Bool)
+ {
+ _dictionaries[dictionary] = value.toBool();
+ Q_EMIT dataChanged(this->index(0), this->index(_dictList.count() - 1));
+ return 2;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ return 0;
+}
+
+void DictManagerModel::setModelProperty(int index, const QVariant value, QString role)
+{
+ if (role.contains("isSelected"))
+ {
+ setDataPriv(index, value, IsSelectedRole);
+ }
+
+}
+
+void DictManagerModel::itemSelected(int index)
+{
+ _currentIndex = index;
+}
+
+CommonDictInterface* DictManagerModel::currentDict()
+{
+ return _dictList[_currentIndex];
+}
+
+bool DictManagerModel::isCurrentDictSelected()
+{
+ return _dictionaries[_dictList[_currentIndex]];
+}
+
+Qt::ItemFlags DictManagerModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags fl = QAbstractItemModel::flags(index);
+ return (fl | Qt::ItemIsEditable);
+}
+
+void DictManagerModel::addDictionary(CommonDictInterface *dictionary, bool isActive)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ _dictionaries.insert(dictionary, isActive);
+ _dictList << dictionary;
+ endInsertRows();
+}
+
+QHash<CommonDictInterface*, bool> DictManagerModel::dictionaries()
+{
+ return _dictionaries;
+}
+
+QList<CommonDictInterface*> DictManagerModel::dictList()
+{
+ return _dictList;
+}
--- /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.
+
+*******************************************************************************/
+
+/*! \file DictManagerModel.h
+ \brief Contains dictionaries data for qml UI
+
+ \author Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+#ifndef DICTMANAGERMODEL_H
+#define DICTMANAGERMODEL_H
+
+#include <QAbstractListModel>
+#include <QHash>
+#include "../../include/GUIInterface.h"
+
+/*!
+ Contains a list of installed dictionaries.
+ Data source for qml list view.
+*/
+class DictManagerModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum DictTypeRoles
+ {
+ NameRole = Qt::UserRole + 1,
+ IconPathRole,
+ IsSelectedRole,
+ NumberRole
+ };
+
+ //! Constructor
+ /*!
+ \param dictionaries hash set (dictionary, is active) with dictionaries
+ \param parent parent of this class.
+ */
+ explicit DictManagerModel(QHash<CommonDictInterface*, bool> dictionaries, QObject *parent = 0);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ //! Replace model data and refresh ui.
+ /*!
+ \param dictionaries hash set (dictionary, is active) with dictionaries
+ */
+ void setDictionaries(QHash<CommonDictInterface*, bool> dictionaries);
+
+ //! Get dictionary hash set
+ QHash<CommonDictInterface*, bool> dictionaries();
+
+ //! Get dictionary list
+ QList<CommonDictInterface*> dictList();
+
+ //! Clear model data and refresh UI
+ void clear();
+ //! Get current selected dictionary
+ CommonDictInterface* currentDict();
+ //! Get true if current selected dictionary was active. Otherwise return false.
+ bool isCurrentDictSelected();
+
+public Q_SLOTS:
+ //! Set value at role in index row of data.
+ /*!
+ \param index dictionary position in data list
+ \param value new value for role
+ \param role role name
+ */
+ void setModelProperty(int index, const QVariant value, QString role);
+ //! Set index of current selected dictionary
+ /*!
+ \param index dictionary position in data list
+ */
+ void itemSelected(int index);
+
+Q_SIGNALS:
+ //! emits when user changed data
+ void itemChanged();
+
+private:
+ QHash<CommonDictInterface*, bool> _dictionaries;
+ QList<CommonDictInterface*> _dictList;
+ int _currentIndex;
+
+ int setDataPriv(int index, const QVariant &value, int role);
+ void addDictionary(CommonDictInterface* dictionary, bool isActive);
+};
+
+#endif // DICTMANAGERMODEL_H
setWindowTitle(tr("Dictionaries"));
this->guiInterface = parent;
+ #ifndef Q_WS_MAEMO_5
+ model = 0;
+ #endif
initalizeUI();
setModal(true);
verticalLayout = new QVBoxLayout;
setLayout(verticalLayout);
+ #ifndef Q_WS_MAEMO_5
+ qmlView = new QDeclarativeView(this);
+
+ ctxt = qmlView->rootContext();
+
+ refreshDictsList();
+ ctxt->setContextProperty("dictModel", &(*model));
+ qmlView->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/DictManagerWidget.qml"));
+
+ QGraphicsObject *rootObject = qmlView->rootObject();
+
+ qmlView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ verticalLayout->addWidget(qmlView);
+
+ #endif
+
+ #ifdef Q_WS_MAEMO_5
dictList = new QListWidget;
verticalLayout->addWidget(dictList);
connect(dictList, SIGNAL(itemChanged(QListWidgetItem*)),
this, SLOT(changed()));
+ #endif
#ifndef Q_WS_MAEMO_5
- connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)),
- this, SLOT(saveChanges()));
- connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)),
- this, SLOT(itemSelected(QListWidgetItem*)));
- connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)),
- settingsButton, SIGNAL(clicked()));
+ connect(rootObject, SIGNAL(addButtonClicked()),
+ this, SLOT(saveChanges()));
+ connect(rootObject, SIGNAL(addButtonClicked()),
+ this, SLOT(addNewDictButtonClicked()));
+
+ connect(rootObject, SIGNAL(removeButtonClicked()),
+ this, SLOT(saveChanges()));
+ connect(rootObject, SIGNAL(removeButtonClicked()),
+ this, SLOT(removeButtonClicked()));
+
+ connect(rootObject, SIGNAL(settingsButtonClicked()),
+ this, SLOT(saveChanges()));
+ connect(rootObject, SIGNAL(settingsButtonClicked()),
+ this, SLOT(settingsButtonClicked()));
+
+
+ connect(model, SIGNAL(itemChanged()),
+ this, SLOT(changed()));
+ connect(rootObject, SIGNAL(itemActivated(int)),
+ this, SLOT(saveChanges()));
+ connect(rootObject, SIGNAL(itemActivated(int)),
+ this, SLOT(settingsButtonClicked()));
+
#endif
+ #ifdef Q_WS_MAEMO_5
refreshDictsList();
+ #endif
#ifndef Q_WS_MAEMO_5
setMinimumSize(500,300);
- closeButton = new QPushButton(tr("Save"));
- buttonGroup->addWidget(closeButton);
-
- setMinimumWidth(sizeHint().width()*1.2);
- setMaximumWidth(sizeHint().width()*2);
- setMinimumHeight(sizeHint().height());
- setMaximumHeight(sizeHint().height()*2);
- connect(closeButton, SIGNAL(clicked()), this, SLOT(save()));
+ //closeButton = new QPushButton(tr("Save"));
+ //buttonGroup->addWidget(closeButton);
+
+// setMinimumWidth(sizeHint().width()*1.2);
+// setMaximumWidth(sizeHint().width()*2);
+// setMinimumHeight(sizeHint().height());
+// setMaximumHeight(sizeHint().height()*2);
+ connect(rootObject, SIGNAL(saveButtonClicked()), this, SLOT(save()));
#endif
}
void DictManagerWidget::refreshDictsList() {
+ #ifndef Q_WS_MAEMO_5
+ QHash<CommonDictInterface*, bool> dicts = guiInterface->getDictionaries();
+
+ if (model == 0){
+ model = new DictManagerModel(dicts, this);
+ } else {
+ model->clear();
+ model->setDictionaries(dicts);
+ }
+
+ #endif
+
+ #ifdef Q_WS_MAEMO_5
dictList->clear();
dictsHash.clear();
removeDictButton->setEnabled(false);
while(i.hasNext()) {
i.next();
+
QListWidgetItem* item = new QListWidgetItem();
QString name;
if (i.key()->type() == "stardict") {
}
dictList->sortItems();
+ #endif
}
void DictManagerWidget::showEvent(QShowEvent *e) {
QMessageBox::question(this, tr("Save"),
tr("Do you want to save changes?"),
QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
+ QList<CommonDictInterface*> checkedDicts;
+
+ for(int i=0; i<dictList->count(); i++) {
+ QListWidgetItem* item = dictList->item(i);
+ if(item->checkState() == Qt::Checked) {
+ checkedDicts.push_back(dictsHash[item]);
+ }
+ }
#endif
QList<CommonDictInterface*> checkedDicts;
- for(int i=0; i<dictList->count(); i++) {
- QListWidgetItem* item = dictList->item(i);
- if(item->checkState() == Qt::Checked) {
- checkedDicts.push_back(dictsHash[item]);
+ for(int i=0; i<model->dictList().count(); i++) {
+// QListWidgetItem* item = dictList->item(i);
+ CommonDictInterface* item = model->dictList()[i];
+ if(model->dictionaries()[item] == true) {
+ checkedDicts.push_back(item);
}
}
_changed = false;
void DictManagerWidget::addNewDictButtonClicked() {
#ifndef Q_WS_MAEMO_5
+ qDebug()<<"1 "<<_changed;
if(!_changed || QMessageBox::question(this,
tr("Save"), tr("Do you want to save changes?"),
QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
+ qDebug()<<"2";
_save = true;
saveChanges();
_save = false;
if(QMessageBox::question(this, tr("Remove dictionary"),
tr("Do you want to remove selected dictionary?"),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
-
+#ifndef Q_WS_MAEMO_5
+ emit removeDictionary(model->currentDict());
+ refreshDictsList();
+#else
QList<QListWidgetItem*> selected = dictList->selectedItems();
if(selected.count() > 0) {
emit removeDictionary(dictsHash[selected[0]]);
refreshDictsList();
}
+#endif
}
}
saveChanges();
_save = false;
}
- #endif
+ model->currentDict()->dictDialog()->changeSettings(this->parentWidget());
+ refreshDictsList();
+ #else
QList<QListWidgetItem*> selected = dictList->selectedItems();
if(selected.count() > 0) {
dictsHash[selected[0]]->dictDialog()->changeSettings(this->parentWidget());
}
refreshDictsList();
+#endif
}
#include <QtGui>
#include "../../include/GUIInterface.h"
#include "MenuWidget.h"
+#include "DictManagerModel.h"
+#include <QtDeclarative/QDeclarativeView>
+#include <QtDeclarative/QDeclarativeContext>
/*!
QHash<QListWidgetItem*, CommonDictInterface*> dictsHash;
GUIInterface* guiInterface;
+ #ifndef Q_WS_MAEMO_5
+ QDeclarativeView* qmlView;
+ QDeclarativeContext* ctxt;
+ DictManagerModel* model;
+ #endif
+
bool _changed;
void refreshDictsList();
--- /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.
+
+*******************************************************************************/
+
+/*! \file DictTypeModel.cpp
+ \brief Contains plugins data for qml UI
+
+ \author Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+#include "DictTypeModel.h"
+
+DictTypeModel::DictTypeModel(QList<CommonDictInterface *> plugins, QObject *parent) :
+ QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[TypeRole] = "type";
+ roles[NumberRole] = "number";
+ setRoleNames(roles);
+
+ setDictTypes(plugins);
+}
+
+int DictTypeModel::rowCount(const QModelIndex &parent) const
+{
+ return _plugins.count();
+}
+
+void DictTypeModel::setDictTypes(QList<CommonDictInterface *> plugins)
+{
+ for(int i = 0; i < plugins.count(); i++)
+ {
+ addType(plugins[i]);
+ }
+}
+
+QVariant DictTypeModel::data(const QModelIndex & index, int role) const
+{
+ if (index.row() < 0 || index.row() > _plugins.count())
+ return QVariant();
+
+ const CommonDictInterface* plugin = _plugins[index.row()];
+ if (role == TypeRole)
+ return plugin->type();
+ if (role == NumberRole)
+ return index.row();
+ return QVariant();
+}
+
+void DictTypeModel::addType(CommonDictInterface *plugin)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ _plugins << plugin;
+ endInsertRows();
+}
--- /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.
+
+*******************************************************************************/
+
+/*! \file DictTypeModel.h
+ \brief Contains plugins data for qml UI
+
+ \author Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+#ifndef DICTTYPEMODEL_H
+#define DICTTYPEMODEL_H
+
+#include <QAbstractListModel>
+#include <QHash>
+#include "../../include/GUIInterface.h"
+
+/*!
+ Contains a list of plugin types.
+ Data source for qml list view.
+*/
+class DictTypeModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum DictTypeRoles
+ {
+ TypeRole = Qt::UserRole + 1,
+ NumberRole
+ };
+
+ //! Constructor
+ /*!
+ \param plugins list of plugin types
+ \param parent parent of this class.
+ */
+ explicit DictTypeModel(QList<CommonDictInterface*> plugins, QObject *parent = 0);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+
+private:
+ void setDictTypes(QList<CommonDictInterface*> plugins);
+ QList<CommonDictInterface*> _plugins;
+
+ void addType(CommonDictInterface* plugin);
+};
+
+#endif // DICTTYPEMODEL_H
#include "DictTypeSelectDialog.h"
DictTypeSelectDialog::DictTypeSelectDialog(QList<CommonDictInterface *> plugins, QWidget *parent) :
- QDialog(parent) {
+ QDialog(parent), model(plugins, this) {
setWindowTitle(tr("Select dictionary type"));
verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
+#ifndef Q_WS_MAEMO_5
+ qmlView = new QDeclarativeView(this);
+
+ ctxt = qmlView->rootContext();
+ ctxt->setContextProperty("dictTypeModel", &model);
+
+ qmlView->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/DictTypeSelectDialog.qml"));
+
+ _selectedPlugin = 0;
+
+ QGraphicsObject *rootObject = qmlView->rootObject();
+ connect(rootObject, SIGNAL(selectedRow(int)),
+ this, SLOT(pluginSelected(int)));
+
+ qmlView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ verticalLayout->addWidget(qmlView);
+
+#endif
+#ifdef Q_WS_MAEMO_5
+
pluginsListWidget = new QListWidget(this);
verticalLayout->addWidget(pluginsListWidget);
connect(pluginsListWidget, SIGNAL(itemActivated(QListWidgetItem*)),
this, SLOT(pluginSelected(QListWidgetItem*)));
+#endif
}
void DictTypeSelectDialog::pluginSelected(QListWidgetItem *item) {
accept();
}
+void DictTypeSelectDialog::pluginSelected(int item) {
+ _selectedPlugin = plugins[item];
+ accept();
+}
+
CommonDictInterface* DictTypeSelectDialog::selectedPlugin() {
return _selectedPlugin;
}
#include <QtGui>
#include "../../include/settings.h"
#include "../../include/CommonDictInterface.h"
+#include "DictTypeModel.h"
+#include <QtDeclarative/QDeclarativeView>
+#include <QtDeclarative/QDeclarativeContext>
#define PLUGIN_ROW_ROLE 99 //TODO remove this
QWidget *parent = 0);
private Q_SLOTS:
void pluginSelected(QListWidgetItem* item);
+ void pluginSelected(int item);
private:
QListWidget* pluginsListWidget;
QList<CommonDictInterface*> plugins;
QVBoxLayout* verticalLayout;
CommonDictInterface* _selectedPlugin;
+
+ QDeclarativeView* qmlView;
+ QDeclarativeContext* ctxt;
+ DictTypeModel model;
};
#endif // DICTTYPESELECTDIALOG_H
#include "HistoryListDialog.h"
HistoryListDialog::HistoryListDialog(QStringList words, QWidget *parent):
- QDialog(parent)
-{
+ QDialog(parent) {
+
+ oryginalList = words;
verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
+ setModal(true);
+ setWindowFlags(Qt::Popup);
+
+#ifndef Q_WS_MAEMO_5
+
+ HistoryListModel *model=new HistoryListModel(words,this);
+ view= new QDeclarativeView();
+ QDeclarativeContext* ctxt=view->rootContext();
+ ctxt->setContextProperty("historyTypeModel", model);
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/HistoryListDialog.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+ view->setMinimumWidth(250);
+ view->setMaximumWidth(250);
+ view->setMinimumHeight(300);
+ view->setWindowFlags(Qt::Popup);
+ verticalLayout->addWidget(view);
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(rootObject,SIGNAL(selectedRow(int)),
+ this,SLOT(itemClicked(int)));
+
+#else
#ifndef Q_WS_MAEMO_5
setWindowFlags(Qt::Popup);
QLabel* title = new QLabel(tr("History"));
verticalLayout->addWidget(title,0, Qt::AlignCenter);
#endif
-
- oryginalList = words;
-
historyListWidget = new QListWidget(this);
verticalLayout->addWidget(historyListWidget);
historyListWidget->addItem(item);
}
- setModal(true);
-
setWindowTitle(tr("History"));
setMinimumHeight(300);
connect(historyListWidget, SIGNAL(activated(QModelIndex)),
this, SLOT(itemClicked(QModelIndex)));
+#endif
}
accept();
}
+void HistoryListDialog::itemClicked(int index) {
+ _selectedWord = oryginalList[index];
+ _selectedRow = index;
+ accept();
+}
QString HistoryListDialog::selectedWord() {
return _selectedWord;
}
int HistoryListDialog::exec() {
+ #ifndef Q_WS_MAEMO_5
+
+ #else
historyListWidget->setFocus();
+ #endif
+
QDialog::exec();
}
#ifndef HISTORYLISTDIALOG_H
#define HISTORYLISTDIALOG_H
+#include <QtGui>
#include <QDialog>
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+
#include "SearchBarWidget.h"
#include "../../include/History.h"
-#include <QtGui>
+#include "HistoryListModel.h"
/*!
private Q_SLOTS:
void itemClicked(QModelIndex);
+ void itemClicked(int);
private:
+ QDeclarativeView *view;
+ QVBoxLayout* mainLayout;
+
QListWidget* historyListWidget;
QVBoxLayout* verticalLayout;
QString _selectedWord;
--- /dev/null
+#include "HistoryListModel.h"
+
+HistoryListModel::HistoryListModel(QStringList words, QObject *parent) :
+ QAbstractListModel(parent) {
+
+ QHash<int, QByteArray> roles;
+ roles[WordRole] = "word";
+ roles[NumberRole] = "number";
+ setRoleNames(roles);
+ setHistoryTypes(words);
+}
+
+int HistoryListModel::rowCount(const QModelIndex &parent) const {
+ return _words.count();
+}
+
+void HistoryListModel::setHistoryTypes(QStringList words) {
+ for(int i = 0; i < words.count(); i++) {
+ addType(words[i]);
+ }
+}
+
+QVariant HistoryListModel::data(const QModelIndex & index, int role) const
+{
+ if (index.row() < 0 || index.row() > _words.count())
+ return QVariant();
+
+ const QString word = _words[index.row()];
+ if (role == WordRole)
+ return word;
+ if (role == NumberRole)
+ return index.row();
+ return QVariant();
+}
+
+void HistoryListModel::addType(QString word) {
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ _words << word;
+ endInsertRows();
+}
--- /dev/null
+#ifndef HISTORYLISTMODEL_H
+#define HISTORYLISTMODEL_H
+
+#include <QAbstractListModel>
+#include <QHash>
+#include "../../include/GUIInterface.h"
+
+
+class HistoryListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum histotyTypeRoles
+ {
+ WordRole = Qt::UserRole + 1,
+ NumberRole
+ };
+ explicit HistoryListModel(QStringList words, QObject *parent = 0);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+
+private:
+ void setHistoryTypes(QStringList words);
+ void addType(QString word);
+
+ QStringList _words;
+};
+
+#endif // HISTORYLISTMODEL_H
splitter->setStretchFactor(1, 150);
mainLayout->addWidget(splitter, 1);
- mainLayout->addWidget(searchBarWidget, 0, Qt::AlignBottom);
+
+ mainLayout->addWidget(searchBarWidget,0, Qt::AlignBottom);
#endif
}
setExactSearch(false);
}
}
-
wordListWidget->setFocus();
}
return backbone->getDictionaries();
}
-
+/**/
void MainWindow::search(QString word) {
setExactSearch(false);
searchBarWidget->search(word);
}
void MainWindow::showHistory(QPoint p) {
-
- HistoryListDialog historyDialog(backbone->history()->list(), searchBarWidget);
-
+ HistoryListDialog historyDialog(backbone->history()->list(), this );// searchBarWidget);
#ifndef Q_WS_MAEMO_5
- QPoint newPos = mapFromGlobal(p);
- newPos.setY(searchBarWidget->pos().y() -
- historyDialog.sizeHint().height());
- newPos.setX(width() - historyDialog.sizeHint().width());
-
- historyDialog.move(newPos);
+ p.setX(p.x() - historyDialog.sizeHint().width() + 5);
+ p.setY(p.y() - historyDialog.sizeHint().height()- 10); //- 80);
+ historyDialog.move(p);
#endif
if(historyDialog.exec() == QDialog::Accepted) {
backbone->removeAllBookmarks();
((WordListWidget*)wordListWidget)->clear();
}
-
-
}
#include "HistoryListDialog.h"
-SearchBarWidget::SearchBarWidget(QWidget *parent) :
- QWidget(parent) {
+SearchBarWidget::SearchBarWidget(QWidget *parent) : QWidget(parent) {
+ qDebug()<<"test1";
+#ifndef Q_WS_MAEMO_5
+ this->setMaximumHeight(50);
+ busyTimer=new QTimer;
+
+ progressBar = new QDeclarativeView();
+ progressBar->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/ProgressBar.qml"));
+ progressBar->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ progressBar->setAlignment(Qt::AlignCenter);
+ progressBar->hide();
+
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/SearchBarWidget.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(progressBar);
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+
+ QGraphicsObject *rootObject = view->rootObject();
+ QGraphicsObject *rootObject2 = progressBar->rootObject();
+
+ connect(rootObject, SIGNAL(searchButtonClicked(QString)),
+ this, SLOT(searchButtonClicked(QString)));
+ connect(rootObject, SIGNAL(historyNextToolButtonClicked()),
+ this, SIGNAL(historyNext()));
+ connect(rootObject, SIGNAL(historyPrevToolButtonClicked()),
+ this, SIGNAL(historyPrev()));
+ connect(rootObject, SIGNAL(historyShowToolButtonClicked()),
+ this, SLOT(showHistoryButtonClicked()));
- initializeUI();
+ connect(this, SIGNAL(progresSetMax(QVariant)),
+ rootObject2, SLOT(setMax(QVariant)));
+ connect(this, SIGNAL(progresSetMin(QVariant)),
+ rootObject2, SLOT(setMin(QVariant)));
+ connect(this, SIGNAL(progresSetValue(QVariant)),
+ rootObject2, SLOT(setValue(QVariant)));
+ connect(this, SIGNAL(progresSetValue2(QVariant)),
+ rootObject2, SLOT(setValue2(QVariant)));
+
+ connect(this, SIGNAL(setEnableHistoryNext(QVariant)),
+ rootObject, SLOT(setEnableHistoryNext(QVariant)));
+ connect(this, SIGNAL(setEnableHistoryShow(QVariant)),
+ rootObject, SLOT(setEnableHistoryShow(QVariant)));
+ connect(this, SIGNAL(setEnableHistoryPrev(QVariant)),
+ rootObject, SLOT(setEnableHistoryPrev(QVariant)));
+ connect(this, SIGNAL(setButtonText(QVariant)),
+ rootObject, SLOT(setButtonText(QVariant)));
+ connect(this, SIGNAL(setLineEditText(QVariant)),
+ rootObject, SLOT(setLineEditText(QVariant)));
+ connect(this, SIGNAL(setLineEditEnables(QVariant)),
+ rootObject, SLOT(setEnableLineEdit(QVariant)));
+
+ connect(busyTimer, SIGNAL(timeout()),
+ this, SLOT(updateBusyTimer()));
+
+ emit setEnableHistoryNext(false);
+ emit setEnableHistoryShow(false);
+ emit setEnableHistoryPrev(false);
+ completerModel = new QStringListModel(this);
+ connect(&delayTimer, SIGNAL(timeout()),
+ this, SLOT(delaySearchTimeout()));
- busy = false;
+ view->setFocus();
+#else
+ initializeUI();
connect(searchPushButton, SIGNAL(clicked()),
this, SLOT(searchPushButtonClicked()));
-
connect(searchWordLineEdit, SIGNAL(returnPressed()),
this, SLOT(searchPushButtonClicked()));
-
connect(historyNextToolButton, SIGNAL(clicked()),
this, SIGNAL(historyNext()));
-
connect(historyPrevToolButton, SIGNAL(clicked()),
this, SIGNAL(historyPrev()));
-
connect(historyShowToolButton, SIGNAL(clicked()),
this, SLOT(showHistoryButtonClicked()));
-
connect(clearSearchWordToolButton, SIGNAL(clicked()),
this, SLOT(clearSearchWordToolButtonClicked()));
-
-
connect(&delayTimer, SIGNAL(timeout()),
this, SLOT(delaySearchTimeout()));
searchWordLineEdit->setFocus();
+#endif
- historyPrevToolButton->setEnabled(false);
- historyNextToolButton->setEnabled(false);
- historyShowToolButton->setEnabled(false);
-
+ busy = false;
setEnabled(true);
+ updateHistoryButtons(false,false,false);
}
SearchBarWidget::~SearchBarWidget() {
}
QIcon SearchBarWidget::generateIcon(QIcon original, qreal rotation) {
+ qDebug()<<"test2";
QPixmap p = original.pixmap(64);
-
if(rotation != 0) {
QMatrix m;
m.rotate(rotation);
return newIcon;
}
-
void SearchBarWidget::setFocus() {
- searchWordLineEdit->setFocus();
+ qDebug()<<"test3";
+#ifndef Q_WS_MAEMO_5
+ view->setFocus();
+#else
+ searchWordLineEdit->setFocus();
+#endif
}
void SearchBarWidget::initializeUI() {
-
- #ifdef Q_WS_MAEMO_5
- setMaximumHeight(150);
- #else
- setMaximumHeight(100);
- #endif
-
+ qDebug()<<"test4";
+#ifdef Q_WS_MAEMO_5
+ setMaximumHeight(150);
horizontalLayout = new QHBoxLayout;
verticalLayout = new QVBoxLayout;
-
searchPushButton = new QPushButton(tr("Search"));
searchPushButton->setMinimumWidth(125);
-
searchWordLineEdit = new QLineEdit;
searchWordLineEdit->setMinimumWidth(250);
-
-
completerModel = new QStringListModel(this);
-
lineEditCompleter = new QCompleter(searchWordLineEdit);
lineEditCompleter->setModel(completerModel);
lineEditCompleter->setCaseSensitivity(Qt::CaseInsensitive);
lineEditCompleter->setCompletionMode(QCompleter::InlineCompletion);
searchWordLineEdit->setCompleter(lineEditCompleter);
-
#ifndef Q_WS_MAEMO_5
searchWordLineEdit->setMinimumHeight(
searchWordLineEdit->sizeHint().height()*3/2);
#endif
-
//create layout for lineEdit to have clear button on it
QHBoxLayout* lineEditLayout = new QHBoxLayout;
searchWordLineEdit->setLayout(lineEditLayout);
#endif
searchingProgressBar->hide();
-
setLayout(verticalLayout);
verticalLayout->addWidget(searchingProgressBar);
//adding clear toolButton to textEdit with right alignment
lineEditLayout->addWidget(clearSearchWordToolButton, 0, Qt::AlignRight);
-
verticalLayout->addLayout(horizontalLayout);
+#endif
}
+void SearchBarWidget::searchButtonClicked(QString text) {
+ qDebug()<<"test5";
+ if(busy)
+ Q_EMIT stopSearching();
+ else
+ search(text);
+}
void SearchBarWidget::searchPushButtonClicked() {
+ qDebug()<<"test6";
+#ifdef Q_WS_MAEMO_5
if(busy) {
Q_EMIT stopSearching();
}
else {
search(searchWordLineEdit->text());
}
+#endif
}
-
void SearchBarWidget::search(QString word) {
+ qDebug()<<"test7";
+ qDebug()<<word;
if(!busy && !word.isEmpty()) {
completerModel->insertRow(completerModel->rowCount());
- QModelIndex index =
- completerModel->index(completerModel->rowCount() -1);
-
+ QModelIndex index=completerModel->index(completerModel->rowCount() -1);
completerModel->setData(index, word);
-
+#ifndef Q_WS_MAEMO_5
+ emit setLineEditText(word);
+#else
searchWordLineEdit->setText(word);
+#endif
Q_EMIT searchForTranslations(word);
}
}
void SearchBarWidget::searchDelay(QString word) {
+ qDebug()<<"test8";
if(!busy && !word.isEmpty()) {
- searchWordLineEdit->setText(word);
-
+ #ifndef Q_WS_MAEMO_5
+ emit setLineEditText(word);
+ #else
+ searchWordLineEdit->setText(word);
+ #endif
+ if(delayTimer.isActive())
+ delayTimer.stop();
+ delayString = word;
+ delayTimer.start(500);
- if(delayTimer.isActive()) {
- delayTimer.stop();
- }
-
- delayString = word;
- delayTimer.start(500);
}
}
void SearchBarWidget::delaySearchTimeout() {
+ qDebug()<<"test9";
delayTimer.stop();
if(!busy) {
Q_EMIT searchForTranslations(delayString);
}
void SearchBarWidget::setEnabled(bool enabled) {
+ qDebug()<<"test10";
+#ifndef Q_WS_MAEMO_5
+ emit setLineEditEnables(enabled);
+ if(!enabled) {
+ qDebug()<<"tu???";
+ emit setEnableHistoryNext(false);
+ emit setEnableHistoryShow(false);
+ emit setEnableHistoryPrev(false);
+ }
+#else
searchWordLineEdit->setEnabled(enabled);
-
if(!enabled) {
historyPrevToolButton->setEnabled(false);
historyNextToolButton->setEnabled(false);
historyShowToolButton->setEnabled(false);
}
+#endif
+qDebug()<<"tu2???";
}
void SearchBarWidget::setBusy() {
+ qDebug()<<"test11";
if(busy) return;
+
+#ifndef Q_WS_MAEMO_5
+ busyTimer->start(50);
+ emit setButtonText(tr("Stop"));
+ this->setMaximumHeight(88);
+ progressBar->show();
+ emit progresSetMax(100);
+ emit progresSetMin(0);
+ emit progresSetValue(-1);
+ emit progresSetValue2(100);
+ progressMax=true;
+#else
searchingProgressBar->show();
searchPushButton->setText(tr("Stop"));
+#endif
+
setEnabled(false);
busy = true;
}
+void SearchBarWidget::updateBusyTimer(){
+ qDebug()<<"test12";
+ if(progressMax==true){
+ emit progresSetValue2(0);
+ progressMax=false;
+ }
+ else{
+ emit progresSetValue2(100);
+ progressMax=true;
+ }
+ busyTimer->start(50);
+}
+
void SearchBarWidget::setIdle() {
+ qDebug()<<"test13";
if(!busy) return;
+#ifndef Q_WS_MAEMO_5
+ progressBar->hide();
+ busyTimer->stop();
+ emit progresSetValue2(0);
+ this->setMaximumHeight(50);
+ emit setButtonText(tr("Search"));
+#else
searchingProgressBar->hide();
searchPushButton->setText(tr("Search"));
+#endif
setEnabled(true);
busy = false;
Q_EMIT refreshHistoryButtons();
void SearchBarWidget::clearSearchWordToolButtonClicked() {
+ qDebug()<<"test14";
+#ifdef Q_WS_MAEMO_5
searchWordLineEdit->clear();
+#endif
}
void SearchBarWidget::updateHistoryButtons(bool prev, bool next, bool list) {
+ qDebug()<<"test15";
if(!busy) {
- historyPrevToolButton->setEnabled(prev);
- historyNextToolButton->setEnabled(next);
- historyShowToolButton->setEnabled(list);
+ #ifndef Q_WS_MAEMO_5
+ emit setEnableHistoryNext(next);
+ emit setEnableHistoryShow(list);
+ emit setEnableHistoryPrev(prev);
+ #else
+ historyPrevToolButton->setEnabled(prev);
+ historyNextToolButton->setEnabled(next);
+ historyShowToolButton->setEnabled(list);
+ #endif
}
}
void SearchBarWidget::showHistoryButtonClicked() {
- #ifdef Q_WS_MAEMO_5
- emit historyShow();
- #else
- QPoint p = historyShowToolButton->pos();
- p.setY(p.y());
- emit historyShow(mapToGlobal(p));
- #endif
+ qDebug()<<"test16";
+#ifndef Q_WS_MAEMO_5
+ QPoint p=view->pos(); // = historyShowToolButton->pos();
+ p=mapToGlobal(p);
+ p.setX(p.x()+view->width());
+ emit historyShow(p);
+#else
+ emit historyShow();
+#endif
}
#include <QWidget>
#include <QtGui>
+#include <QDeclarativeView>
+
#include "../backbone/backbone.h"
#include "../../include/History.h"
~SearchBarWidget();
Q_SIGNALS:
+
+ void setEnableHistoryNext(QVariant enable);
+ void setEnableHistoryShow(QVariant enable);
+ void setEnableHistoryPrev(QVariant enable);
+ void setButtonText(QVariant text);
+ void setLineEditText(QVariant text);
+ void setLineEditEnables(QVariant enabled);
+ void progresSetMax(QVariant);
+ void progresSetMin(QVariant);
+ void progresSetValue(QVariant);
+ void progresSetValue2(QVariant);
+
//! Requests to search for a list of words matching a word passed as
//! a parameter
void searchForTranslations(QString);
void refreshHistoryButtons();
public Q_SLOTS:
+
+ void updateBusyTimer();
+
+ void searchButtonClicked(QString text);
+
//! Enables or disables search word line edit and history buttons
/*!
While searching it disables only history button and line edit.
private:
+
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+ QDeclarativeView *progressBar;
+ QTimer *busyTimer;
+ bool progressMax;
+
QLineEdit* searchWordLineEdit;
QCompleter* lineEditCompleter;
QStringListModel* completerModel;
#include "SettingsWidget.h"
#include <QDebug>
-SettingsWidget::SettingsWidget(GUIInterface *parent) :
- QDialog(parent)
-{
- guiInterface = parent;
+SettingsWidget::SettingsWidget(GUIInterface *parent) : QDialog(parent) {
+guiInterface = parent;
+
+#ifndef Q_WS_MAEMO_5
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/SettingsWidget.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ view->setMinimumWidth(250);
+ view->setMaximumWidth(250);
+ view->setMinimumHeight(view->sizeHint().height());
+ view->setMaximumHeight(view->sizeHint().height());
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+ view->setWindowTitle(tr("Settings"));
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(this, SIGNAL(setMinHistory(QVariant)),
+ rootObject, SLOT(setMinHistory(QVariant)));
+ connect(this, SIGNAL(setValueHistory(QVariant)),
+ rootObject, SLOT(setValueHistory(QVariant)));
+ connect(this, SIGNAL(setMaxHistory(QVariant)),
+ rootObject, SLOT(setMaxHistory(QVariant)));
+ connect(this, SIGNAL(setMinSearchResult(QVariant)),
+ rootObject, SLOT(setMinSearchResult(QVariant)));
+ connect(this, SIGNAL(setValueSearchResult(QVariant)),
+ rootObject, SLOT(setValueSearchResult(QVariant)));
+ connect(this, SIGNAL(setMaxSearchResult(QVariant)),
+ rootObject, SLOT(setMaxSearchResult(QVariant)));
+ connect(this, SIGNAL(setCheckedBookmarks(QVariant)),
+ rootObject, SLOT(setCheckedBookmarks(QVariant)));
+ connect(this, SIGNAL(setCheckedDictionaries(QVariant)),
+ rootObject, SLOT(setCheckedDictionaries(QVariant)));
+
+ connect(rootObject, SIGNAL(historySizeValueChanged(int)),
+ this, SLOT(historySizeValueChanged(int)));
+ connect(rootObject, SIGNAL(searchResulValueChanged(int)),
+ this, SLOT(searchResulValueChanged(int)));
+ connect(rootObject, SIGNAL(dictionariesCheckBoxChanged(bool)),
+ this, SLOT(dictionariesCheckBoxChanged(bool)));
+ connect(rootObject, SIGNAL(bookmarksCheckBoxChanged(bool)),
+ this, SLOT(bookmarksCheckBoxChanged(bool)));
+ connect(rootObject, SIGNAL(saveButtonClicked()),
+ this, SLOT(save()));
+
+#else
setWindowTitle(tr("Settings"));
+ setModal(true);
+#endif
initalizeUI();
+}
- setModal(true);
+void SettingsWidget::historySizeValueChanged(int value){
+ historyValue = value;
+ changed();
+}
+
+void SettingsWidget::searchResulValueChanged(int value){
+ searchResultValue=value;
+ changed();
+}
+
+void SettingsWidget::dictionariesCheckBoxChanged(bool boolean){
+ dictionariesCheckBox=boolean;
+ changed();
+}
+
+void SettingsWidget::bookmarksCheckBoxChanged(bool boolean){
+ bookmarksCheckBox=boolean;
+ changed();
}
void SettingsWidget::initalizeUI() {
+#ifndef Q_WS_MAEMO_5
+ emit setMinHistory(1);
+ emit setMaxHistory(50);
+ emit setMinHistory(0);
+ emit setMaxHistory(500);
+ settings = 0;
+#else
verticalLayout = new QVBoxLayout;
- setLayout(verticalLayout);
-
historySizeLayout = new QHBoxLayout;
-
historySizeSpinBox = new SpinBox;
+ searchResultLayout = new QHBoxLayout;
+ searchResultSizeSpinBox = new SpinBox;
+ searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"));
+ searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"));
+
historySizeSpinBox->setMinimum(1);
historySizeSpinBox->setMaximum(50);
-
historySizeToolTip = tr("Limits maximum number of words saved in history");
+ historySizeLayout->addWidget(historySizeSpinBox);
#ifdef Q_WS_MAEMO_5
historySizeInfoToolButton = new QToolButton;
historySizeInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
- #endif
-
- historySizeLayout->addWidget(historySizeSpinBox);
- #ifdef Q_WS_MAEMO_5
historySizeLayout->addWidget(historySizeInfoToolButton);
+ searchResultSizeInfoToolButton = new QToolButton;
+ searchResultSizeInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
#endif
-
-
-
- searchResultLayout = new QHBoxLayout;
-
- searchResultSizeSpinBox = new SpinBox;
searchResultSizeSpinBox->setMinimum(0);
searchResultSizeSpinBox->setMaximum(500);
searchResultSizeSpinBox->setSpecialValueText(tr("Unlimited"));
-
searchResultSizeToolTip = tr("Limits maximum number of found words, affects"
" only when searching in file.");
-
- #ifdef Q_WS_MAEMO_5
- searchResultSizeInfoToolButton = new QToolButton;
- searchResultSizeInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
- #endif
-
searchResultLayout->addWidget(searchResultSizeSpinBox);
+
#ifdef Q_WS_MAEMO_5
searchResultLayout->addWidget(searchResultSizeInfoToolButton);
#endif
-
-
-
-
spinBoxesFormLayout = new QFormLayout;
- spinBoxesFormLayout->addRow(tr("Search result size"),
- searchResultLayout);
- spinBoxesFormLayout->addRow(tr("History size"),
- historySizeLayout);
-
-
-
+ spinBoxesFormLayout->addRow(tr("Search result size"), searchResultLayout);
+ spinBoxesFormLayout->addRow(tr("History size"), historySizeLayout);
verticalLayout->addLayout(spinBoxesFormLayout);
-
-
checkBoxesLabel = new QLabel(tr("Search in:"),this);
- searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"));
- searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"));
-
verticalLayout->addSpacing(20);
verticalLayout->addWidget(checkBoxesLabel);
verticalLayout->addWidget(searchInDictionariesCheckBox);
verticalLayout->addWidget(searchInBookmarksCheckBox);
+ setLayout(verticalLayout);
- connect(historySizeSpinBox, SIGNAL(valueChanged(int)), this,
- SLOT(changed()));
- connect(searchResultSizeSpinBox, SIGNAL(valueChanged(int)), this,
- SLOT(changed()));
- connect(searchInDictionariesCheckBox, SIGNAL(toggled(bool)), this,
- SLOT(changed()));
- connect(searchInBookmarksCheckBox, SIGNAL(toggled(bool)), this,
- SLOT(changed()));
-
+ connect(historySizeSpinBox, SIGNAL(valueChanged(int)),
+ this,SLOT(changed()));
+ connect(searchResultSizeSpinBox, SIGNAL(valueChanged(int)),
+ this,SLOT(changed()));
+ connect(searchInDictionariesCheckBox, SIGNAL(toggled(bool)),
+ this,SLOT(changed()));
+ connect(searchInBookmarksCheckBox, SIGNAL(toggled(bool)),
+ this,SLOT(changed()));
-#ifdef Q_WS_MAEMO_5
+ #ifdef Q_WS_MAEMO_5
connect(searchResultSizeInfoToolButton, SIGNAL(clicked()),
this, SLOT(showSearchResultSizeInfo()));
-
connect(historySizeInfoToolButton, SIGNAL(clicked()),
this, SLOT(showHistorySizeInfo()));
-#else
+ #else
historySizeSpinBox->setToolTip(historySizeToolTip);
searchResultSizeSpinBox->setToolTip(searchResultSizeToolTip);
-#endif
+ #endif
settings = 0;
setMaximumHeight(sizeHint().height());
connect(closeButton, SIGNAL(clicked()), this, SLOT(save()));
#endif
+#endif
}
void SettingsWidget::showEvent(QShowEvent *e) {
+#ifndef Q_WS_MAEMO_5
+ settings = guiInterface->settings();
+
+ emit setValueHistory(settings->value("history_size").toInt());
+ emit setValueSearchResult(settings->value("search_limit").toInt());
+
+ if(settings->value("search_bookmarks") == "true")
+ emit setCheckedBookmarks(true);
+ else
+ emit setCheckedBookmarks(false);
+
+ if(settings->value("search_dictionaries") == "true")
+ emit setCheckedDictionaries(true);
+ else
+ emit setCheckedDictionaries(false);
+
+ QDialog::showEvent(e);
+#else
#ifndef Q_WS_MAEMO_5
_save = false;
#endif
searchInDictionariesCheckBox->setChecked(true);
else
searchInDictionariesCheckBox->setChecked(false);
-
- _changed = false;
QDialog::showEvent(e);
+#endif
+ _changed = false;
}
void SettingsWidget::hideEvent(QHideEvent *e) {
QDialog::hideEvent(e);
- #ifndef Q_WS_MAEMO_5
- if(settings && _save) {
- #else
- if(settings && _changed &&
- QMessageBox::question(this,
- tr("Save"),
- tr("Do you want to save changes?"),
- QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
+#ifndef Q_WS_MAEMO_5
+ if(settings && _save) {
+ Settings* newSettings = new Settings;
+ newSettings->setValue("history_size",QString::number(historyValue));
+ newSettings->setValue("search_limit",QString::number(searchResultValue));
+ if(dictionariesCheckBox==true)
+ newSettings->setValue("search_dictionaries", "true");
+ else
+ newSettings->setValue("search_dictionaries", "false");
+
+ if(bookmarksCheckBox==true)
+ newSettings->setValue("search_bookmarks", "true");
+ else
+ newSettings->setValue("search_bookmarks", "false");
+ foreach(QString key, newSettings->keys()) {
+ if(settings->value(key) != newSettings->value(key)) {
+ guiInterface->setSettings(newSettings);
+ break;
+ }
+ }
+ _changed = false;
+ if(settings) {
+ delete settings;
+ settings = 0;
+ }
+ }
+#else
+ if(settings && _changed &&
+ QMessageBox::question(this,
+ tr("Save"),
+ tr("Do you want to save changes?"),
+ QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
- #endif
Settings* newSettings = new Settings;
newSettings->setValue("history_size",
QString::number(historySizeSpinBox->value()));
newSettings->setValue("search_bookmarks", "false");
//setting new settings only if they are different than old ones
- QString key;
- foreach(key, newSettings->keys()) {
+ foreach(QString key, newSettings->keys()) {
if(settings->value(key) != newSettings->value(key)) {
guiInterface->setSettings(newSettings);
break;
}
}
-
}
if(settings) {
delete settings;
settings = 0;
}
_changed = false;
+#endif
}
#include <QWidget>
#include <QtGui>
#include <QPushButton>
+#include <QDeclarativeView>
+#include <QVariant>
+
#include "../../include/GUIInterface.h"
#include "../../include/settings.h"
#include "SpinBox.h"
+
/*!
Shows settings that user can change.
It allows to change limit of searches and limit of history.
explicit SettingsWidget(GUIInterface *parent = 0);
Q_SIGNALS:
+ void setMinHistory(QVariant minValue);
+ void setMaxHistory(QVariant minValue);
+ void setValueHistory(QVariant value);
+ void setMinSearchResult(QVariant minValue);
+ void setMaxSearchResult(QVariant minValue);
+ void setValueSearchResult(QVariant value);
+ void setCheckedBookmarks(QVariant boolen);
+ void setCheckedDictionaries(QVariant boolen);
+
void notify(Notify::NotifyType, QString);
protected:
void hideEvent(QHideEvent *);
private Q_SLOTS:
+ void historySizeValueChanged(int value);
+ void searchResulValueChanged(int value);
+ void dictionariesCheckBoxChanged(bool boolean);
+ void bookmarksCheckBoxChanged(bool boolean);
+
void changed();
#ifndef Q_WS_MAEMO_5
void save();
private:
void initalizeUI();
+
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+
SpinBox* historySizeSpinBox;
SpinBox* searchResultSizeSpinBox;
QVBoxLayout* verticalLayout;
QHBoxLayout* footerLayout;
bool _save;
#endif
-
-
-
+ int historyValue;
+ int searchResultValue;
+ bool dictionariesCheckBox;
+ bool bookmarksCheckBox;
};
#endif // SETTINGSWIDGET_H
#include "TranslationView.h"
#include "TranslationWidget.h"
-TranslationView::TranslationView(QWidget *parent) :
- QWebView(parent)
-{
+
+
+TranslationView::TranslationView(QWidget *parent) : QWebView(parent) {
+
+#ifndef Q_WS_MAEMO_5
+
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/TranslationView.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(this, SIGNAL(setUrl(QVariant)),
+ rootObject, SLOT(setUrl(QVariant)));
+#else
+
realParent = qobject_cast<TranslationWidget*>(parent);
searchSelectedAction = new QAction(tr("Search"), this);
copySelectedAction = new QAction(tr("Copy"), this);
connect(searchSelectedAction, SIGNAL(triggered()),
this, SIGNAL(search()));
connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection()));
+
+#endif
+}
+
+void TranslationView::setHtml(QString htmlString){
+ QString url = QDir::homePath() + "/.mdictionary/" + "html.html";
+ QFile file(url);
+ if(file.open(QIODevice::WriteOnly | QIODevice::Text)){
+ QByteArray array = htmlString.toUtf8();
+ file.write(array);
+ file.close();
+ emit setUrl(url);
+ }
}
void TranslationView::wheelEvent(QWheelEvent *e) {
+#ifndef Q_WS_MAEMO_5
+#else
if(e->modifiers() & Qt::ControlModifier) {
if(e->delta()>0) {
zoomIn();
else {
QWebView::wheelEvent(e);
}
+#endif
}
bool TranslationView::eventFilter(QObject *, QEvent *e) {
+#ifndef Q_WS_MAEMO_5
+#else
switch (e->type()) {
case QEvent::MouseButtonPress:
if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
break;
}
return false;
+#endif
}
void TranslationView::contextMenuEvent(QContextMenuEvent *e) {
+#ifndef Q_WS_MAEMO_5
+#else
QMenu *menu = new QMenu;
if(selectedText().isEmpty())
searchSelectedAction->setEnabled(false);
delete menu;
e->ignore();
+#endif
}
void TranslationView::zoomIn() {
+#ifndef Q_WS_MAEMO_5
+#else
if(zoomFactor() >= 3)
return;
setZoomFactor(zoomFactor()*1.05);
realParent->updateZoom(zoomFactor());
-
+#endif
}
void TranslationView::zoomOut() {
+#ifndef Q_WS_MAEMO_5
+#else
if(zoomFactor() <= 0.5)
return;
setZoomFactor(zoomFactor()*0.95);
realParent->updateZoom(zoomFactor());
+#endif
}
void TranslationView::copy() {
+#ifndef Q_WS_MAEMO_5
+#else
pageAction(QWebPage::Copy)->trigger();
+#endif
}
void TranslationView::selection() {
+#ifndef Q_WS_MAEMO_5
+#else
if(selectedText().size())
Q_EMIT copyAvailable(true);
else
Q_EMIT copyAvailable(false);
+#endif
}
void TranslationView::selectAll() {
+#ifndef Q_WS_MAEMO_5
+#else
pageAction(QWebPage::SelectAll)->trigger();
+#endif
}
#include <QAction>
#include <QWebView>
#include <QEvent>
+#include <QDeclarativeView>
+#include <QVBoxLayout>
+#include <QString>
+#include <QByteArray>
class TranslationWidget;
Q_OBJECT
public:
explicit TranslationView(QWidget *parent = 0);
+ void setHtml(QString htmlString);
public Q_SLOTS:
void zoomIn();
Q_SIGNALS:
void search();
void copyAvailable(bool);
+ void setHtmlSignal(QVariant htmlString);
+ void setUrl(QVariant url);
protected:
void contextMenuEvent(QContextMenuEvent *);
void wheelEvent(QWheelEvent *);
private:
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+
QAction* searchSelectedAction;
QAction* copySelectedAction;
QAction* selectAllAction;
setWindowTitle("mDictionary");
- connect(webkit, SIGNAL(search()),
- this, SLOT(searchSelected()));
+// connect(webkit, SIGNAL(search()),
+// this, SLOT(searchSelected()));
QFile file(":/xsl/xsl.xsl");
if(!file.open(QFile::ReadOnly))
QString trans= createTranslation(translations);
QString head = "<html><head>";
- head += "<link rel=\"stylesheet\" type=\"text/css\" "
+ head += "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"> "
+ "<link rel=\"stylesheet\" type=\"text/css\" "
"href=\"/usr/share/mdictionary/css/" "style.css"
"\" /></head><body ondragstart=\"return false\">";
trans = head + trans + "</body></html>";
trans.replace("$STAR$", "/usr/share/mdictionary/staron.png");
- webkit->setHtml(trans, QUrl().fromLocalFile("/"));
+ webkit->setHtml(trans);
+// webkit->setHtml(trans, QUrl().fromLocalFile("/"));
}
qreal fac = set->value("zoom").toFloat();
if(!fac)
fac++;
- webkit->setZoomFactor(fac);
+// webkit->setZoomFactor(fac);
delete set;
QWidget*w = new QWidget(this);
}
void TranslationWidget::searchSelected() {
- if(webkit->selectedText().isEmpty()) {
+/* if(webkit->selectedText().isEmpty()) {
Q_EMIT notify(Notify::Warning, tr("No text is selected"));
}
else {
#endif
Q_EMIT search(webkit->selectedText().toLower());
}
+ */
}
void TranslationWidget::copySelected() {
- if(webkit->selectedText().isEmpty()) {
+ /* if(webkit->selectedText().isEmpty()) {
Q_EMIT notify(Notify::Warning, tr("No text is selected"));
}
else {
Q_EMIT notify(Notify::Info, tr("Copyied selected text"));
}
+ */
}
#ifdef Q_WS_MAEMO_5
void TranslationWidget::keyPressEvent(QKeyEvent* event) {
switch (event->key()) {
case Qt::Key_F7:
- webkit->zoomIn();
+ // webkit->zoomIn();
event->accept();
break;
case Qt::Key_F8:
- webkit->zoomOut();
+// webkit->zoomOut();
event->accept();
break;
}
mainLayout = new QVBoxLayout(this);
setLayout(mainLayout);
+ #ifndef Q_WS_MAEMO_5
+ qmlView = new QDeclarativeView(this);
+ qmlView->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/WelcomeScreenWidget.qml"));
+
+ mainLayout->addWidget(qmlView, 0, Qt::AlignCenter);
+
+ #endif
+ #ifdef Q_WS_MAEMO_5
+
imageLabel = new QLabel(this);
mainLabel = new QLabel(infoNote, this);
imageLabel->resize(imageLabel->pixmap()->size());
- //mainLabel->setWordWrap(true);
+ mainLabel->setWordWrap(true);
+ #endif
#ifdef Q_WS_MAEMO_5
- mainLayout->addSpacing(20);
+ //mainLayout->addSpacing(20);
#endif
}
#include <QWidget>
#include <QScrollArea>
#include <QtGui>
+#include <QtDeclarative/QDeclarativeView>
+//#include <QtDeclarative/QDeclarativeEngine>
+//#include <QtDeclarative/QDeclarativeContext>
//! Displays welcome screen with logo and name of application
class WelcomeScreenWidget : public QScrollArea
private:
QVBoxLayout* mainLayout;
QLabel* mainLabel, * licenseLabel, *imageLabel;
+
+ QDeclarativeView* qmlView;
+// QDeclarativeEngine* engine;
+// QDeclarativeContext* context;
+ QWidget* widget;
};
#endif // WELCOMESCREENWIDGET_H
--- /dev/null
+#include "WordListModel.h"
+
+WordListModel::WordListModel(QObject *parent) :
+ QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[WordRole] = "word";
+ roles[IsBookmarkedRole] = "isBookmarked";
+ roles[NumberRole] = "number";
+ setRoleNames(roles);
+
+
+}
+
+int WordListModel::rowCount(const QModelIndex &parent) const
+{
+ return _wordList.count();
+}
+
+void WordListModel::addWord(QString word, QList<Translation *> translations, bool isBookmarked)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ _translations.insert(word, translations);
+ _wordList << word;
+ _wordInBookmarks.insert(word, isBookmarked);
+ endInsertRows();
+}
+
+void WordListModel::clear()
+{
+ bool empty = true;
+ if (!_wordList.isEmpty()){
+ beginResetModel();
+ empty = false;
+ }
+ _translations.clear();
+ _wordInBookmarks.clear();
+ _wordList.clear();
+ if (!empty){
+ endResetModel();
+ }
+}
+
+QVariant WordListModel::data(const QModelIndex &index, int role) const
+{
+ if (index.row() < 0 || index.row() > _translations.count()){
+ return QVariant();
+ }
+
+ if (role == WordRole)
+ {
+ return _wordList[index.row()];
+ }
+ if (role == NumberRole){
+ return index.row();
+ }
+ if (role == IsBookmarkedRole){
+ return _wordInBookmarks[_wordList[index.row()]];
+ }
+ return QVariant();
+}
+
+bool WordListModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ int res = setDataPriv(index.row(), value, role);
+ if (res == 0)
+ return false;
+ if (res > 0)
+ return true;
+ return true;
+}
+
+Qt::ItemFlags WordListModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags fl = QAbstractItemModel::flags(index);
+ return (fl | Qt::ItemIsEditable);
+}
+
+void WordListModel::setTranslations(QHash<QString, QList<Translation *> > translations, QHash<QString, bool> wordsInBookmarks)
+{
+ QHashIterator<QString, QList<Translation *> > i(translations);
+ while (i.hasNext()) {
+ i.next();
+ addWord(i.key(), i.value(), wordsInBookmarks[i.key()]);
+ }
+
+ sort(0);
+
+}
+
+void WordListModel::sort(int column, Qt::SortOrder order)
+{
+ if (column != 0)
+ return;
+
+ int left = 0;
+ int right = _wordList.count() - 1;
+
+ if (left < right){
+ if (order == Qt::AscendingOrder){
+ qSort(_wordList.begin(), _wordList.end());
+ } else if (order == Qt::DescendingOrder) {
+ qSort(_wordList.begin(), _wordList.end(), qGreater<QString>());
+ }
+ }
+}
+
+void WordListModel::setModelProperty(int index, const QVariant value, QString role)
+{
+ if (role.contains("isBookmarked"))
+ {
+ setDataPriv(index, value, IsBookmarkedRole);
+ }
+}
+
+int WordListModel::setDataPriv(int index, const QVariant &value, int role)
+{
+ bool bookmarksOnly = false;
+ if (_wordInBookmarks.values().count(false) == 0){
+ bookmarksOnly = true;
+ }
+
+ if (index < 0 || index > _translations.count())
+ return 0;
+
+ QString word = _wordList[index];
+ if (role == WordRole)
+ return 1;
+ if (role == NumberRole)
+ return 1;
+ if (role == IsBookmarkedRole)
+ {
+ if (value.type() == QVariant::Bool)
+ {
+ _wordInBookmarks[word] = value.toBool();
+ Q_EMIT dataChanged(this->index(0), this->index(_translations.count() - 1));
+ if (_wordInBookmarks[word] == true){
+ Q_EMIT addToBookmarks(word);
+ } else {
+ Q_EMIT removeFromBookmarks(word);
+ if (bookmarksOnly == true){
+ beginRemoveRows(QModelIndex(), index, index + 1);
+ this->_translations.remove(_wordList[index]);
+ this->_wordInBookmarks.remove(_wordList[index]);
+ this->_wordList.removeAt(index);
+ endRemoveRows();
+ }
+ }
+ return 2;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ return 0;
+}
--- /dev/null
+#ifndef WORDLISTMODEL_H
+#define WORDLISTMODEL_H
+
+#include <QAbstractListModel>
+//#include "../../include/GUIInterface.h"
+#include "../../include/translation.h"
+
+class WordListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+
+ enum DictTypeRoles
+ {
+ WordRole = Qt::UserRole + 1,
+ IsBookmarkedRole,
+ NumberRole
+ };
+
+ explicit WordListModel(QObject *parent = 0);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ //! Replace model data and refresh ui.
+ /*!
+ \param dictionaries hash set (dictionary, is active) with dictionaries
+ */
+ void setTranslations(QHash<QString, QList<Translation*> > translations, QHash<QString, bool> wordsInBookmarks);
+ //! Clear model data and refresh UI
+ void clear();
+
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+signals:
+
+ void addToBookmarks(QString word);
+
+ void removeFromBookmarks(QString word);
+
+public slots:
+
+ //! Set value at role in index row of data.
+ /*!
+ \param index word position in data list
+ \param value new value for role
+ \param role role name
+ */
+ void setModelProperty(int index, const QVariant value, QString role);
+
+private:
+ int setDataPriv(int index, const QVariant &value, int role);
+ void addWord(QString word, QList<Translation*> translations, bool isBookmarked);
+
+ QHash<QString, QList<Translation*> > _translations;
+ QHash<QString, bool > _wordInBookmarks;
+ QList<QString> _wordList;
+
+};
+
+#endif // WORDLISTMODEL_H
QTreeView(parent) {
//creating new model to store words and stars
+#ifdef Q_WS_MAEMO_5
model = new QStandardItemModel(this);
setModel(model);
- setHeaderHidden(true);
- setRootIsDecorated(false);
+
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//set our custom style to draw checkboxes as stars
proxyStyle = new WordListProxyStyle();
setStyle(proxyStyle);
+ //for future use, set checkbox icons for maemo
+// ctxt->setContextProperty("CheckedPath", "qrc:/icons/96x96/staron.png");
+// ctxt->setContextProperty("UncheckedPath", "qrc:/icons/96x96/staroff.png");
+#else
+
+ listModel = new WordListModel(this);
+
+ verticalLayout = new QVBoxLayout;
+ setLayout(verticalLayout);
+
+ qmlView = new QDeclarativeView(this);
+
+ ctxt = qmlView->rootContext();
+
+ ctxt->setContextProperty("wordModel", &(*listModel));
+ ctxt->setContextProperty("CheckedPath", "qrc:/icons/16x16/staron.png");
+ ctxt->setContextProperty("UncheckedPath", "qrc:/icons/16x16/staroff.png");
+
+ qmlView->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/WordListWidget.qml"));
+
+ QGraphicsObject *rootObject = qmlView->rootObject();
+
+ qmlView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+
+ verticalLayout->addWidget(qmlView);
+
+ connect(rootObject, SIGNAL(wordSelected(QString)), this, SLOT(wordClicked(QString)));
+ connect(listModel, SIGNAL(addToBookmarks(QString)), this, SLOT(addToBookmarks(QString)));
+ connect(listModel, SIGNAL(removeFromBookmarks(QString)), this, SLOT(removeFromBookmarks(QString)));
+
+ connect(this, SIGNAL(setWordListState(QVariant)), rootObject, SLOT(setEnabled(QVariant)));
+
+#endif
+
+ setHeaderHidden(true);
+ setRootIsDecorated(false);
+
//setting size of star in pixels, on maemo checboxes are much bigger
#ifdef Q_WS_MAEMO_5
checkBoxWidth = 70;
clear();
searchResult = result;
+#ifdef Q_WS_MAEMO
if(searchResult.count()>0) {
setEnabled(true);
model->setColumnCount(2);
model->setItem(0,item);
}
+#else
+
+ QHash<QString, bool> wordsInBookmarks;
+ QHashIterator<QString, QList<Translation *> > i(result);
+ while (i.hasNext()){
+ i.next();
+
+ bool bookmark = false;
+ Translation* t;
+ foreach(t, searchResult[i.key()]) {
+ if(t->isBookmark()) {
+ bookmark = true;
+ break;
+ }
+ }
+ wordsInBookmarks.insert(i.key(), bookmark);
+ }
+
+ if (result.count() == 0){
+ result.insert("!@#$%", QList<Translation*>());
+ wordsInBookmarks.insert("!@#$%", false);
+ Q_EMIT setWordListState(false);
+ }
+
+ if (listModel == 0){
+ listModel = new WordListModel(this);
+ }
+ listModel->setTranslations(result, wordsInBookmarks);
+
+#endif
setFocus();
}
+#ifdef Q_WS_MAEMO
void WordListWidget::wordClicked(QModelIndex index) {
//we're getting translation based on data in index
Q_EMIT showTranslation(
}
}
}
+#else
+ void WordListWidget::wordClicked(QString word){
+ emit showTranslation(searchResult[word]);
+ }
+
+ void WordListWidget::addToBookmarks(QString word){
+ emit addBookmark(searchResult[word]);
+ }
+
+ void WordListWidget::removeFromBookmarks(QString word){
+ emit removeBookmark(searchResult[word]);
+ }
+
+#endif
+#ifdef Q_WS_MAEMO_5
void WordListWidget::mouseReleaseEvent(QMouseEvent *event) {
//firstly we normally handle this event
QTreeView::resizeEvent(event);
}
-void WordListWidget::resizeColumns() {
- setColumnWidth(0, viewport()->width() -checkBoxWidth - 5);
- setColumnWidth(1, checkBoxWidth);
-}
-
void WordListWidget::keyPressEvent(QKeyEvent *event) {
QTreeView::keyPressEvent(event);
wordClicked(selectedIndexes().at(0));
}
}
+#endif
+
+void WordListWidget::resizeColumns() {
+ setColumnWidth(0, viewport()->width() -checkBoxWidth - 5);
+ setColumnWidth(1, checkBoxWidth);
+}
void WordListWidget::lockList() {
+#ifdef Q_WS_MAEMO_5
setEnabled(false);
+#else
+ Q_EMIT setWordListState(false);
+#endif
}
void WordListWidget::unlockList() {
+#ifdef Q_WS_MAEMO_5
setEnabled(true);
+#else
+ Q_EMIT setWordListState(true);
+#endif
}
void WordListWidget::clear() {
+#ifdef Q_WS_MAEMO_5
model->clear();
+#else
+ if (listModel != 0){
+ listModel->clear();
+ }
+#endif
QHash<QString, QList<Translation*> >::iterator i;
for(i = searchResult.begin(); i != searchResult.end(); i++) {
#include <QtGui>
#include <QStringListModel>
+#include <QVBoxLayout>
#include "../backbone/backbone.h"
#include "WordListProxyStyle.h"
+#include "WordListModel.h"
+#include <QtDeclarative/QDeclarativeView>
+#include <QtDeclarative/QDeclarativeContext>
/*!
It allows user to select word to see its translation or to mark or unmark
//! Requests to remove selected word from bookmarks
void removeBookmark(QList<Translation*>);
+ void setWordListState(QVariant state);
+
public Q_SLOTS:
//! Shows search results
void clear();
protected:
+#ifdef Q_WS_MAEMO_5
//! Reimplemented standard mouseReleaseEvent to check if user clicked on
//! a word or on its star to emit suitable signal
void mouseReleaseEvent(QMouseEvent *event);
//! Checks if user press return and if so displays translation of selected word
void keyPressEvent( QKeyEvent * event);
-
+#endif
private Q_SLOTS:
+#ifdef Q_WS_MAEMO_5
//! Emits signal to show translation of clicked item. Signal is emitted
//! only when a word was clicked.
void wordClicked(QModelIndex index);
//! Emits signal to show add or remove word from bookmarks.
//! Signal is emitted only when a star was clicked.
void wordChecked(QModelIndex index);
-
+#else
+ void wordClicked(QString word);
+ void addToBookmarks(QString word);
+ void removeFromBookmarks(QString word);
+#endif
private:
//! Association between words and their translations
QHash<QString, QList<Translation*> > searchResult;
WordListProxyStyle* proxyStyle;
+
+#ifndef Q_WS_MAEMO_5
+ QVBoxLayout* verticalLayout;
+ QDeclarativeView* qmlView;
+ QDeclarativeContext* ctxt;
+ WordListModel* listModel;
+#endif
};
#endif // WORDLISTWIDGET_H
xmlpatterns \
sql \
dbus \
- webkit
+ webkit \
+ declarative
maemo5:QT += maemo5
gui/TranslationView.cpp \
gui/DBusAdapter.cpp \
gui/NotifyManager.cpp \
- gui/SpinBox.cpp
+ gui/SpinBox.cpp \
+ gui/DictTypeModel.cpp \
+ gui/DictManagerModel.cpp \
+ gui/HistoryListModel.cpp \
+ gui/WordListModel.cpp \
+ ../include/ComboBoxModel.cpp
HEADERS += gui/MainWindow.h \
backbone/ConfigGenerator.h \
../include/CommonDictInterface.h \
gui/MenuWidget.h \
gui/MenuTabWidget.h \
- gui/DictManagerWidget.h \
gui/DictTypeSelectDialog.h \
../include/History.h \
gui/HistoryListDialog.h \
../include/DictDialog.h \
gui/DBusAdapter.h \
gui/NotifyManager.h \
- gui/SpinBox.h
+ gui/SpinBox.h \
+ gui/DictTypeModel.h \
+ gui/DictManagerModel.h \
+ gui/DictManagerWidget.h \
+ gui/HistoryListModel.h \
+ gui/WordListModel.h \
+ ../include/ComboBoxModel.h
RESOURCES += ../../data/gui.qrc
TRANSLATIONS += pl_PL.ts \
en_US.ts
+OTHER_FILES += \
+ qml/WelcomeScreenWidget.qml \
+ qml/Button.qml \
+ qml/AboutWidget.qml \
+ qml/SearchBarWidget.qml \
+ qml/IconButton.qml \
+ qml/MyTextLineEdit.qml \
+ qml/ProgressBar.qml \
+ qml/ElementsListView.qml \
+ qml/DictTypeSelectDialog.qml \
+ qml/DictManagerWidget.qml \
+ qml/WordListWidget.qml \
+ qml/TranslationView.qml \
+ qml/FlickableWebView.qml \
+ qml/ScrollBar.qml \
+ qml/Checkbox.qml \
+ qml/MySpinBox.qml \
+ qml/SettingsWidget.qml \
+ qml/HistoryListDialog.qml \
+ qml/ComboBox.qml
+
target.path = $$BIN_DIR
INSTALLS += target
unix {
+ #icons and misc
maemo5 {
desktop.path = $$SHARE_DIR/applications/hildon
icon64.path = $$SHARE_DIR/icons/hicolor/64x64/hildon
shared.files += ../../data/icons/16x16/staron.png
shared.files += ../../data/xsl/mask.png
- meego {
+ #css
+ meego_css {
+ css.path = $$DATA_DIR/css
+ css.files += ../../data/css_meego/style.css
+ }
+ else:meego {
css.path = $$DATA_DIR/css
css.files += ../../data/css_meego/style.css
}
css.files += ../../data/css_desktop/style.css
}
- meego {
+ #css images
+ meego_css {
+ css_images.path = $$DATA_DIR/css/images
+ css_images.files += ../../data/css_meego/images/header-background.png
+ css_images.files += ../../data/css_meego/images/header-border.png
+ css_images.files += ../../data/css_meego/images/shadow-grey-bg.png
+ css_images.files += ../../data/css_meego/images/shadow-white-bg.png
+ css_images.files += ../../data/css_meego/images/tab-background.png
+ css_images.files += ../../data/css_meego/images/key-background.png
+ css_images.files += ../../data/css_meego/images/shadow-transparent-bg.png
+ css_images.files += ../../data/css_meego/images/splash2.png
+ css_images.files += ../../data/css_meego/images/people.png
+ }
+ else:meego {
css_images.path = $$DATA_DIR/css/images
css_images.files += ../../data/css_meego/images/header-background.png
css_images.files += ../../data/css_meego/images/header-border.png
css_images.files += ../../data/css_meego/images/shadow-white-bg.png
css_images.files += ../../data/css_meego/images/tab-background.png
css_images.files += ../../data/css_meego/images/key-background.png
- css_images.files += ../../data/css_meego/images/shadow-transparent-bg. png
- css_images.files += ../../data/css_meego/images/splash2.png
+ css_images.files += ../../data/css_meego/images/shadow-transparent-bg.png
+ css_images.files += ../../data/css_meego/images/splash2.png
+ css_images.files += ../../data/css_meego/images/people.png
}
else:maemo5 {
css.path = $$DATA_DIR/css
css_images.files += ../../data/css_desktop/images/key-background.png
}
+ #services
service.path = $$SHARE_DIR/dbus-1/services
service.files += ../../data/other/com.comarch.mdictionary.service
+
+ #qmls (stub)
+ meego {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ./qml/WelcomeScreenWidget.qml
+ qmls.files += ./qml/Button.qml
+ qmls.files += ./qml/AboutWidget.qml
+ qmls.files += ./qml/SearchBarWidget.qml
+ qmls.files += ./qml/IconButton.qml
+ qmls.files += ./qml/MyTextLineEdit.qml
+ qmls.files += ./qml/ProgressBar.qml
+ qmls.files += ./qml/ElementsListView.qml
+ qmls.files += ./qml/DictTypeSelectDialog.qml
+ qmls.files += ./qml/DictManagerWidget.qml
+ qmls.files += ./qml/WordListWidget.qml
+ qmls.files += ./qml/TranslationView.qml
+ qmls.files += ./qml/FlickableWebView.qml
+ qmls.files += ./qml/ScrollBar.qml
+ qmls.files += ./qml/Checkbox.qml
+ qmls.files += ./qml/MySpinBox.qml
+ qmls.files += ./qml/SettingsWidget.qml
+ qmls.files += ./qml/ComboBox.qml
+ }
+ else:maemo5 {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ./qml/WelcomeScreenWidget.qml
+ }
+ else {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ./qml/WelcomeScreenWidget.qml
+ qmls.files += ./qml/Button.qml
+ qmls.files += ./qml/AboutWidget.qml
+ qmls.files += ./qml/SearchBarWidget.qml
+ qmls.files += ./qml/IconButton.qml
+ qmls.files += ./qml/MyTextLineEdit.qml
+ qmls.files += ./qml/ProgressBar.qml
+ qmls.files += ./qml/ElementsListView.qml
+ qmls.files += ./qml/DictTypeSelectDialog.qml
+ qmls.files += ./qml/DictManagerWidget.qml
+ qmls.files += ./qml/WordListWidget.qml
+ qmls.files += ./qml/TranslationView.qml
+ qmls.files += ./qml/FlickableWebView.qml
+ qmls.files += ./qml/ScrollBar.qml
+ qmls.files += ./qml/Checkbox.qml
+ qmls.files += ./qml/MySpinBox.qml
+ qmls.files += ./qml/SettingsWidget.qml
+ qmls.files += ./qml/HistoryListDialog.qml
+ qmls.files += ./qml/ComboBox.qml
+ }
- INSTALLS += desktop icon64 shared service css css_images
+ INSTALLS += desktop icon64 shared service css css_images qmls
}
--- /dev/null
+import Qt 4.7
+import QtWebKit 1.0
+
+Rectangle {
+ id: item
+ opacity: 1
+ anchors.fill: parent
+
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+ signal linkClicked(string link);
+
+ Image {
+ id: image1
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "qrc:/icons/logo/mdictionary.png"
+ }
+
+ Text {
+ id: text1
+ y: 200
+ text: "<h2><u>mDictionary</u></h2>"
+ anchors.horizontalCenterOffset: 0
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Text {
+ id: text2
+ y: 220
+ anchors.horizontalCenter: parent.horizontalCenter
+ textFormat: Text.RichText
+ text: "Maemo/Meego Multilingual Dictionary <br> Copyright 2006-2010, Comarch S.A. <br> <a href=\"http://mdictionary.garage.maemo.org\"> http://mdictionary.garage.maemo.org</a>"
+ anchors.horizontalCenterOffset: 0
+ onLinkActivated: linkClicked(link);
+ }
+
+ Text {
+ id: text3
+ y: 270
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "<font size=\"small\"><a href=\"https://garage.maemo.org/tracker/?func=add&group_id=58&atid=305\">Report bug</a></font>"
+ anchors.horizontalCenterOffset: 0
+ onLinkActivated: linkClicked(link);
+ }
+
+ Text {
+ id: text4
+ y: 290
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "<p><font size=\"small\">This program is free software: you can redistribute it and/or modify <br> it under the terms of the GNU General Public License as published by <br> the Free Software Foundation, either version 3 of the License,or <br>(at your option) any later version.<br>This program is distributed in the hope that it will be useful,<br>but WITHOUT ANY WARRANTY; without even the implied warranty of<br> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the <br> GNU General Public License for more details.<br> You should have received a copy of the GNU General Public License<br> along with this program. If not, see <<a href=\"http://www.gnu.org/licenses/\"> http://www.gnu.org/licenses/</a>>.</p></font>"
+ anchors.horizontalCenterOffset: 0
+ onLinkActivated: linkClicked(link);
+ }
+
+ /* MySpinBox {
+ id: test01
+ y:20;
+ x:20;
+ width: 40
+ height: 20;
+ }
+ */
+}
--- /dev/null
+import Qt 4.7
+
+BorderImage {
+ id: button
+ property alias textInButton: buttonText.text
+ signal clicked
+ opacity: 1
+
+ function setText(string) { textInButton = qsTr(string); }
+ border { left: 10; top: 10; right: 10; bottom: 10 }
+
+ MouseArea {
+ id: mouseArea
+ anchors.centerIn: parent;
+ width: parent.width;
+ height: parent.height;
+ onClicked: {
+ button.clicked();
+ }
+ }
+
+ Text {
+ z:1
+ id: buttonText
+ anchors.centerIn: parent;
+ font.pixelSize: parent.height * .5
+ style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+ }
+
+ Image {
+ id: image1
+ width: (35*parent.height)/107 +1
+ height: parent.height
+ anchors.left: parent.left
+ source: "qrc:/button/buttonLeft.png"
+ smooth: true
+ fillMode:Image.Stretch
+ }
+
+ Image {
+ id: image3
+ smooth: true
+ height: parent.height
+ anchors.right: image2.left
+ anchors.rightMargin: -1
+ anchors.left: image1.right
+ anchors.leftMargin: -1
+ source: "qrc:/button/buttonCenter.png"
+ fillMode:Image.Stretch
+ }
+
+ Image {
+ id: image2
+ smooth: true
+ width: (35*parent.height)/107 +1
+ height: parent.height
+ anchors.right: parent.right
+ source: "qrc:/button/buttonR.png"
+ fillMode:Image.Stretch
+ }
+
+ states: [
+ State {
+ name: "pressed";
+ when: (mouseArea.pressed == true && button.enabled == true);
+
+ PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
+ PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
+ PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" }
+ },
+ State {
+ name: "disabled";
+ when: (button.enabled == false);
+
+ PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" }
+ PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" }
+ PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" }
+ }
+ ]
+}
--- /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.
+
+*******************************************************************************/
+/*!
+ author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+import Qt 4.7
+
+Image {
+ id: checkbox
+ property bool selected
+ property string pathToCheckedImage: "qrc:/button/checkboxChecked.png"
+ property string pathToUncheckedImage: "qrc:/button/checkbox.png"
+ signal changed
+ height: {
+ var aspectRatio = sourceSize.height / sourceSize.width
+ return checkbox.width * aspectRatio
+ }
+ width: sourceSize.width
+ smooth: true
+ states: [
+ State {
+ name: "checked";
+ when: (checkbox.selected == true);
+
+ PropertyChanges { target: checkbox; source: pathToCheckedImage }
+ },
+ State {
+ name: "unchecked";
+ when: (checkbox.selected == false);
+
+ PropertyChanges { target: checkbox; source: pathToUncheckedImage }
+ }
+ ]
+ MouseArea{
+ id: area
+ anchors.fill: parent
+ onClicked: {
+ checkbox.selected = !checkbox.selected
+ changed()
+ }
+ }
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ id: rectangle1
+ radius: 10
+ border.color: "#000666";
+ property alias value:text1.text
+ property alias index: list1.currentIndex
+ property alias model: list1.model
+ property bool expanded: false
+ property bool disabled: false
+ property int expandedHeight
+ property int basicHeight
+ property string startValue
+ height: basicHeight
+
+ function show(Boolean){
+ expanded = Boolean
+ }
+
+ function setStartValue(val, idx){
+ startValue = val
+ list1.currentIndex = idx
+ }
+
+ signal valueSelected(string selected);
+
+ Text {
+ id: text1
+ width: rectangle1.width-15
+ height: rectangle1.height*0.6;
+ text: list1.selected
+ anchors.centerIn: parent
+ font.pixelSize: rectangle1.height * .5;
+ onTextChanged: { rectangle1.valueSelected(text) }
+ }
+
+ Rectangle {
+ id: shadeDisable
+ width: parent.width;
+ height: parent.height;
+ anchors.centerIn: parent;
+ radius: parent.radius
+ color: "grey";
+ opacity: 0.5
+ }
+
+ Image {
+ id: imageDown
+ z:15;
+ width: 11;
+ height: 0.5 * rectangle1.height;
+ anchors.top: parent.top
+ anchors.right: parent.right
+ anchors.topMargin: 4
+ anchors.rightMargin: 6
+ anchors.bottomMargin: 4
+ source: "qrc:/button/down_enable.png";
+
+ MouseArea{
+ id: imgMouseArea
+ anchors.fill: parent
+ onClicked: {
+ rectangle1.show(!rectangle1.expanded)
+ }
+ }
+ }
+
+ MouseArea{
+ id: topMouseArea
+ z: 5
+ anchors.fill: parent
+ onClicked: {
+ rectangle1.show(!rectangle1.expanded)
+ }
+ }
+
+ ElementsListView{
+ id: list1
+ width: parent.width
+ visible: false
+ z: 0
+ property string selected: rectangle1.startValue
+
+ function selectedValue(nr, value) {
+ currentIndex = nr
+ selected = value
+ rectangle1.show(false)
+ }
+
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ highlightResizeSpeed: 1000
+
+ delegate: Component{
+ id: list1Delegate
+ Item {
+ width: rectangle1.width
+ height: contentText.height
+
+ MouseArea{
+ id: listMouseArea
+ anchors.fill: parent
+ z: 1
+ onClicked: {
+ list1.selectedValue(number, content)
+ }
+ hoverEnabled: true
+ onEntered: {
+ list1.currentIndex = number
+ }
+ }
+
+ Row{
+ anchors.fill: parent
+
+ Text{
+ id: contentText
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.leftMargin: 5
+ text: content
+ }
+ }
+ }
+ }
+
+ }
+
+ states: [
+ State {
+ name: "basic";
+ when: (rectangle1.expanded == false && rectangle1.disabled == false)
+ PropertyChanges { target: list1; z: 0; visible: false }
+ PropertyChanges { target: text1; z: 0; visible: true }
+ PropertyChanges { target: rectangle1; border.width: 1}
+ PropertyChanges { target: rectangle1; height: rectangle1.basicHeight}
+ PropertyChanges { target: imageDown; height: 0.5 * rectangle1.basicHeight}
+ PropertyChanges { target: shadeDisable; visible: false; z:-1}
+ },
+ State {
+ name: "expanded"
+ when: (rectangle1.expanded == true && rectangle1.disabled == false)
+ PropertyChanges { target: list1; z: 10; visible: true }
+ PropertyChanges { target: text1; z: 10; visible: false }
+ PropertyChanges { target: rectangle1; border.width: 0}
+ PropertyChanges { target: rectangle1; height: rectangle1.expandedHeight}
+ PropertyChanges { target: imageDown; height: 0.5 * rectangle1.basicHeight}
+ PropertyChanges { target: shadeDisable; visible: false; z: -1}
+ },
+ State {
+ name: "disabled";
+ when: rectangle1.disabled == true
+ PropertyChanges { target: list1; z: 0; visible: false }
+ PropertyChanges { target: text1; z: 0; visible: true }
+ PropertyChanges { target: rectangle1; border.width: 1}
+ PropertyChanges { target: rectangle1; expanded: false}
+ PropertyChanges { target: rectangle1; height: rectangle1.basicHeight}
+ PropertyChanges { target: imageDown; visible: true}
+ PropertyChanges { target: shadeDisable; visible: true; z:10}
+ }
+ ]
+
+}
+
--- /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.
+
+*******************************************************************************/
+/*!
+ author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+import Qt 4.7
+
+Rectangle {
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+
+ function setEnableRemove(Boolean) { removeButton.enabled = Boolean }
+ function setEnableSettings(Boolean) { settingsButton.enabled = Boolean }
+ function changeDictionaryState(nr, state) {
+ dictList.currentIndex = nr
+ dictModel.setModelProperty(dictList.currentIndex, state, "isSelected")
+ rectangle1.setEnableRemove(true)
+ rectangle1.setEnableSettings(true)
+ }
+
+ signal addButtonClicked;
+ signal removeButtonClicked;
+ signal settingsButtonClicked;
+ signal saveButtonClicked;
+ signal itemActivated(int nr);
+
+ id: rectangle1
+ color: myPalette.base
+ anchors.fill: parent
+
+ ElementsListView{
+ id: dictList
+ width: rectangle1.width
+// height: rectangle1.height
+ anchors.top: parent.top
+ anchors.bottom: buttonsBox.top
+ anchors.bottomMargin: buttonsBox.height + buttonsBox.anchors.topMargin
+ highlightResizeSpeed: 1000
+ delegate: Component{
+ id: dictListDelegate
+ Item {
+ width: rectangle1.width
+ height: {
+ if (nameText.height + 4 > logo.height)
+ return nameText.height + 4;
+ else
+ return logo.height;
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {
+ dictList.currentIndex = number
+ rectangle1.setEnableRemove(true)
+ rectangle1.setEnableSettings(true)
+ dictModel.itemSelected(dictList.currentIndex)
+ }
+ onDoubleClicked: {
+ rectangle1.itemActivated(dictList.currentIndex)
+ }
+ }
+ Row {
+ anchors.fill: parent
+ Checkbox{
+ id: check
+ width: nameText.height
+ selected: isSelected
+ onChanged: rectangle1.changeDictionaryState(number, selected)
+ }
+
+
+ Image {
+ id: logo
+ source: iconPath
+ height: {
+ var aspectRatio = sourceSize.height / sourceSize.width
+ return logo.width * aspectRatio
+ }
+ anchors.leftMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ width: nameText.height + 4
+ smooth: true
+ }
+ Text {
+ id: nameText
+ text: name
+ anchors.leftMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+ }
+
+ }
+ model: dictModel
+ }
+
+ //buttons
+
+ Item {
+ id: buttonsBox
+ width: parent.width
+ height: 30
+ anchors.bottom: parent.bottom
+ anchors.top: dictList.bottom
+ anchors.topMargin: 8
+
+ Button {
+ id: addButton
+ width: (parent.width - 4) / 4
+ height: buttonsBox.height
+ anchors.left: buttonsBox.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ textInButton: qsTr("Add")
+ onClicked: addButtonClicked();
+ }
+
+ Button {
+ id: removeButton
+ width: (parent.width - 4) / 4
+ height: buttonsBox.height
+ anchors.left: addButton.right
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ textInButton: qsTr("Remove")
+ enabled: false
+ onClicked: removeButtonClicked();
+ }
+
+ Button {
+ id: settingsButton
+ width: (parent.width - 4) / 4
+ height: buttonsBox.height
+ anchors.left: removeButton.right
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ textInButton: qsTr("Settings")
+ enabled: false
+ onClicked: settingsButtonClicked();
+ }
+
+ Button {
+ id: saveButton
+ width: (parent.width - 4) / 4
+ height: buttonsBox.height
+ anchors.left: settingsButton.right
+ anchors.leftMargin: 4
+ anchors.right: buttonsBox.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ textInButton: qsTr("Save")
+ onClicked: saveButtonClicked()
+ }
+
+ }
+
+}
--- /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.
+
+*******************************************************************************/
+/*!
+ author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+import Qt 4.7
+
+Rectangle {
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ signal selectedRow(int nr)
+
+ id: rectangle1
+ color: myPalette.base
+ anchors.fill: parent
+
+ ElementsListView{
+ id: dictTypeList
+ width: rectangle1.width
+ height: rectangle1.height
+ highlightResizeSpeed: 1000
+ delegate: Component{
+ id: dictTypeListDelegate
+ Item {
+ width: rectangle1.width
+ height: typeText.height
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {
+ dictTypeList.currentIndex = number
+ }
+ onDoubleClicked: {
+ selectedRow(number)
+ }
+ }
+ Row {
+ Text {
+ id: typeText
+ text: type
+ width: rectangle1.width
+ }
+ }
+ }
+
+ }
+ model: dictTypeModel
+ }
+}
--- /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.
+
+*******************************************************************************/
+/*!
+ author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+import Qt 4.7
+
+ListView {
+ anchors.fill: parent
+ focus: true
+ currentIndex: 0
+ highlight: Rectangle { color: "lightsteelblue"; radius: 5; width: parent.parent.width }
+ highlightMoveSpeed: 1000
+}
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+import QtWebKit 1.0
+
+Flickable {
+ id: flickable
+ width: parent.width
+ contentWidth: Math.max(parent.width,webView.width)
+ contentHeight: Math.max(parent.height,webView.height)
+ anchors.top: headerSpace.bottom
+ anchors.bottom: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ pressDelay: 200
+ onWidthChanged : {
+ if (width > webView.width*webView.contentsScale && webView.contentsScale < 1.0)
+ webView.contentsScale = width / webView.width * webView.contentsScale;
+ }
+
+ property alias url: webView.url
+
+ function doZoom(variable) { webView.doZoom(variable,1,1) }
+
+ WebView {
+ id: webView
+ transformOrigin: Item.TopLeft
+ url: flickable.url
+ smooth: false
+ focus: true
+ preferredWidth: flickable.width
+ preferredHeight: flickable.height
+ contentsScale: 1
+ pressGrabTime: 0
+
+ Keys.onRightPressed: {
+ console.log("test");
+ }
+
+ function doZoom(zoom,centerX,centerY)
+ {
+ var tempX = flickable.width/2 - parent.x*zoom;
+ var tempY = flickable.height/2 - parent.y*zoom;
+ if (centerX) {
+ var sc = zoom*contentsScale;
+ scaleAnim.to = sc;
+ flickVX.from = flickable.contentX
+ flickVX.to = Math.max(0,Math.min(tempX-flickable.width/2,webView.width*sc-flickable.width))
+ finalX.value = flickVX.to
+ flickVY.from = flickable.contentY
+ flickVY.to = Math.max(0,Math.min(tempY-flickable.height/2,webView.height*sc-flickable.height))
+ finalY.value = flickVY.to
+ quickZoom.start()
+ }
+ }
+
+ onContentsSizeChanged: {
+ contentsScale = Math.min(1,flickable.width / contentsSize.width)
+ }
+
+ onDoubleClick: {
+ if (!heuristicZoom(clickX,clickY,2.5)) {
+ var zf = flickable.width / contentsSize.width
+ if (zf >= contentsScale)
+ zf = 2.0/zoomFactor // zoom in (else zooming out)
+ doZoom(zf,clickX*zf,clickY*zf)
+ }
+ }
+
+ SequentialAnimation {
+ id: quickZoom
+
+ PropertyAction {
+ target: webView
+ property: "renderingEnabled"
+ value: false
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ id: scaleAnim
+ target: webView
+ property: "contentsScale"
+ easing.type: Easing.Linear
+ duration: 200
+ }
+ NumberAnimation {
+ id: flickVX
+ target: flickable
+ property: "contentX"
+ easing.type: Easing.Linear
+ duration: 200
+ from: 0
+ to: 0
+ }
+ NumberAnimation {
+ id: flickVY
+ target: flickable
+ property: "contentY"
+ easing.type: Easing.Linear
+ duration: 200
+ from: 0
+ to: 0
+ }
+ }
+ PropertyAction {
+ id: finalX
+ target: flickable
+ property: "contentX"
+ value: 0
+ }
+ PropertyAction {
+ id: finalY
+ target: flickable
+ property: "contentY"
+ value: 0
+ }
+ PropertyAction {
+ target: webView
+ property: "renderingEnabled"
+ value: true
+ }
+ }
+ onZoomTo: doZoom(zoom,centerX,centerY)
+ }
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle{
+ property bool newPlugin:false;
+
+ function setInfo(string){
+ infoLabel.text = string;
+ }
+ function setStartValues(startFrom, startTo, startFromIndex, startToIndex){
+ comboFrom.setStartValue(startFrom, startFromIndex)
+ comboTo.setStartValue(startTo, startToIndex)
+ }
+ function revertLang(){
+ var tmpidx = comboFrom.index
+ comboFrom.index = comboTo.index
+ comboTo.index = tmpidx
+
+ var tmpval = comboFrom.value
+ comboFrom.value = comboTo.value
+ comboTo.value = tmpval
+ }
+
+ function setNew(bool){
+ newPlugin=bool;
+ }
+
+ signal saveButtonClicked(string langFrom, string langTo);
+
+ height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
+ width: 200
+
+ id:rectangle1
+
+
+
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+
+ Text {
+ id: infoLabel
+ height: paintedHeight+5;
+ anchors.right: parent.right
+ anchors.left: parent.left
+ anchors.top: parent.top
+ wrapMode: Text.Wrap;
+ transformOrigin: Item.Left
+ font.pixelSize: 12
+ z: 15
+ }
+
+ Text {
+ id: fromLabel
+ text: qsTr("From: ")
+ height: paintedHeight+5;
+ anchors.top: infoLabel.bottom
+ anchors.left: parent.left
+ wrapMode: Text.Wrap;
+ transformOrigin: Item.Left
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: toLabel
+ text: qsTr("To: ")
+ height: paintedHeight+5;
+ anchors.top: fromLabel.bottom
+ anchors.left: parent.left
+ wrapMode: Text.Wrap;
+ transformOrigin: Item.Left
+ font.pixelSize: 12
+ }
+
+ ComboBox{
+ id: comboFrom
+ model: comboBoxModel
+ anchors.left: parent.left
+ anchors.leftMargin: {
+ if (fromLabel.width < 30 && toLabel.width < 30){
+ return 30
+ }
+ else if (fromLabel.width > toLabel.width){
+ return fromLabel.width + 10
+ }
+ else {
+ return toLabel.width + 10
+ }
+ }
+
+ anchors.top: infoLabel.bottom
+ anchors.right: revertButton.left
+ anchors.rightMargin: 10
+ expanded: false
+ basicHeight: fromLabel.height
+ expandedHeight: parent.height - comboFrom.x - saveButton.height -20
+ }
+
+ ComboBox{
+ id: comboTo
+ model: comboBoxModel
+ anchors.left: parent.left
+ anchors.leftMargin: {
+ if (fromLabel.width < 30 && toLabel.width < 30){
+ return 30
+ }
+ else if (fromLabel.width > toLabel.width){
+ return fromLabel.width + 10
+ }
+ else {
+ return toLabel.width + 10
+ }
+ }
+
+ anchors.right: revertButton.left
+ anchors.rightMargin: 10
+ anchors.top: comboFrom.bottom
+ expanded: false
+ basicHeight: fromLabel.height
+ expandedHeight: parent.height - comboTo.x - saveButton.height - 20 - fromLabel.height
+ }
+
+ IconButton{
+ id: revertButton
+ width: height
+ height: fromLabel.height
+ anchors.top: fromLabel.top
+ anchors.topMargin: fromLabel.height /2
+ anchors.right: parent.right
+ pathToIcon: "qrc:/button/revert.png"
+ onClicked: { rectangle1.revertLang() }
+ }
+
+ Button {
+ id: saveButton
+ height: 30
+ z: 1
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ anchors.left: parent.left
+ onClicked: {
+ rectangle1.saveButtonClicked(comboFrom.value, comboTo.value);
+ }
+ }
+
+ states: [
+ State {
+ name: "new"
+ when: newPlugin==true
+ PropertyChanges { target: saveButton; textInButton: qsTr("Add") }
+ },
+ State {
+ name: "edit"
+ when: newPlugin==false
+ PropertyChanges { target: saveButton; textInButton: qsTr("Save settings") }
+ }
+ ]
+}
+
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+ signal selectedRow(int nr)
+
+ id: rectangle1
+ width: 100
+ height: 300
+
+
+ Rectangle {
+ id: rectangle2
+ color: "#ffffff"
+ anchors.topMargin: 20
+ anchors.fill: parent
+ }
+
+ ElementsListView{
+
+ id: historyList
+ width: rectangle1.width
+ anchors.topMargin: 20
+ anchors.bottom: parent.bottom
+ anchors.top: parent.top
+ highlightResizeSpeed: 1000
+ delegate: Component{
+ id: historyListDelegate
+ Item {
+ width: rectangle1.width
+ height: typeText.height
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {
+ historyList.currentIndex = number
+ }
+ onDoubleClicked: {
+ selectedRow(number)
+ }
+ }
+ Row {
+ Text {
+ id: typeText
+ text: (number+1) +". "+word
+ width: rectangle1.width
+ }
+ }
+ }
+ }
+ model: historyTypeModel
+ }
+
+ Text {
+ id: text1
+ x: 29
+ y: 0
+ width: 80
+ height: 20
+ text: qsTr("History");
+ anchors.horizontalCenterOffset: 19
+ anchors.topMargin: 0
+ anchors.top: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 12
+ }
+
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ id: rectangle
+
+ property alias pathToIcon: image.source;
+ property int iconWidth:rectangle.width;
+ property int iconHeight:rectangle.height;
+
+ signal clicked;
+ radius: 50
+
+ MouseArea {
+ id: mouseArea
+ anchors.centerIn: parent;
+ width: rectangle.width
+ height: rectangle.height;
+ onClicked: {
+ rectangle.clicked();
+ }
+ }
+
+ Image {
+ id: image
+ z:4;
+ smooth: true
+ anchors.centerIn: parent
+ width: iconWidth;
+ height: iconHeight;
+ }
+
+ Image {
+ id: image1
+ z: 1
+ smooth: true
+ width: (35*parent.height)/107 +1
+ height: parent.height
+ anchors.left: parent.left
+ source: "qrc:/button/buttonLeft.png"
+ }
+
+ Image {
+ id: image3
+ z: 1
+ smooth: true
+ height: parent.height
+ anchors.right: image2.left
+ anchors.rightMargin: -1
+ anchors.left: image1.right
+ anchors.leftMargin: -1
+ source: "qrc:/button/buttonCenter.png"
+
+ }
+
+
+ Image {
+ id: image2
+ z: 1
+ smooth: true
+ width: (35*parent.height)/107 +1
+ height: parent.height
+ anchors.right: parent.right
+ source: "qrc:/button/buttonR.png"
+ }
+
+
+ states: [
+ State {
+ name: "disable";
+ when: (rectangle.enabled == false);
+ PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" }
+ PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" }
+ PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" }
+ },
+ State {
+ name: "clicked";
+ when: (mouseArea.pressed == true && rectangle.enabled == true);
+ PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
+ PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
+ PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" }
+ }
+ ]
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ id: rectangle1
+ radius: 10
+ border.color: "#000666";
+ property int maxValue:500;
+ property int minValue:0;
+ property alias value:text_input1.text
+
+ signal valueChange(int intiger);
+
+ function stringToInt(string){
+ var value=0;
+ var pow10=1;
+ for (var i=string.length-1;i>=0;i--){
+ value+=(string.charCodeAt(i)-48)*pow10;
+ pow10= pow10*10;
+ }
+ if(value>maxValue)
+ return maxValue;
+ if(value<minValue)
+ return minValue;
+ return value;
+ }
+
+ TextInput {
+ id: text_input1
+ x: 1
+ width: rectangle1.width-15
+ height: rectangle1.height*0.6;
+ text: "123"
+ anchors.centerIn: parent
+ validator: IntValidator{bottom: minValue; top: maxValue;}
+ transformOrigin: Item.Left
+ selectByMouse: true;
+ font.pixelSize: rectangle1.height * .5;
+ onCursorPositionChanged: moveCursorSelection(cursorPosition);
+ onTextChanged: rectangle1.valueChange(stringToInt(text_input1.text));
+ onFocusChanged: {
+ if(focus==false)
+ text=stringToInt(text);
+ }
+ }
+
+ Timer {
+ id:timerUp;
+ interval: 100;
+ running: false;
+ repeat: true
+ onTriggered:{
+ if(mouseAreaUp.pressedButtons==Qt.LeftButton)
+ text_input1.text=((stringToInt(text_input1.text)+1)>maxValue)?(maxValue):(stringToInt(text_input1.text)+1);
+ else
+ running=false;
+ }
+ }
+
+ Timer {
+ id:timerDown;
+ interval: 100;
+ running: false;
+ repeat: true
+ onTriggered:{
+ if(mouseAreaDown.pressedButtons==Qt.LeftButton)
+ text_input1.text=((stringToInt(text_input1.text)-1)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+ else
+ running=false;
+ }
+ }
+
+ Rectangle {
+ id: shadeDisable
+ width: parent.width;
+ height: parent.height;
+ anchors.centerIn: parent;
+ radius: parent.radius
+ color: "grey";
+ opacity: 0
+ }
+
+ Image {
+ id: imageUp
+ z:4;
+ width: 11;
+ height: 6;
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.rightMargin: 2
+ anchors.topMargin: 2
+ source: "qrc:/button/up_enable.png";
+ }
+
+ Image {
+ id: imageDown
+ z:4;
+ width: 11;
+ height: 6;
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.rightMargin: 2
+ anchors.bottomMargin: 2
+ source: "qrc:/button/down_enable.png";
+ }
+
+ MouseArea {
+ id: mouseAreaUp
+ z:5
+ width: 13;
+ height: rectangle1.height/2;
+ anchors.right: parent.right
+ anchors.top: parent.top
+ onClicked: text_input1.text=((stringToInt(text_input1.text)+1)>maxValue)?(maxValue):(stringToInt(text_input1.text)+1);
+ onPressAndHold:{
+ timerUp.restart;
+ timerUp.running=true;
+ }
+ }
+
+ MouseArea {
+ id: mouseAreaDown
+ z:5
+ width: 13;
+ height: rectangle1.height/2;
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ onClicked: text_input1.text=((stringToInt(text_input1.text)-1)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+ onPressAndHold:{
+ timerDown.restart;
+ timerDown.running=true;
+ }
+ }
+
+ /* states: [
+ State {
+ name: "DisableState"; when: rectangle1.enabled==false;
+ PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 }
+ }
+ ]
+ */
+}
+
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ id: rectangle1
+ radius: 10
+ border.color: "#000666";
+ property alias textInLineEdit:text_input1.text
+
+ signal enterPressed(string text);
+
+ function setText(string) { textInLineEdit = string; }
+
+ TextInput {
+ id: text_input1
+ width: rectangle1.width-20
+ height: rectangle1.height*0.6;
+ text: "textInput"
+ transformOrigin: Item.Left
+ anchors.centerIn: parent
+ selectByMouse: true;
+ font.pixelSize: rectangle1.height * .5;
+ onCursorPositionChanged: moveCursorSelection(cursorPosition);
+ focus: rectangle1.focus;
+ Keys.onPressed: {
+ if ((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
+ rectangle1.enterPressed(text_input1.text)
+ }
+ }
+
+ Rectangle {
+ id: shadeDisable
+ anchors.centerIn: parent;
+ radius: parent.radius
+ color: "grey";
+ opacity: 0
+ width: parent.width;
+ height: parent.height;
+ }
+
+ states: [
+ State {
+ name: "FokusState"; when: text_input1.focus==true && rectangle1.enabled==true;
+ PropertyChanges {
+ target: rectangle1
+ border.width: 3
+ }
+ },
+ State {
+ name: "DisableState"; when: rectangle1.enabled==false;
+ PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 }
+ }
+ ]
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ id: progressBar
+
+ property int minimum: 0
+ property int maximum: 100
+ property int value: -1
+ property int value2: 50
+
+ function setMax(intiger) { maximum=intiger }
+ function setMin(intiger) { minimum=intiger }
+ function setValue(intiger) {
+ value= intiger;
+ if(intiger>-1){
+ highlight.anchors.leftMargin=0;
+ highlight.anchors.position=0;
+ }
+ }
+ function setValue2(intiger) { value2= intiger }
+
+ width: 250;
+ height: 23
+ clip: true
+
+ BorderImage {
+ source: "qrc:/progressBar/background.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ }
+
+
+ Rectangle {
+ id: highlight
+ z: 1;
+
+ property int widthDest: (progressBar.width * (value - minimum)) / (maximum - minimum) - 6
+ property int position: (progressBar.width * (value2 - minimum)) / (maximum - minimum)
+
+ width: (value>-1) ? (highlight.widthDest) : (90)
+ anchors.leftMargin: (value>-1) ? (0) : (highlight.position)
+
+ Behavior on width {
+ SmoothedAnimation {
+ velocity: 1200
+ }
+ }
+
+ Behavior on position {
+ SequentialAnimation{
+ loops: (value>-1)?0:Animation.Infinite
+ SmoothedAnimation { velocity:450 ; to: progressBar.width - 96}
+ SmoothedAnimation { velocity: 450 ; to: 6 }
+ }
+ }
+
+ radius: 1
+ anchors.top: parent.top
+ anchors.left: parent.left
+
+ anchors.bottom: parent.bottom
+ anchors.margins: 3
+
+ gradient: Gradient {
+ GradientStop {color:"#0510a0"; position: 0.0 }
+ GradientStop {color:"#6b98f7"; position: 1.0 }
+ }
+ }
+
+ Text {
+ z: 1;
+ anchors.right: highlight.right
+ anchors.rightMargin: (value>-1) ? 6 : 35;
+ anchors.verticalCenter: parent.verticalCenter
+ color: "white"
+ font.bold: true
+ text: (value>-1) ? (Math.floor((value - minimum) / (maximum - minimum) * 100) + '%') : ("");
+ }
+}
--- /dev/null
+import Qt 4.7
+
+Item {
+ id: container
+
+ property variant scrollArea
+ property variant orientation: Qt.Vertical
+
+ opacity: 0
+
+ function position()
+ {
+ var ny = 0;
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+ if (ny > 2)
+ return ny;
+ else
+ return 2;
+ }
+
+ function size()
+ {
+ var nh, ny;
+
+ if (container.orientation == Qt.Vertical)
+ nh = scrollArea.visibleArea.heightRatio * container.height;
+ else
+ nh = scrollArea.visibleArea.widthRatio * container.width;
+
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+
+ if (ny > 3) {
+ var t;
+ if (container.orientation == Qt.Vertical)
+ t = Math.ceil(container.height - 3 - ny);
+ else
+ t = Math.ceil(container.width - 3 - ny);
+ if (nh > t) return t; else return nh;
+ } else
+ return nh + ny;
+ }
+
+ //Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.5 }
+
+ /* BorderImage {
+ source: "pics/scrollbar.png"
+ border { left: 1; right: 1; top: 1; bottom: 1 }
+ x: container.orientation == Qt.Vertical ? 2 : position()
+ width: container.orientation == Qt.Vertical ? container.width - 4 : size()
+ y: container.orientation == Qt.Vertical ? position() : 2
+ height: container.orientation == Qt.Vertical ? size() : container.height - 4
+ } */
+
+ states: State {
+ name: "visible"
+ when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally
+ PropertyChanges { target: container; opacity: 1.0 }
+ }
+
+ transitions: Transition {
+ from: "visible"; to: ""
+ NumberAnimation { properties: "opacity"; duration: 600 }
+ }
+}
--- /dev/null
+import Qt 4.7
+
+Item {
+ id: scrollBar
+
+ // The properties that define the scrollbar's state.
+ // position and pageSize are in the range 0.0 - 1.0. They are relative to the
+ // height of the page, i.e. a pageSize of 0.5 means that you can see 50%
+ // of the height of the view.
+ // orientation can be either Qt.Vertical or Qt.Horizontal
+ property variant orientation : Qt.Vertical
+ property int windowHeight :100
+ property alias position: slider.x
+
+ signal changeCursor
+
+ // Size the bar to the required size, depending upon the orientation.
+ Rectangle {
+ id: slider;
+ width: 1;
+ height: windowHeight;
+ radius: height/2 - 1
+ color: "black"
+ opacity: 0.7
+ }
+
+ MouseArea {
+ property variant lastPresX;
+ anchors.rightMargin: 5
+ anchors.leftMargin: 5
+ id: mouse_area1
+ anchors.fill: slider
+ onEntered: {
+
+ }
+
+ onMousePositionChanged:{
+ var num=0;
+ if(Qt.LeftButton) {
+ num= slider.x+(mouseX-lastPresX);
+
+ if(num>(scrollBar.width-slider.width))
+ slider.x=scrollBar.width-slider.width
+ else if(num<0)
+ slider.x=0;
+ else
+ slider.x=num ;
+ }
+ }
+ onPressed: lastPresX=mouseX;
+ }
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ id: searchBarWidget
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+ property alias enableLineEdit: inputSearchText.enabled;
+
+ function setButtonText(string) { searchButton.setText(string) }
+ function setEnableHistoryPrev(Boolean) { historyPrevToolButton.enabled = Boolean }
+ function setEnableHistoryNext(Boolean) { historyNextToolButton.enabled = Boolean }
+ function setEnableHistoryShow(Boolean) { historyShowToolButton.enabled = Boolean }
+ function setEnableLineEdit(Boolean) { enableLineEdit = Boolean }
+ function setLineEditText(string) { inputSearchText.setText(string) }
+ function clear() { inputSearchText.setText("") }
+
+ signal searchButtonClicked(string text);
+ signal historyNextToolButtonClicked;
+ signal historyShowToolButtonClicked;
+ signal historyPrevToolButtonClicked;
+
+ MyTextLineEdit{
+ id: inputSearchText
+ width: (searchBarWidget.width - (searchBarWidget.height*3.5 + searchButton.width + 9));
+ height: searchBarWidget.height -1;
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ onEnterPressed: searchBarWidget.searchButtonClicked(text);
+ focus: searchBarWidget.focus
+ IconButton {
+ id: clearButton;
+ width: inputSearchText.height-6;
+ height: inputSearchText.height-6;
+ anchors.rightMargin: 4
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ enabled: true;
+ pathToIcon: "qrc:/button/go-clear.png";
+ onClicked: clear();
+ }
+ }
+
+ Item {
+ id: buttonsBox
+ width: searchBarWidget.height*3.5 + searchButton.width + 9
+ height: searchBarWidget.height
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+
+ Button {
+ id: searchButton
+ width: 100
+ height: searchBarWidget.height;
+ anchors.rightMargin: 3
+ anchors.right: historyPrevToolButton.left
+ anchors.verticalCenter: parent.verticalCenter
+ textInButton: qsTr("Search")
+ onClicked: searchBarWidget.searchButtonClicked(inputSearchText.textInLineEdit);
+ }
+
+ IconButton {
+ id: historyNextToolButton;
+ width: searchBarWidget.height
+ height: searchBarWidget.height
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ enabled: true;
+ pathToIcon: "qrc:/button/go-next.png";
+ onClicked: searchBarWidget.historyNextToolButtonClicked();
+ }
+
+ IconButton {
+ id: historyShowToolButton;
+ width: searchBarWidget.height
+ height: searchBarWidget.height
+ anchors.rightMargin: 3
+ anchors.right: historyNextToolButton.left
+ anchors.verticalCenter: parent.verticalCenter
+ enabled: true;
+ pathToIcon: "qrc:/button/go-show.png";
+ onClicked: searchBarWidget.historyShowToolButtonClicked();
+ }
+
+ IconButton {
+ id: historyPrevToolButton;
+ width: searchBarWidget.height
+ height: searchBarWidget.height
+ anchors.rightMargin: 3
+ anchors.right: historyShowToolButton.left
+ anchors.verticalCenter: parent.verticalCenter
+ enabled: true;
+ pathToIcon: "qrc:/button/go-previous.png";
+ onClicked: searchBarWidget.historyPrevToolButtonClicked();
+ }
+ }
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ id: rectangle1
+ width: 230
+ height:170
+
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+ signal historySizeValueChanged(int intiger);
+ signal searchResulValueChanged(int intiger);
+ signal dictionariesCheckBoxChanged(bool Boolean);
+ signal bookmarksCheckBoxChanged(bool Boolean);
+ signal saveButtonClicked();
+
+ function setMinHistory(intiger){
+ historySpinbox.minValue=intiger;
+ }
+ function setMaxHistory(intiger){
+ historySpinbox.maxValue=intiger;
+ }
+ function setValueHistory(intiger){
+ historySpinbox.value=intiger;
+ }
+
+ function setMaxSearchResult(intiger){
+ searchSpinbox.maxValue=intiger;
+ }
+ function setMinSearchResult(intiger){
+ searchSpinbox.minValue=intiger;
+ }
+ function setValueSearchResult(intiger){
+ searchSpinbox.value=intiger;
+ }
+
+ function setCheckedBookmarks(bool){
+ bookmarkCheckBox.selected=bool;
+ }
+ function setCheckedDictionaries(bool){
+ dictionariesCheckBox.selected=bool;
+ }
+
+ Text {
+ id: textSearch
+ width: 120
+ height: paintedHeight+5;
+ text: qsTr("Search result size")
+ anchors.verticalCenterOffset: 2
+ anchors.left: parent.left
+ anchors.verticalCenter: searchSpinbox.verticalCenter
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textHistory
+ width: 120
+ height: paintedHeight+5;
+ text: qsTr("History size")
+ anchors.verticalCenterOffset: 2
+ anchors.left: parent.left
+ anchors.verticalCenter: historySpinbox.verticalCenter
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textSearchIn
+ width: 120
+ height: paintedHeight+5;
+ text: qsTr("Search in:")
+ anchors.top: textHistory.bottom
+ anchors.topMargin: 15
+ anchors.left: parent.left
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textBookmark
+ width: 120
+ height: 20
+ text: qsTr("Bookmarks")
+ anchors.verticalCenterOffset: 2
+ anchors.left: bookmarkCheckBox.right
+ anchors.leftMargin: 10
+ anchors.verticalCenter: bookmarkCheckBox.verticalCenter
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textDictionaries
+ width: 120
+ height: 20
+ text: qsTr("Dictionaries")
+ anchors.verticalCenterOffset: 2
+ anchors.left: dictionariesCheckBox.right
+ anchors.leftMargin: 10
+ anchors.verticalCenter: dictionariesCheckBox.verticalCenter
+ font.pixelSize: 12
+ }
+
+ MySpinBox {
+ id: searchSpinbox
+ width: 40
+ height: 20;
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.left: textSearch.right
+ anchors.leftMargin: 20
+ onValueChange: rectangle1.searchResulValueChanged(intiger);
+ }
+
+ MySpinBox {
+ id: historySpinbox
+ width: 40
+ height: 20;
+ anchors.horizontalCenter: searchSpinbox.horizontalCenter
+ anchors.top: searchSpinbox.bottom
+ anchors.topMargin: 10
+ onValueChange: rectangle1.historySizeValueChanged(intiger);
+ }
+
+ Checkbox {
+ id: bookmarkCheckBox
+ width: 20
+ height: 20
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ anchors.top: textSearchIn.bottom
+ anchors.topMargin: 0
+ onChanged: rectangle1.bookmarksCheckBoxChanged(selected);
+ }
+
+ Checkbox {
+ id: dictionariesCheckBox
+ width: 20
+ height: 20
+ anchors.horizontalCenter: bookmarkCheckBox.horizontalCenter
+ anchors.top: bookmarkCheckBox.bottom
+ anchors.topMargin: 3
+ onChanged: rectangle1.dictionariesCheckBoxChanged(selected);
+ }
+
+ Button {
+ id: saveButton
+ width: 66
+ height:26
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 5
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ textInButton: qsTr("Save")
+ onClicked: rectangle1.saveButtonClicked();
+ }
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle{
+ property bool newPlugin:false;
+
+ function setInfo(string){
+ textInfo.text = string;
+ }
+ function setPath(string){
+ textPath.text = string;
+ }
+ function setButtonText(string){
+ saveButton.textInButton=string;
+ }
+ function setNew(bool){
+ newPlugin=bool;
+ }
+
+ signal saveButtonClicked();
+ signal browseButtonClicked();
+ signal heightChange(int intiger);
+
+ id:rectangle1
+ width: 220
+ height: newPlugin ? textPath.height+50 : textInfo.height+50
+
+ onHeightChanged:{
+ heightChange((newPlugin ? textPath.height+50 : textInfo.height+50));
+ //console.log( "debug" + (newPlugin ? textPath.paintedHeight+55 : textInfo.paintedHeight+55));
+ }
+
+
+
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+
+ Text {
+ id: textInfo
+ text: "Tekst: "
+ height: paintedHeight+5;
+ anchors.right: parent.right
+ anchors.left: parent.left
+ anchors.top: parent.top
+ wrapMode: Text.Wrap;
+ transformOrigin: Item.Left
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textPath
+ text: qsTr("Dictionary file: not selected")
+ height: paintedHeight+5;
+ anchors.top: parent.top
+ anchors.right: browseButton.left
+ anchors.left: parent.left
+ wrapMode: Text.Wrap;
+ transformOrigin: Item.Left
+ font.pixelSize: 12
+ opacity: 0
+ }
+
+ Button {
+ id: browseButton
+ width: 80;
+ height: 25;
+ textInButton: qsTr("Browse");
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.right: parent.right
+ opacity: 0
+ onClicked: rectangle1.browseButtonClicked();
+ }
+
+ Button {
+ id: saveButton
+ height: 30
+ anchors.bottom: parent.bottom
+ textInButton: qsTr("Save")
+ anchors.right: parent.right
+ anchors.left: parent.left
+ onClicked: rectangle1.saveButtonClicked();
+ }
+
+ states: [
+ State {
+ name: "new"
+ when: newPlugin==true
+ PropertyChanges { target: textInfo; opacity: 0}
+ PropertyChanges { target: textPath; opacity: 1}
+ PropertyChanges { target: browseButton; opacity: 1 }
+ }
+ ]
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+ id: rectangle1
+ width: 400;
+ height: 400;
+ anchors.fill: parent
+
+ signal dictLink(string link);
+
+ ScrollBar2 {
+ id: horizontalScrollBar1
+ z:2;
+ width: parent.width-12;
+ windowHeight: parent.height
+ anchors.left: parent.left
+ orientation: Qt.Horizontal
+ position: 100
+ }
+ ScrollBar2 {
+ id: horizontalScrollBar2
+ z:2;
+ width: parent.width-12;
+ windowHeight: parent.height
+ anchors.left: horizontalScrollBar1.left
+ anchors.leftMargin: horizontalScrollBar1.position
+ orientation: Qt.Horizontal
+ position: 100
+ }
+ ScrollBar2 {
+ id: horizontalScrollBar3
+ z:2;
+ width: parent.width-12;
+ windowHeight: parent.height
+ anchors.left: horizontalScrollBar2.left
+ anchors.leftMargin: horizontalScrollBar2.position
+ orientation: Qt.Horizontal
+ position: 100
+ }
+
+ ElementsListView{
+ id: dictList
+ width: rectangle1.width
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ highlightResizeSpeed: 1000
+
+ header: Component{
+ id: dictListHeader
+ Item {
+ width: rectangle1.width
+ height: 20
+ Row {
+ anchors.fill: parent
+ Rectangle {
+ id: fromRecHeader
+ width: horizontalScrollBar1.position
+ height: parent.height
+ radius: 1
+ gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+
+ Text {
+ id: fromTextHeader
+ text: qsTr("From");
+ elide: Text.ElideRight
+ font.pixelSize: 12
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: toRecHeader
+ width: horizontalScrollBar2.position
+ height: parent.height
+ radius: 1
+ gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+
+ Text {
+ id: toTextHeader
+ text: qsTr("To");
+ elide: Text.ElideRight
+ font.pixelSize: 12
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: nameRecHeader
+ width: horizontalScrollBar3.position
+ height: parent.height
+ radius: 1
+ gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+
+ Text {
+ id: nameTextHeader
+ text: qsTr("Title");
+ elide: Text.ElideRight
+ font.pixelSize: 12
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: sizeRecHeader
+ width: 100;
+ height: parent.height
+ radius: 1
+ gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+
+ Text {
+ id: sizeTextHeader
+ text: qsTr("Size");
+ elide: Text.ElideRight
+ font.pixelSize: 12
+ anchors.centerIn: parent
+ }
+ }
+ }
+ }
+ }
+
+ delegate: Component{
+ id: dictListDelegate
+ Item {
+ width: rectangle1.width
+ height:nameText.height
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {
+ dictList.currentIndex = index
+ }
+ onDoubleClicked: {
+ rectangle1.dictLink(link)
+ }
+ }
+ Row {
+ anchors.fill: parent
+ Text {
+ id: fromText
+ text: " "+from+" ";
+ width: horizontalScrollBar1.position
+ elide: Text.ElideRight
+ }
+
+ Text {
+ id: toText
+ text: " "+to+" ";
+ width: horizontalScrollBar2.position
+ elide: Text.ElideRight
+ }
+
+ Text {
+ id: nameText
+ text: " "+name+" ";
+ width: horizontalScrollBar3.position
+ elide: Text.ElideRight
+ }
+ Text {
+ id: sizeText
+ text: " "+size+" ";
+ width: 100
+ elide: Text.ElideRight
+ }
+ }
+ }
+ }
+ model: dictModel
+ }
+}
--- /dev/null
+import Qt 4.7
+import QtWebKit 1.0
+
+Rectangle {
+ id: webBrowser
+ width: 500
+ height: 500
+
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color: myPalette.window
+
+ function setUrl(string){
+ webView.url = "file:///home/jakub/test.html";
+ webView.url = string;
+ }
+
+ FlickableWebView {
+ id: webView
+ width:parent.width
+ height:parent.height
+ anchors { top: headerSpace.bottom; left: parent.left; right: parent.right; bottom: parent.bottom }
+ }
+
+ Item { id: headerSpace; width: parent.width; height: 1}
+
+ ScrollBar {
+ scrollArea: webView;
+ width: 8
+ anchors { right: parent.right; top: parent.bottom; bottom: parent.bottom }
+ }
+
+ ScrollBar {
+ scrollArea: webView;
+ height: 8; orientation: Qt.Horizontal
+ anchors { right: parent.right; rightMargin: 8; left: parent.left; bottom: parent.bottom }
+ }
+
+ Button {
+ id: button1
+ textInButton: "+"
+ width: 20;
+ height: 20;
+ anchors.right: parent.right
+ anchors.bottom: button2.top
+ onClicked: webView.doZoom(1.05);
+ }
+
+ Button {
+ id: button2
+ textInButton: "-"
+ width: 20;
+ height: 20;
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ onClicked: webView.doZoom(.95);
+ }
+}
--- /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.
+
+*******************************************************************************/
+/*!
+ author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+import Qt 4.7
+
+Rectangle {
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+
+ id: rectangle1
+ width: (helloText.width > logo.width) ? (helloText.width) : (logo.width)
+ height: logo.height + helloText.height
+ color: myPalette.window
+ anchors.fill: parent
+
+ Image {
+ id: logo
+ source: "qrc:/icons/logo/mdictionary.png"
+ anchors.horizontalCenter: parent.horizontalCenter
+ fillMode: Image.PreserveAspectFit
+ anchors.top: parent.top
+ }
+
+ Text {
+ id: helloText
+ text: qsTr("<center><h1>Welcome in mDictionary!</h1></center>")
+ anchors.bottom: parent.bottom
+ }
+
+}
--- /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.
+
+*******************************************************************************/
+/*!
+ author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+import Qt 4.7
+
+Rectangle {
+
+ function changeWordState(nr, state) {
+ wordList.currentIndex = nr
+ wordModel.setModelProperty(wordList.currentIndex, state, "isBookmarked")
+
+ }
+
+ function setEnabled(Boolean) { wordList.enabled = Boolean } // slot
+
+ signal wordSelected(string word);
+
+
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+
+ id: rectangle1
+ color: myPalette.base
+ anchors.fill: parent
+
+ ElementsListView{
+ id: wordList
+ width: rectangle1.width
+
+ anchors.fill: parent
+ highlightResizeSpeed: 1000
+
+ delegate: Component{
+ id: wordListDelegate
+ Item {
+ width: rectangle1.width
+ height: {
+ if (wordText.height + 4 > check.height)
+ return wordText.height + 4;
+ else
+ return check.height;
+ }
+
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {
+ wordList.currentIndex = number
+ rectangle1.wordSelected(word)
+ }
+ }
+
+
+ Text {
+ id: wordText
+ anchors.verticalCenter: parent.verticalCenter
+ text:
+ {
+ if (word == "!@#$%"){
+ qsTr("Can't find any matching words")
+ } else {
+ word
+ }
+ }
+ }
+
+ Checkbox{
+ id: check
+ width: wordText.height
+ selected: isBookmarked
+ pathToCheckedImage: CheckedPath
+ pathToUncheckedImage: UncheckedPath
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+
+ anchors.verticalCenter: parent.verticalCenter
+ onChanged: rectangle1.changeWordState(number, selected)
+ visible: {
+ if (word == "!@#$%"){
+ false
+ } else {
+ true
+ }
+ }
+ }
+
+ }
+
+ }
+
+ model: wordModel
+ }
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle{
+ id:rectangle1
+ width: 220
+ height: textPlugin.height + textFrom.height + textTo.height + textDescription.height + textInfo.height +90
+
+ property bool newPlugin:false;
+
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+ function setPlugin(string){
+ textPlugin.text = qsTr("Plugin") + ": " + string;
+ }
+ function setFrom(string){
+ textFrom.text = qsTr("From") + ": " + string;
+ }
+ function setTo(string){
+ textTo.text = qsTr("To") + ": " + string;
+ }
+ function setDescription(string){
+ textDescription.text = qsTr("Description") + ": " + string;
+ }
+ function setInfo(string){
+ textInfo.text = string;
+ }
+ function setButtonText(string){
+ saveButton.textInButton=string;
+ }
+ function setCheckedOptimalize(bool){
+ optimalizeCheckbox.selected=bool;
+ }
+ function setCheckedStrip(bool){
+ stripCheckbox.selected=bool;
+ }
+ function setNew(bool){
+ newPlugin=bool;
+ }
+ function setPath(string){
+ textPath.text=string;
+ }
+
+ signal saveButtonClicked();
+ signal downloadButtonClicked();
+ signal browseButtonClicked();
+ signal optimalizeCheckboxChanged(bool Boolean);
+ signal stripCheckboxChanged(bool Boolean);
+
+ Text {
+ id: textPlugin
+ width: rectangle1.width
+ height: paintedHeight+5;
+ text: "Plugin: "
+ wrapMode: Text.Wrap;
+ transformOrigin: Item.Left
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textFrom
+ width:rectangle1.width
+ height: paintedHeight+5;
+ text: "From: "
+ wrapMode: Text.Wrap;
+ anchors.top: textPlugin.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textTo
+ width: rectangle1.width
+ height: paintedHeight+5;
+ text: "To: "
+ wrapMode: Text.Wrap;
+ anchors.top: textFrom.bottom
+ transformOrigin: Item.Left
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textDescription
+ width: rectangle1.width
+ height: paintedHeight+5;
+ text: "Description: "
+ wrapMode: Text.Wrap;
+ anchors.top: textTo.bottom
+ transformOrigin: Item.Left
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textInfo
+ width: rectangle1.width
+ height: paintedHeight+5;
+ text: ": "
+ wrapMode: Text.Wrap;
+ anchors.top: textDescription.bottom
+ transformOrigin: Item.Left
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 12
+ }
+
+ Checkbox {
+ id: optimalizeCheckbox
+ width: 20
+ height: 20
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ anchors.top: textInfo.bottom
+ onChanged: rectangle1.optimalizeCheckboxChanged(selected);
+ }
+
+ Checkbox {
+ id: stripCheckbox
+ width: 20
+ height: 20
+ anchors.top: optimalizeCheckbox.bottom
+ anchors.topMargin: 5
+ anchors.horizontalCenter: optimalizeCheckbox.horizontalCenter
+ onChanged: rectangle1.stripCheckboxChanged(selected);
+ }
+
+ Text {
+ id: textOptimalize
+ width: 80
+ height: 20
+ text: qsTr("Optimize")
+ anchors.left: optimalizeCheckbox.right
+ anchors.leftMargin: 5
+ anchors.verticalCenterOffset: 3
+ anchors.verticalCenter: optimalizeCheckbox.verticalCenter
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: textStrip
+ width: 80
+ height: 20
+ text: qsTr("Strip accents")
+ anchors.verticalCenterOffset: 3
+ anchors.verticalCenter: stripCheckbox.verticalCenter
+ anchors.horizontalCenter: textOptimalize.horizontalCenter
+ font.pixelSize: 12
+ }
+
+ Button {
+ id: saveButton
+ height: 30
+ textInButton: qsTr("Save")
+ anchors.top: stripCheckbox.bottom
+ anchors.topMargin: 10
+ anchors.right: parent.right
+ anchors.left: parent.left
+ onClicked: rectangle1.saveButtonClicked();
+ }
+
+ Text {
+ id: textPath
+ height: paintedHeight+5;
+ text: qsTr("Dictionary file: not selected")
+ wrapMode: Text.Wrap;
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.right: browseButton.left
+ anchors.rightMargin: 0
+ anchors.left: parent.left
+ anchors.leftMargin: 0
+ font.pixelSize: 12
+ opacity: 0
+ }
+
+ Button {
+ id: browseButton
+ width: 80;
+ height: 25;
+ textInButton: qsTr("Browse");
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ opacity: 0
+ onClicked: rectangle1.browseButtonClicked();
+ }
+
+ Button {
+ id: downloadButton
+ width: 80;
+ height: 25;
+ textInButton: qsTr("Download");
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ anchors.top: browseButton.bottom
+ anchors.topMargin: 10
+ opacity: 0
+ onClicked: rectangle1.downloadButtonClicked();
+ }
+
+ states: [
+ State {
+ name: "Stan1"
+ when: newPlugin==true
+ PropertyChanges { target: textPlugin; opacity: 0}
+ PropertyChanges { target: textFrom; opacity: 0}
+ PropertyChanges { target: textTo; opacity: 0}
+ PropertyChanges { target: textDescription; opacity: 0}
+ PropertyChanges { target: textInfo; opacity: 0}
+
+ PropertyChanges { target: textPath; opacity: 1}
+ PropertyChanges { target: browseButton; opacity: 1 }
+ PropertyChanges { target: downloadButton; opacity: 1}
+ }
+ ]
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ id: rectangle1
+ width: 250
+ height: 80
+
+
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+ function setValue(intiger){
+ progressbar1.setValue(intiger);
+ }
+ function setText(string){
+ text.text=string;
+ }
+ function setMaximumValue(intiger){
+ if(intiger==0){
+ timerUp.running=true;
+ setValue(-1);
+ }
+ else{
+ timerUp.running=false;
+ progressbar1.setMax(intiger);
+ }
+ }
+
+ signal cancelDownloading();
+
+ Text {
+ id: text
+ text: qsTr("Downloading dictionaries list");
+ anchors.right: parent.right
+ anchors.left: parent.left
+ font.pixelSize: 12
+ horizontalAlignment: Text.AlignHCenter;
+ }
+
+ ProgressBar {
+ id: progressbar1
+ anchors.top: text.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ value: -1
+ value2: 30
+ }
+
+ Button {
+ id: button1
+ height: 25;
+ textInButton: qsTr("Cancel");
+ anchors.top: progressbar1.bottom
+ anchors.right: parent.right
+ anchors.left: parent.left
+ onClicked: {
+ rectangle1.cancelDownloading();
+ }
+ }
+
+ Timer {
+ property bool progressMax:true;
+ id:timerUp;
+ interval: 50;
+ running: false;
+ repeat: true
+ onTriggered:{
+ if(progressMax==true){
+ progressbar1.setValue2(0);
+ progressMax=false;
+ }
+ else{
+ progressbar1.setValue2(100);
+ progressMax=true;
+ }
+ }
+ }
+}
this->plugin = plugin;
this->type = type;
_settings = 0;
+ _actualLangFrom = 0;
+ _actualLangTo = 0;
if(plugin) {
_langTo=GooglePlugin::languages.key(
_langFrom=GooglePlugin::languages.key("en");
}
- initializeUI();
-
+#ifdef Q_WS_MAEMO_5
connect(confirmButton, SIGNAL(clicked()),
this, SLOT(accept()));
connect(changeLangButton, SIGNAL(clicked()),
this, SLOT(changeLangButtonClicked()));
+#else
+
+ int i=0,j=0;
+ int actualLangTo=0;
+ int actualLangFrom=0;
+
+ QList<QString> langList;
+ foreach(QString langs, GooglePlugin::languages.keys()){
+ if(langs==_langTo)
+ actualLangTo=j;
+ if(langs==_langFrom)
+ actualLangFrom=i;
+ if(langs!="Detect langlage"){
+ langList.append(langs);
+ j++;
+ }
+ i++;
+ }
+
+ _actualLangFrom = actualLangFrom;
+ _actualLangTo = actualLangTo;
+ model = new ComboBoxModel(langList);
+
+ view= new QDeclarativeView();
+ ctxt = view->rootContext();
+ ctxt->setContextProperty("comboBoxModel", &(*model));
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/GoogleDialog.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ //view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+ view->setWindowTitle(tr("Google Settings"));
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(rootObject, SIGNAL(saveButtonClicked(QString, QString)),
+ this, SLOT(saveButtonClicked(QString,QString)));
+
+ connect(this, SIGNAL(setInfo(QVariant)),
+ rootObject, SLOT(setInfo(QVariant)));
+ connect(this,SIGNAL(setNew(QVariant)),
+ rootObject, SLOT(setNew(QVariant)));
+ connect(this,SIGNAL(setStartValues(QVariant,QVariant,QVariant,QVariant)),
+ rootObject, SLOT(setStartValues(QVariant, QVariant, QVariant, QVariant)));
+
+#endif
+
+ initializeUI();
}
void GoogleDialog::initializeUI() {
+#ifndef Q_WS_MAEMO_5
+
+ setWindowTitle(tr("Google Plugin Settings"));
+ if (type != New){
+ emit setNew(false);
+ QString info=tr("Plugin: ") + plugin->type().toUpper() +"\n" +
+ tr("From: ") + _langFrom + "\n" +
+ tr("To: ") + _langTo;
+ emit setInfo(info);
+ }
+ else{
+ emit setNew(true);
+ }
+ emit setStartValues(_langFrom, _langTo, _actualLangFrom, _actualLangTo);
+
+// setMinimumSize(sizeHint());
+
+
+#else
+
int i=0,j=0;
int actualLangTo=0;
int actualLangFrom=0;
setModal(true);
setMinimumSize(sizeHint());
setMaximumSize(sizeHint());
+#endif
}
}
}
-
+#ifdef Q_WS_MAEMO_5
void GoogleDialog::accept() {
saveSettings();
QDialog::accept();
GooglePlugin::languages.value(_langFrom));
}
+#else
+void GoogleDialog::saveButtonClicked(QString langFrom, QString langTo){
+ saveSettings(langFrom, langTo);
+ QDialog::accept();
+}
+
+void GoogleDialog::saveSettings(QString langFrom, QString langTo){
+ _settings = new Settings;
+ _langFrom = langFrom;
+ _langTo = langTo;
+ if(plugin) {
+ foreach(QString key, plugin->settings()->keys())
+ _settings->setValue(key, plugin->settings()->value(key));
+ }
+
+ _settings->setValue("lang_to",
+ GooglePlugin::languages.value(langTo));
+ _settings->setValue("lang_from",
+ GooglePlugin::languages.value(langFrom));
+}
+#endif
Settings* GoogleDialog::getSettings() {
return _settings;
#include <QDialog>
#include "../../include/settings.h"
+#include "../../include/ComboBoxModel.h"
#include <QtGui>
+
+
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+#include <QList>
+
#include "GooglePlugin.h"
/*!
//! requests to show notification
void notify(Notify::NotifyType, QString);
+#ifndef Q_WS_MAEMO_5
+ void setInfo(QVariant info);
+ void setNew(QVariant text);
+ void setStartValues(QVariant from, QVariant to, QVariant fromIndex, QVariant toIndex);
+#endif
+
public Q_SLOTS:
+#ifdef Q_Ws_MAEMO_5
//! reimplemented accept method, to save new settings
void accept();
+#endif
private Q_SLOTS:
//! assigns the language chosen from a list(langFromComboBox) to _langFrom
//! handles the "swap languages" button
void changeLangButtonClicked();
+
+#ifndef Q_Ws_MAEMO_5
+ void saveButtonClicked(QString langFrom, QString langTo);
+#endif
+
private:
+
void initializeUI();
//! saves new settings after acceptance of dialog
+#ifdef Q_Ws_MAEMO_5
void saveSettings();
+#else
+ void saveSettings(QString langFrom, QString langTo);
+
+ ComboBoxModel* model;
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+ QDeclarativeContext* ctxt;
+#endif
+
+ int lastHeight;
QLabel* infoLabel;
QLabel* langFromLabel;
QHBoxLayout* changeLangLayout;
QString _langFrom;
QString _langTo;
+ int _actualLangTo;
+ int _actualLangFrom;
Settings* _settings;
GooglePlugin* plugin;
_settings->setValue("type","google");
_settings->setValue("connection_accepted","true");
_dictDialog = new GoogleDictDialog(this,this);
- _icon = QIcon("/usr/share/mdictionary/google.png");
+ _iconPath = "/usr/share/mdictionary/google.png";
+ _icon = QIcon(_iconPath);
stopped = false;
initLanguages();
return &_icon;
}
+QString GooglePlugin::iconPath(){
+ return _iconPath;
+}
+
CommonDictInterface* GooglePlugin::getNew(const Settings* settings) const {
GooglePlugin *plugin = new GooglePlugin();
}
QString text = QString::fromUtf8(http->readAll());
+// qDebug()<<"google test"<<text;
text=jsonParse(text);
if(text!="") {
text="<key>" + word + "</key>" + "<t>" + text + "</t>";
//! \returns plugin icon
QIcon* icon();
+ //! \returns plugin icon's resource path
+ QString iconPath();
+
//! \returns empty translation object (to be fetched later) for a given key
Translation* getTranslationFor(QString key);
//! icon displayed during translations and when a dictionary is chosen
QIcon _icon;
+ //! Path to icon
+ QString _iconPath;
Settings *_settings;
//! indicates if search is stopped
bool stopped;
QT = core \
gui \
- network
+ network \
+ declarative
maemo5:QT += maemo5
GooglePlugin.cpp \
TranslationGoogle.cpp \
GoogleDictDialog.cpp \
- GoogleDialog.cpp
+ GoogleDialog.cpp \
+ ../../include/ComboBoxModel.cpp
HEADERS += \
GooglePlugin.h \
../../include/translation.h \
../../include/settings.h \
../../include/CommonDictInterface.h \
+ ../../include/ComboBoxModel.h \
TranslationGoogle.h \
GoogleDictDialog.h \
GoogleDialog.h
RESOURCES += \
google.qrc
-
unix {
- INSTALLS += plugin-icon
-
- plugin-icon.path = $$DATA_DIR
- plugin-icon.files += google.png
+ meego {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ../../mdictionary/qml/GoogleDialog.qml
+ }
+ else:maemo5 {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ../../mdictionary/qml/GoogleDialog.qml
+ }
+ else {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ../../mdictionary/qml/GoogleDialog.qml
+ }
+
+ plugin-icon.path = $$DATA_DIR
+ plugin-icon.files += google.png
+
+ INSTALLS += plugin-icon \
+ qmls
}
check.commands = echo 'No check here'
QMAKE_EXTRA_TARGETS += check
+
+OTHER_FILES += \
+ ../../mdictionary/qml/GoogleDialog.qml
}
cha=QString::fromUtf8(c);
- return cha.at(0);
+ if(cha.size()!=0)
+ return cha.at(0);
+ else
+ return '\0';
}
#include <QFile>
StarDialog::StarDialog(StarDictPlugin *plugin, StarDialogType type,
- QWidget *parent) : QDialog(parent) {
+ QWidget *parent) : QDialog(parent) {
this->plugin = plugin;
this->type = type;
- initializeUI();
+
+#ifndef Q_WS_MAEMO_5
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/StarDictDialog.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+ view->setWindowTitle(tr("StarDict Settings"));
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(this, SIGNAL(setInfo(QVariant)),
+ rootObject, SLOT(setInfo(QVariant)));
+ connect(this,SIGNAL(setButtonText(QVariant)),
+ rootObject, SLOT(setButtonText(QVariant)));
+ connect(this,SIGNAL(setNew(QVariant)),
+ rootObject, SLOT(setNew(QVariant)));
+ connect(this,SIGNAL(setPath(QVariant)),
+ rootObject, SLOT(setPath(QVariant)));
+
+ connect(rootObject, SIGNAL(saveButtonClicked()),
+ this, SLOT(accept()));
+ connect(rootObject, SIGNAL(browseButtonClicked()),
+ this, SLOT(selectFile()));
+ connect(rootObject, SIGNAL(heightChange(int)),
+ this, SLOT(heightChange(int)));
+
+#else
if(type == New)
connect(browseButton, SIGNAL(clicked()),this, SLOT(selectFile()));
connect(confirmButton, SIGNAL(clicked()),this, SLOT(accept()));
+#endif
+ initializeUI();
+}
+
+void StarDialog::heightChange(int height){
+ if(height>sizeHint().height())
+ resize(sizeHint().width(),height);
+ lastHeight=height;
}
+void StarDialog::resizeEvent(QResizeEvent *e){
+ QDialog::resizeEvent(e);
+ if(lastHeight>sizeHint().height()){
+ resize(sizeHint().width(),lastHeight);
+ }
+}
void StarDialog::initializeUI() {
+#ifndef Q_WS_MAEMO_5
+ if(type != New){
+ emit setNew(false);
+ QString info=tr("Plugin: ") + plugin->type().toUpper() +"\n" +
+ tr("Book name: ") + plugin->settings()->value("bookname") + "\n" +
+ tr("Version: ") + plugin->settings()->value("version") + "\n" +
+ tr("Word count: ") + plugin->settings()->value("wordcount") + "\n" +
+ tr("Author: ") + plugin->settings()->value("author") + "\n" +
+ tr("E-mail: ") + plugin->settings()->value("email") + "\n" +
+ tr("Website: ") + plugin->settings()->value("website") + "\n" +
+ tr("Description: ") + plugin->settings()->value("description")+"\n"+
+ tr("Date: ") + plugin->settings()->value("date");
+ emit setInfo(info);
+ emit setButtonText("Save settings");
+ }
+ else{
+ emit setNew(true);
+ emit setButtonText("Add");
+ }
+
+ if(!plugin)
+ _dictionaryFilePath = "";
+
+#else
mainVerticalLayout = new QVBoxLayout;
widget = new QWidget;
widget->setLayout(mainVerticalLayout);
browseButton->setMaximumWidth(150);
infoLabel->setText(tr("Dictionary file: not selected"));
setWindowTitle(tr("Add new StarDict dictionary"));
- infoLabel->setText(tr("Dictionary file: not selected"));
browseLayout->addWidget(infoLabel, 0, Qt::AlignLeft);
browseLayout->addLayout(buttonLayout);
browseLayout->addWidget(browseButton, 0, Qt::AlignRight);
scrollArea->setLineWidth(0);
scrollArea->setMidLineWidth(0);
scrollArea->setFrameStyle(QFrame::NoFrame);
+#endif
}
NULL,
NULL);
if (!fileName.isEmpty()) {
+#ifndef Q_WS_MAEMO_5
+ emit setPath(tr("Dictionary file: %1").arg(fileName));
+#else
infoLabel->setText(tr("Dictionary file: %1").arg(fileName));
+#endif
_dictionaryFilePath = fileName;
if (_dictionaryFilePath.endsWith(".tar.bz2"))
_isCompressed = true;
else
_isCompressed = false;
+#ifndef Q_WS_MAEMO_5
+ // qDebug()<<"hint"<<view->sizeHint();
+ // qDebug()<<"size"<<view->size();
+ resize(view->sizeHint());
+
+#else
updateGeometry();
+#endif
}
}
void StarDialog::saveSettings() {
- _settings = new Settings;
+ _settings = new Settings;
if(plugin)
foreach(QString key, plugin->settings()->keys())
_settings->setValue(key, plugin->settings()->value(key));
else
_settings->setValue("dictFileName", _dictName + ".dict");
}
-
if(_settings->value("synFileName")=="")
if (QFile::exists(_dictName + ".syn") == true)
_settings->setValue("synFileName", _dictName + ".syn");
#include <QDialog>
#include "../../include/settings.h"
#include <QtGui>
+#include <QDeclarativeView>
#include "StarDictPlugin.h"
//! Requests to show notification
void notify(Notify::NotifyType, QString);
+ void setInfo(QVariant info);
+ void setButtonText(QVariant text);
+ void setNew(QVariant text);
+ void setPath(QVariant path);
+
public Q_SLOTS:
/*!
Reimplemented accept method, to check if all necessary fields in
*/
void accept();
+
+
private Q_SLOTS:
+ void resizeEvent(QResizeEvent *e);
+
//! displays dialog to browse and select file
void selectFile();
+ void heightChange(int height);
+
private:
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+ int lastHeight;
+
//! create a user interface
void initializeUI();
this, SIGNAL(notify(Notify::NotifyType,QString)));
_settings->setValue("type","stardict");
- _icon = QIcon("/usr/share/mdictionary/stardict.png");
+ _iconPath = "/usr/share/mdictionary/stardict.png";
+ _icon = QIcon(_iconPath);
stopped = false;
_settings->setValue("strip_accents","true");
return &_icon;
}
+QString StarDictPlugin::iconPath(){
+ return _iconPath;
+}
+
Q_EXPORT_PLUGIN2(stardict, StarDictPlugin)
//! \returns plugin icon
QIcon* icon();
+ //! \returns plugin icon's resource path
+ QString iconPath();
+
/*!
plugin should delete any files (eg. cache) that have been created and are ready
to be deleted
QString _name;
QString _infoNote;
QIcon _icon;
+ //! Path to icon
+ QString _iconPath;
volatile bool stopped;
Settings *_settings;
StarDictDialog* _dictDialog;
QChar UncompressedReader::readChar() {
char c[4]={0};
QString cha;
-
_stream.readRawData(c,1);
if(((unsigned char)c[0])>239)
_stream.readRawData(c+1,3);
qDebug()<<"error - starDict - read wordList from UTF-8";
cha=QString::fromUtf8(c);
-
- return cha.at(0);
+ if(cha.size()!=0)
+ return cha.at(0);
+ else
+ return '\0';
}
QString result;
QChar c;
c = readChar();
-
while(c != '\0') {
result += c;
c = readChar();
QT = core \
gui \
xml \
- sql
+ sql \
+ declarative
maemo5:QT += maemo5
UncompressedReader.cpp \
StarDictReaderFactory.cpp
-
HEADERS += \
StarDictPlugin.h \
TranslationStarDict.h \
StarDictReaderFactory.h \
StarDictReader.h
-RESOURCES += \
- StarDict.qrc
+RESOURCES += StarDict.qrc
TRANSLATIONS += pl_PL.ts \
en_US.ts
unix {
- INSTALLS += plugin-icon
+ plugin-icon.path = $$DATA_DIR
+ plugin-icon.files += stardict.png
+ meego {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ../../mdictionary/qml/StarDictDialog.qml
+ }
+ else:maemo5 {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ../../mdictionary/qml/StarDictDialog.qml
+ }
+ else {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ../../mdictionary/qml/StarDictDialog.qml
+ }
- plugin-icon.path = $$DATA_DIR
- plugin-icon.files += stardict.png
+ INSTALLS += plugin-icon \
+ qmls
}
-check.commands = echo 'No check here'
+check.commands = echo \
+ 'No check here'
QMAKE_EXTRA_TARGETS += check
+
+OTHER_FILES += ../../mdictionary/qml/StarDictDialog.qml
--- /dev/null
+#include "DictsListModel.h"
+
+
+DictsListModel::DictsListModel(QList<DownloadDict> dicts, QObject *parent) :
+ QAbstractListModel(parent) {
+
+ _currentIndex = 0;
+ QHash<int, QByteArray> roles;
+ roles[NumberRole] = "number";
+ roles[FromRole] = "from";
+ roles[ToRole] = "to";
+ roles[NameRole] = "name";
+ roles[SizeRole] = "size";
+ roles[LinkRole] = "link";
+ setRoleNames(roles);
+
+ this->dicts=dicts;
+ qSort(this->dicts);
+
+// connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(itemChanged()));
+}
+
+
+int DictsListModel::rowCount(const QModelIndex &) const {
+ return dicts.count();
+}
+
+
+QVariant DictsListModel::data(const QModelIndex & index, int role) const {
+ if (index.row() < 0 || index.row() > dicts.count())
+ return QVariant();
+
+ DownloadDict dict = dicts[index.row()];
+ if (role == NumberRole){
+ return index.row();
+ }
+ if (role == FromRole){
+ return dict.fromLang();
+ }
+ if (role == ToRole){
+ return dict.toLang();
+ }
+ if (role == NameRole){
+ return dict.title();
+ }
+ if (role == SizeRole){
+ return QString::number(dict.size(),'g', 2) + QString (" MB");
+ }
+ if (role == LinkRole) {
+ return dict.link();
+ }
+ return QVariant();
+}
+
+
+QVariant DictsListModel::headerData(int section, Qt::Orientation orientation, int role) const{
+ qDebug()<<"tu jestem"<< role;
+
+ if (role == FromRole){
+ return "From";
+ }
+ if (role == ToRole){
+ return "To";
+ }
+ if (role == NameRole){
+ return "Title";
+ }
+ if (role == SizeRole){
+ return "Size";
+ }
+ return QVariant();
+}
+
+
+void DictsListModel::itemSelected(int index) {
+ _currentIndex = index;
+}
+
+
+DownloadDict DictsListModel::currentDict() {
+ return dicts[_currentIndex];
+}
+
+
+Qt::ItemFlags DictsListModel::flags(const QModelIndex &index) const {
+ Qt::ItemFlags fl = QAbstractItemModel::flags(index);
+ return (fl | Qt::ItemIsEditable);
+}
+
+
+QList<DownloadDict> DictsListModel::dictionaries() {
+ return dicts;
+}
--- /dev/null
+#ifndef DICTSLISTMODEL_H
+#define DICTSLISTMODEL_H
+
+#include <QAbstractListModel>
+#include <QDebug>
+#include "DownloadDict.h"
+
+
+class DictsListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum DictTypeRoles {
+ NumberRole=Qt::UserRole + 1,
+ FromRole,
+ ToRole,
+ NameRole,
+ SizeRole,
+ LinkRole
+ };
+ explicit DictsListModel(QList<DownloadDict> dicts, QObject *parent = 0);
+ int rowCount(const QModelIndex &) const;
+ QVariant data(const QModelIndex & index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ DownloadDict currentDict();
+ QList<DownloadDict> dictionaries();
+
+public Q_SLOTS:
+ void itemSelected(int index);
+
+
+private:
+ QList<DownloadDict> dicts;
+ int _currentIndex;
+};
+
+#endif // DICTSLISTMODEL_H
--- /dev/null
+#ifndef DICTSPROXYLISTMODEL_H
+#define DICTSPROXYLISTMODEL_H
+
+#include <QSortFilterProxyModel>
+#include <QDebug>
+
+class DictsProxyListModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ enum DictTypeRoles {
+ NumberRole=Qt::UserRole + 1,
+ FromRole,
+ ToRole,
+ NameRole,
+ SizeRole,
+ LinkRole };
+
+ DictsProxyListModel(QObject *parent = 0): QSortFilterProxyModel(parent){ }
+ QString from() { return _from;}
+ QString to() {return _to;}
+ void setFrom(QString from) { _from = from; invalidateFilter(); }
+ void setTo(QString to) {_to = to; invalidateFilter();}
+
+protected:
+ bool filterAcceptsRow(int source_row, const QModelIndex&) const {
+ QString sourceFrom = sourceModel()->data(sourceModel()->index(source_row, 0),FromRole).toString();
+ QString sourceTo = sourceModel()->data(sourceModel()->index(source_row, 0),ToRole).toString();
+ return ((_from.isEmpty() || sourceFrom == _from) &&
+ (_to.isEmpty() || sourceTo == _to));
+ }
+
+ bool lessThan(const QModelIndex &left, const QModelIndex &right) const {
+ QString l = left.model()->data(left,sortRole()).toString();
+ QString r = right.model()->data(right,sortRole()).toString();
+ if(sortRole() == SizeRole){
+ l.remove(" MB");
+ r.remove(" MB");
+ float lNumber = l.toFloat();
+ float rNumber = r.toFloat();
+ return (lNumber < rNumber);
+ }
+ else if(sortRole()>Qt::UserRole)
+ return (l < r);
+ else
+ QSortFilterProxyModel::lessThan(left, right);
+ }
+
+private:
+ QString _from;
+ QString _to;
+
+};
+
+#endif // DICTPROXYLISTMODEL_H
_link = lreg.capturedTexts().at(1);
}
+ DownloadDict(const DownloadDict &dict) {
+ _from = dict.fromLang();
+ _to = dict.toLang();
+ _title = dict.title();
+ _size = dict.size();
+ _link = dict.link();
+ }
+
//! \return dictionary source language
QString fromLang() const {return _from;}
\return 1 if this is before other
*/
bool operator <(DownloadDict other) const {
- if(_from < other.fromLang()) return true;
- if(_from > other.fromLang()) return false;
- if(_to < other.toLang()) return true;
- return false;
+ if(_from < other.fromLang())
+ return true;
+ else if(_from > other.fromLang())
+ return false;
+ else if(_to < other.toLang())
+ return true;
+ else
+ return false;
}
private:
XdxfDialogType type,
QWidget *parent) :
QDialog(parent) {
+
this->plugin = plugin;
this->type = type;
+#ifndef Q_WS_MAEMO_5
+
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/XdxfDialog.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+ view->setWindowTitle(tr("Xdxf Settings"));
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(this, SIGNAL(setPlugin(QVariant)),
+ rootObject, SLOT(setPlugin(QVariant)));
+ connect(this, SIGNAL(setFrom(QVariant)),
+ rootObject, SLOT(setFrom(QVariant)));
+ connect(this, SIGNAL(setTo(QVariant)),
+ rootObject, SLOT(setTo(QVariant)));
+ connect(this, SIGNAL(setDescription(QVariant)),
+ rootObject, SLOT(setDescription(QVariant)));
+ connect(this, SIGNAL(setInfo(QVariant)),
+ rootObject, SLOT(setInfo(QVariant)));
+ connect(this, SIGNAL(setCheckedOptimalize(QVariant)),
+ rootObject, SLOT(setCheckedOptimalize(QVariant)));
+ connect(this, SIGNAL(setCheckedStrip(QVariant)),
+ rootObject, SLOT(setCheckedStrip(QVariant)));
+ connect(this,SIGNAL(setButtonText(QVariant)),
+ rootObject, SLOT(setButtonText(QVariant)));
+ connect(this,SIGNAL(setNew(QVariant)),
+ rootObject, SLOT(setNew(QVariant)));
+ connect(this,SIGNAL(setPath(QVariant)),
+ rootObject, SLOT(setPath(QVariant)));
+
+ connect(rootObject, SIGNAL(saveButtonClicked()),
+ this, SLOT(accept()));
+ connect(rootObject, SIGNAL(downloadButtonClicked()),
+ this, SLOT(downloadFile()));
+ connect(rootObject, SIGNAL(browseButtonClicked()),
+ this, SLOT(selectFile()));
+
+ connect(rootObject, SIGNAL(optimalizeCheckboxChanged(bool)),
+ this, SLOT(setGenerateCache(bool)));
+ connect(rootObject, SIGNAL(stripCheckboxChanged(bool)),
+ this, SLOT(setAccents(bool)));
+
+#else
+
cacheToolTip = tr("Optimize for quicker searches (may take some time)");
accentsToolTip = tr("Strip accents (searching takes more time, but spelling doesn't have to be exact)");
- initializeUI();
-
connect(cacheCheckBox, SIGNAL(toggled(bool)),
this, SLOT(setGenerateCache(bool)));
connect(accentsCheckBox, SIGNAL(toggled(bool)),
connect(&XdxfPlugin::dictDownloader, SIGNAL(fileDownloaded(QString)),
this, SLOT(fileDownloaded(QString)));
}
-
connect(confirmButton, SIGNAL(clicked()),
this, SLOT(accept()));
+#endif
+ initializeUI();
}
-void XdxfDialog::fileDownloaded(QString) {
- infoLabel->setText(tr("Dictionary file: %1").arg(XdxfPlugin::dictDownloader.downloadedFile()));
- _dictionaryFilePath = XdxfPlugin::dictDownloader.downloadedFile();
- updateGeometry();
-}
+void XdxfDialog::initializeUI() {
+#ifndef Q_WS_MAEMO_5
+
+ if(type != New){
+ emit setNew(false);
+ emit setPlugin(plugin->type().toUpper());
+ emit setFrom(plugin->langFrom());
+ emit setTo(plugin->langTo());
+ emit setDescription(plugin->name());
+ emit setInfo(plugin->infoNote());
+ emit setButtonText("Save settings");
+ }
+ else{
+ emit setButtonText("Add");
+ emit setNew(true);
+ connect(&XdxfPlugin::dictDownloader, SIGNAL(fileDownloaded(QString)),
+ this, SLOT(fileDownloaded(QString)));
+ }
+ if(!plugin) {
+ emit setCheckedOptimalize(true);
+ emit setCheckedStrip(true);
+// accentsCheckBox->setEnabled(false);
+ _generateCache = true;
+ _accents = true;
+ _dictionaryFilePath = "";
+ }
+ else if(plugin && plugin->settings()->value("cached") == "true") {
+ emit setCheckedOptimalize(true);
+ emit setCheckedStrip(true);
+// accentsCheckBox->setEnabled(false);
+ _generateCache = true;
+ _accents = true;
+ }
+ else {
+ emit setCheckedOptimalize(false);
+ _generateCache = false;
+ if(plugin->settings()->value("strip_accents") == "true") {
+ emit setCheckedStrip(true);
+ _accents = true;
+ }
+ else {
+ emit setCheckedStrip(false);
+ _accents = false;
+ }
+ }
-void XdxfDialog::initializeUI() {
+#else
mainVerticalLayout = new QVBoxLayout;
widget = new QWidget;
widget->setLayout(mainVerticalLayout);
scrollArea->setLineWidth(0);
scrollArea->setMidLineWidth(0);
scrollArea->setFrameStyle(QFrame::NoFrame);
+#endif
}
void XdxfDialog::setAccents(bool accents) {
+ qDebug()<<"setAcents"<<accents;
_accents = accents;
}
void XdxfDialog::setGenerateCache(bool generate) {
_generateCache = generate;
-
+#ifndef Q_WS_MAEMO_5
+ if(generate) {
+ _lastAccents = _accents;
+ emit setCheckedOptimalize(true);
+ emit setCheckedStrip(true);
+ }
+ else{
+ emit setCheckedStrip(_lastAccents);
+ }
+// accentsCheckBox->setEnabled(!generate);
+#else
if(generate) {
_lastAccents = _accents;
accentsCheckBox->setChecked(true);
else
accentsCheckBox->setChecked(_lastAccents);
accentsCheckBox->setEnabled(!generate);
+#endif
}
NULL,
NULL);
if (!fileName.isEmpty()) {
- infoLabel->setText(tr("Dictionary file: %1").arg(fileName));
_dictionaryFilePath = fileName;
- updateGeometry();
+ #ifndef Q_WS_MAEMO_5
+ emit setPath(tr("Dictionary file: %1").arg(fileName));
+ #else
+ infoLabel->setText(tr("Dictionary file: %1").arg(fileName));
+ updateGeometry();
+ #endif
}
}
+void XdxfDialog::fileDownloaded(QString) {
+#ifndef Q_WS_MAEMO_5
+ qDebug()<<"fileDownloaded";
+ emit setPath(tr("Dictionary file: %1").arg(XdxfPlugin::dictDownloader.downloadedFile()));
+ _dictionaryFilePath = XdxfPlugin::dictDownloader.downloadedFile();
+#else
+ infoLabel->setText(tr("Dictionary file: %1").arg(XdxfPlugin::dictDownloader.downloadedFile()));
+ _dictionaryFilePath = XdxfPlugin::dictDownloader.downloadedFile();
+ updateGeometry();
+#endif
+}
+
+
void XdxfDialog::downloadFile() {
- XdxfPlugin::dictDownloader.download(this);
+ XdxfPlugin::dictDownloader.download(this);
}
}
else
_settings->setValue("path", _dictionaryFilePath);
-
if(_generateCache)
_settings->setValue("generateCache", "true");
else
#define XDXFDIALOG_H
#include <QDialog>
-#include "../../include/settings.h"
#include <QtGui>
-#include "xdxfplugin.h"
+#include <QDeclarativeView>
+#include "xdxfplugin.h"
+#include "../../include/settings.h"
/*!
This class can create dialogs for adding a new dictionary or changing settings
//! Requests to show notification
void notify(Notify::NotifyType, QString);
+ void setPlugin(QVariant name);
+ void setFrom(QVariant lang);
+ void setTo(QVariant lang);
+ void setDescription(QVariant descript);
+ void setInfo(QVariant info);
+ void setCheckedOptimalize(QVariant boolean);
+ void setCheckedStrip(QVariant boolean);
+ void setButtonText(QVariant text);
+ void setNew(QVariant text);
+ void setPath(QVariant path);
+
public Q_SLOTS:
/*!
Reimplemented accept method, to check if all necessary fields in
void accept();
private Q_SLOTS:
+
//! displays dialog to browse and select file
void selectFile();
private:
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+
void initializeUI();
//! saves new settings after acceptance of dialog
XdxfDictDownloadProgressDialog::XdxfDictDownloadProgressDialog(QWidget*parent):
QDialog(parent) {
+qDebug()<<"etap 01";
+#ifndef Q_WS_MAEMO_5
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/XdxfDictDownloader.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+ view->setWindowTitle(tr("Progres Dialog"));
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(this, SIGNAL(setValue(QVariant)),
+ rootObject, SLOT(setValue(QVariant)));
+ connect(this, SIGNAL(setTextt(QVariant)),
+ rootObject, SLOT(setText(QVariant)));
+ connect(this, SIGNAL(setMaximumValue(QVariant)),
+ rootObject, SLOT(setMaximumValue(QVariant)));
+
+ connect(rootObject, SIGNAL(cancelDownloading()),
+ this, SLOT(reject()));
+
+#else
verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
#ifndef Q_WS_MAEMO_5
setMinimumWidth(350);
#endif
+#endif
}
void XdxfDictDownloadProgressDialog::show() {
+qDebug()<<"etap 02";
+#ifndef Q_WS_MAEMO_5
+ emit setMaximumValue(0);
+ maximumValue=0;
+#else
downloadProgressBar->setMaximum(0);
QDialog::show();
+#endif
+ QDialog::show();
}
void XdxfDictDownloadProgressDialog::setText(QString text) {
+qDebug()<<"etap 03";
+
+#ifndef Q_WS_MAEMO_5
+ emit setTextt(text);
+#else
setWindowTitle(text);
- #ifndef Q_WS_MAEMO_5
- downloadLabel->setText(text);
- #endif
+#endif
}
void XdxfDictDownloadProgressDialog::updateProgress(float progress) {
+qDebug()<<"etap 04";
+#ifndef Q_WS_MAEMO_5
+ if(maximumValue == 0) {
+ emit setMaximumValue(100);
+ }
+ emit setValue((int)(progress*100));
+#else
if(downloadProgressBar->maximum() == 0) {
downloadProgressBar->setMaximum(100);
}
downloadProgressBar->setValue(progress*100);
+#endif
}
void XdxfDictDownloadProgressDialog::reject() {
+qDebug()<<"etap 05";
#ifndef Q_WS_MAEMO_5
Q_EMIT cancelDownloading();
#else
#include <QDialog>
#include <QtGui>
+#include <QDeclarativeView>
/*!
Shows downloading progress bar. Currently it displays "busy bar".
void show();
Q_SIGNALS:
+ void setMaximumValue(QVariant value);
+ void setTextt(QVariant text);
+ void setValue(QVariant value);
+
//! signal emitted when user cancels downloading of a dictionary
void cancelDownloading();
private:
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+ int maximumValue;
+
+
QLabel* downloadLabel;
QProgressBar* downloadProgressBar;
QPushButton* cancelButton;
connect(this, SIGNAL(downloadProgress(float)),
progressDialog, SLOT(updateProgress(float)));
+ qDebug()<<"etam 3.1";
progressDialog->setText(tr("Downloading dictionaries list"));
progressDialog->show();
}
XdxfDictSelectDialog selectDialog(dicts, parentDialog);
if(selectDialog.exec()==QDialog::Accepted) {
-
+ qDebug()<<"etap 3.2";
progressDialog->setText(tr("Downloading dictionary"));
progressDialog->show();
}
+
#define XDXFDICTDOWNLOADER_H
#include <QObject>
-#include "XdxfDictSelectDialog.h"
#include <QTimer>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <DownloadDict.h>
+#include <string.h>
+#include <errno.h>
+
+#include "XdxfDictSelectDialog.h"
#include "XdxfDictDownloadProgressDialog.h"
#include "../../include/Notify.h"
#include "HttpDownloader.h"
-#include <string.h>
-#include <errno.h>
/*!
XdxfDictDownloader is responsible for getting dict list from XDXF website
//! emmited what is update Download Progress
void downloadProgress(float);
+ void downloadProgress2(QVariant);
private Q_SLOTS:
//! obtained list of dictionaries from website
XdxfDictSelectDialog::XdxfDictSelectDialog(QList<DownloadDict> dicts,
QWidget *parent) :
QDialog(parent) {
+
+
setWindowTitle(tr("Select dictionary"));
+ //here removing already added dictionary
+ for (int i = 0; i < dicts.size(); i++){
+ if(QFile::exists(QDir::homePath() + "/.mdictionary/" + dicts[i].title() + ".xdxf")){
+ dicts.removeAt(i);
+ i--;
+ }
+ }
+
+#ifndef Q_WS_MAEMO_5
+ model2 = new DictsListModel(dicts, this);
+ proxyModel2 = new DictsProxyListModel;
+ proxyModel2->setSourceModel(model2);
+ proxyModel2->setTo("Polish");
+ view= new QDeclarativeView();
+ QDeclarativeContext* ctxt=view->rootContext();
+ ctxt->setContextProperty("dictModel", proxyModel2);
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/TableWidget.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ this->setLayout(mainLayout);
+ proxyModel2->setTo("English");
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(rootObject,SIGNAL(dictLink(QString)),
+ this,SLOT(itemClicked(QString)));
+#else
+
layout = new QVBoxLayout;
setLayout(layout);
checkBoxLayout->addWidget(langToLabel);
checkBoxLayout->addWidget(langTo, 10);
- //here removing already added dictionary
-
- for (int i = 0; i < dicts.size(); i++){
- if(QFile::exists(QDir::homePath() + "/.mdictionary/" + dicts[i].title() + ".xdxf")){
- dicts.removeAt(i);
- i--;
- }
- }
-
model = new DictsModel(dicts, this);
proxyModel = new DictsProxyModel;
#endif
initializeDicts();
+ #endif
}
void XdxfDictSelectDialog::refreshDictList() {
+#ifndef Q_WS_MAEMO_5
+
+
+#else
+
//if selected language is "Any"(index 0), from filter string is set to empty string, proxy model uses empty string as special case and don't filter by this field.
if(langTo->currentIndex() == 0)
proxyModel->setTo(QString());
proxyModel->setFrom(QString());
else
proxyModel->setFrom(langFrom->currentText());
+
+#endif
}
+void XdxfDictSelectDialog::itemClicked(QString link) {
+#ifndef Q_WS_MAEMO_5
+ _link = link;
+ accept();
+#endif
+}
+
void XdxfDictSelectDialog::itemClicked(QModelIndex index) {
+#ifdef Q_WS_MAEMO_5
_link = index.model()->data(index, Qt::UserRole).toString();
accept();
+#endif
}
#include <QtGui>
#include <QFile>
#include <QDir>
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+
#include "DownloadDict.h"
+#include "DictsListModel.h"
#include "DictsModel.h"
#include "DictsProxyModel.h"
+#include "DictsProxyListModel.h"
/*!
//! accept dialog and sets download link of clicked dictionary
void itemClicked(QModelIndex);
+ void itemClicked(QString link);
+
private:
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+ DictsListModel* model2;
+ DictsProxyListModel *proxyModel2;
+
QTreeView* treeView;
DictsModel* model;
DictsProxyModel *proxyModel; //used by treeView to allow filtering and sorti
TARGET = xdxf
+
include(../plugin.pri)
+
QT = core \
gui \
xml \
sql \
- network
+ network\
+ declarative
+
maemo5 {
LIBS += -lbz2 \
}
LIBS += -ltar \
-lbz2
}
-
maemo5:QT += maemo5
+
SOURCES += xdxfplugin.cpp \
TranslationXdxf.cpp \
XdxfDictDialog.cpp \
XdxfDictSelectDialog.cpp \
XdxfDictDownloadProgressDialog.cpp \
DictsModel.cpp \
- HttpDownloader.cpp
+ HttpDownloader.cpp \
+ DictsListModel.cpp
+
HEADERS += xdxfplugin.h \
TranslationXdxf.h \
../../include/DictDialog.h \
DownloadDict.h \
DictsModel.h \
DictsProxyModel.h \
- HttpDownloader.h
+ HttpDownloader.h \
+ DictsListModel.h \
+ DictsProxyListModel.h
+
RESOURCES += xdxf.qrc
+
TRANSLATIONS += pl_PL.ts \
- en_US.ts
-unix {
- INSTALLS += dicts \
- plugin-icon
+ en_US.ts
+
+OTHER_FILES += ../../mdictionary/qml/XdxfDialog.qml \
+ ../../mdictionary/qml/XdxfDictDownloader.qml \
+ ../../mdictionary/qml/TableWidget.qml \
+ ../../mdictionary/qml/ScrollBar2.qml
+
+unix {
dicts.path = $$PLUGINS_DIR
dicts.files += ../../../data/dicts/eng-us.xdxf
dicts.files += ../../../data/dicts/eng-thai.xdxf
plugin-icon.path = $$DATA_DIR
plugin-icon.files += xdxf.png
+
+ meego {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ../../mdictionary/qml/XdxfDialog.qml
+ }
+ else:maemo5 {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ../../mdictionary/qml/XdxfDialog.qml
+ }
+ else {
+ qmls.path = $$DATA_DIR/qml
+ qmls.files += ../../mdictionary/qml/XdxfDialog.qml
+ qmls.files += ../../mdictionary/qml/XdxfDictDownloader.qml
+ qmls.files += ../../mdictionary/qml/TableWidget.qml
+ qmls.files += ../../mdictionary/qml/ScrollBar2.qml
+
+ }
+
+ INSTALLS += dicts \
+ plugin-icon\
+ qmls
}
check.commands = echo \
- 'No check here'
+ 'No check here'
QMAKE_EXTRA_TARGETS += check
<qresource prefix="/xdxf">
<file>translations/pl_PL.qm</file>
<file>translations/en_US.qm</file>
+ <file>scrollbar.png</file>
</qresource>
</RCC>
}
_settings->setValue("type","xdxf");
- _icon = QIcon("/usr/share/mdictionary/xdxf.png");
+ _iconPath = "/usr/share/mdictionary/xdxf.png";
+ _icon = QIcon(_iconPath);
_wordsCount = -1;
stopped = false;
return &_icon;
}
+QString XdxfPlugin::iconPath(){
+ return _iconPath;
+}
+
int XdxfPlugin::countWords() {
if(_wordsCount>0)
//! \returns plugin icon
QIcon* icon();
+ //! \returns plugin icon's resource path
+ QString iconPath();
+
/*!
plugin should delete any files (eg. cache) that have been created and are ready
to be deleted
QString _infoNote;
QString _dictionaryInfo;
QIcon _icon;
+ //! Path to icon
+ QString _iconPath;
QSqlDatabase db;
QString db_name;
long _wordsCount;