projectoptions.ui.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. #include <qaccel.h>
  13. #include <kmessagebox.h>
  14. #include <kurl.h>
  15. #include "tpr.h"
  16. #include "programoptions.h"
  17. extern tprSettings settings;
  18. ProgramOptions *programoptions;
  19. //the program options subdialog is created at initialization of a ProjectOptions and remains existant until the ProjectOptions is destroyed.
  20. #define UnwrapLabel(theQLabel) ((theQLabel)->setAlignment((theQLabel)->alignment()&~WordBreak))
  21. //Qt automatically sets RichText labels to have word wrap, which makes labels with underlines in them look bad. This simply undoes the wrapping.
  22. //manually created accelerators
  23. QAccel *AOncalcVariableName_1;
  24. QAccel *AOncalcVariableName_2;
  25. QAccel *AGCCSwitches;
  26. QAccel *AAsSwitches;
  27. QAccel *AA68kSwitches;
  28. QAccel *ACallAfterBuilding;
  29. QAccel *AParameters;
  30. void ProjectOptions::init()
  31. {
  32. //Qt automatically sets QLabels to wrapped when they are RichText. This undoes this change.
  33. UnwrapLabel(LOncalcVariableName_1);
  34. UnwrapLabel(LOncalcVariableName_2);
  35. UnwrapLabel(LGCCSwitches);
  36. UnwrapLabel(LAsSwitches);
  37. UnwrapLabel(LA68kSwitches);
  38. UnwrapLabel(LCallAfterBuilding);
  39. UnwrapLabel(LParameters);
  40. //Toggle controls to match settings.
  41. ImportSettings();
  42. //Create the Program Options dialog and toggle its controls
  43. programoptions=new ProgramOptions(this);
  44. programoptions->ImportSettings();
  45. //Update stuff
  46. CheckOncalcNames();
  47. UpdateVisibilities();
  48. //Create accelerators for text boxes manually
  49. QAccel *accel; //for temporarily holding the accelerator pointer
  50. #define MakeAccelerator(destaccelptr,thewidget,thepage,thekey) destaccelptr=accel=new QAccel(PO_TabWidget->page(thepage)); \
  51. accel->connectItem(accel->insertItem(thekey),thewidget,SLOT(setFocus()));
  52. MakeAccelerator(AOncalcVariableName_1,OncalcVariableName_1,0,ALT+Key_V);
  53. MakeAccelerator(AOncalcVariableName_2,OncalcVariableName_2,0,ALT+Key_I);
  54. MakeAccelerator(AGCCSwitches,GCCSwitches,1,ALT+Key_G);
  55. MakeAccelerator(AAsSwitches,AsSwitches,1,ALT+Key_S);
  56. MakeAccelerator(AA68kSwitches,A68kSwitches,1,ALT+Key_A);
  57. MakeAccelerator(ACallAfterBuilding,CallAfterBuilding,3,ALT+Key_A);
  58. MakeAccelerator(AParameters,Parameters,3,ALT+Key_R);
  59. #undef MakeAccelerator
  60. }
  61. void ProjectOptions::destroy()
  62. {
  63. delete(AOncalcVariableName_1);
  64. delete(AOncalcVariableName_2);
  65. delete(AGCCSwitches);
  66. delete(AAsSwitches);
  67. delete(AA68kSwitches);
  68. delete(ACallAfterBuilding);
  69. delete(AParameters);
  70. delete(programoptions);
  71. if (result()!=QDialog::Accepted)
  72. return;
  73. //Save settings
  74. ExportSettings();
  75. }
  76. void ProjectOptions::ImportSettings(void)
  77. {
  78. Boolean isregular;
  79. //Tab: General
  80. OncalcVariableName_1->setText(settings.data_var);
  81. if (settings.copy_data_var)
  82. {
  83. if (settings.copy_data_var_arc)
  84. CreateCopyIfArchived->toggle();
  85. else
  86. CreateCopyAlways->toggle();
  87. }
  88. OncalcVariableName_2->setText(settings.pack_name);
  89. isregular=TRUE;
  90. if (settings.fargo)
  91. FargoProgram->toggle(),isregular=FALSE;
  92. if (settings.flash_os)
  93. FlashOperatingSystem->toggle(),isregular=FALSE;
  94. if (settings.archive)
  95. FunctionArchive->toggle(),isregular=FALSE;
  96. if (isregular)
  97. {
  98. if (settings.use_data_var)
  99. {
  100. ExternalDataVariable->toggle();
  101. LOncalcVariableName_1->setEnabled(TRUE);
  102. OncalcVariableName_1->setEnabled(TRUE);
  103. LCreateCopyNever->setEnabled(TRUE);
  104. CreateCopyNever->setEnabled(TRUE);
  105. CreateCopyIfArchived->setEnabled(TRUE);
  106. CreateCopyAlways->setEnabled(TRUE);
  107. }
  108. if (settings.pack)
  109. {
  110. CompressProgram->toggle();
  111. LOncalcVariableName_2->setEnabled(TRUE);
  112. OncalcVariableName_2->setEnabled(TRUE);
  113. }
  114. }
  115. else
  116. {
  117. ExternalDataVariable->setEnabled(FALSE);
  118. CompressProgram->setEnabled(FALSE);
  119. }
  120. //Tab: Compilation
  121. GCCSwitches->setText(settings.cc_switches);
  122. AsSwitches->setText(settings.as_switches);
  123. A68kSwitches->setText(settings.a68k_switches);
  124. if (settings.debug_info)
  125. GenerateDebugInformation->toggle();
  126. //Tab: Linking
  127. if (settings.optimize_nops)
  128. NOPs->toggle();
  129. if (settings.optimize_returns)
  130. ReturnSequences->toggle();
  131. if (settings.optimize_branches)
  132. Branches->toggle();
  133. if (settings.optimize_moves)
  134. MoveLoadPushInstructions->toggle();
  135. if (settings.optimize_tests)
  136. TestCompareInstructions->toggle();
  137. if (settings.optimize_calcs)
  138. CalculationInstructions->toggle();
  139. if (settings.remove_unused)
  140. RemoveUnusedSections->toggle();
  141. if (settings.reorder_sections)
  142. ReorderSections->toggle();
  143. if (settings.cut_ranges)
  144. CutUnusedRanges->toggle();
  145. if (settings.merge_constants)
  146. MergeConstants->toggle();
  147. if (settings.std_lib)
  148. LinkAgainstStandardLibrary->toggle();
  149. if (settings.initialize_bss)
  150. InitializeBSSSection->toggle();
  151. if (settings.outputbin)
  152. OutputVariableImageWithoutWrapper->toggle();
  153. //Tab: Post-Build
  154. CallAfterBuilding->setText(settings.post_build);
  155. Parameters->setText(settings.cmd_line);
  156. }
  157. void ProjectOptions::ExportSettings(void)
  158. {
  159. //Tab: General
  160. settings.fargo=FALSE;
  161. settings.flash_os=FALSE;
  162. settings.archive=FALSE;
  163. settings.use_data_var=FALSE;
  164. settings.pack=FALSE;
  165. if (FargoProgram->isOn())
  166. settings.fargo=TRUE;
  167. else if (FlashOperatingSystem->isOn())
  168. settings.flash_os=TRUE;
  169. else if (FunctionArchive->isOn())
  170. settings.archive=TRUE;
  171. 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
  172. {
  173. if (ExternalDataVariable->isOn())
  174. settings.use_data_var=TRUE;
  175. if (CompressProgram->isOn())
  176. settings.pack=TRUE;
  177. }
  178. //Subselections for External data variable and Compress program are always preserved.
  179. settings.data_var=OncalcVariableName_1->text();
  180. settings.copy_data_var_arc=FALSE;
  181. if (CreateCopyNever->isOn())
  182. settings.copy_data_var=FALSE;
  183. else
  184. {
  185. settings.copy_data_var=TRUE;
  186. if (CreateCopyIfArchived->isOn())
  187. settings.copy_data_var_arc=TRUE;
  188. }
  189. settings.pack_name=OncalcVariableName_2->text();
  190. //Tab: Compilation
  191. }
  192. void ProjectOptions::RegularProgramToggle()
  193. {
  194. int state;
  195. buttonOk->setAccel(0);
  196. buttonOk->setText("OK");
  197. state=RegularProgram->isOn()?TRUE:FALSE;
  198. if (!state)
  199. {
  200. if (ExternalDataVariable->isOn())
  201. ExternalDataVariable->toggle();
  202. if (CompressProgram->isOn())
  203. CompressProgram->toggle();
  204. }
  205. ExternalDataVariable->setEnabled(state);
  206. CompressProgram->setEnabled(state);
  207. ExternalDataVariableToggle();
  208. CompressProgramToggle();
  209. }
  210. void ProjectOptions::ExternalDataVariableToggle()
  211. {
  212. int state;
  213. state=ExternalDataVariable->isOn()?TRUE:FALSE;
  214. LOncalcVariableName_1->setEnabled(state);
  215. OncalcVariableName_1->setEnabled(state);
  216. LCreateCopyNever->setEnabled(state);
  217. CreateCopyNever->setEnabled(state);
  218. CreateCopyIfArchived->setEnabled(state);
  219. CreateCopyAlways->setEnabled(state);
  220. CheckOncalcNames();
  221. }
  222. void ProjectOptions::CompressProgramToggle()
  223. {
  224. int state;
  225. state=CompressProgram->isOn()?TRUE:FALSE;
  226. LOncalcVariableName_2->setEnabled(state);
  227. OncalcVariableName_2->setEnabled(state);
  228. CheckOncalcNames();
  229. }
  230. void ProjectOptions::CheckOncalcNames()
  231. {
  232. const QString &edvname=OncalcVariableName_1->text();
  233. const QString &compname=OncalcVariableName_2->text();
  234. Boolean edvon=OncalcVariableName_1->isEnabled();
  235. Boolean compon=OncalcVariableName_2->isEnabled();
  236. if ((edvon&&edvname.isEmpty()) || (compon&&compname.isEmpty()) || (edvon&&compon&&!edvname.compare(compname)))
  237. buttonOk->setEnabled(FALSE);
  238. else
  239. buttonOk->setEnabled(TRUE);
  240. }
  241. void ProjectOptions::UpdateVisibilities()
  242. {
  243. Boolean regularprogram=RegularProgram->isOn();
  244. Boolean functionarchive=FunctionArchive->isOn();
  245. if (regularprogram)
  246. ProgramOptionsButton->show();
  247. else
  248. ProgramOptionsButton->hide();
  249. PO_TabWidget->setTabEnabled(PO_TabWidget->page(2),!functionarchive);
  250. PO_TabWidget->setTabEnabled(PO_TabWidget->page(3),!functionarchive);
  251. }
  252. void ProjectOptions::ProgramOptionsFunc()
  253. {
  254. programoptions->exec();
  255. }