settingsdialog.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #include <QFileDialog>
  2. #include <QDir>
  3. #include <QDebug>
  4. #include "iqtprojectgenerator.h"
  5. #include "settingsdialog.h"
  6. #include "ui_settingsdialog.h"
  7. #include "settings.h"
  8. SettingsDialog::SettingsDialog(IQtProjectGenerator * generator,
  9. const QString & widgetFile,
  10. QWidget * parent)
  11. : QDialog(parent),
  12. m_generator(generator),
  13. m_platformGui(NULL),
  14. ui(new Ui::SettingsDialog)
  15. {
  16. ui->setupUi(this);
  17. m_platformGui = m_generator->createSettingsWidget(widgetFile,
  18. this);
  19. ui->settingsFrame->layout()->addWidget(m_platformGui);
  20. m_platformPlugins = m_generator->createSettingsPluginsWidget(this);
  21. ui->pluginsFrame->layout()->addWidget(m_platformPlugins);
  22. setWindowTitle("Settings");
  23. setModal(true);
  24. connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(save()));
  25. /* OBS FDOS
  26. // Read values
  27. ui->uid3Value->setText(Settings::get(Settings::UID3).toString());
  28. ui->qtenvValue->setText(Settings::get(Settings::QtEnvBatPath).toString()); // Note: check for Qt before mobility path! Mobility tries to guess based on Qt path.
  29. ui->logFileValue->setText(Settings::get(Settings::LogFilePath).toString());
  30. ui->layoutValue->setCurrentIndex(Settings::get(Settings::WidgetLayout).toInt());
  31. ui->checkWidgetPannable->setChecked(Settings::get(Settings::PanningEnabled).toBool());
  32. ui->checkTextSelectable->setChecked(Settings::get(Settings::TextSelectionEnabled).toBool());
  33. if (Settings::get(Settings::MobilityIsTechnologyPreview).toBool()) // Uses Mobility path, so check that first
  34. {
  35. ui->radioMobilityPreview->setChecked(true);
  36. }
  37. else
  38. {
  39. ui->radioMobilityBeta->setChecked(true);
  40. }
  41. // Connect browse buttons
  42. connect(ui->buttonBrowseBat, SIGNAL(clicked()), this, SLOT(browseForBat()));
  43. connect(ui->buttonBrowseLog, SIGNAL(clicked()), this, SLOT(browseForLog()));
  44. */
  45. }
  46. SettingsDialog::~SettingsDialog()
  47. {
  48. delete ui;
  49. }
  50. void SettingsDialog::save()
  51. {
  52. /* OBS FDOS
  53. Settings::set(Settings::UID3, ui->uid3Value->text().trimmed());
  54. Settings::set(Settings::QtEnvBatPath, ui->qtenvValue->text().trimmed());
  55. Settings::set(Settings::LogFilePath, ui->logFileValue->text().trimmed());
  56. Settings::set(Settings::WidgetLayout, ui->layoutValue->currentIndex());
  57. Settings::set(Settings::PanningEnabled, ui->checkWidgetPannable->isChecked());
  58. Settings::set(Settings::TextSelectionEnabled, ui->checkTextSelectable->isChecked());
  59. Settings::set(Settings::MobilityIsTechnologyPreview, ui->radioMobilityPreview->isChecked());
  60. */
  61. m_generator->saveSettings(m_platformGui);
  62. m_generator->savePluginSettings(m_platformPlugins);
  63. }
  64. /* OBS FDOS
  65. void SettingsDialog::browseForBat()
  66. {
  67. QFileInfo file = getFileInfo(Settings::get(Settings::QtEnvBatPath).toString());
  68. QString fileName = QFileDialog::getOpenFileName(this, tr("Select qtenv.bat"), file.absolutePath(), tr("Batch files") + " (*.bat);;" + tr("All Files (*)"));
  69. if (!fileName.isEmpty())
  70. {
  71. fileName = QDir::toNativeSeparators(fileName);
  72. ui->qtenvValue->setText(fileName);
  73. }
  74. }
  75. void SettingsDialog::browseForLog()
  76. {
  77. // Existing
  78. QFileInfo file = getFileInfo(Settings::get(Settings::LogFilePath).toString());
  79. QString fileName = QFileDialog::getOpenFileName(this, tr("Select application log file"), file.absolutePath(), tr("Log files") + " (*.log);;" + tr("All Files (*)"));
  80. if (!fileName.isEmpty())
  81. {
  82. fileName = QDir::toNativeSeparators(fileName);
  83. ui->logFileValue->setText(fileName);
  84. }
  85. }
  86. / **
  87. * Returns a FileInfo object created of the given file. If the file's
  88. * directory does not exist, returns a FileInfo of root directory instead.
  89. * /
  90. QFileInfo SettingsDialog::getFileInfo(QString fileName)
  91. {
  92. QFileInfo file(fileName);
  93. if (!QFile::exists(file.absolutePath()))
  94. {
  95. file = QFileInfo(QDir::root().absolutePath());
  96. }
  97. return file;
  98. }
  99. OBS */