ENH: Add cross compiling support in the GUI in the same dialog that prompts for
[cmake.git] / Source / QtDialog / CMakeFirstConfigure.cxx
blob8e81956c37cd9ed45a4ecf612abec7fbb77c02e5
2 #include "CMakeFirstConfigure.h"
4 #include <QSettings>
6 CMakeFirstConfigure::CMakeFirstConfigure()
8 this->UI.setupUi(this);
9 this->UI.useDefaults->setChecked(true);
10 this->updatePage();
12 this->UI.useToolChainFile->setChecked(true);
13 this->updateToolChainPage();
15 QObject::connect(this->UI.useDefaults, SIGNAL(toggled(bool)),
16 this, SLOT(updatePage()));
17 QObject::connect(this->UI.compilerSetup, SIGNAL(toggled(bool)),
18 this, SLOT(updatePage()));
19 QObject::connect(this->UI.crossCompilerSetup, SIGNAL(toggled(bool)),
20 this, SLOT(updatePage()));
22 QObject::connect(this->UI.useToolChainFile, SIGNAL(toggled(bool)),
23 this, SLOT(updateToolChainPage()));
26 CMakeFirstConfigure::~CMakeFirstConfigure()
30 void CMakeFirstConfigure::setGenerators(const QStringList& gens)
32 this->UI.generators->clear();
33 this->UI.generators->addItems(gens);
36 QString CMakeFirstConfigure::getGenerator() const
38 return this->UI.generators->currentText();
41 void CMakeFirstConfigure::loadFromSettings()
43 QSettings settings;
44 settings.beginGroup("Settings/StartPath");
46 // restore generator
47 QString lastGen = settings.value("LastGenerator").toString();
48 int idx = this->UI.generators->findText(lastGen);
49 if(idx != -1)
51 this->UI.generators->setCurrentIndex(idx);
53 settings.endGroup();
55 // restore compiler setup
56 settings.beginGroup("Settings/Compiler");
57 this->UI.CCompiler->setText(settings.value("CCompiler").toString());
58 this->UI.CXXCompiler->setText(settings.value("CXXCompiler").toString());
59 this->UI.FortranCompiler->setText(settings.value("FortranCompiler").toString());
60 settings.endGroup();
62 // restore cross compiler setup
63 settings.beginGroup("Settings/CrossCompiler");
64 this->UI.crossCCompiler->setText(settings.value("CCompiler").toString());
65 this->UI.crossCXXCompiler->setText(settings.value("CXXCompiler").toString());
66 this->UI.crossFortranCompiler->setText(settings.value("FortranCompiler").toString());
67 this->UI.useToolChainFile->setChecked(settings.value("UseToolChainFile", true).toBool());
68 this->UI.toolChainFile->setText(settings.value("ToolChainFile").toString());
69 this->UI.systemName->setText(settings.value("SystemName").toString());
70 this->UI.systemVersion->setText(settings.value("SystemVersion").toString());
71 this->UI.systemProcessor->setText(settings.value("SystemProcessor").toString());
72 this->UI.crossFindRoot->setText(settings.value("FindRoot").toString());
73 this->UI.crossProgramMode->setCurrentIndex(settings.value("ProgramMode", 0).toInt());
74 this->UI.crossLibraryMode->setCurrentIndex(settings.value("LibraryMode", 0).toInt());
75 this->UI.crossIncludeMode->setCurrentIndex(settings.value("IncludeMode", 0).toInt());
76 settings.endGroup();
79 void CMakeFirstConfigure::saveToSettings()
81 QSettings settings;
82 settings.beginGroup("Settings/StartPath");
84 // save generator
85 QString lastGen = this->UI.generators->currentText();
86 settings.setValue("LastGenerator", lastGen);
88 settings.endGroup();
90 // save compiler setup
91 settings.beginGroup("Settings/Compiler");
92 settings.setValue("CCompiler", this->UI.CCompiler->text());
93 settings.setValue("CXXCompiler", this->UI.CXXCompiler->text());
94 settings.setValue("FortranCompiler", this->UI.FortranCompiler->text());
95 settings.endGroup();
97 // save cross compiler setup
98 settings.beginGroup("Settings/CrossCompiler");
99 settings.setValue("CCompiler", this->UI.crossCCompiler->text());
100 settings.setValue("CXXCompiler", this->UI.crossCXXCompiler->text());
101 settings.setValue("FortranCompiler", this->UI.crossFortranCompiler->text());
102 settings.setValue("UseToolChainFile", this->UI.useToolChainFile->isChecked());
103 settings.setValue("ToolChainFile", this->UI.toolChainFile->text());
104 settings.setValue("SystemName", this->UI.systemName->text());
105 settings.setValue("SystemVersion", this->UI.systemVersion->text());
106 settings.setValue("SystemProcessor", this->UI.systemProcessor->text());
107 settings.setValue("FindRoot", this->UI.crossFindRoot->text());
108 settings.setValue("ProgramMode", this->UI.crossProgramMode->currentIndex());
109 settings.setValue("LibraryMode", this->UI.crossLibraryMode->currentIndex());
110 settings.setValue("IncludeMode", this->UI.crossIncludeMode->currentIndex());
111 settings.endGroup();
114 void CMakeFirstConfigure::updatePage()
116 if(this->UI.useDefaults->isChecked())
118 this->UI.stackedWidget->setCurrentIndex(0);
120 else if(this->UI.compilerSetup->isChecked())
122 this->UI.stackedWidget->setCurrentIndex(1);
124 else if(this->UI.crossCompilerSetup->isChecked())
126 this->UI.stackedWidget->setCurrentIndex(2);
130 void CMakeFirstConfigure::updateToolChainPage()
132 if(this->UI.useToolChainFile->isChecked())
134 this->UI.toolChainStack->setCurrentIndex(0);
136 else
138 this->UI.toolChainStack->setCurrentIndex(1);
142 bool CMakeFirstConfigure::defaultSetup() const
144 return this->UI.useDefaults->isChecked();
147 bool CMakeFirstConfigure::compilerSetup() const
149 return this->UI.compilerSetup->isChecked();
152 bool CMakeFirstConfigure::crossCompilerSetup() const
154 return this->UI.crossCompilerSetup->isChecked();
157 QString CMakeFirstConfigure::crossCompilerToolChainFile() const
159 if(this->UI.useToolChainFile->isChecked())
161 return this->UI.toolChainFile->text();
163 return QString();
166 QString CMakeFirstConfigure::getSystemName() const
168 return this->UI.systemName->text();
171 QString CMakeFirstConfigure::getCCompiler() const
173 if(this->compilerSetup())
175 return this->UI.CCompiler->text();
177 else if(this->crossCompilerSetup())
179 return this->UI.crossCCompiler->text();
181 return QString();
184 QString CMakeFirstConfigure::getCXXCompiler() const
186 if(this->compilerSetup())
188 return this->UI.CXXCompiler->text();
190 else if(this->crossCompilerSetup())
192 return this->UI.crossCXXCompiler->text();
194 return QString();
197 QString CMakeFirstConfigure::getFortranCompiler() const
199 if(this->compilerSetup())
201 return this->UI.FortranCompiler->text();
203 else if(this->crossCompilerSetup())
205 return this->UI.crossFortranCompiler->text();
207 return QString();
211 QString CMakeFirstConfigure::getSystemVersion() const
213 return this->UI.systemVersion->text();
216 QString CMakeFirstConfigure::getSystemProcessor() const
218 return this->UI.systemProcessor->text();
222 QString CMakeFirstConfigure::getCrossRoot() const
224 return this->UI.crossFindRoot->text();
227 static const char* crossModes[3] = {"BOTH", "ONLY", "NEVER" };
229 QString CMakeFirstConfigure::getCrossProgramMode() const
231 return crossModes[this->UI.crossProgramMode->currentIndex()];
234 QString CMakeFirstConfigure::getCrossLibraryMode() const
236 return crossModes[this->UI.crossLibraryMode->currentIndex()];
239 QString CMakeFirstConfigure::getCrossIncludeMode() const
241 return crossModes[this->UI.crossIncludeMode->currentIndex()];