projectoptions.ui.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /****************************************************************************
  2. ** ui.h extension file, included from the uic-generated form implementation.
  3. **
  4. ** If you want to add, delete, or rename functions or slots, use
  5. ** Qt Designer to update this file, preserving your code.
  6. **
  7. ** You should not define a constructor or destructor in this file.
  8. ** Instead, write your code in functions called init() and destroy().
  9. ** These will automatically be called by the form's constructor and
  10. ** destructor.
  11. *****************************************************************************/
  12. /*
  13. ktigcc - TIGCC IDE for KDE
  14. Copyright (C) 2004-2006 Kevin Kofler
  15. Copyright (C) 2006 Joey Adams
  16. This program is free software; you can redistribute it and/or modify
  17. it under the terms of the GNU General Public License as published by
  18. the Free Software Foundation; either version 2, or (at your option)
  19. any later version.
  20. This program is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. GNU General Public License for more details.
  24. You should have received a copy of the GNU General Public License
  25. along with this program; if not, write to the Free Software Foundation,
  26. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  27. */
  28. #include <qaccel.h>
  29. #include <kmessagebox.h>
  30. #include "ktigcc.h"
  31. #include "tpr.h"
  32. #include "programoptions.h"
  33. extern tprSettings settings;
  34. ProgramOptions *programoptions;
  35. //the program options subdialog is created at initialization of a ProjectOptions and remains existant until the ProjectOptions is destroyed.
  36. void ProjectOptions::init()
  37. {
  38. if (!have_fargo) FargoProgram->hide();
  39. if (!have_flashos) FlashOperatingSystem->hide();
  40. //Create the Program Options dialog
  41. programoptions=new ProgramOptions(this);
  42. //Toggle controls to match settings.
  43. ImportSettings();
  44. //Update stuff
  45. CheckOncalcNames();
  46. UpdateVisibilities();
  47. }
  48. void ProjectOptions::destroy()
  49. {
  50. //Save settings
  51. if (result()==QDialog::Accepted)
  52. ExportSettings();
  53. delete(programoptions);
  54. }
  55. void ProjectOptions::ImportSettings(void)
  56. {
  57. Boolean isregular;
  58. //Tab: General
  59. OncalcVariableName_1->setText(settings.data_var);
  60. if (settings.copy_data_var)
  61. {
  62. if (settings.copy_data_var_arc)
  63. CreateCopyIfArchived->setChecked(TRUE);
  64. else
  65. CreateCopyAlways->setChecked(TRUE);
  66. }
  67. OncalcVariableName_2->setText(settings.pack_name);
  68. isregular=TRUE;
  69. if (settings.fargo)
  70. FargoProgram->setChecked(TRUE),isregular=FALSE;
  71. if (settings.flash_os)
  72. FlashOperatingSystem->setChecked(TRUE),isregular=FALSE;
  73. if (settings.archive)
  74. FunctionArchive->setChecked(TRUE),isregular=FALSE;
  75. if (isregular)
  76. {
  77. if (settings.use_data_var)
  78. {
  79. ExternalDataVariable->setChecked(TRUE);
  80. LOncalcVariableName_1->setEnabled(TRUE);
  81. OncalcVariableName_1->setEnabled(TRUE);
  82. LCreateCopyNever->setEnabled(TRUE);
  83. CreateCopyNever->setEnabled(TRUE);
  84. CreateCopyIfArchived->setEnabled(TRUE);
  85. CreateCopyAlways->setEnabled(TRUE);
  86. }
  87. if (settings.pack)
  88. {
  89. CompressProgram->setChecked(TRUE);
  90. LOncalcVariableName_2->setEnabled(TRUE);
  91. OncalcVariableName_2->setEnabled(TRUE);
  92. }
  93. }
  94. else
  95. {
  96. ExternalDataVariable->setEnabled(FALSE);
  97. CompressProgram->setEnabled(FALSE);
  98. }
  99. //Tab: Compilation
  100. GCCSwitches->setText(settings.cc_switches);
  101. AsSwitches->setText(settings.as_switches);
  102. A68kSwitches->setText(settings.a68k_switches);
  103. GenerateDebugInformation->setChecked(settings.debug_info);
  104. //Tab: Linking
  105. NOPs->setChecked(settings.optimize_nops);
  106. ReturnSequences->setChecked(settings.optimize_returns);
  107. Branches->setChecked(settings.optimize_branches);
  108. MoveLoadPushInstructions->setChecked(settings.optimize_moves);
  109. TestCompareInstructions->setChecked(settings.optimize_tests);
  110. CalculationInstructions->setChecked(settings.optimize_calcs);
  111. RemoveUnusedSections->setChecked(settings.remove_unused);
  112. ReorderSections->setChecked(settings.reorder_sections);
  113. CutUnusedRanges->setChecked(settings.cut_ranges);
  114. MergeConstants->setChecked(settings.merge_constants);
  115. LinkAgainstStandardLibrary->setChecked(settings.std_lib);
  116. InitializeBSSSection->setChecked(settings.initialize_bss);
  117. OutputVariableImageWithoutWrapper->setChecked(settings.outputbin);
  118. //Tab: Post-Build
  119. CallAfterBuilding->setText(settings.post_build);
  120. Parameters->setText(settings.cmd_line);
  121. programoptions->ImportSettings();
  122. }
  123. void ProjectOptions::ExportSettings(void)
  124. {
  125. //Tab: General
  126. settings.fargo=FALSE;
  127. settings.flash_os=FALSE;
  128. settings.archive=FALSE;
  129. settings.use_data_var=FALSE;
  130. settings.pack=FALSE;
  131. if (FargoProgram->isChecked())
  132. settings.fargo=TRUE;
  133. else if (FlashOperatingSystem->isChecked())
  134. settings.flash_os=TRUE;
  135. else if (FunctionArchive->isChecked())
  136. settings.archive=TRUE;
  137. else if (RegularProgram->isChecked()) //the original TIGCC IDE automatically unchecked External data variable and Compress program when you toggled away from Regular Program, so we will only consider these two if Regular Program is toggled
  138. {
  139. if (ExternalDataVariable->isChecked())
  140. settings.use_data_var=TRUE;
  141. if (CompressProgram->isChecked())
  142. settings.pack=TRUE;
  143. }
  144. //Subselections for External data variable and Compress program are always preserved.
  145. settings.data_var=OncalcVariableName_1->text();
  146. settings.copy_data_var_arc=FALSE;
  147. if (CreateCopyNever->isChecked())
  148. settings.copy_data_var=FALSE;
  149. else
  150. {
  151. settings.copy_data_var=TRUE;
  152. if (CreateCopyIfArchived->isChecked())
  153. settings.copy_data_var_arc=TRUE;
  154. }
  155. settings.pack_name=OncalcVariableName_2->text();
  156. //Tab: Compilation
  157. settings.cc_switches=GCCSwitches->text();
  158. settings.as_switches=AsSwitches->text();
  159. settings.a68k_switches=A68kSwitches->text();
  160. settings.debug_info=GenerateDebugInformation->isChecked();
  161. //Tab: Linking
  162. settings.optimize_nops=NOPs->isChecked();
  163. settings.optimize_returns=ReturnSequences->isChecked();
  164. settings.optimize_branches=Branches->isChecked();
  165. settings.optimize_moves=MoveLoadPushInstructions->isChecked();
  166. settings.optimize_tests=TestCompareInstructions->isChecked();
  167. settings.optimize_calcs=CalculationInstructions->isChecked();
  168. settings.remove_unused=RemoveUnusedSections->isChecked();
  169. settings.reorder_sections=ReorderSections->isChecked();
  170. settings.cut_ranges=CutUnusedRanges->isChecked();
  171. settings.merge_constants=MergeConstants->isChecked();
  172. settings.std_lib=LinkAgainstStandardLibrary->isChecked();
  173. settings.initialize_bss=InitializeBSSSection->isChecked();
  174. settings.outputbin=OutputVariableImageWithoutWrapper->isChecked();
  175. //Tab: Post-Build
  176. settings.post_build=CallAfterBuilding->text();
  177. settings.cmd_line=Parameters->text();
  178. programoptions->ExportSettings();
  179. }
  180. void ProjectOptions::RegularProgram_toggled(bool state)
  181. {
  182. if (!state)
  183. {
  184. ExternalDataVariable->setChecked(FALSE);
  185. CompressProgram->setChecked(FALSE);
  186. ExternalDataVariable_toggled(FALSE);
  187. CompressProgram_toggled(FALSE);
  188. }
  189. ExternalDataVariable->setEnabled(state);
  190. CompressProgram->setEnabled(state);
  191. }
  192. void ProjectOptions::ExternalDataVariable_toggled(bool state)
  193. {
  194. LOncalcVariableName_1->setEnabled(state);
  195. OncalcVariableName_1->setEnabled(state);
  196. LCreateCopyNever->setEnabled(state);
  197. CreateCopyNever->setEnabled(state);
  198. CreateCopyIfArchived->setEnabled(state);
  199. CreateCopyAlways->setEnabled(state);
  200. CheckOncalcNames();
  201. }
  202. void ProjectOptions::CompressProgram_toggled(bool state)
  203. {
  204. LOncalcVariableName_2->setEnabled(state);
  205. OncalcVariableName_2->setEnabled(state);
  206. CheckOncalcNames();
  207. }
  208. void ProjectOptions::CheckOncalcNames()
  209. {
  210. const QString &edvname=OncalcVariableName_1->text();
  211. const QString &compname=OncalcVariableName_2->text();
  212. Boolean edvon=OncalcVariableName_1->isEnabled();
  213. Boolean compon=OncalcVariableName_2->isEnabled();
  214. if ((edvon&&edvname.isEmpty()) || (compon&&compname.isEmpty()) || (edvon&&compon&&!edvname.compare(compname)))
  215. buttonOk->setEnabled(FALSE);
  216. else
  217. buttonOk->setEnabled(TRUE);
  218. }
  219. void ProjectOptions::UpdateVisibilities()
  220. {
  221. Boolean regularprogram=RegularProgram->isChecked();
  222. Boolean functionarchive=FunctionArchive->isChecked();
  223. if (regularprogram)
  224. ProgramOptionsButton->show();
  225. else
  226. ProgramOptionsButton->hide();
  227. PO_TabWidget->setTabEnabled(PO_TabWidget->page(2),!functionarchive);
  228. PO_TabWidget->setTabEnabled(PO_TabWidget->page(3),!functionarchive);
  229. }
  230. void ProjectOptions::ProgramOptionsFunc()
  231. {
  232. programoptions->exec();
  233. }