From c1242780cf8f2455d694478bdf5ae8e03d714653 Mon Sep 17 00:00:00 2001 From: jakub Date: Fri, 14 Jan 2011 12:25:50 +0100 Subject: [PATCH] starDict dialog in qml --- src/mdictionary/qml/XdxfDialog.qml | 1 - src/plugins/stardict/StarDialog.cpp | 89 +++++++++++++++++++++++++++++++++-- src/plugins/stardict/StarDialog.h | 16 +++++++ src/plugins/stardict/stardict.png | Bin 3768 -> 0 bytes src/plugins/stardict/stardict.pro | 33 +++++++++---- src/plugins/xdxf/XdxfDialog.cpp | 7 +-- src/plugins/xdxf/xdxf.pro | 15 +++--- 7 files changed, 135 insertions(+), 26 deletions(-) delete mode 100644 src/plugins/stardict/stardict.png diff --git a/src/mdictionary/qml/XdxfDialog.qml b/src/mdictionary/qml/XdxfDialog.qml index 567c455..1b71ff3 100644 --- a/src/mdictionary/qml/XdxfDialog.qml +++ b/src/mdictionary/qml/XdxfDialog.qml @@ -38,7 +38,6 @@ Rectangle{ newPlugin=bool; } function setPath(string){ - console.log("new path"); textPath.text=string; } diff --git a/src/plugins/stardict/StarDialog.cpp b/src/plugins/stardict/StarDialog.cpp index 9936646..fcfa6be 100644 --- a/src/plugins/stardict/StarDialog.cpp +++ b/src/plugins/stardict/StarDialog.cpp @@ -30,17 +30,86 @@ #include 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); @@ -54,7 +123,6 @@ void StarDialog::initializeUI() { 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); @@ -114,6 +182,7 @@ void StarDialog::initializeUI() { scrollArea->setLineWidth(0); scrollArea->setMidLineWidth(0); scrollArea->setFrameStyle(QFrame::NoFrame); +#endif } @@ -125,20 +194,31 @@ void StarDialog::selectFile() { 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"<sizeHint(); + // qDebug()<<"size"<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)); @@ -158,7 +238,6 @@ void StarDialog::saveSettings() { else _settings->setValue("dictFileName", _dictName + ".dict"); } - if(_settings->value("synFileName")=="") if (QFile::exists(_dictName + ".syn") == true) _settings->setValue("synFileName", _dictName + ".syn"); diff --git a/src/plugins/stardict/StarDialog.h b/src/plugins/stardict/StarDialog.h index 3153491..876e341 100644 --- a/src/plugins/stardict/StarDialog.h +++ b/src/plugins/stardict/StarDialog.h @@ -31,6 +31,7 @@ #include #include "../../include/settings.h" #include +#include #include "StarDictPlugin.h" @@ -78,6 +79,11 @@ Q_SIGNALS: //! 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 @@ -86,11 +92,21 @@ public Q_SLOTS: */ 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(); diff --git a/src/plugins/stardict/stardict.png b/src/plugins/stardict/stardict.png deleted file mode 100644 index 19ab37ce4cca9c0a078cd089db002bf4bee32f00..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3768 zcmV;p4oC5cP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igh- z3oHa8qmse^000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}000gXNklG>du~a)U zYVKd}>Avrt^E>DK&UPR0%j^HywP$~Ef8k=w;l&oP?WMtBrgFo&s%Ht|V#$$< z31a8VLz^o-ke)uXojdzBUrbpS4ak8V^M1A2%KiH2sA6=PvDxw;+V@J&ZSOfC^+x_X zix;QxUf{jp@{xc>EBDlU3drtli@%zSq<44`yEGIGj{tX{Lnl>P(i!xAr7&b0B{6I&>4&%1r)@smH3iUmcpsW^UIP@NVy7Z641OHRVSm&@TFmad-ObwPlf9RJ|*xRc(Uq`X@- zx;jo}B$5=Bo&?20ic(pTFDRe^?T(?LqU47wuWkM8ynvh-`_P6?V!s`N`+!+tjT(x1pP*1o zQ7UDMI~M@UEDZ#tsUl4copu04JAfHXVNe4MM4*`&nR&>dFa(1l7gT)|1$b|WB87Jb zKmjTsibhS*r~&7yL~WW77tA}|5=G&M`9k`{inYm{$2fWNcNb1i$6L}+SZW$jF2!BN z1Byk>6gCB*P*sEw5P~5|6(I$HU_w7CT1!CoQ5Ev zG4d&VWQe@N`>uRu;2Jf>OpTbCF-%njjsa1mFAoo=cM$-N9Qch#lcfB>=kFDMAW5CBtx2D1P%^HlcyfDBC_(7gwRnbFL=su55J z7`;ysMTSB?(}|n~7O;J5gknJ-ziM6U{<+XPw0F}_DTVhhd0(7a6oy7ap=t^QC4vGW zkjgCnHH&Rikh37Qs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T8<5 zkU8gE&J_y6a*4?21tNl(8HXc>b2xsYh<2;}Vt?P%2Ue{97DcL`uU6&E!2?B{I_=Pj z1yMemKr20hDCfMv`)qh~5DH*2?|k+1=f5uX!y*m_gA+xm*tG!-?Y5vcBd9k#gv|+Z z@|&YqJoOMsn?1jD)#gV4JaY2zJ-4=6@<^>#xh0otV{jm#r#D5hAanWC42W_-l3>9F z2cnwmi6Ug}1qm}ny#`Frc&HMzi5Dv6tkom zlcjKp3%YPDw+{&JE#|8!yIx!qR;v1{hJX^V-K#q=m(S$LAdcaQoq+AYvIyC%^ z|G1E^&n8ZMd~~`x^LU!}+~s_NkP=s1^PLO#=Gn}6?9fBCV`KMy`4{zPoJ0HW{Hp`I iKGy!_-;&;|*M9+KL~6L4YujA_0000langTo()); 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))); @@ -161,10 +162,6 @@ void XdxfDialog::initializeUI() { _accents = false; } } - if(type == New) - emit setButtonText("Add"); - else - emit setButtonText("Save settings"); #else mainVerticalLayout = new QVBoxLayout; diff --git a/src/plugins/xdxf/xdxf.pro b/src/plugins/xdxf/xdxf.pro index f91a16a..f342bfb 100644 --- a/src/plugins/xdxf/xdxf.pro +++ b/src/plugins/xdxf/xdxf.pro @@ -1,5 +1,7 @@ TARGET = xdxf + include(../plugin.pri) + QT = core \ gui \ xml \ @@ -15,8 +17,8 @@ maemo5 { LIBS += -ltar \ -lbz2 } - maemo5:QT += maemo5 + SOURCES += xdxfplugin.cpp \ TranslationXdxf.cpp \ XdxfDictDialog.cpp \ @@ -27,6 +29,7 @@ SOURCES += xdxfplugin.cpp \ XdxfDictDownloadProgressDialog.cpp \ DictsModel.cpp \ HttpDownloader.cpp + HEADERS += xdxfplugin.h \ TranslationXdxf.h \ ../../include/DictDialog.h \ @@ -43,13 +46,15 @@ HEADERS += xdxfplugin.h \ DictsModel.h \ DictsProxyModel.h \ HttpDownloader.h + RESOURCES += xdxf.qrc + TRANSLATIONS += pl_PL.ts \ - en_US.ts + en_US.ts + OTHER_FILES += \ ../../mdictionary/qml/XdxfDialog.qml - unix { dicts.path = $$PLUGINS_DIR dicts.files += ../../../data/dicts/eng-us.xdxf @@ -75,7 +80,5 @@ unix { qmls } check.commands = echo \ - 'No check here' + 'No check here' QMAKE_EXTRA_TARGETS += check - - -- 1.7.9.5