src/partDownloader.cc

branch
experimental
changeset 889
ba9e4bcc2fcc
parent 888
7ad8fb667084
child 891
00d76b281021
child 927
409b82a4765e
child 944
1a6f1997fcbe
equal deleted inserted replaced
885:9c4fc9b433ae 889:ba9e4bcc2fcc
20 #include <QNetworkRequest> 20 #include <QNetworkRequest>
21 #include <QNetworkReply> 21 #include <QNetworkReply>
22 #include <QDir> 22 #include <QDir>
23 #include <QProgressBar> 23 #include <QProgressBar>
24 #include <QPushButton> 24 #include <QPushButton>
25 #include <QFileDialog>
26 #include <QMessageBox>
25 #include "partDownloader.h" 27 #include "partDownloader.h"
26 #include "ui_downloadfrom.h" 28 #include "ui_downloadfrom.h"
27 #include "basics.h" 29 #include "basics.h"
28 #include "mainWindow.h" 30 #include "mainWindow.h"
29 #include "ldDocument.h" 31 #include "ldDocument.h"
30 #include "glRenderer.h" 32 #include "glRenderer.h"
31 #include "configDialog.h"
32 33
33 CFGENTRY (String, DownloadFilePath, "") 34 CFGENTRY (String, DownloadFilePath, "")
34 CFGENTRY (Bool, GuessDownloadPaths, true) 35 CFGENTRY (Bool, GuessDownloadPaths, true)
35 CFGENTRY (Bool, AutoCloseDownloadDialog, true) 36 CFGENTRY (Bool, AutoCloseDownloadDialog, true)
36 37
38 39
39 // ============================================================================= 40 // =============================================================================
40 // 41 //
41 void PartDownloader::staticBegin() 42 void PartDownloader::staticBegin()
42 { 43 {
43 QString path = getDownloadPath(); 44 PartDownloader dlg;
44 45
45 if (path.isEmpty() or not QDir (path).exists()) 46 if (not dlg.checkValidPath())
46 {
47 Critical (PartDownloader::tr ("You need to specify a valid path for "
48 "downloaded files in the configuration to download paths."));
49
50 (new ConfigDialog (ConfigDialog::DownloadTab, null))->exec();
51 return; 47 return;
52 } 48
53 49 dlg.exec();
54 PartDownloader* dlg = new PartDownloader;
55 dlg->exec();
56 } 50 }
57 51
58 // ============================================================================= 52 // =============================================================================
59 // 53 //
60 QString PartDownloader::getDownloadPath() 54 QString PartDownloader::getDownloadPath()
96 // ============================================================================= 90 // =============================================================================
97 // 91 //
98 PartDownloader::~PartDownloader() 92 PartDownloader::~PartDownloader()
99 { 93 {
100 delete form(); 94 delete form();
95 }
96
97 // =============================================================================
98 //
99 bool PartDownloader::checkValidPath()
100 {
101 QString path = getDownloadPath();
102
103 if (path.isEmpty() or not QDir (path).exists())
104 {
105 QMessageBox::information(this, "Notice", "Please input a path for files to download.");
106 path = QFileDialog::getExistingDirectory (this, "Path for downloaded files:");
107
108 if (path.isEmpty())
109 return false;
110
111 cfg::DownloadFilePath = path;
112 }
113
114 return true;
101 } 115 }
102 116
103 // ============================================================================= 117 // =============================================================================
104 // 118 //
105 QString PartDownloader::getURL() 119 QString PartDownloader::getURL()

mercurial