src/partDownloader.cpp

changeset 970
c8aae45afd85
parent 969
b1742ee91d5b
child 971
c00f9665a9f8
equal deleted inserted replaced
969:b1742ee91d5b 970:c8aae45afd85
29 #include "basics.h" 29 #include "basics.h"
30 #include "mainwindow.h" 30 #include "mainwindow.h"
31 #include "ldDocument.h" 31 #include "ldDocument.h"
32 #include "glRenderer.h" 32 #include "glRenderer.h"
33 33
34 CFGENTRY (String, DownloadFilePath, "") 34 ConfigOption (QString DownloadFilePath)
35 CFGENTRY (Bool, GuessDownloadPaths, true) 35 ConfigOption (bool GuessDownloadPaths = true)
36 CFGENTRY (Bool, AutoCloseDownloadDialog, true) 36 ConfigOption (bool AutoCloseDownloadDialog = true)
37 37
38 const QString g_unofficialLibraryURL ("http://ldraw.org/library/unofficial/"); 38 const char* g_unofficialLibraryURL = "http://ldraw.org/library/unofficial/";
39 39
40 // ============================================================================= 40 // =============================================================================
41 // 41 //
42 void PartDownloader::staticBegin() 42 void PartDownloader::staticBegin()
43 { 43 {
44 PartDownloader dlg; 44 PartDownloader dlg (g_win);
45 45
46 if (not dlg.checkValidPath()) 46 if (not dlg.checkValidPath())
47 return; 47 return;
48 48
49 dlg.exec(); 49 dlg.exec();
51 51
52 // ============================================================================= 52 // =============================================================================
53 // 53 //
54 QString PartDownloader::getDownloadPath() 54 QString PartDownloader::getDownloadPath()
55 { 55 {
56 QString path = cfg::DownloadFilePath; 56 QString path = m_config->downloadFilePath;
57 57
58 if (DIRSLASH[0] != '/') 58 if (DIRSLASH[0] != '/')
59 path.replace (DIRSLASH, "/"); 59 path.replace (DIRSLASH, "/");
60 60
61 return path; 61 return path;
63 63
64 // ============================================================================= 64 // =============================================================================
65 // 65 //
66 PartDownloader::PartDownloader (QWidget* parent) : 66 PartDownloader::PartDownloader (QWidget* parent) :
67 QDialog (parent), 67 QDialog (parent),
68 HierarchyElement (parent),
68 m_source (Source (0)) 69 m_source (Source (0))
69 { 70 {
70 setForm (new Ui_DownloadFrom); 71 setForm (new Ui_DownloadFrom);
71 form()->setupUi (this); 72 form()->setupUi (this);
72 form()->fname->setFocus(); 73 form()->fname->setFocus();
106 path = QFileDialog::getExistingDirectory (this, "Path for downloaded files:"); 107 path = QFileDialog::getExistingDirectory (this, "Path for downloaded files:");
107 108
108 if (path.isEmpty()) 109 if (path.isEmpty())
109 return false; 110 return false;
110 111
111 cfg::DownloadFilePath = path; 112 m_config->downloadFilePath = path;
112 } 113 }
113 114
114 return true; 115 return true;
115 } 116 }
116 117
142 void PartDownloader::modifyDestination (QString& dest) const 143 void PartDownloader::modifyDestination (QString& dest) const
143 { 144 {
144 dest = dest.simplified(); 145 dest = dest.simplified();
145 146
146 // If the user doesn't want us to guess, stop right here. 147 // If the user doesn't want us to guess, stop right here.
147 if (not cfg::GuessDownloadPaths) 148 if (not m_config->guessDownloadPaths)
148 return; 149 return;
149 150
150 // Ensure .dat extension 151 // Ensure .dat extension
151 if (dest.right (4) != ".dat") 152 if (dest.right (4) != ".dat")
152 { 153 {
329 } 330 }
330 331
331 for (LDDocument* f : m_files) 332 for (LDDocument* f : m_files)
332 f->reloadAllSubfiles(); 333 f->reloadAllSubfiles();
333 334
334 if (cfg::AutoCloseDownloadDialog and not failed) 335 if (m_config->autoCloseDownloadDialog and not failed)
335 { 336 {
336 // Close automatically if desired. 337 // Close automatically if desired.
337 accept(); 338 accept();
338 } 339 }
339 else 340 else

mercurial