From beb2f8a40b5d1770c9727c1df18fe233639d8862 Mon Sep 17 00:00:00 2001 From: jakub Date: Fri, 21 Jan 2011 09:55:45 +0100 Subject: [PATCH] add history widget --- src/mdictionary/gui/DictTypeSelectDialog.cpp | 3 +- src/mdictionary/gui/HistoryListDialog.cpp | 46 ++++++++-- src/mdictionary/gui/HistoryListDialog.h | 10 ++- src/mdictionary/gui/HistoryListModel.cpp | 40 +++++++++ src/mdictionary/gui/HistoryListModel.h | 31 +++++++ src/mdictionary/gui/MainWindow.cpp | 4 +- src/mdictionary/mdictionary.pro | 10 ++- src/mdictionary/qml/DictTypeSelectDialog.qml | 1 - src/mdictionary/qml/HistoryListDialog.qml | 69 ++++++++++++++ src/mdictionary/qml/ProgressBar.qml | 18 ++-- src/mdictionary/qml/StarDictDialog.qml | 94 ++++++++++++++++++++ src/mdictionary/qml/XdxfDialog.qml | 1 - src/mdictionary/qml/XdxfDictDownloader.qml | 81 +++++++++++++++++ src/plugins/google/GoogleDialog.h | 5 ++ src/plugins/google/google.pro | 26 ++++-- src/plugins/stardict/stardict.pro | 3 +- src/plugins/xdxf/XdxfDialog.h | 1 + .../xdxf/XdxfDictDownloadProgressDialog.cpp | 52 ++++++++++- src/plugins/xdxf/XdxfDictDownloadProgressDialog.h | 10 +++ src/plugins/xdxf/XdxfDictDownloader.cpp | 4 +- src/plugins/xdxf/XdxfDictDownloader.h | 8 +- src/plugins/xdxf/xdxf.pro | 5 +- 22 files changed, 481 insertions(+), 41 deletions(-) create mode 100644 src/mdictionary/gui/HistoryListModel.cpp create mode 100644 src/mdictionary/gui/HistoryListModel.h create mode 100644 src/mdictionary/qml/HistoryListDialog.qml create mode 100644 src/mdictionary/qml/StarDictDialog.qml create mode 100644 src/mdictionary/qml/XdxfDictDownloader.qml diff --git a/src/mdictionary/gui/DictTypeSelectDialog.cpp b/src/mdictionary/gui/DictTypeSelectDialog.cpp index 4ab853b..bf61dd2 100644 --- a/src/mdictionary/gui/DictTypeSelectDialog.cpp +++ b/src/mdictionary/gui/DictTypeSelectDialog.cpp @@ -41,9 +41,8 @@ DictTypeSelectDialog::DictTypeSelectDialog(QList plugins, 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; diff --git a/src/mdictionary/gui/HistoryListDialog.cpp b/src/mdictionary/gui/HistoryListDialog.cpp index 0074181..804f907 100644 --- a/src/mdictionary/gui/HistoryListDialog.cpp +++ b/src/mdictionary/gui/HistoryListDialog.cpp @@ -28,19 +28,42 @@ #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); @@ -50,14 +73,13 @@ HistoryListDialog::HistoryListDialog(QStringList words, QWidget *parent): historyListWidget->addItem(item); } - setModal(true); - setWindowTitle(tr("History")); setMinimumHeight(300); connect(historyListWidget, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); +#endif } @@ -67,6 +89,11 @@ void HistoryListDialog::itemClicked(QModelIndex index) { accept(); } +void HistoryListDialog::itemClicked(int index) { + _selectedWord = oryginalList[index]; + _selectedRow = index; + accept(); +} QString HistoryListDialog::selectedWord() { return _selectedWord; @@ -77,6 +104,11 @@ int HistoryListDialog::selectedRow() { } int HistoryListDialog::exec() { + #ifndef Q_WS_MAEMO_5 + + #else historyListWidget->setFocus(); + #endif + QDialog::exec(); } diff --git a/src/mdictionary/gui/HistoryListDialog.h b/src/mdictionary/gui/HistoryListDialog.h index a4de93a..4e9ce4a 100644 --- a/src/mdictionary/gui/HistoryListDialog.h +++ b/src/mdictionary/gui/HistoryListDialog.h @@ -27,10 +27,14 @@ #ifndef HISTORYLISTDIALOG_H #define HISTORYLISTDIALOG_H +#include #include +#include +#include + #include "SearchBarWidget.h" #include "../../include/History.h" -#include +#include "HistoryListModel.h" /*! @@ -59,8 +63,12 @@ public Q_SLOTS: private Q_SLOTS: void itemClicked(QModelIndex); + void itemClicked(int); private: + QDeclarativeView *view; + QVBoxLayout* mainLayout; + QListWidget* historyListWidget; QVBoxLayout* verticalLayout; QString _selectedWord; diff --git a/src/mdictionary/gui/HistoryListModel.cpp b/src/mdictionary/gui/HistoryListModel.cpp new file mode 100644 index 0000000..27a9ca6 --- /dev/null +++ b/src/mdictionary/gui/HistoryListModel.cpp @@ -0,0 +1,40 @@ +#include "HistoryListModel.h" + +HistoryListModel::HistoryListModel(QStringList words, QObject *parent) : + QAbstractListModel(parent) { + + QHash 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(); +} diff --git a/src/mdictionary/gui/HistoryListModel.h b/src/mdictionary/gui/HistoryListModel.h new file mode 100644 index 0000000..8073790 --- /dev/null +++ b/src/mdictionary/gui/HistoryListModel.h @@ -0,0 +1,31 @@ +#ifndef HISTORYLISTMODEL_H +#define HISTORYLISTMODEL_H + +#include +#include +#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 diff --git a/src/mdictionary/gui/MainWindow.cpp b/src/mdictionary/gui/MainWindow.cpp index 48f3159..2b6bafc 100644 --- a/src/mdictionary/gui/MainWindow.cpp +++ b/src/mdictionary/gui/MainWindow.cpp @@ -374,7 +374,7 @@ void MainWindow::showHistory(QPoint p) { 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 @@ -600,6 +600,4 @@ void MainWindow::removeBookmarks() { backbone->removeAllBookmarks(); ((WordListWidget*)wordListWidget)->clear(); } - - } diff --git a/src/mdictionary/mdictionary.pro b/src/mdictionary/mdictionary.pro index fea6334..75ebf14 100644 --- a/src/mdictionary/mdictionary.pro +++ b/src/mdictionary/mdictionary.pro @@ -40,7 +40,8 @@ SOURCES += gui/main.cpp \ 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 \ @@ -73,7 +74,8 @@ HEADERS += gui/MainWindow.h \ gui/NotifyManager.h \ gui/SpinBox.h \ gui/DictTypeModel.h \ - gui/DictManagerModel.h + gui/DictManagerModel.h \ + gui/HistoryListModel.h RESOURCES += ../../data/gui.qrc @@ -97,7 +99,8 @@ OTHER_FILES += \ qml/ScrollBar.qml \ qml/Checkbox.qml \ qml/MySpinBox.qml \ - qml/SettingsWidget.qml + qml/SettingsWidget.qml \ + qml/HistoryListDialog.qml target.path = $$BIN_DIR INSTALLS += target @@ -219,6 +222,7 @@ unix { 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 diff --git a/src/mdictionary/qml/DictTypeSelectDialog.qml b/src/mdictionary/qml/DictTypeSelectDialog.qml index e57069a..ac20bfe 100644 --- a/src/mdictionary/qml/DictTypeSelectDialog.qml +++ b/src/mdictionary/qml/DictTypeSelectDialog.qml @@ -63,5 +63,4 @@ Rectangle { } model: dictTypeModel } - } diff --git a/src/mdictionary/qml/HistoryListDialog.qml b/src/mdictionary/qml/HistoryListDialog.qml new file mode 100644 index 0000000..feb7ad9 --- /dev/null +++ b/src/mdictionary/qml/HistoryListDialog.qml @@ -0,0 +1,69 @@ +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 + } + +} diff --git a/src/mdictionary/qml/ProgressBar.qml b/src/mdictionary/qml/ProgressBar.qml index 2e102c3..2a0de49 100644 --- a/src/mdictionary/qml/ProgressBar.qml +++ b/src/mdictionary/qml/ProgressBar.qml @@ -10,7 +10,13 @@ Rectangle { 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; @@ -40,11 +46,11 @@ Rectangle { } } - 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 } } } @@ -68,6 +74,6 @@ Rectangle { 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) + '%') : (""); } } diff --git a/src/mdictionary/qml/StarDictDialog.qml b/src/mdictionary/qml/StarDictDialog.qml new file mode 100644 index 0000000..2291d11 --- /dev/null +++ b/src/mdictionary/qml/StarDictDialog.qml @@ -0,0 +1,94 @@ +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 } + } + ] +} diff --git a/src/mdictionary/qml/XdxfDialog.qml b/src/mdictionary/qml/XdxfDialog.qml index 1b71ff3..e16180b 100644 --- a/src/mdictionary/qml/XdxfDialog.qml +++ b/src/mdictionary/qml/XdxfDialog.qml @@ -41,7 +41,6 @@ Rectangle{ textPath.text=string; } - signal saveButtonClicked(); signal downloadButtonClicked(); signal browseButtonClicked(); diff --git a/src/mdictionary/qml/XdxfDictDownloader.qml b/src/mdictionary/qml/XdxfDictDownloader.qml new file mode 100644 index 0000000..6973147 --- /dev/null +++ b/src/mdictionary/qml/XdxfDictDownloader.qml @@ -0,0 +1,81 @@ +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; + } + } + } +} diff --git a/src/plugins/google/GoogleDialog.h b/src/plugins/google/GoogleDialog.h index dfb798d..52464b1 100644 --- a/src/plugins/google/GoogleDialog.h +++ b/src/plugins/google/GoogleDialog.h @@ -32,6 +32,8 @@ #include #include "../../include/settings.h" #include +#include + #include "GooglePlugin.h" /*! @@ -88,6 +90,9 @@ private Q_SLOTS: void changeLangButtonClicked(); private: + QVBoxLayout* mainLayout; + QDeclarativeView *view; + void initializeUI(); //! saves new settings after acceptance of dialog diff --git a/src/plugins/google/google.pro b/src/plugins/google/google.pro index 444472c..54b09cd 100644 --- a/src/plugins/google/google.pro +++ b/src/plugins/google/google.pro @@ -4,7 +4,8 @@ include(../plugin.pri) QT = core \ gui \ - network + network \ + declarative maemo5:QT += maemo5 @@ -30,12 +31,25 @@ TRANSLATIONS += pl_PL.ts \ 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 diff --git a/src/plugins/stardict/stardict.pro b/src/plugins/stardict/stardict.pro index 47a8f38..96b6a25 100644 --- a/src/plugins/stardict/stardict.pro +++ b/src/plugins/stardict/stardict.pro @@ -65,5 +65,4 @@ check.commands = echo \ 'No check here' QMAKE_EXTRA_TARGETS += check -OTHER_FILES += \ - ../../mdictionary/qml/StarDictDialog.qml \ +OTHER_FILES += ../../mdictionary/qml/StarDictDialog.qml diff --git a/src/plugins/xdxf/XdxfDialog.h b/src/plugins/xdxf/XdxfDialog.h index 2f1a053..d1775da 100644 --- a/src/plugins/xdxf/XdxfDialog.h +++ b/src/plugins/xdxf/XdxfDialog.h @@ -33,6 +33,7 @@ #include "../../include/settings.h" #include #include + #include "xdxfplugin.h" diff --git a/src/plugins/xdxf/XdxfDictDownloadProgressDialog.cpp b/src/plugins/xdxf/XdxfDictDownloadProgressDialog.cpp index 8f89199..5bf2ca7 100644 --- a/src/plugins/xdxf/XdxfDictDownloadProgressDialog.cpp +++ b/src/plugins/xdxf/XdxfDictDownloadProgressDialog.cpp @@ -29,6 +29,32 @@ 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); @@ -54,32 +80,52 @@ XdxfDictDownloadProgressDialog::XdxfDictDownloadProgressDialog(QWidget*parent): #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 diff --git a/src/plugins/xdxf/XdxfDictDownloadProgressDialog.h b/src/plugins/xdxf/XdxfDictDownloadProgressDialog.h index 2a1efc3..a103de6 100644 --- a/src/plugins/xdxf/XdxfDictDownloadProgressDialog.h +++ b/src/plugins/xdxf/XdxfDictDownloadProgressDialog.h @@ -30,6 +30,7 @@ #include #include +#include /*! Shows downloading progress bar. Currently it displays "busy bar". @@ -56,10 +57,19 @@ public Q_SLOTS: 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; diff --git a/src/plugins/xdxf/XdxfDictDownloader.cpp b/src/plugins/xdxf/XdxfDictDownloader.cpp index 60f01bf..9995e9c 100644 --- a/src/plugins/xdxf/XdxfDictDownloader.cpp +++ b/src/plugins/xdxf/XdxfDictDownloader.cpp @@ -72,6 +72,7 @@ void XdxfDictDownloader::download(QWidget *parent) { connect(this, SIGNAL(downloadProgress(float)), progressDialog, SLOT(updateProgress(float))); + qDebug()<<"etam 3.1"; progressDialog->setText(tr("Downloading dictionaries list")); progressDialog->show(); } @@ -175,7 +176,7 @@ void XdxfDictDownloader::dictListReceived(QNetworkReply *reply) { XdxfDictSelectDialog selectDialog(dicts, parentDialog); if(selectDialog.exec()==QDialog::Accepted) { - + qDebug()<<"etap 3.2"; progressDialog->setText(tr("Downloading dictionary")); progressDialog->show(); @@ -244,3 +245,4 @@ bool XdxfDictDownloader::extract(QString file) { } + diff --git a/src/plugins/xdxf/XdxfDictDownloader.h b/src/plugins/xdxf/XdxfDictDownloader.h index ebd048d..171fadd 100644 --- a/src/plugins/xdxf/XdxfDictDownloader.h +++ b/src/plugins/xdxf/XdxfDictDownloader.h @@ -30,16 +30,17 @@ #define XDXFDICTDOWNLOADER_H #include -#include "XdxfDictSelectDialog.h" #include #include #include #include +#include +#include + +#include "XdxfDictSelectDialog.h" #include "XdxfDictDownloadProgressDialog.h" #include "../../include/Notify.h" #include "HttpDownloader.h" -#include -#include /*! XdxfDictDownloader is responsible for getting dict list from XDXF website @@ -71,6 +72,7 @@ Q_SIGNALS: //! emmited what is update Download Progress void downloadProgress(float); + void downloadProgress2(QVariant); private Q_SLOTS: //! obtained list of dictionaries from website diff --git a/src/plugins/xdxf/xdxf.pro b/src/plugins/xdxf/xdxf.pro index f342bfb..929060c 100644 --- a/src/plugins/xdxf/xdxf.pro +++ b/src/plugins/xdxf/xdxf.pro @@ -52,8 +52,8 @@ RESOURCES += xdxf.qrc 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 @@ -73,6 +73,7 @@ unix { else { qmls.path = $$DATA_DIR/qml qmls.files += ../../mdictionary/qml/XdxfDialog.qml + qmls.files += ../../mdictionary/qml/XdxfDictDownloader.qml } INSTALLS += dicts \ -- 1.7.9.5