src/ldpaths.cpp

changeset 1028
5877e49e9a28
parent 1014
f0a8ecb6a357
child 1063
1f15c52c11f6
equal deleted inserted replaced
1027:b2f58a8e3d24 1028:5877e49e9a28
21 #include "mainwindow.h" 21 #include "mainwindow.h"
22 #include "dialogs/ldrawpathdialog.h" 22 #include "dialogs/ldrawpathdialog.h"
23 23
24 ConfigOption (QString LDrawPath) 24 ConfigOption (QString LDrawPath)
25 25
26 LDPaths::LDPaths (QObject* parent) : 26 LDPaths::LDPaths (Configuration *config, QObject* parent) :
27 QObject (parent), 27 QObject(parent),
28 m_dialog (nullptr) {} 28 m_config(config),
29 m_dialog(nullptr) {}
30
29 31
30 void LDPaths::checkPaths() 32 void LDPaths::checkPaths()
31 { 33 {
32 QString pathconfig = Config->lDrawPath(); 34 QString pathconfig = m_config->lDrawPath();
33 35
34 if (not configurePaths (pathconfig)) 36 if (not configurePaths (pathconfig))
35 { 37 {
36 m_dialog = new LDrawPathDialog (pathconfig, false); 38 m_dialog = new LDrawPathDialog (pathconfig, false);
37 connect (m_dialog, SIGNAL (pathChanged(QString)), this, SLOT (configurePaths (QString))); 39 connect(m_dialog, &LDrawPathDialog::pathChanged, this, &LDPaths::configurePaths);
38 40
39 if (not m_dialog->exec()) 41 if (m_dialog->exec() != QDialog::Accepted)
40 exit (1); 42 exit(1);
41 else 43 else
42 Config->setLDrawPath (m_dialog->path()); 44 m_config->setLDrawPath(m_dialog->path());
43 } 45 }
44 } 46 }
47
45 48
46 bool LDPaths::isValid (const QDir& dir) const 49 bool LDPaths::isValid (const QDir& dir) const
47 { 50 {
48 if (dir.exists()) 51 if (dir.exists())
49 { 52 {
64 m_error = "That directory does not exist."; 67 m_error = "That directory does not exist.";
65 68
66 return m_error.isEmpty(); 69 return m_error.isEmpty();
67 } 70 }
68 71
72
69 bool LDPaths::configurePaths (QString path) 73 bool LDPaths::configurePaths (QString path)
70 { 74 {
71 QDir dir (path); 75 QDir dir (path);
72 bool ok = isValid (dir); 76 bool ok = isValid (dir);
73 77
83 m_dialog->setStatusText (m_error.isEmpty() ? "OK" : m_error, ok); 87 m_dialog->setStatusText (m_error.isEmpty() ? "OK" : m_error, ok);
84 88
85 return ok; 89 return ok;
86 } 90 }
87 91
92
88 QString& LDPaths::ldConfigPath() 93 QString& LDPaths::ldConfigPath()
89 { 94 {
90 static QString value; 95 static QString value;
91 return value; 96 return value;
92 } 97 }
98
93 99
94 QDir& LDPaths::primitivesDir() 100 QDir& LDPaths::primitivesDir()
95 { 101 {
96 static QDir value; 102 static QDir value;
97 return value; 103 return value;
98 } 104 }
99 105
106
100 QDir& LDPaths::partsDir() 107 QDir& LDPaths::partsDir()
101 { 108 {
102 static QDir value; 109 static QDir value;
103 return value; 110 return value;
104 } 111 }
105 112
113
106 QDir& LDPaths::baseDir() 114 QDir& LDPaths::baseDir()
107 { 115 {
108 static QDir value; 116 static QDir value;
109 return value; 117 return value;
110 } 118 }

mercurial