src/partDownloader.cc

branch
experimental
changeset 889
ba9e4bcc2fcc
parent 888
7ad8fb667084
child 891
00d76b281021
child 927
409b82a4765e
child 944
1a6f1997fcbe
--- a/src/partDownloader.cc	Sun Sep 07 18:41:23 2014 +0300
+++ b/src/partDownloader.cc	Tue Sep 09 01:15:24 2014 +0300
@@ -22,13 +22,14 @@
 #include <QDir>
 #include <QProgressBar>
 #include <QPushButton>
+#include <QFileDialog>
+#include <QMessageBox>
 #include "partDownloader.h"
 #include "ui_downloadfrom.h"
 #include "basics.h"
 #include "mainWindow.h"
 #include "ldDocument.h"
 #include "glRenderer.h"
-#include "configDialog.h"
 
 CFGENTRY (String, DownloadFilePath, "")
 CFGENTRY (Bool, GuessDownloadPaths, true)
@@ -40,19 +41,12 @@
 //
 void PartDownloader::staticBegin()
 {
-	QString path = getDownloadPath();
-
-	if (path.isEmpty() or not QDir (path).exists())
-	{
-		Critical (PartDownloader::tr ("You need to specify a valid path for "
-			"downloaded files in the configuration to download paths."));
+	PartDownloader dlg;
 
-		(new ConfigDialog (ConfigDialog::DownloadTab, null))->exec();
+	if (not dlg.checkValidPath())
 		return;
-	}
 
-	PartDownloader* dlg = new PartDownloader;
-	dlg->exec();
+	dlg.exec();
 }
 
 // =============================================================================
@@ -102,6 +96,26 @@
 
 // =============================================================================
 //
+bool PartDownloader::checkValidPath()
+{
+	QString path = getDownloadPath();
+
+	if (path.isEmpty() or not QDir (path).exists())
+	{
+		QMessageBox::information(this, "Notice", "Please input a path for files to download.");
+		path = QFileDialog::getExistingDirectory (this, "Path for downloaded files:");
+
+		if (path.isEmpty())
+			return false;
+
+		cfg::DownloadFilePath = path;
+	}
+
+	return true;
+}
+
+// =============================================================================
+//
 QString PartDownloader::getURL()
 {
 	const Source src = getSource();

mercurial