projectoptions.ui.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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 <kurl.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. //Toggle controls to match settings.
  39. ImportSettings();
  40. //Create the Program Options dialog and toggle its controls
  41. programoptions=new ProgramOptions(this);
  42. programoptions->ImportSettings();
  43. //Update stuff
  44. CheckOncalcNames();
  45. UpdateVisibilities();
  46. }
  47. void ProjectOptions::destroy()
  48. {
  49. delete(programoptions);
  50. if (result()!=QDialog::Accepted)
  51. return;
  52. //Save settings
  53. ExportSettings();
  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->toggle();
  64. else
  65. CreateCopyAlways->toggle();
  66. }
  67. OncalcVariableName_2->setText(settings.pack_name);
  68. isregular=TRUE;
  69. if (settings.fargo)
  70. FargoProgram->toggle(),isregular=FALSE;
  71. if (settings.flash_os)
  72. FlashOperatingSystem->toggle(),isregular=FALSE;
  73. if (settings.archive)
  74. FunctionArchive->toggle(),isregular=FALSE;
  75. if (isregular)
  76. {
  77. if (settings.use_data_var)
  78. {
  79. ExternalDataVariable->toggle();
  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->toggle();
  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. if (settings.debug_info)
  104. GenerateDebugInformation->toggle();
  105. //Tab: Linking
  106. if (settings.optimize_nops)
  107. NOPs->toggle();
  108. if (settings.optimize_returns)
  109. ReturnSequences->toggle();
  110. if (settings.optimize_branches)
  111. Branches->toggle();
  112. if (settings.optimize_moves)
  113. MoveLoadPushInstructions->toggle();
  114. if (settings.optimize_tests)
  115. TestCompareInstructions->toggle();
  116. if (settings.optimize_calcs)
  117. CalculationInstructions->toggle();
  118. if (settings.remove_unused)
  119. RemoveUnusedSections->toggle();
  120. if (settings.reorder_sections)
  121. ReorderSections->toggle();
  122. if (settings.cut_ranges)
  123. CutUnusedRanges->toggle();
  124. if (settings.merge_constants)
  125. MergeConstants->toggle();
  126. if (settings.std_lib)
  127. LinkAgainstStandardLibrary->toggle();
  128. if (settings.initialize_bss)
  129. InitializeBSSSection->toggle();
  130. if (settings.outputbin)
  131. OutputVariableImageWithoutWrapper->toggle();
  132. //Tab: Post-Build
  133. CallAfterBuilding->setText(settings.post_build);
  134. Parameters->setText(settings.cmd_line);
  135. }
  136. void ProjectOptions::ExportSettings(void)
  137. {
  138. //Tab: General
  139. settings.fargo=FALSE;
  140. settings.flash_os=FALSE;
  141. settings.archive=FALSE;
  142. settings.use_data_var=FALSE;
  143. settings.pack=FALSE;
  144. if (FargoProgram->isOn())
  145. settings.fargo=TRUE;
  146. else if (FlashOperatingSystem->isOn())
  147. settings.flash_os=TRUE;
  148. else if (FunctionArchive->isOn())
  149. settings.archive=TRUE;
  150. else if (RegularProgram->isOn()) //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
  151. {
  152. if (ExternalDataVariable->isOn())
  153. settings.use_data_var=TRUE;
  154. if (CompressProgram->isOn())
  155. settings.pack=TRUE;
  156. }
  157. //Subselections for External data variable and Compress program are always preserved.
  158. settings.data_var=OncalcVariableName_1->text();
  159. settings.copy_data_var_arc=FALSE;
  160. if (CreateCopyNever->isOn())
  161. settings.copy_data_var=FALSE;
  162. else
  163. {
  164. settings.copy_data_var=TRUE;
  165. if (CreateCopyIfArchived->isOn())
  166. settings.copy_data_var_arc=TRUE;
  167. }
  168. settings.pack_name=OncalcVariableName_2->text();
  169. //Tab: Compilation
  170. }
  171. void ProjectOptions::RegularProgramToggle()
  172. {
  173. int state;
  174. buttonOk->setAccel(0);
  175. buttonOk->setText("OK");
  176. state=RegularProgram->isOn()?TRUE:FALSE;
  177. if (!state)
  178. {
  179. if (ExternalDataVariable->isOn())
  180. ExternalDataVariable->toggle();
  181. if (CompressProgram->isOn())
  182. CompressProgram->toggle();
  183. }
  184. ExternalDataVariable->setEnabled(state);
  185. CompressProgram->setEnabled(state);
  186. ExternalDataVariableToggle();
  187. CompressProgramToggle();
  188. }
  189. void ProjectOptions::ExternalDataVariableToggle()
  190. {
  191. int state;
  192. state=ExternalDataVariable->isOn()?TRUE:FALSE;
  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::CompressProgramToggle()
  202. {
  203. int state;
  204. state=CompressProgram->isOn()?TRUE:FALSE;
  205. LOncalcVariableName_2->setEnabled(state);
  206. OncalcVariableName_2->setEnabled(state);
  207. CheckOncalcNames();
  208. }
  209. void ProjectOptions::CheckOncalcNames()
  210. {
  211. const QString &edvname=OncalcVariableName_1->text();
  212. const QString &compname=OncalcVariableName_2->text();
  213. Boolean edvon=OncalcVariableName_1->isEnabled();
  214. Boolean compon=OncalcVariableName_2->isEnabled();
  215. if ((edvon&&edvname.isEmpty()) || (compon&&compname.isEmpty()) || (edvon&&compon&&!edvname.compare(compname)))
  216. buttonOk->setEnabled(FALSE);
  217. else
  218. buttonOk->setEnabled(TRUE);
  219. }
  220. void ProjectOptions::UpdateVisibilities()
  221. {
  222. Boolean regularprogram=RegularProgram->isOn();
  223. Boolean functionarchive=FunctionArchive->isOn();
  224. if (regularprogram)
  225. ProgramOptionsButton->show();
  226. else
  227. ProgramOptionsButton->hide();
  228. PO_TabWidget->setTabEnabled(PO_TabWidget->page(2),!functionarchive);
  229. PO_TabWidget->setTabEnabled(PO_TabWidget->page(3),!functionarchive);
  230. }
  231. void ProjectOptions::ProgramOptionsFunc()
  232. {
  233. programoptions->exec();
  234. }