r17542 by craig - Add in dictionary downloader code, updates to downloader threading and add in GUI to hyphenator preferences for downloading
scribus-commit
scribus-commit at lists.scribus.net
Thu Jun 7 20:01:10 UTC 2012
Author: craig
Date: Thu Jun 7 20:01:10 2012
New Revision: 17542
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17542
Log:
Add in dictionary downloader code, updates to downloader threading and add in GUI to hyphenator preferences for downloading
Added:
branches/Version14x/Scribus/scribus/ui/downloaddictionaries.cpp (with props)
branches/Version14x/Scribus/scribus/ui/downloaddictionaries.h (with props)
branches/Version14x/Scribus/scribus/ui/downloaddictionaries.ui
Modified:
branches/Version14x/Scribus/scribus/CMakeLists.txt
branches/Version14x/Scribus/scribus/downloadmanager/scdlthread.cpp
branches/Version14x/Scribus/scribus/hysettings.cpp
branches/Version14x/Scribus/scribus/hysettings.h
branches/Version14x/Scribus/scribus/hysettingsBase.ui
branches/Version14x/Scribus/scribus/langmgr.cpp
branches/Version14x/Scribus/scribus/langmgr.h
branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
branches/Version14x/Scribus/scribus/prefs.cpp
branches/Version14x/Scribus/scribus/reformdoc.cpp
branches/Version14x/Scribus/scribus/scribusapp.cpp
branches/Version14x/Scribus/scribus/scribusapp.h
Modified: branches/Version14x/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/CMakeLists.txt
==============================================================================
--- branches/Version14x/Scribus/scribus/CMakeLists.txt (original)
+++ branches/Version14x/Scribus/scribus/CMakeLists.txt Thu Jun 7 20:01:10 2012
@@ -62,6 +62,7 @@
tocindexprefs.ui
ui/copypagetomasterpage.ui
ui/createrange.ui
+ ui/downloaddictionaries.ui
ui/helpbrowser.ui
unicodesearch.ui
useprintermarginsdialog.ui
@@ -118,6 +119,8 @@
docinfo.h
docitemattrprefs.h
docsections.h
+ downloadmanager/scdlmgr.h
+ downloadmanager/scdlthread.h
editor.h
effectsdialog.h
extimageprops.h
@@ -278,6 +281,7 @@
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 @@
docsections.cpp
documentchecker.cpp
documentinformation.cpp
+ downloadmanager/scdlmgr.cpp
+ downloadmanager/scdlthread.cpp
editor.cpp
effectsdialog.cpp
exif.cpp
@@ -602,6 +608,7 @@
tt/simpletreemodel/treemodel.cpp
ui/copypagetomasterpagedialog.cpp
ui/createrange.cpp
+ ui/downloaddictionaries.cpp
ui/edittoolbar.cpp
ui/filetoolbar.cpp
ui/modetoolbar.cpp
Modified: branches/Version14x/Scribus/scribus/downloadmanager/scdlthread.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/downloadmanager/scdlthread.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/downloadmanager/scdlthread.cpp (original)
+++ branches/Version14x/Scribus/scribus/downloadmanager/scdlthread.cpp Thu Jun 7 20:01:10 2012
@@ -98,6 +98,7 @@
if (downloadQueue.isEmpty())
{
qDebug()<<downloadedCount<<"/"<<totalCount<<"files downloaded successfully";
+ downloadedCount=totalCount=0;
emit finished();
return;
}
Modified: branches/Version14x/Scribus/scribus/hysettings.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/hysettings.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/hysettings.cpp (original)
+++ branches/Version14x/Scribus/scribus/hysettings.cpp Thu Jun 7 20:01:10 2012
@@ -4,31 +4,37 @@
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>
-
-HySettings::HySettings( QWidget* parent/*, QMap<QString,QString>* langs*/ ) : QWidget( parent )
-{
-// langsMap = *langs;
+#include <QTableWidgetItem>
+
+extern ScribusQApp* ScQApp;
+
+HySettings::HySettings( QWidget* parent) : QWidget( parent )
+{
+
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 @@
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 @@
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 @@
}
return ret;
}
+
+void HySettings::setSpellingInvisible()
+{
+ tabWidget->removeTab(1);
+}
Modified: branches/Version14x/Scribus/scribus/hysettings.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/hysettings.h
==============================================================================
--- branches/Version14x/Scribus/scribus/hysettings.h (original)
+++ branches/Version14x/Scribus/scribus/hysettings.h Thu Jun 7 20:01:10 2012
@@ -17,10 +17,22 @@
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 @@
QString getLanguage();
QSet<QString> getIgnoreList();
QHash<QString, QString> getExceptionList();
+ void setSpellingInvisible();
private slots:
void addToIgnoreList();
@@ -41,8 +54,19 @@
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;
};
Modified: branches/Version14x/Scribus/scribus/hysettingsBase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/hysettingsBase.ui
==============================================================================
--- branches/Version14x/Scribus/scribus/hysettingsBase.ui (original)
+++ branches/Version14x/Scribus/scribus/hysettingsBase.ui Thu Jun 7 20:01:10 2012
@@ -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" >
+ <property name="spacing">
<number>5</number>
</property>
- <property name="verticalSpacing" >
- <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>&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 &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>&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>&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 &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>&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 &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>&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>&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 &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>
Modified: branches/Version14x/Scribus/scribus/langmgr.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/langmgr.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/langmgr.cpp (original)
+++ branches/Version14x/Scribus/scribus/langmgr.cpp Thu Jun 7 20:01:10 2012
@@ -20,7 +20,7 @@
***************************************************************************/
#include <iostream>
-
+#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QMap>
@@ -302,6 +302,40 @@
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();
Modified: branches/Version14x/Scribus/scribus/langmgr.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/langmgr.h
==============================================================================
--- branches/Version14x/Scribus/scribus/langmgr.h (original)
+++ branches/Version14x/Scribus/scribus/langmgr.h Thu Jun 7 20:01:10 2012
@@ -50,6 +50,8 @@
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);
Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp Thu Jun 7 20:01:10 2012
@@ -32,7 +32,7 @@
HunspellPluginImpl::HunspellPluginImpl() : QObject(0)
{
//hspellers=NULL;
- numDicts=0;
+// numDicts=0;
m_runningForSE=false;
m_SE=NULL;
}
@@ -45,7 +45,7 @@
h = NULL;
}
hspellerMap.clear();
- numDicts = 0;
+// numDicts = 0;
}
bool HunspellPluginImpl::run(const QString & target, ScribusDoc* doc)
@@ -62,45 +62,17 @@
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;
Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h Thu Jun 7 20:01:10 2012
@@ -30,7 +30,6 @@
HunspellPluginImpl();
~HunspellPluginImpl();
bool run(const QString & target, ScribusDoc* doc=0);
- bool findDictionaries();
bool initHunspell();
bool checkWithHunspell();
bool checkWithHunspellSE();
@@ -43,7 +42,7 @@
protected:
QMap<QString, QString> dictionaryMap;
QStringList dictionaryPaths;
- int numDicts, numAFFs;
+ //int numDicts, numAFFs;
QMap<QString, Hunspell*> hspellerMap;
ScribusDoc* m_doc;
bool m_runningForSE;
Modified: branches/Version14x/Scribus/scribus/prefs.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/prefs.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/prefs.cpp (original)
+++ branches/Version14x/Scribus/scribus/prefs.cpp Thu Jun 7 20:01:10 2012
@@ -87,7 +87,7 @@
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);
Modified: branches/Version14x/Scribus/scribus/reformdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/reformdoc.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/reformdoc.cpp (original)
+++ branches/Version14x/Scribus/scribus/reformdoc.cpp Thu Jun 7 20:01:10 2012
@@ -80,7 +80,8 @@
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);
Modified: branches/Version14x/Scribus/scribus/scribusapp.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/scribusapp.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusapp.cpp (original)
+++ branches/Version14x/Scribus/scribus/scribusapp.cpp Thu Jun 7 20:01:10 2012
@@ -94,10 +94,13 @@
{
ScQApp=this;
ScCore=NULL;
+
+ initDLMgr();
}
ScribusQApp::~ScribusQApp()
{
+ m_scDLMgr->deleteLater();
PrefsManager::deleteInstance();
}
@@ -107,6 +110,12 @@
if (!langs.isEmpty())
installTranslators(langs);
+}
+
+void ScribusQApp::initDLMgr()
+{
+ m_scDLMgr=new ScDLManager(this);
+ connect(m_scDLMgr, SIGNAL(fileReceived(const QString&)), SLOT(downloadComplete(const QString&)));
}
void ScribusQApp::parseCommandLine()
@@ -502,6 +511,11 @@
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())
Modified: branches/Version14x/Scribus/scribus/scribusapp.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17542&path=/branches/Version14x/Scribus/scribus/scribusapp.h
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusapp.h (original)
+++ branches/Version14x/Scribus/scribus/scribusapp.h Thu Jun 7 20:01:10 2012
@@ -25,6 +25,7 @@
#include <QString>
#include "scribusapi.h"
+#include "downloadmanager/scdlmgr.h"
class ScribusCore;
class ScribusMainWindow;
@@ -36,7 +37,6 @@
ScribusQApp( int & argc, char ** argv );
~ScribusQApp();
int init();
- void initLang();
void parseCommandLine();
void changeGUILanguage(const QString & lang);
/*!
@@ -66,9 +66,17 @@
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 @@
QString prefsUserFile;
QList<QString> filesToLoad;
QString fileName;
+ ScDLManager *m_scDLMgr;
protected:
virtual bool event(QEvent *event);
More information about the scribus-commit
mailing list