qmlView = new QDeclarativeView(this);
ctxt = qmlView->rootContext();
-
-// model = new DictTypeModel(plugins, this);
ctxt->setContextProperty("dictTypeModel", &model);
+
qmlView->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/DictTypeSelectDialog.qml"));
_selectedPlugin = 0;
#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
HistoryListDialog historyDialog(backbone->history()->list(), this );// searchBarWidget);
#ifndef Q_WS_MAEMO_5
p.setX(p.x() - historyDialog.sizeHint().width() + 5);
- p.setY(p.y() - historyDialog.sizeHint().height() - 80);
+ p.setY(p.y() - historyDialog.sizeHint().height()- 10); //- 80);
historyDialog.move(p);
#endif
backbone->removeAllBookmarks();
((WordListWidget*)wordListWidget)->clear();
}
-
-
}
gui/NotifyManager.cpp \
gui/SpinBox.cpp \
gui/DictTypeModel.cpp \
- gui/DictManagerModel.cpp
+ gui/DictManagerModel.cpp \
+ gui/HistoryListModel.cpp
HEADERS += gui/MainWindow.h \
backbone/ConfigGenerator.h \
gui/NotifyManager.h \
gui/SpinBox.h \
gui/DictTypeModel.h \
- gui/DictManagerModel.h
+ gui/DictManagerModel.h \
+ gui/HistoryListModel.h
RESOURCES += ../../data/gui.qrc
qml/ScrollBar.qml \
qml/Checkbox.qml \
qml/MySpinBox.qml \
- qml/SettingsWidget.qml
+ qml/SettingsWidget.qml \
+ qml/HistoryListDialog.qml
target.path = $$BIN_DIR
INSTALLS += target
qmls.files += ./qml/Checkbox.qml
qmls.files += ./qml/MySpinBox.qml
qmls.files += ./qml/SettingsWidget.qml
+ qmls.files += ./qml/HistoryListDialog.qml
}
INSTALLS += desktop icon64 shared service css css_images qmls
}
model: dictTypeModel
}
-
}
--- /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
+ }
+
+}
function setMax(intiger) { maximum=intiger }
function setMin(intiger) { minimum=intiger }
- function setValue(intiger) { value= intiger }
+ function setValue(intiger) {
+ value= intiger;
+ if(intiger>-1){
+ highlight.anchors.leftMargin=0;
+ highlight.anchors.position=0;
+ }
+ }
function setValue2(intiger) { value2= intiger }
width: 250;
}
}
- Behavior on anchors.leftMargin {
+ Behavior on position {
SequentialAnimation{
- loops: Animation.Infinite
- SmoothedAnimation { velocity: 450; to: progressBar.width - 96}
- SmoothedAnimation { velocity: 450; to: 6 }
+ loops: (value>-1)?0:Animation.Infinite
+ SmoothedAnimation { velocity:450 ; to: progressBar.width - 96}
+ SmoothedAnimation { velocity: 450 ; to: 6 }
}
}
anchors.verticalCenter: parent.verticalCenter
color: "white"
font.bold: true
- text: (value>-1) ? (Math.floor((value - minimum) / (maximum - minimum) * 100) + '%') : ("???");
+ text: (value>-1) ? (Math.floor((value - minimum) / (maximum - minimum) * 100) + '%') : ("");
}
}
--- /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 }
+ }
+ ]
+}
textPath.text=string;
}
-
signal saveButtonClicked();
signal downloadButtonClicked();
signal browseButtonClicked();
--- /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){
+ console.log("ala value " +intiger);
+ progressbar1.setValue(intiger);
+ }
+ function setText(string){
+ console.log("ala text " +string);
+ text.text=string;
+ }
+ function setMaximumValue(intiger){
+ console.log("ala max " +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: {
+ console.log("click");
+ 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;
+ }
+ }
+ }
+}
#include <QDialog>
#include "../../include/settings.h"
#include <QtGui>
+#include <QDeclarativeView>
+
#include "GooglePlugin.h"
/*!
void changeLangButtonClicked();
private:
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+
void initializeUI();
//! saves new settings after acceptance of dialog
QT = core \
gui \
- network
+ network \
+ declarative
maemo5:QT += maemo5
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
'No check here'
QMAKE_EXTRA_TARGETS += check
-OTHER_FILES += \
- ../../mdictionary/qml/StarDictDialog.qml \
+OTHER_FILES += ../../mdictionary/qml/StarDictDialog.qml
#include "../../include/settings.h"
#include <QtGui>
#include <QDeclarativeView>
+
#include "xdxfplugin.h"
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
TRANSLATIONS += pl_PL.ts \
en_US.ts
-OTHER_FILES += \
- ../../mdictionary/qml/XdxfDialog.qml
+OTHER_FILES += ../../mdictionary/qml/XdxfDialog.qml \
+ ../../mdictionary/qml/XdxfDictDownloader.qml
unix {
dicts.path = $$PLUGINS_DIR
else {
qmls.path = $$DATA_DIR/qml
qmls.files += ../../mdictionary/qml/XdxfDialog.qml
+ qmls.files += ../../mdictionary/qml/XdxfDictDownloader.qml
}
INSTALLS += dicts \