From: Marcin Kazmierczak Date: Tue, 5 Oct 2010 14:05:31 +0000 (+0200) Subject: Merge branch 'stardict' of ssh://drop.maemo.org/git/mdictionary into stardict X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=8f668304b6b3756a00cf76f695bf475fa39cdae4;hp=046e1632eeab5707f258b523d007b12a300ca0e5;p=mdictionary Merge branch 'stardict' of ssh://drop.maemo.org/git/mdictionary into stardict Conflicts: src/plugins/stardict/StarDialog.cpp --- diff --git a/debian/mdictionary.install b/debian/mdictionary.install index 80cb872..b67ebf1 100644 --- a/debian/mdictionary.install +++ b/debian/mdictionary.install @@ -7,4 +7,4 @@ 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/applications/mdictionary.desktop +usr/share/applications/hildon/mdictionary.desktop diff --git a/src/plugins/stardict/StarDialog.cpp b/src/plugins/stardict/StarDialog.cpp index c8deb1b..b6b4e78 100644 --- a/src/plugins/stardict/StarDialog.cpp +++ b/src/plugins/stardict/StarDialog.cpp @@ -23,6 +23,7 @@ #include "StarDialog.h" #include +#include StarDialog::StarDialog(StarDictPlugin *plugin, StarDialogType type, @@ -180,6 +181,12 @@ void StarDialog::selectFile() { if (!fileName.isEmpty()) { infoLabel->setText(tr("Dictionary file: %1").arg(fileName)); _dictionaryFilePath = fileName; + if (_dictionaryFilePath.endsWith(".tar.bz2")){ + _isCompressed = true; + } + else { + _isCompressed = false; + } updateGeometry(); } } @@ -192,6 +199,12 @@ void StarDialog::saveSettings() { } else { _settings->setValue("path", _dictionaryFilePath); + _settings->setValue("ifoFileName", _dictName + ".ifo"); + _settings->setValue("idxFileName", _dictName + ".idx"); + _settings->setValue("dictFileName", _dictName + ".dict"); + if (QFile::exists(_dictName + ".syn") == true) { + _settings->setValue("synFileName", _dictName + ".syn"); + } } if(_accents) _settings->setValue("strip_accents", "true"); @@ -206,10 +219,32 @@ void StarDialog::accept() { return; } + if(type == New && !_dictionaryFilePath.isEmpty() && !checkFiles()) { + Q_EMIT notify(Notify::Warning, tr("Dictionary files are not complete")); + return; + } + saveSettings(); QDialog::accept(); } +bool StarDialog::checkFiles() { + if (!_isCompressed){ + _dictName = _dictionaryFilePath.left(_dictionaryFilePath.lastIndexOf(".")); + if (QFile::exists(_dictName + ".idx") == false && QFile::exists(_dictName + ".idx.gz") == false) { + return false; + } + if (QFile::exists(_dictName + ".dict") == false && QFile::exists(_dictName + ".dict.dz") == false) { + return false; + } + return true; + } + else { + //TODO: untar files (?) + return false; + } +} + Settings* StarDialog::getSettings() { return _settings; } diff --git a/src/plugins/stardict/StarDialog.h b/src/plugins/stardict/StarDialog.h index 1a15ffa..b87cf0f 100644 --- a/src/plugins/stardict/StarDialog.h +++ b/src/plugins/stardict/StarDialog.h @@ -104,6 +104,7 @@ private: //! saves new settings after acceptance of dialog void saveSettings(); + bool checkFiles(); QLabel* infoLabel; QPushButton* browseButton; @@ -133,6 +134,9 @@ private: bool _accents; bool _lastAccents; + bool _isCompressed; + QString _dictName; + Settings* _settings; StarDictPlugin* plugin; diff --git a/src/plugins/xdxf/XdxfDictDownloader.cpp b/src/plugins/xdxf/XdxfDictDownloader.cpp index 908f1ef..6ae05a6 100644 --- a/src/plugins/xdxf/XdxfDictDownloader.cpp +++ b/src/plugins/xdxf/XdxfDictDownloader.cpp @@ -27,6 +27,8 @@ #include "XdxfDictDownloader.h" #include "XdxfDictDownloadProgressDialog.h" #include +#include + #include #include @@ -211,6 +213,7 @@ bool XdxfDictDownloader::extract(QString file) { fclose(archive); // Extracting tar + #ifndef Q_WS_MAEMO_5 TAR *t; char * tarfname = new char[file.replace(QRegExp(".bz2%"), "").size()+1]; strcpy(tarfname, file.replace(QRegExp(".bz2%"), "").toStdString().c_str()); @@ -224,6 +227,11 @@ bool XdxfDictDownloader::extract(QString file) { return false; } tar_close(t); + #else + QProcess tar; + tar.start("tar -xvf " + file.replace(QRegExp(".bz2%"), "") + " -C /tmp/mdict"); + tar.waitForFinished(-1); + #endif return true; }