Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / QtDialog / FirstConfigure.cxx
blobf522760c0d2c1c62e35c1a1597948c3046ab57f3
2 #include "FirstConfigure.h"
3 #include "Compilers.h"
5 #include <QSettings>
6 #include <QRadioButton>
7 #include <QComboBox>
8 #include <QVBoxLayout>
11 StartCompilerSetup::StartCompilerSetup(QWidget* p)
12 : QWizardPage(p)
14 QVBoxLayout* l = new QVBoxLayout(this);
15 l->addWidget(new QLabel(tr("Specify the generator for this project")));
16 this->GeneratorOptions = new QComboBox(this);
17 l->addWidget(this->GeneratorOptions);
18 l->addSpacing(6);
20 this->CompilerSetupOptions[0] = new QRadioButton("Use default native compilers", this);
21 this->CompilerSetupOptions[1] = new QRadioButton("Specify native compilers", this);
22 this->CompilerSetupOptions[2] = new QRadioButton("Specify toolchain file for cross-compiling", this);
23 this->CompilerSetupOptions[3] = new QRadioButton("Specify options for cross-compiling", this);
24 l->addWidget(this->CompilerSetupOptions[0]);
25 l->addWidget(this->CompilerSetupOptions[1]);
26 l->addWidget(this->CompilerSetupOptions[2]);
27 l->addWidget(this->CompilerSetupOptions[3]);
29 this->CompilerSetupOptions[0]->setChecked(true);
31 QObject::connect(this->CompilerSetupOptions[0], SIGNAL(toggled(bool)),
32 this, SLOT(onSelectionChanged(bool)));
33 QObject::connect(this->CompilerSetupOptions[1], SIGNAL(toggled(bool)),
34 this, SLOT(onSelectionChanged(bool)));
35 QObject::connect(this->CompilerSetupOptions[2], SIGNAL(toggled(bool)),
36 this, SLOT(onSelectionChanged(bool)));
37 QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)),
38 this, SLOT(onSelectionChanged(bool)));
41 StartCompilerSetup::~StartCompilerSetup()
45 void StartCompilerSetup::setGenerators(const QStringList& gens)
47 this->GeneratorOptions->clear();
48 this->GeneratorOptions->addItems(gens);
51 void StartCompilerSetup::setCurrentGenerator(const QString& gen)
53 int idx = this->GeneratorOptions->findText(gen);
54 if(idx != -1)
56 this->GeneratorOptions->setCurrentIndex(idx);
60 QString StartCompilerSetup::getGenerator() const
62 return this->GeneratorOptions->currentText();
65 bool StartCompilerSetup::defaultSetup() const
67 return this->CompilerSetupOptions[0]->isChecked();
70 bool StartCompilerSetup::compilerSetup() const
72 return this->CompilerSetupOptions[1]->isChecked();
75 bool StartCompilerSetup::crossCompilerToolChainFile() const
77 return this->CompilerSetupOptions[2]->isChecked();
80 bool StartCompilerSetup::crossCompilerSetup() const
82 return this->CompilerSetupOptions[3]->isChecked();
85 void StartCompilerSetup::onSelectionChanged(bool on)
87 if(on)
88 selectionChanged();
91 int StartCompilerSetup::nextId() const
93 if(compilerSetup())
94 return NativeSetup;
95 if(crossCompilerSetup())
96 return CrossSetup;
97 if(crossCompilerToolChainFile())
98 return ToolchainSetup;
99 return -1;
102 NativeCompilerSetup::NativeCompilerSetup(QWidget* p)
103 : QWizardPage(p)
105 QVBoxLayout* l = new QVBoxLayout(this);
106 QWidget* c = new QWidget(this);
107 l->addWidget(c);
108 this->setupUi(c);
111 NativeCompilerSetup::~NativeCompilerSetup()
115 QString NativeCompilerSetup::getCCompiler() const
117 return this->CCompiler->text();
120 void NativeCompilerSetup::setCCompiler(const QString& s)
122 this->CCompiler->setText(s);
125 QString NativeCompilerSetup::getCXXCompiler() const
127 return this->CXXCompiler->text();
130 void NativeCompilerSetup::setCXXCompiler(const QString& s)
132 this->CXXCompiler->setText(s);
135 QString NativeCompilerSetup::getFortranCompiler() const
137 return this->FortranCompiler->text();
140 void NativeCompilerSetup::setFortranCompiler(const QString& s)
142 this->FortranCompiler->setText(s);
146 CrossCompilerSetup::CrossCompilerSetup(QWidget* p)
147 : QWizardPage(p)
149 this->setupUi(this);
150 QWidget::setTabOrder(systemName, systemVersion);
151 QWidget::setTabOrder(systemVersion, systemProcessor);
152 QWidget::setTabOrder(systemProcessor, CrossCompilers->CCompiler);
153 QWidget::setTabOrder(CrossCompilers->CCompiler, CrossCompilers->CXXCompiler);
154 QWidget::setTabOrder(CrossCompilers->CXXCompiler, CrossCompilers->FortranCompiler);
155 QWidget::setTabOrder(CrossCompilers->FortranCompiler, crossFindRoot);
156 QWidget::setTabOrder(crossFindRoot, crossProgramMode);
157 QWidget::setTabOrder(crossProgramMode, crossLibraryMode);
158 QWidget::setTabOrder(crossLibraryMode, crossIncludeMode);
160 // fill in combo boxes
161 QStringList modes;
162 modes << "Search in Target Root, then native system";
163 modes << "Search only in Target Root";
164 modes << "Search only in native system";
165 crossProgramMode->addItems(modes);
166 crossLibraryMode->addItems(modes);
167 crossIncludeMode->addItems(modes);
168 crossProgramMode->setCurrentIndex(2);
169 crossLibraryMode->setCurrentIndex(1);
170 crossIncludeMode->setCurrentIndex(1);
172 this->registerField("systemName*", this->systemName);
175 CrossCompilerSetup::~CrossCompilerSetup()
179 QString CrossCompilerSetup::getCCompiler() const
181 return this->CrossCompilers->CCompiler->text();
184 void CrossCompilerSetup::setCCompiler(const QString& s)
186 this->CrossCompilers->CCompiler->setText(s);
189 QString CrossCompilerSetup::getCXXCompiler() const
191 return this->CrossCompilers->CXXCompiler->text();
194 void CrossCompilerSetup::setCXXCompiler(const QString& s)
196 this->CrossCompilers->CXXCompiler->setText(s);
199 QString CrossCompilerSetup::getFortranCompiler() const
201 return this->CrossCompilers->FortranCompiler->text();
204 void CrossCompilerSetup::setFortranCompiler(const QString& s)
206 this->CrossCompilers->FortranCompiler->setText(s);
209 QString CrossCompilerSetup::getSystem() const
211 return this->systemName->text();
214 void CrossCompilerSetup::setSystem(const QString& t)
216 this->systemName->setText(t);
220 QString CrossCompilerSetup::getVersion() const
222 return this->systemVersion->text();
225 void CrossCompilerSetup::setVersion(const QString& t)
227 this->systemVersion->setText(t);
231 QString CrossCompilerSetup::getProcessor() const
233 return this->systemProcessor->text();
236 void CrossCompilerSetup::setProcessor(const QString& t)
238 this->systemProcessor->setText(t);
241 QString CrossCompilerSetup::getFindRoot() const
243 return this->crossFindRoot->text();
246 void CrossCompilerSetup::setFindRoot(const QString& t)
248 return this->crossFindRoot->setText(t);
251 int CrossCompilerSetup::getProgramMode() const
253 return this->crossProgramMode->currentIndex();
256 int CrossCompilerSetup::getLibraryMode() const
258 return this->crossLibraryMode->currentIndex();
261 int CrossCompilerSetup::getIncludeMode() const
263 return this->crossIncludeMode->currentIndex();
266 void CrossCompilerSetup::setProgramMode(int m)
268 this->crossProgramMode->setCurrentIndex(m);
271 void CrossCompilerSetup::setLibraryMode(int m)
273 this->crossLibraryMode->setCurrentIndex(m);
276 void CrossCompilerSetup::setIncludeMode(int m)
278 this->crossIncludeMode->setCurrentIndex(m);
281 ToolchainCompilerSetup::ToolchainCompilerSetup(QWidget* p)
282 : QWizardPage(p)
284 QVBoxLayout* l = new QVBoxLayout(this);
285 l->addWidget(new QLabel(tr("Specify the Toolchain file")));
286 this->ToolchainFile = new QCMakeFilePathEditor(this);
287 l->addWidget(this->ToolchainFile);
290 ToolchainCompilerSetup::~ToolchainCompilerSetup()
294 QString ToolchainCompilerSetup::toolchainFile() const
296 return this->ToolchainFile->text();
299 void ToolchainCompilerSetup::setToolchainFile(const QString& t)
301 this->ToolchainFile->setText(t);
306 FirstConfigure::FirstConfigure()
308 //this->setOption(QWizard::HaveFinishButtonOnEarlyPages, true);
309 this->mStartCompilerSetupPage = new StartCompilerSetup(this);
310 this->setPage(Start, this->mStartCompilerSetupPage);
311 QObject::connect(this->mStartCompilerSetupPage, SIGNAL(selectionChanged()),
312 this, SLOT(restart()));
314 this->mNativeCompilerSetupPage = new NativeCompilerSetup(this);
315 this->setPage(NativeSetup, this->mNativeCompilerSetupPage);
317 this->mCrossCompilerSetupPage = new CrossCompilerSetup(this);
318 this->setPage(CrossSetup, this->mCrossCompilerSetupPage);
320 this->mToolchainCompilerSetupPage = new ToolchainCompilerSetup(this);
321 this->setPage(ToolchainSetup, this->mToolchainCompilerSetupPage);
324 FirstConfigure::~FirstConfigure()
328 void FirstConfigure::setGenerators(const QStringList& gens)
330 this->mStartCompilerSetupPage->setGenerators(gens);
333 QString FirstConfigure::getGenerator() const
335 return this->mStartCompilerSetupPage->getGenerator();
338 void FirstConfigure::loadFromSettings()
340 QSettings settings;
341 // restore generator
342 settings.beginGroup("Settings/StartPath");
343 QString lastGen = settings.value("LastGenerator").toString();
344 this->mStartCompilerSetupPage->setCurrentGenerator(lastGen);
345 settings.endGroup();
347 // restore compiler setup
348 settings.beginGroup("Settings/Compiler");
349 this->mNativeCompilerSetupPage->setCCompiler(settings.value("CCompiler").toString());
350 this->mNativeCompilerSetupPage->setCXXCompiler(settings.value("CXXCompiler").toString());
351 this->mNativeCompilerSetupPage->setFortranCompiler(settings.value("FortranCompiler").toString());
352 settings.endGroup();
354 // restore cross compiler setup
355 settings.beginGroup("Settings/CrossCompiler");
356 this->mCrossCompilerSetupPage->setCCompiler(settings.value("CCompiler").toString());
357 this->mCrossCompilerSetupPage->setCXXCompiler(settings.value("CXXCompiler").toString());
358 this->mCrossCompilerSetupPage->setFortranCompiler(settings.value("FortranCompiler").toString());
359 this->mToolchainCompilerSetupPage->setToolchainFile(settings.value("ToolChainFile").toString());
360 this->mCrossCompilerSetupPage->setSystem(settings.value("SystemName").toString());
361 this->mCrossCompilerSetupPage->setVersion(settings.value("SystemVersion").toString());
362 this->mCrossCompilerSetupPage->setProcessor(settings.value("SystemProcessor").toString());
363 this->mCrossCompilerSetupPage->setFindRoot(settings.value("FindRoot").toString());
364 this->mCrossCompilerSetupPage->setProgramMode(settings.value("ProgramMode", 0).toInt());
365 this->mCrossCompilerSetupPage->setLibraryMode(settings.value("LibraryMode", 0).toInt());
366 this->mCrossCompilerSetupPage->setIncludeMode(settings.value("IncludeMode", 0).toInt());
367 settings.endGroup();
370 void FirstConfigure::saveToSettings()
372 QSettings settings;
374 // save generator
375 settings.beginGroup("Settings/StartPath");
376 QString lastGen = this->mStartCompilerSetupPage->getGenerator();
377 settings.setValue("LastGenerator", lastGen);
378 settings.endGroup();
380 // save compiler setup
381 settings.beginGroup("Settings/Compiler");
382 settings.setValue("CCompiler", this->mNativeCompilerSetupPage->getCCompiler());
383 settings.setValue("CXXCompiler", this->mNativeCompilerSetupPage->getCXXCompiler());
384 settings.setValue("FortranCompiler", this->mNativeCompilerSetupPage->getFortranCompiler());
385 settings.endGroup();
387 // save cross compiler setup
388 settings.beginGroup("Settings/CrossCompiler");
389 settings.setValue("CCompiler", this->mCrossCompilerSetupPage->getCCompiler());
390 settings.setValue("CXXCompiler", this->mCrossCompilerSetupPage->getCXXCompiler());
391 settings.setValue("FortranCompiler", this->mCrossCompilerSetupPage->getFortranCompiler());
392 settings.setValue("ToolChainFile", this->getCrossCompilerToolChainFile());
393 settings.setValue("SystemName", this->mCrossCompilerSetupPage->getSystem());
394 settings.setValue("SystemVersion", this->mCrossCompilerSetupPage->getVersion());
395 settings.setValue("SystemProcessor", this->mCrossCompilerSetupPage->getProcessor());
396 settings.setValue("FindRoot", this->mCrossCompilerSetupPage->getFindRoot());
397 settings.setValue("ProgramMode", this->mCrossCompilerSetupPage->getProgramMode());
398 settings.setValue("LibraryMode", this->mCrossCompilerSetupPage->getLibraryMode());
399 settings.setValue("IncludeMode", this->mCrossCompilerSetupPage->getIncludeMode());
400 settings.endGroup();
403 bool FirstConfigure::defaultSetup() const
405 return this->mStartCompilerSetupPage->defaultSetup();
408 bool FirstConfigure::compilerSetup() const
410 return this->mStartCompilerSetupPage->compilerSetup();
413 bool FirstConfigure::crossCompilerSetup() const
415 return this->mStartCompilerSetupPage->crossCompilerSetup();
418 bool FirstConfigure::crossCompilerToolChainFile() const
420 return this->mStartCompilerSetupPage->crossCompilerToolChainFile();
423 QString FirstConfigure::getCrossCompilerToolChainFile() const
425 return this->mToolchainCompilerSetupPage->toolchainFile();
428 QString FirstConfigure::getSystemName() const
430 return this->mCrossCompilerSetupPage->getSystem();
433 QString FirstConfigure::getCCompiler() const
435 if(this->compilerSetup())
437 return this->mNativeCompilerSetupPage->getCCompiler();
439 else if(this->crossCompilerSetup())
441 return this->mCrossCompilerSetupPage->getCCompiler();
443 return QString();
446 QString FirstConfigure::getCXXCompiler() const
448 if(this->compilerSetup())
450 return this->mNativeCompilerSetupPage->getCXXCompiler();
452 else if(this->crossCompilerSetup())
454 return this->mCrossCompilerSetupPage->getCXXCompiler();
456 return QString();
459 QString FirstConfigure::getFortranCompiler() const
461 if(this->compilerSetup())
463 return this->mNativeCompilerSetupPage->getFortranCompiler();
465 else if(this->crossCompilerSetup())
467 return this->mCrossCompilerSetupPage->getFortranCompiler();
469 return QString();
473 QString FirstConfigure::getSystemVersion() const
475 return this->mCrossCompilerSetupPage->getVersion();
478 QString FirstConfigure::getSystemProcessor() const
480 return this->mCrossCompilerSetupPage->getProcessor();
483 QString FirstConfigure::getCrossRoot() const
485 return this->mCrossCompilerSetupPage->getFindRoot();
488 const QString CrossModes[] =
490 "BOTH",
491 "ONLY",
492 "NEVER"
495 QString FirstConfigure::getCrossProgramMode() const
497 return CrossModes[this->mCrossCompilerSetupPage->getProgramMode()];
500 QString FirstConfigure::getCrossLibraryMode() const
502 return CrossModes[this->mCrossCompilerSetupPage->getLibraryMode()];
505 QString FirstConfigure::getCrossIncludeMode() const
507 return CrossModes[this->mCrossCompilerSetupPage->getIncludeMode()];