projectoptions.ui.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. ProgramOptions *programoptions;
  34. //the program options subdialog is created at initialization of a ProjectOptions and remains existant until the ProjectOptions is destroyed.
  35. void ProjectOptions::init()
  36. {
  37. if (!have_fargo) FargoProgram->hide();
  38. if (!have_flashos) FlashOperatingSystem->hide();
  39. //Create the Program Options dialog
  40. programoptions=new ProgramOptions(this);
  41. //Toggle controls to match settings.
  42. ImportSettings();
  43. //Update stuff
  44. CheckOncalcNames();
  45. UpdateVisibilities();
  46. }
  47. void ProjectOptions::destroy()
  48. {
  49. //Save settings
  50. if (result()==QDialog::Accepted)
  51. ExportSettings();
  52. delete(programoptions);
  53. }
  54. void ProjectOptions::ImportSettings(void)
  55. {
  56. Boolean isregular;
  57. //Tab: General
  58. OncalcVariableName_1->setText(settings.data_var);
  59. if (settings.copy_data_var)
  60. {
  61. if (settings.copy_data_var_arc)
  62. CreateCopyIfArchived->setChecked(TRUE);
  63. else
  64. CreateCopyAlways->setChecked(TRUE);
  65. }
  66. OncalcVariableName_2->setText(settings.pack_name);
  67. isregular=TRUE;
  68. if (settings.fargo)
  69. FargoProgram->setChecked(TRUE),isregular=FALSE;
  70. if (settings.flash_os)
  71. FlashOperatingSystem->setChecked(TRUE),isregular=FALSE;
  72. if (settings.archive)
  73. FunctionArchive->setChecked(TRUE),isregular=FALSE;
  74. if (isregular)
  75. {
  76. if (settings.use_data_var)
  77. {
  78. ExternalDataVariable->setChecked(TRUE);
  79. LOncalcVariableName_1->setEnabled(TRUE);
  80. OncalcVariableName_1->setEnabled(TRUE);
  81. LCreateCopyNever->setEnabled(TRUE);
  82. CreateCopyNever->setEnabled(TRUE);
  83. CreateCopyIfArchived->setEnabled(TRUE);
  84. CreateCopyAlways->setEnabled(TRUE);
  85. }
  86. if (settings.pack)
  87. {
  88. CompressProgram->setChecked(TRUE);
  89. LOncalcVariableName_2->setEnabled(TRUE);
  90. OncalcVariableName_2->setEnabled(TRUE);
  91. }
  92. }
  93. else
  94. {
  95. ExternalDataVariable->setEnabled(FALSE);
  96. CompressProgram->setEnabled(FALSE);
  97. }
  98. //Tab: Compilation
  99. GCCSwitches->setText(settings.cc_switches);
  100. AsSwitches->setText(settings.as_switches);
  101. A68kSwitches->setText(settings.a68k_switches);
  102. GenerateDebugInformation->setChecked(settings.debug_info);
  103. //Tab: Linking
  104. NOPs->setChecked(settings.optimize_nops);
  105. ReturnSequences->setChecked(settings.optimize_returns);
  106. Branches->setChecked(settings.optimize_branches);
  107. MoveLoadPushInstructions->setChecked(settings.optimize_moves);
  108. TestCompareInstructions->setChecked(settings.optimize_tests);
  109. CalculationInstructions->setChecked(settings.optimize_calcs);
  110. RemoveUnusedSections->setChecked(settings.remove_unused);
  111. ReorderSections->setChecked(settings.reorder_sections);
  112. CutUnusedRanges->setChecked(settings.cut_ranges);
  113. MergeConstants->setChecked(settings.merge_constants);
  114. LinkAgainstStandardLibrary->setChecked(settings.std_lib);
  115. InitializeBSSSection->setChecked(settings.initialize_bss);
  116. OutputVariableImageWithoutWrapper->setChecked(settings.outputbin);
  117. //Tab: Post-Build
  118. CallAfterBuilding->setText(settings.post_build);
  119. Parameters->setText(settings.cmd_line);
  120. programoptions->ImportSettings();
  121. }
  122. void ProjectOptions::ExportSettings(void)
  123. {
  124. //Tab: General
  125. settings.fargo=FALSE;
  126. settings.flash_os=FALSE;
  127. settings.archive=FALSE;
  128. settings.use_data_var=FALSE;
  129. settings.pack=FALSE;
  130. if (FargoProgram->isChecked())
  131. settings.fargo=TRUE;
  132. else if (FlashOperatingSystem->isChecked())
  133. settings.flash_os=TRUE;
  134. else if (FunctionArchive->isChecked())
  135. settings.archive=TRUE;
  136. 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
  137. {
  138. if (ExternalDataVariable->isChecked())
  139. settings.use_data_var=TRUE;
  140. if (CompressProgram->isChecked())
  141. settings.pack=TRUE;
  142. }
  143. //Subselections for External data variable and Compress program are always preserved.
  144. settings.data_var=OncalcVariableName_1->text();
  145. settings.copy_data_var_arc=FALSE;
  146. if (CreateCopyNever->isChecked())
  147. settings.copy_data_var=FALSE;
  148. else
  149. {
  150. settings.copy_data_var=TRUE;
  151. if (CreateCopyIfArchived->isChecked())
  152. settings.copy_data_var_arc=TRUE;
  153. }
  154. settings.pack_name=OncalcVariableName_2->text();
  155. //Tab: Compilation
  156. settings.cc_switches=GCCSwitches->text();
  157. settings.as_switches=AsSwitches->text();
  158. settings.a68k_switches=A68kSwitches->text();
  159. settings.debug_info=GenerateDebugInformation->isChecked();
  160. //Tab: Linking
  161. settings.optimize_nops=NOPs->isChecked();
  162. settings.optimize_returns=ReturnSequences->isChecked();
  163. settings.optimize_branches=Branches->isChecked();
  164. settings.optimize_moves=MoveLoadPushInstructions->isChecked();
  165. settings.optimize_tests=TestCompareInstructions->isChecked();
  166. settings.optimize_calcs=CalculationInstructions->isChecked();
  167. settings.remove_unused=RemoveUnusedSections->isChecked();
  168. settings.reorder_sections=ReorderSections->isChecked();
  169. settings.cut_ranges=CutUnusedRanges->isChecked();
  170. settings.merge_constants=MergeConstants->isChecked();
  171. settings.std_lib=LinkAgainstStandardLibrary->isChecked();
  172. settings.initialize_bss=InitializeBSSSection->isChecked();
  173. settings.outputbin=OutputVariableImageWithoutWrapper->isChecked();
  174. //Tab: Post-Build
  175. settings.post_build=CallAfterBuilding->text();
  176. settings.cmd_line=Parameters->text();
  177. programoptions->ExportSettings();
  178. }
  179. void ProjectOptions::RegularProgram_toggled(bool state)
  180. {
  181. if (!state)
  182. {
  183. ExternalDataVariable->setChecked(FALSE);
  184. CompressProgram->setChecked(FALSE);
  185. ExternalDataVariable_toggled(FALSE);
  186. CompressProgram_toggled(FALSE);
  187. }
  188. ExternalDataVariable->setEnabled(state);
  189. CompressProgram->setEnabled(state);
  190. }
  191. void ProjectOptions::ExternalDataVariable_toggled(bool state)
  192. {
  193. LOncalcVariableName_1->setEnabled(state);
  194. OncalcVariableName_1->setEnabled(state);
  195. LCreateCopyNever->setEnabled(state);
  196. CreateCopyNever->setEnabled(state);
  197. CreateCopyIfArchived->setEnabled(state);
  198. CreateCopyAlways->setEnabled(state);
  199. CheckOncalcNames();
  200. }
  201. void ProjectOptions::CompressProgram_toggled(bool state)
  202. {
  203. LOncalcVariableName_2->setEnabled(state);
  204. OncalcVariableName_2->setEnabled(state);
  205. CheckOncalcNames();
  206. }
  207. void ProjectOptions::CheckOncalcNames()
  208. {
  209. const QString &edvname=OncalcVariableName_1->text();
  210. const QString &compname=OncalcVariableName_2->text();
  211. Boolean edvon=OncalcVariableName_1->isEnabled();
  212. Boolean compon=OncalcVariableName_2->isEnabled();
  213. if ((edvon&&edvname.isEmpty()) || (compon&&compname.isEmpty()) || (edvon&&compon&&!edvname.compare(compname)))
  214. buttonOk->setEnabled(FALSE);
  215. else
  216. buttonOk->setEnabled(TRUE);
  217. }
  218. void ProjectOptions::UpdateVisibilities()
  219. {
  220. Boolean regularprogram=RegularProgram->isChecked();
  221. Boolean functionarchive=FunctionArchive->isChecked();
  222. if (regularprogram)
  223. ProgramOptionsButton->show();
  224. else
  225. ProgramOptionsButton->hide();
  226. PO_TabWidget->setTabEnabled(PO_TabWidget->page(2),!functionarchive);
  227. PO_TabWidget->setTabEnabled(PO_TabWidget->page(3),!functionarchive);
  228. }
  229. void ProjectOptions::ProgramOptionsFunc()
  230. {
  231. programoptions->exec();
  232. }