summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-06-07 20:01:10 +0000
committercraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-06-07 20:01:10 +0000
commit1ae91cf9fdb1dc8292404bf2d6c58384f0557eda (patch)
tree93f0ed17416cd4e6aca7803f3a7efbffb476b317
parent1b786f099b838cf42237bf7b18b9615f858673b3 (diff)
downloadscribus-1ae91cf9fdb1dc8292404bf2d6c58384f0557eda.tar.gz
scribus-1ae91cf9fdb1dc8292404bf2d6c58384f0557eda.tar.xz
scribus-1ae91cf9fdb1dc8292404bf2d6c58384f0557eda.zip
Add in dictionary downloader code, updates to downloader threading and add in GUI to hyphenator preferences for downloading
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17542 11d20701-8431-0410-a711-e3c959e3b870
-rw-r--r--scribus/CMakeLists.txt7
-rw-r--r--scribus/downloadmanager/scdlthread.cpp1
-rw-r--r--scribus/hysettings.cpp212
-rw-r--r--scribus/hysettings.h28
-rw-r--r--scribus/hysettingsBase.ui647
-rw-r--r--scribus/langmgr.cpp36
-rw-r--r--scribus/langmgr.h2
-rw-r--r--scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp40
-rw-r--r--scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h3
-rw-r--r--scribus/prefs.cpp2
-rw-r--r--scribus/reformdoc.cpp3
-rw-r--r--scribus/scribusapp.cpp14
-rw-r--r--scribus/scribusapp.h11
-rw-r--r--scribus/ui/downloaddictionaries.cpp184
-rw-r--r--scribus/ui/downloaddictionaries.h56
-rw-r--r--scribus/ui/downloaddictionaries.ui73
16 files changed, 984 insertions, 335 deletions
diff --git a/scribus/CMakeLists.txt b/scribus/CMakeLists.txt
index dcd7e10..8503d6c 100644
--- a/scribus/CMakeLists.txt
+++ b/scribus/CMakeLists.txt
@@ -62,6 +62,7 @@ SET(SCRIBUS_UI_SRC
tocindexprefs.ui
ui/copypagetomasterpage.ui
ui/createrange.ui
+ ui/downloaddictionaries.ui
ui/helpbrowser.ui
unicodesearch.ui
useprintermarginsdialog.ui
@@ -118,6 +119,8 @@ SET(SCRIBUS_MOC_CLASSES
docinfo.h
docitemattrprefs.h
docsections.h
+ downloadmanager/scdlmgr.h
+ downloadmanager/scdlthread.h
editor.h
effectsdialog.h
extimageprops.h
@@ -278,6 +281,7 @@ SET(SCRIBUS_MOC_CLASSES
tt/simpletreemodel/treemodel.h
ui/copypagetomasterpagedialog.h
ui/createrange.h
+ ui/downloaddictionaries.h
ui/edittoolbar.h
ui/filetoolbar.h
ui/modetoolbar.h
@@ -364,6 +368,8 @@ SET(SCRIBUS_SOURCES
docsections.cpp
documentchecker.cpp
documentinformation.cpp
+ downloadmanager/scdlmgr.cpp
+ downloadmanager/scdlthread.cpp
editor.cpp
effectsdialog.cpp
exif.cpp
@@ -602,6 +608,7 @@ SET(SCRIBUS_SOURCES
tt/simpletreemodel/treemodel.cpp
ui/copypagetomasterpagedialog.cpp
ui/createrange.cpp
+ ui/downloaddictionaries.cpp
ui/edittoolbar.cpp
ui/filetoolbar.cpp
ui/modetoolbar.cpp
diff --git a/scribus/downloadmanager/scdlthread.cpp b/scribus/downloadmanager/scdlthread.cpp
index 5be2c15..a2a12ac 100644
--- a/scribus/downloadmanager/scdlthread.cpp
+++ b/scribus/downloadmanager/scdlthread.cpp
@@ -98,6 +98,7 @@ void ScDLThread::startNextDownload()
if (downloadQueue.isEmpty())
{
qDebug()<<downloadedCount<<"/"<<totalCount<<"files downloaded successfully";
+ downloadedCount=totalCount=0;
emit finished();
return;
}
diff --git a/scribus/hysettings.cpp b/scribus/hysettings.cpp
index 27dc7b0..edd7cf1 100644
--- a/scribus/hysettings.cpp
+++ b/scribus/hysettings.cpp
@@ -4,31 +4,37 @@ to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
+#include "fileunzip.h"
#include "hysettings.h"
#include "hyphenator.h"
#include "langmgr.h"
+#include "scribusapp.h"
#include "scribusdoc.h"
#include "util_icon.h"
#include "util.h"
-#include "QHeaderView"
+#include "ui/downloaddictionaries.h"
+#include "scpaths.h"
+#include <QDomDocument>
+#include <QHeaderView>
#include <QInputDialog>
+#include <QTableWidgetItem>
-HySettings::HySettings( QWidget* parent/*, QMap<QString,QString>* langs*/ ) : QWidget( parent )
+extern ScribusQApp* ScQApp;
+
+HySettings::HySettings( QWidget* parent) : QWidget( parent )
{
-// langsMap = *langs;
+
setupUi(this);
-// QMap<QString,QString>::Iterator it;
-// QStringList lada;
-// for (it = langs->begin(); it != langs->end(); ++it)
-// lada.append(it.value());
-// lada.sort();
-// language->addItems(lada);
+
+ downloadLocation=ScPaths::downloadDir();
LanguageManager *lmg(LanguageManager::instance());
language->setInsertPolicy(QComboBox::InsertAlphabetically);
foreach(QString hlang, lmg->hyphLangs())
{
language->addItem( lmg->getLangFromAbbrev(hlang), lmg->getLangFromAbbrev(hlang,false) );
}
+ updateDictList();
+ setAvailDictsXMLFile(downloadLocation + "scribus_spell_dicts.xml");
buttonExceptAdd->setIcon(QIcon(loadIcon("16/list-add.png")));
buttonExceptEdit->setEnabled(false);
@@ -46,6 +52,8 @@ HySettings::HySettings( QWidget* parent/*, QMap<QString,QString>* langs*/ ) : QW
connect(buttonExceptEdit, SIGNAL(clicked()), this, SLOT(editExceptListEntry()));
connect(buttonExceptRemove, SIGNAL(clicked()), this, SLOT(removeExceptListEntry()));
connect(exceptList, SIGNAL(itemSelectionChanged()), this, SLOT(enableExceptButtons()));
+ connect(spellDownloadButton, SIGNAL(clicked()), this, SLOT(downloadSpellDicts()));
+ connect(availListDownloadButton, SIGNAL(clicked()), this, SLOT(updateAvailDictList()));
}
void HySettings::restoreDefaults(struct ApplicationPrefs *prefsData)
@@ -156,6 +164,187 @@ void HySettings::enableExceptButtons()
buttonExceptRemove->setEnabled(true);
}
+void HySettings::downloadSpellDicts()
+{
+ qDebug()<<"Now attempting downloads";
+ int rows=availDictTableWidget->rowCount();
+ QStringList dlLangs;
+ for (int i=0; i<rows; ++i)
+ {
+ QTableWidgetItem *dlItem=availDictTableWidget->item(i,3);
+ if (dlItem->checkState()==Qt::Checked)
+ dlLangs<<availDictTableWidget->item(i,1)->text();
+ }
+ qDebug()<<dlLangs;
+ int i=0;
+ downloadList.clear();
+ foreach(DictData d, dictList)
+ {
+ if (dlLangs.contains(d.lang))
+ {
+ ScQApp->dlManager()->addURL(d.url, true, downloadLocation);
+ downloadList.append(d);
+ ++i;
+ }
+ }
+ if (i>0)
+ {
+ connect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadSpellDictsFinished()));
+ ScQApp->dlManager()->startDownloads();
+ }
+}
+
+void HySettings::updateDictList()
+{
+ bool dictsFound=LanguageManager::instance()->findDictionaries(dictionaryPaths);
+ if (!dictsFound)
+ return;
+ dictionaryMap.clear();
+ LanguageManager::instance()->findDictionarySets(dictionaryPaths, dictionaryMap);
+
+ dictTableWidget->clear();
+ dictTableWidget->setRowCount(dictionaryMap.count());
+ dictTableWidget->setColumnCount(3);
+ QMapIterator<QString, QString> i(dictionaryMap);
+ int row=0;
+ while (i.hasNext())
+ {
+ i.next();
+ int column=0;
+ //qDebug()<<i.key()<<i.value();
+ QTableWidgetItem *newItem1 = new QTableWidgetItem(LanguageManager::instance()->getLangFromAbbrev(i.key()));
+ newItem1->setFlags(newItem1->flags() & ~Qt::ItemIsEditable);
+ dictTableWidget->setItem(row, column++, newItem1);
+ QTableWidgetItem *newItem2 = new QTableWidgetItem(i.key());
+ newItem2->setFlags(newItem1->flags());
+ dictTableWidget->setItem(row, column++, newItem2);
+ QTableWidgetItem *newItem3 = new QTableWidgetItem(i.value());
+ newItem3->setFlags(newItem1->flags());
+ newItem3->setToolTip(i.value());
+ dictTableWidget->setItem(row, column++, newItem3);
+ ++row;
+ }
+ QStringList headers;
+ headers << tr("Language") << tr("Code") << tr("Location");
+ dictTableWidget->setHorizontalHeaderLabels(headers);
+ dictTableWidget->resizeColumnsToContents();
+}
+
+void HySettings::updateAvailDictList()
+{
+ ScQApp->dlManager()->addURL("http://services.scribus.net/scribus_spell_dicts.xml", true, downloadLocation);
+ connect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadDictListFinished()));
+ ScQApp->dlManager()->startDownloads();
+}
+
+void HySettings::downloadDictListFinished()
+{
+ disconnect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadDictListFinished()));
+ setAvailDictsXMLFile(downloadLocation + "scribus_spell_dicts.xml");
+}
+
+void HySettings::downloadSpellDictsFinished()
+{
+ disconnect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadDictListFinished()));
+ //qDebug()<<"Downloads All Finished";
+ QString userDictDir(ScPaths::getUserDictDir(true));
+ foreach(DictData d, downloadList)
+ {
+ QString basename = QFileInfo(d.url).fileName();
+ QString filename=downloadLocation+"/"+basename;
+ //qDebug()<<filename;
+ FileUnzip* fun = new FileUnzip(filename);
+ QStringList files=d.files.split(";", QString::SkipEmptyParts);
+ foreach (QString s, files)
+ {
+ qDebug()<<"Unzipping"<<userDictDir+s;
+ QString data=fun->getFile(s, userDictDir);
+ }
+ delete fun;
+ }
+ updateDictList();
+}
+
+void HySettings::setAvailDictsXMLFile(QString availDictsXMLDataFile)
+{
+ QFile dataFile(availDictsXMLDataFile);
+ dataFile.open(QIODevice::ReadOnly);
+ QTextStream ts(&dataFile);
+ ts.setCodec(QTextCodec::codecForName("UTF-8"));
+ QString errorMsg;
+ int eline;
+ int ecol;
+ QDomDocument doc( "scribus_spell_dicts" );
+ QString data(ts.readAll());
+ dataFile.close();
+ if ( !doc.setContent( data, &errorMsg, &eline, &ecol ))
+ {
+ if (data.toLower().contains("404 not found"))
+ qDebug()<<"File not found on server";
+ else
+ qDebug()<<"Could not open file"<<availDictsXMLDataFile;
+ return;
+ }
+ dictList.clear();
+ QDomElement docElem = doc.documentElement();
+ QDomNode n = docElem.firstChild();
+ while( !n.isNull() ) {
+ QDomElement e = n.toElement();
+ if( !e.isNull() ) {
+ if (e.tagName()=="dictionary")
+ {
+ if (e.hasAttribute("type"))
+ {
+ if (e.attribute("type")=="spell")
+ {
+ struct DictData d;
+ d.desc=e.attribute("description");
+ d.download=false;
+ d.files=e.attribute("files");
+ d.url=e.attribute("URL");
+ d.version=e.attribute("version");
+ d.lang=e.attribute("language");
+ d.license=e.attribute("license");
+ QUrl url(d.url);
+ if (url.isValid() && !url.isEmpty() && !url.host().isEmpty())
+ dictList.append(d);
+ else
+ qDebug()<<"hysettings : availDicts : invalid URL"<<d.url;
+ }
+ }
+ }
+ }
+ n = n.nextSibling();
+ }
+ availDictTableWidget->clear();
+ availDictTableWidget->setRowCount(dictList.count());
+ availDictTableWidget->setColumnCount(4);
+ int row=0;
+ foreach(DictData d, dictList)
+ {
+ int column=0;
+ //qDebug()<<d.version<<d.files<<d.url<<d.desc<<d.license;
+ QTableWidgetItem *newItem1 = new QTableWidgetItem(d.desc);
+ newItem1->setFlags(newItem1->flags() & ~Qt::ItemIsEditable);
+ availDictTableWidget->setItem(row, column++, newItem1);
+ QTableWidgetItem *newItem2 = new QTableWidgetItem(d.lang);
+ newItem2->setFlags(newItem1->flags());
+ availDictTableWidget->setItem(row, column++, newItem2);
+ QTableWidgetItem *newItem3 = new QTableWidgetItem();
+ newItem3->setCheckState(dictionaryMap.contains(d.lang) ? Qt::Checked : Qt::Unchecked);
+ newItem3->setFlags(newItem1->flags() & ~Qt::ItemIsUserCheckable);
+ availDictTableWidget->setItem(row, column++, newItem3);
+ QTableWidgetItem *newItem4 = new QTableWidgetItem();
+ newItem4->setCheckState(d.download ? Qt::Checked : Qt::Unchecked);
+ availDictTableWidget->setItem(row, column++, newItem4);
+ ++row;
+ }
+ QStringList headers;
+ headers << tr("Language") << tr("Code") << tr("Installed") << tr("Download");
+ availDictTableWidget->setHorizontalHeaderLabels(headers);
+ availDictTableWidget->resizeColumnsToContents();
+}
+
int HySettings::getWordLen()
{
return wordLen->value();
@@ -200,3 +389,8 @@ QHash<QString, QString> HySettings::getExceptionList()
}
return ret;
}
+
+void HySettings::setSpellingInvisible()
+{
+ tabWidget->removeTab(1);
+}
diff --git a/scribus/hysettings.h b/scribus/hysettings.h
index 6b0541a..acc5a41 100644
--- a/scribus/hysettings.h
+++ b/scribus/hysettings.h
@@ -17,10 +17,22 @@ class ScribusDoc;
class SCRIBUS_API HySettings : public QWidget, Ui::hysettingsBase
{
+ //TODO: Dict license showing, URL background unzipping, checksumming
+ struct DictData
+ {
+ QString lang;
+ QString version;
+ QString files;
+ QString url;
+ QString desc;
+ QString license;
+ bool download;
+ };
+
Q_OBJECT
public:
- HySettings( QWidget* parent/*, QMap<QString,QString>* langs*/);
+ HySettings( QWidget* parent);
~HySettings() {};
void restoreDefaults(struct ApplicationPrefs *prefsData);
void restoreDefaults(ScribusDoc *prefsData);
@@ -31,6 +43,7 @@ public:
QString getLanguage();
QSet<QString> getIgnoreList();
QHash<QString, QString> getExceptionList();
+ void setSpellingInvisible();
private slots:
void addToIgnoreList();
@@ -41,8 +54,19 @@ private slots:
void editExceptListEntry();
void removeExceptListEntry();
void enableExceptButtons();
+ void downloadSpellDicts();
+ void updateDictList();
+ void updateAvailDictList();
+ void downloadDictListFinished();
+ void downloadSpellDictsFinished();
+ void setAvailDictsXMLFile(QString availDictsXMLDataFile);
-// protected:
+ protected:
+ QMap<QString, QString> dictionaryMap;
+ QStringList dictionaryPaths;
+ QString downloadLocation;
+ QList <DictData> dictList;
+ QList <DictData> downloadList;
// QMap<QString,QString> langsMap;
};
diff --git a/scribus/hysettingsBase.ui b/scribus/hysettingsBase.ui
index dacb176..f1b8942 100644
--- a/scribus/hysettingsBase.ui
+++ b/scribus/hysettingsBase.ui
@@ -1,306 +1,385 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>hysettingsBase</class>
- <widget class="QWidget" name="hysettingsBase" >
- <property name="geometry" >
+ <widget class="QWidget" name="hysettingsBase">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>593</width>
- <height>444</height>
+ <width>720</width>
+ <height>445</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QGridLayout" >
- <property name="leftMargin" >
+ <layout class="QGridLayout">
+ <property name="margin">
<number>10</number>
</property>
- <property name="topMargin" >
- <number>10</number>
- </property>
- <property name="rightMargin" >
- <number>10</number>
- </property>
- <property name="bottomMargin" >
- <number>10</number>
- </property>
- <property name="horizontalSpacing" >
- <number>5</number>
- </property>
- <property name="verticalSpacing" >
+ <property name="spacing">
<number>5</number>
</property>
- <item row="0" column="0" >
- <widget class="QGroupBox" name="groupBox" >
- <property name="title" >
- <string>General Options</string>
+ <item row="0" column="0">
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="tabShape">
+ <enum>QTabWidget::Rounded</enum>
</property>
- <layout class="QVBoxLayout" >
- <property name="spacing" >
- <number>5</number>
- </property>
- <property name="leftMargin" >
- <number>10</number>
- </property>
- <property name="topMargin" >
- <number>10</number>
- </property>
- <property name="rightMargin" >
- <number>10</number>
- </property>
- <property name="bottomMargin" >
- <number>10</number>
- </property>
- <item>
- <widget class="QCheckBox" name="verbose" >
- <property name="toolTip" >
- <string>A dialog box showing all possible hyphens for each word will show up when you use the Extras, Hyphenate Text option.</string>
- </property>
- <property name="text" >
- <string>&amp;Hyphenation Suggestions</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="input" >
- <property name="toolTip" >
- <string>Enables automatic hyphenation of your text while typing.</string>
- </property>
- <property name="text" >
- <string>Hyphenate Text Automatically &amp;During Typing</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QGroupBox" name="groupBox_4" >
- <property name="title" >
- <string>Behaviour</string>
+ <property name="currentIndex">
+ <number>0</number>
</property>
- <layout class="QGridLayout" >
- <property name="leftMargin" >
- <number>10</number>
- </property>
- <property name="topMargin" >
- <number>10</number>
- </property>
- <property name="rightMargin" >
- <number>10</number>
- </property>
- <property name="bottomMargin" >
- <number>10</number>
- </property>
- <property name="horizontalSpacing" >
- <number>5</number>
- </property>
- <property name="verticalSpacing" >
- <number>5</number>
- </property>
- <item row="0" column="0" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>&amp;Language:</string>
- </property>
- <property name="buddy" >
- <cstring>language</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="3" >
- <widget class="QComboBox" name="language" />
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>&amp;Smallest Word:</string>
- </property>
- <property name="buddy" >
- <cstring>wordLen</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QSpinBox" name="wordLen" >
- <property name="toolTip" >
- <string>Length of the smallest word to be hyphenated.</string>
- </property>
- <property name="minimum" >
- <number>3</number>
- </property>
- </widget>
- </item>
- <item row="1" column="2" colspan="2" >
- <widget class="QLabel" name="label_3" >
- <property name="text" >
- <string>Chars</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="3" >
- <widget class="QLabel" name="label_4" >
- <property name="text" >
- <string>Consecutive Hyphenations &amp;Allowed:</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
- <property name="buddy" >
- <cstring>maxCount</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="3" >
- <widget class="QSpinBox" name="maxCount" >
- <property name="toolTip" >
- <string>Maximum number of Hyphenations following each other.
+ <widget class="QWidget" name="hyphenationTab">
+ <attribute name="title">
+ <string>Hyphenation</string>
+ </attribute>
+ <layout class="QGridLayout" name="hyphGridLayout">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>General Options</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <property name="margin">
+ <number>10</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="verbose">
+ <property name="toolTip">
+ <string>A dialog box showing all possible hyphens for each word will show up when you use the Extras, Hyphenate Text option.</string>
+ </property>
+ <property name="text">
+ <string>&amp;Hyphenation Suggestions</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="input">
+ <property name="toolTip">
+ <string>Enables automatic hyphenation of your text while typing.</string>
+ </property>
+ <property name="text">
+ <string>Hyphenate Text Automatically &amp;During Typing</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QGroupBox" name="groupBox_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Behaviour</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>10</number>
+ </property>
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>&amp;Language:</string>
+ </property>
+ <property name="buddy">
+ <cstring>language</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="3">
+ <widget class="QComboBox" name="language"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>&amp;Smallest Word:</string>
+ </property>
+ <property name="buddy">
+ <cstring>wordLen</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="wordLen">
+ <property name="toolTip">
+ <string>Length of the smallest word to be hyphenated.</string>
+ </property>
+ <property name="minimum">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" colspan="2">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Chars</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="3">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Consecutive Hyphenations &amp;Allowed:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="buddy">
+ <cstring>maxCount</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QSpinBox" name="maxCount">
+ <property name="toolTip">
+ <string>Maximum number of Hyphenations following each other.
A value of 0 means unlimited hyphenations.</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QGroupBox" name="groupBox_2" >
- <property name="title" >
- <string>Exceptions</string>
- </property>
- <layout class="QGridLayout" >
- <property name="leftMargin" >
- <number>10</number>
- </property>
- <property name="topMargin" >
- <number>10</number>
- </property>
- <property name="rightMargin" >
- <number>10</number>
- </property>
- <property name="bottomMargin" >
- <number>10</number>
- </property>
- <property name="horizontalSpacing" >
- <number>5</number>
- </property>
- <property name="verticalSpacing" >
- <number>5</number>
- </property>
- <item row="0" column="0" colspan="4" >
- <widget class="QListWidget" name="exceptList" />
- </item>
- <item row="1" column="0" >
- <widget class="QPushButton" name="buttonExceptAdd" >
- <property name="text" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QPushButton" name="buttonExceptEdit" >
- <property name="text" >
- <string>Edit</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2" >
- <widget class="QPushButton" name="buttonExceptRemove" >
- <property name="text" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="3" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QGroupBox" name="groupBox_3" >
- <property name="title" >
- <string>Ignore List</string>
- </property>
- <layout class="QGridLayout" >
- <property name="leftMargin" >
- <number>10</number>
- </property>
- <property name="topMargin" >
- <number>10</number>
- </property>
- <property name="rightMargin" >
- <number>10</number>
- </property>
- <property name="bottomMargin" >
- <number>10</number>
- </property>
- <property name="horizontalSpacing" >
- <number>5</number>
- </property>
- <property name="verticalSpacing" >
- <number>5</number>
- </property>
- <item row="0" column="0" colspan="4" >
- <widget class="QListWidget" name="ignoreList" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="Preferred" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QPushButton" name="buttonIgnoreAdd" >
- <property name="text" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QPushButton" name="buttonIgnoreEdit" >
- <property name="text" >
- <string>Edit</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2" >
- <widget class="QPushButton" name="buttonIgnoreRemove" >
- <property name="text" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="3" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>21</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Exceptions</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>10</number>
+ </property>
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <item row="0" column="0" colspan="4">
+ <widget class="QListWidget" name="exceptList"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="buttonExceptAdd">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="buttonExceptEdit">
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QPushButton" name="buttonExceptRemove">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Ignore List</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>10</number>
+ </property>
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <item row="0" column="0" colspan="4">
+ <widget class="QListWidget" name="ignoreList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="buttonIgnoreAdd">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="buttonIgnoreEdit">
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QPushButton" name="buttonIgnoreRemove">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="spellingTab">
+ <attribute name="title">
+ <string>Spelling</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Installed Spelling Dictionaries</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTableWidget" name="dictTableWidget">
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Downloadable Spelling Dictionaries</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTableWidget" name="availDictTableWidget">
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="availListDownloadButton">
+ <property name="text">
+ <string>Refresh Downloadable List</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="spellDownloadButton">
+ <property name="text">
+ <string>Download Selected Dictionaries</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>
</widget>
- <layoutdefault spacing="5" margin="10" />
+ <layoutdefault spacing="5" margin="10"/>
<resources/>
<connections/>
</ui>
diff --git a/scribus/langmgr.cpp b/scribus/langmgr.cpp
index f19832b..7f13ed3 100644
--- a/scribus/langmgr.cpp
+++ b/scribus/langmgr.cpp
@@ -20,7 +20,7 @@ for which a new license (GPL+exception) is in place.
***************************************************************************/
#include <iostream>
-
+#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QMap>
@@ -302,6 +302,40 @@ QString LanguageManager::numericSequence(QString seq)
return retSeq;
}
+bool LanguageManager::findDictionaries(QStringList &sl)
+{
+ sl=ScPaths::instance().spellDirs();
+ if (sl.count()==0)
+ return false;
+ return true;
+}
+
+void LanguageManager::findDictionarySets(QStringList &dictionaryPaths, QMap<QString, QString> &dictionaryMap)
+{
+ for (int i=0; i<dictionaryPaths.count(); ++i)
+ {
+ // Find the dic and aff files in the location
+ QDir dictLocation(dictionaryPaths.at(i));
+ QStringList dictFilters("*.dic");
+ QStringList dictList(dictLocation.entryList(dictFilters, QDir::Files, QDir::Name));
+ dictList.replaceInStrings(".dic","");
+
+ //Ensure we have aff+dic file pairs, remove any hyphenation dictionaries from the list
+ QString dictName;
+ foreach(dictName, dictList)
+ {
+ if (!QFile::exists(dictionaryPaths.at(i)+dictName+".aff"))
+ dictList.removeAll(dictName);
+ else
+ {
+ if (!dictionaryMap.contains(dictName))
+ dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dictName);
+ }
+ }
+// qDebug()<<"Number of dictionaries/AFFs found in"<<dictionaryPaths.at(i)<<":"<<dictList.count();
+ }
+}
+
LanguageManager::~LanguageManager()
{
langList.clear();
diff --git a/scribus/langmgr.h b/scribus/langmgr.h
index a1335c8..82492e7 100644
--- a/scribus/langmgr.h
+++ b/scribus/langmgr.h
@@ -50,6 +50,8 @@ public:
void fillInstalledStringList(QStringList *stringListToFill, bool addDefaults);
void printInstalledList();
QString numericSequence(QString seq);
+ bool findDictionaries(QStringList& sl);
+ void findDictionarySets(QStringList& dictionaryPaths, QMap<QString, QString>& dictionaryMap);
void addHyphLang(const QString& lang, const QString& filename);
const QString getHyphFilename(const QString& lang, bool langIsAbbreviated = true);
diff --git a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
index be5cfda..2ff9493 100644
--- a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
+++ b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
@@ -32,7 +32,7 @@ for which a new license (GPL+exception) is in place.
HunspellPluginImpl::HunspellPluginImpl() : QObject(0)
{
//hspellers=NULL;
- numDicts=0;
+// numDicts=0;
m_runningForSE=false;
m_SE=NULL;
}
@@ -45,7 +45,7 @@ HunspellPluginImpl::~HunspellPluginImpl()
h = NULL;
}
hspellerMap.clear();
- numDicts = 0;
+// numDicts = 0;
}
bool HunspellPluginImpl::run(const QString & target, ScribusDoc* doc)
@@ -62,45 +62,17 @@ bool HunspellPluginImpl::run(const QString & target, ScribusDoc* doc)
return spellCheckOk;
}
-bool HunspellPluginImpl::findDictionaries()
-{
- dictionaryPaths=ScPaths::instance().spellDirs();
- if (dictionaryPaths.count()==0)
- return false;
- return true;
-}
-
bool HunspellPluginImpl::initHunspell()
{
- bool dictPathFound=findDictionaries();
+ bool dictPathFound=LanguageManager::instance()->findDictionaries(dictionaryPaths);
if (!dictPathFound)
{
qDebug()<<"No preinstalled dictonary paths found";
return false;
}
- for (int i=0; i<dictionaryPaths.count(); ++i)
- {
- // Find the dic and aff files in the location
- QDir dictLocation(dictionaryPaths.at(i));
- QStringList dictFilters("*.dic");
- QStringList dictList(dictLocation.entryList(dictFilters, QDir::Files, QDir::Name));
- dictList.replaceInStrings(".dic","");
-
- //Ensure we have aff+dic file pairs, remove any hyphenation dictionaries from the list
- QString dictName;
- foreach(dictName, dictList)
- {
- if (!QFile::exists(dictionaryPaths.at(i)+dictName+".aff"))
- dictList.removeAll(dictName);
- else
- {
- if (!dictionaryMap.contains(dictName))
- dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dictName);
- }
- }
- qDebug()<<"Number of dictionaries/AFFs found in"<<dictionaryPaths.at(i)<<":"<<dictList.count();
- }
- numDicts=dictionaryMap.count();
+ dictionaryMap.clear();
+ LanguageManager::instance()->findDictionarySets(dictionaryPaths, dictionaryMap);
+// numDicts=dictionaryMap.count();
if (dictionaryMap.count()==0)
return false;
diff --git a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
index 7963d4a..3048636 100644
--- a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
+++ b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
@@ -30,7 +30,6 @@ class HunspellPluginImpl : public QObject
HunspellPluginImpl();
~HunspellPluginImpl();
bool run(const QString & target, ScribusDoc* doc=0);
- bool findDictionaries();
bool initHunspell();
bool checkWithHunspell();
bool checkWithHunspellSE();
@@ -43,7 +42,7 @@ class HunspellPluginImpl : public QObject
protected:
QMap<QString, QString> dictionaryMap;
QStringList dictionaryPaths;
- int numDicts, numAFFs;
+ //int numDicts, numAFFs;
QMap<QString, Hunspell*> hspellerMap;
ScribusDoc* m_doc;
bool m_runningForSE;
diff --git a/scribus/prefs.cpp b/scribus/prefs.cpp
index 30609bb..88eb0a8 100644
--- a/scribus/prefs.cpp
+++ b/scribus/prefs.cpp
@@ -87,7 +87,7 @@ Preferences::Preferences( QWidget* parent) : PrefsDialogBase( parent )
addItem( tr("Tools"), loadIcon("tools.png"), tabTools);
tabHyphenator = new HySettings(prefsWidgets/*, &ap->LangTransl*/);
- addItem( tr("Hyphenator"), loadIcon("hyphenate.png"), tabHyphenator);
+ addItem( tr("Hyphenation and Spelling"), loadIcon("hyphenate.png"), tabHyphenator);
tabFonts = new FontPrefs(prefsWidgets, false, prefsManager->preferencesLocation(), ap->doc);
addItem( tr("Fonts"), loadIcon("font.png"), tabFonts);
diff --git a/scribus/reformdoc.cpp b/scribus/reformdoc.cpp
index a4bc3a0..4d1e2c5 100644
--- a/scribus/reformdoc.cpp
+++ b/scribus/reformdoc.cpp
@@ -80,7 +80,8 @@ ReformDoc::ReformDoc( QWidget* parent, ScribusDoc* doc ) : PrefsDialogBase( pare
tabTools = new TabTools( prefsWidgets, &doc->toolSettings, docUnitIndex, doc);
addItem( tr("Tools"), loadIcon("tools.png"), tabTools);
- tabHyphenator = new HySettings(prefsWidgets/*, &ScMW->LangTransl*/);
+ tabHyphenator = new HySettings(prefsWidgets);
+ tabHyphenator->setSpellingInvisible();
addItem( tr("Hyphenator"), loadIcon("hyphenate.png"), tabHyphenator);
tabFonts = new FontPrefs(prefsWidgets, true, PrefsManager::instance()->preferencesLocation(), doc);
diff --git a/scribus/scribusapp.cpp b/scribus/scribusapp.cpp
index b725217..82582d1 100644
--- a/scribus/scribusapp.cpp
+++ b/scribus/scribusapp.cpp
@@ -94,10 +94,13 @@ ScribusQApp::ScribusQApp( int & argc, char ** argv ) : QApplication(argc, argv),
{
ScQApp=this;
ScCore=NULL;
+
+ initDLMgr();
}
ScribusQApp::~ScribusQApp()
{
+ m_scDLMgr->deleteLater();
PrefsManager::deleteInstance();
}
@@ -109,6 +112,12 @@ void ScribusQApp::initLang()
installTranslators(langs);
}
+void ScribusQApp::initDLMgr()
+{
+ m_scDLMgr=new ScDLManager(this);
+ connect(m_scDLMgr, SIGNAL(fileReceived(const QString&)), SLOT(downloadComplete(const QString&)));
+}
+
void ScribusQApp::parseCommandLine()
{
showSplash=!neverSplashExists();
@@ -502,6 +511,11 @@ bool ScribusQApp::neverSplashExists()
return QFileInfo(ScPaths::getApplicationDataDir() + ".neversplash").exists();
}
+void ScribusQApp::downloadComplete(const QString &t)
+{
+ qDebug()<<"ScribusQApp: download finished:"<<t;
+}
+
bool ScribusQApp::event(QEvent *event)
{
switch (event->type())
diff --git a/scribus/scribusapp.h b/scribus/scribusapp.h
index 65d07aa..9048328 100644
--- a/scribus/scribusapp.h
+++ b/scribus/scribusapp.h
@@ -25,6 +25,7 @@ for which a new license (GPL+exception) is in place.
#include <QString>
#include "scribusapi.h"
+#include "downloadmanager/scdlmgr.h"
class ScribusCore;
class ScribusMainWindow;
@@ -36,7 +37,6 @@ class SCRIBUS_API ScribusQApp : public QApplication
ScribusQApp( int & argc, char ** argv );
~ScribusQApp();
int init();
- void initLang();
void parseCommandLine();
void changeGUILanguage(const QString & lang);
/*!
@@ -66,9 +66,17 @@ class SCRIBUS_API ScribusQApp : public QApplication
void neverSplash(bool splashOff);
bool neverSplashExists();
const QString& currGUILanguage() {return GUILang;};
+ ScDLManager* dlManager() { return m_scDLMgr; }
+
+ public slots:
+
+ protected slots:
+ void downloadComplete(const QString& t);
private:
ScribusCore* m_ScCore;
+ void initLang();
+ void initDLMgr();
void showHeader();
void showVersion();
/*!
@@ -95,6 +103,7 @@ class SCRIBUS_API ScribusQApp : public QApplication
QString prefsUserFile;
QList<QString> filesToLoad;
QString fileName;
+ ScDLManager *m_scDLMgr;
protected:
virtual bool event(QEvent *event);
diff --git a/scribus/ui/downloaddictionaries.cpp b/scribus/ui/downloaddictionaries.cpp
new file mode 100644
index 0000000..db990e9
--- /dev/null
+++ b/scribus/ui/downloaddictionaries.cpp
@@ -0,0 +1,184 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+#include "downloaddictionaries.h"
+
+#include "fileunzip.h"
+#include "scpaths.h"
+#include "scribusapp.h"
+#include <QDebug>
+#include <QDomDocument>
+#include <QFile>
+#include <QFileInfo>
+#include <QLabel>
+#include <QListWidget>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QString>
+#include <QTableWidgetItem>
+#include <QTextCodec>
+#include <QTextStream>
+
+
+extern ScribusQApp* ScQApp;
+
+DownloadDictionaries::DownloadDictionaries(QWidget* parent, Qt::WFlags fl)
+ : QDialog(parent, fl)
+{
+ setupUi(this);
+ downloadLocation=ScPaths::downloadDir();
+
+ connect(closeButton, SIGNAL(clicked()), SLOT(close()));
+ connect(downloadButton, SIGNAL(clicked()), SLOT(download()));
+ connect(downloadListButton, SIGNAL(clicked()), SLOT(downloadDictList()));
+}
+
+DownloadDictionaries::~DownloadDictionaries()
+{
+}
+
+void DownloadDictionaries::setXMLFile(const QString &f)
+{
+ m_xmlDataFile=f;
+ parseData();
+}
+
+void DownloadDictionaries::parseData()
+{
+ QFile dataFile(m_xmlDataFile);
+ dataFile.open(QIODevice::ReadOnly);
+ QTextStream ts(&dataFile);
+ ts.setCodec(QTextCodec::codecForName("UTF-8"));
+ QString errorMsg;
+ int eline;
+ int ecol;
+ QDomDocument doc( "scribus_spell_dicts" );
+ QString data(ts.readAll());
+ dataFile.close();
+ if ( !doc.setContent( data, &errorMsg, &eline, &ecol ))
+ {
+ if (data.toLower().contains("404 not found"))
+ qDebug()<<"File not found on server";
+ else
+ qDebug()<<"Could not open file"<<m_xmlDataFile;
+ return;
+ }
+// qDebug()<<"opened"<<m_xmlDataFile<<"for reading ok";
+ QDomElement docElem = doc.documentElement();
+ QDomNode n = docElem.firstChild();
+ while( !n.isNull() ) {
+ QDomElement e = n.toElement();
+ if( !e.isNull() ) {
+ if (e.tagName()=="dictionary")
+ {
+ if (e.hasAttribute("type"))
+ {
+ if (e.attribute("type")=="spell")
+ {
+ struct DictData d;
+ d.desc=e.attribute("description");
+ d.download=false;
+ d.files=e.attribute("files");
+ d.url=e.attribute("URL");
+ d.version=e.attribute("version");
+ d.lang=e.attribute("language");
+ d.license=e.attribute("license");
+ dictList.append(d);
+ }
+ }
+ }
+ }
+ n = n.nextSibling();
+ }
+ dictTableWidget->clear();
+ dictTableWidget->setRowCount(dictList.count());
+ dictTableWidget->setColumnCount(3);
+ int row=0;
+ foreach(DictData d, dictList)
+ {
+ int column=0;
+ qDebug()<<d.version<<d.files<<d.url<<d.desc<<d.license;
+ QTableWidgetItem *newItem1 = new QTableWidgetItem(d.desc);
+ newItem1->setFlags(newItem1->flags() & ~Qt::ItemIsEditable);
+ dictTableWidget->setItem(row, column++, newItem1);
+ QTableWidgetItem *newItem2 = new QTableWidgetItem(d.lang);
+ newItem2->setFlags(newItem1->flags());
+ dictTableWidget->setItem(row, column++, newItem2);
+ QTableWidgetItem *newItem3 = new QTableWidgetItem();
+ newItem3->setCheckState(d.download ? Qt::Checked : Qt::Unchecked);
+ dictTableWidget->setItem(row, column++, newItem3);
+ ++row;
+ }
+ QStringList headers;
+ headers << tr("Language") << tr("Code") << tr("Location");
+ dictTableWidget->setHorizontalHeaderLabels(headers);
+ dictTableWidget->resizeColumnsToContents();
+}
+
+void DownloadDictionaries::download()
+{
+ qDebug()<<"Now attempting downloads";
+ int rows=dictTableWidget->rowCount();
+ QStringList dlLangs;
+ for (int i=0; i<rows; ++i)
+ {
+ QTableWidgetItem *dlItem=dictTableWidget->item(i,2);
+ if (dlItem->checkState()==Qt::Checked)
+ dlLangs<<dictTableWidget->item(i,1)->text();
+ }
+ qDebug()<<dlLangs;
+ int i=0;
+ downloadList.clear();
+ foreach(DictData d, dictList)
+ {
+ if (dlLangs.contains(d.lang))
+ {
+ ScQApp->dlManager()->addURL(d.url, true, downloadLocation);
+ downloadList.append(d);
+ ++i;
+ }
+ }
+ if (i>0)
+ {
+ connect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadsFinished()));
+ ScQApp->dlManager()->startDownloads();
+ }
+}
+
+void DownloadDictionaries::downloadDictList()
+{
+ ScQApp->dlManager()->addURL("http://services.scribus.net/scribus_spell_dicts.xml", true, downloadLocation);
+ connect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadDictListFinished()));
+ ScQApp->dlManager()->startDownloads();
+}
+
+void DownloadDictionaries::downloadDictListFinished()
+{
+ disconnect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadDictListFinished()));
+ setXMLFile(downloadLocation + "scribus_spell_dicts.xml");
+}
+
+void DownloadDictionaries::downloadsFinished()
+{
+ disconnect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadsFinished()));
+ qDebug()<<"Downloads All Finished";
+ QString userDictDir(ScPaths::getUserDictDir(true));
+ foreach(DictData d, downloadList)
+ {
+ QString basename = QFileInfo(d.url).fileName();
+ QString filename=downloadLocation+"/"+basename;
+ qDebug()<<filename;
+ FileUnzip* fun = new FileUnzip(filename);
+ QStringList files=d.files.split(";", QString::SkipEmptyParts);
+ foreach (QString s, files)
+ {
+ qDebug()<<"Unzipping"<<userDictDir+s;
+ QString data=fun->getFile(s, userDictDir);
+ }
+ delete fun;
+ }
+}
+
diff --git a/scribus/ui/downloaddictionaries.h b/scribus/ui/downloaddictionaries.h
new file mode 100644
index 0000000..d1366c8
--- /dev/null
+++ b/scribus/ui/downloaddictionaries.h
@@ -0,0 +1,56 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+#ifndef DOWNLOADDICTIONARIES
+#define DOWNLOADDICTIONARIES
+
+#include "scribusapi.h"
+#include "ui_downloaddictionaries.h"
+
+#include <QDialog>
+#include <QString>
+#include <QWidget>
+
+
+
+class SCRIBUS_API DownloadDictionaries : public QDialog, Ui::DownloadDictionaries
+{
+ struct DictData
+ {
+ QString lang;
+ QString version;
+ QString files;
+ QString url;
+ QString desc;
+ QString license;
+ bool download;
+ };
+
+ Q_OBJECT
+ public:
+ DownloadDictionaries(QWidget* parent, Qt::WFlags fl=0);
+ ~DownloadDictionaries();
+
+ void setXMLFile(const QString& f);
+
+
+ protected:
+ void parseData();
+
+
+ QString m_xmlDataFile;
+ QList <DictData> dictList;
+ QList <DictData> downloadList;
+ QString downloadLocation;
+
+ protected slots:
+ void download();
+ void downloadDictList();
+ void downloadDictListFinished();
+ void downloadsFinished();
+};
+
+#endif
diff --git a/scribus/ui/downloaddictionaries.ui b/scribus/ui/downloaddictionaries.ui
new file mode 100644
index 0000000..5634129
--- /dev/null
+++ b/scribus/ui/downloaddictionaries.ui
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DownloadDictionaries</class>
+ <widget class="QDialog" name="DownloadDictionaries">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>542</width>
+ <height>270</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Download Dictionaries</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="availableListLabel">
+ <property name="text">
+ <string>Available Dictionary Downloads</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTableWidget" name="dictTableWidget">
+ <property name="selectionMode">
+ <enum>QAbstractItemView::SingleSelection</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="downloadListButton">
+ <property name="text">
+ <string>Update Dictionary List</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="downloadButton">
+ <property name="text">
+ <string>Download Dictionaries</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closeButton">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>