r19814 by craig - #12912: Add some GUi controls around if the downloads list is available

scribus-commit scribus-commit at lists.scribus.net
Thu Feb 12 10:17:46 UTC 2015


Author: craig
Date: Thu Feb 12 10:17:46 2015
New Revision: 19814

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19814
Log:
#12912: Add some GUi controls around if the downloads list is available

Modified:
    trunk/Scribus/scribus/ui/prefs_hyphenator.cpp
    trunk/Scribus/scribus/ui/prefs_spelling.cpp

Modified: trunk/Scribus/scribus/ui/prefs_hyphenator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19814&path=/trunk/Scribus/scribus/ui/prefs_hyphenator.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_hyphenator.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_hyphenator.cpp Thu Feb 12 10:17:46 2015
@@ -37,15 +37,14 @@
 	languageList.sort();
 	hyphLanguageComboBox->addItems( languageList );
 
-	//<<DL
 	updateDictList();
 	downloadLocation=ScPaths::downloadDir();
+	hyphDownloadButton->setEnabled(false);
 	setAvailDictsXMLFile(downloadLocation + "scribus_hyph_dicts.xml");
 	downloadProgressBar->setVisible(false);
 	dlLabel->setVisible(false);
 	connect(hyphDownloadButton, SIGNAL(clicked()), this, SLOT(downloadHyphDicts()));
 	connect(availHyphListDownloadButton, SIGNAL(clicked()), this, SLOT(updateAvailDictList()));
-	//>DL
 
 	exceptionAddButton->setIcon(QIcon(loadIcon("16/list-add.png")));
 	exceptionEditButton->setEnabled(false);
@@ -191,7 +190,6 @@
 
 void Prefs_Hyphenator::downloadHyphDicts()
 {
-	hyphDownloadButton->setEnabled(false);
 	int rows=availHyphDictTableWidget->rowCount();
 	QStringList dlLangs;
 	for (int i=0; i<rows; ++i)
@@ -200,7 +198,9 @@
 		if (dlItem->checkState()==Qt::Checked)
 			dlLangs<<availHyphDictTableWidget->item(i,1)->text();
 	}
-	//qDebug()<<dlLangs;
+	if (dlLangs.isEmpty())
+		return;
+	hyphDownloadButton->setEnabled(false);
 	downloadList.clear();
 	downloadProgressBar->setValue(0);
 	downloadProgressBar->setVisible(true);
@@ -308,6 +308,8 @@
 void Prefs_Hyphenator::setAvailDictsXMLFile(QString availDictsXMLDataFile)
 {
 	QFile dataFile(availDictsXMLDataFile);
+	if (!dataFile.exists())
+		return;
 	dataFile.open(QIODevice::ReadOnly);
 	QTextStream ts(&dataFile);
 	ts.setCodec(QTextCodec::codecForName("UTF-8"));
@@ -358,6 +360,11 @@
 		n = n.nextSibling();
 	}
 	availHyphDictTableWidget->clear();
+	if(dictList.isEmpty())
+	{
+		hyphDownloadButton->setEnabled(false);
+		return;
+	}
 	availHyphDictTableWidget->setRowCount(dictList.count());
 	availHyphDictTableWidget->setColumnCount(4);
 	int row=0;
@@ -384,4 +391,5 @@
 	headers << tr("Language") << tr("Code") << tr("Installed") << tr("Download");
 	availHyphDictTableWidget->setHorizontalHeaderLabels(headers);
 	availHyphDictTableWidget->resizeColumnsToContents();
-}
+	hyphDownloadButton->setEnabled(true);
+}

Modified: trunk/Scribus/scribus/ui/prefs_spelling.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19814&path=/trunk/Scribus/scribus/ui/prefs_spelling.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_spelling.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_spelling.cpp Thu Feb 12 10:17:46 2015
@@ -39,6 +39,7 @@
 
 	updateDictList();
 	downloadLocation=ScPaths::downloadDir();
+	spellDownloadButton->setEnabled(false);
 	setAvailDictsXMLFile(downloadLocation + "scribus_spell_dicts.xml");
 	downloadProgressBar->setVisible(false);
 	dlLabel->setVisible(false);
@@ -64,7 +65,6 @@
 
 void Prefs_Spelling::downloadSpellDicts()
 {
-	spellDownloadButton->setEnabled(false);
 	int rows=availDictTableWidget->rowCount();
 	QStringList dlLangs;
 	for (int i=0; i<rows; ++i)
@@ -73,7 +73,9 @@
 		if (dlItem->checkState()==Qt::Checked)
 			dlLangs<<availDictTableWidget->item(i,1)->text();
 	}
-	//qDebug()<<dlLangs;
+	if (dlLangs.isEmpty())
+		return;
+	spellDownloadButton->setEnabled(false);
 	downloadList.clear();
 	downloadProgressBar->setValue(0);
 	downloadProgressBar->setVisible(true);
@@ -235,6 +237,8 @@
 void Prefs_Spelling::setAvailDictsXMLFile(QString availDictsXMLDataFile)
 {
 	QFile dataFile(availDictsXMLDataFile);
+	if (!dataFile.exists())
+		return;
 	dataFile.open(QIODevice::ReadOnly);
 	QTextStream ts(&dataFile);
 	ts.setCodec(QTextCodec::codecForName("UTF-8"));
@@ -285,6 +289,11 @@
 		n = n.nextSibling();
 	}
 	availDictTableWidget->clear();
+	if(dictList.isEmpty())
+	{
+		spellDownloadButton->setEnabled(false);
+		return;
+	}
 	availDictTableWidget->setRowCount(dictList.count());
 	availDictTableWidget->setColumnCount(4);
 	int row=0;
@@ -311,6 +320,7 @@
 	headers << tr("Language") << tr("Code") << tr("Installed") << tr("Download");
 	availDictTableWidget->setHorizontalHeaderLabels(headers);
 	availDictTableWidget->resizeColumnsToContents();
+	spellDownloadButton->setEnabled(true);
 }
 
 QString Prefs_Spelling::affixFileName(QStringList files)




More information about the scribus-commit mailing list