projectoptions.ui.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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 <kfiledialog.h>
  31. #include <kprocess.h>
  32. #include "ktigcc.h"
  33. #include "tpr.h"
  34. #include "programoptions.h"
  35. ProgramOptions *programoptions;
  36. //the program options subdialog is created at initialization of a ProjectOptions and remains existant until the ProjectOptions is destroyed.
  37. void ProjectOptions::init()
  38. {
  39. if (!have_fargo) FargoProgram->hide();
  40. if (!have_flashos) FlashOperatingSystem->hide();
  41. //Create the Program Options dialog
  42. programoptions=new ProgramOptions(this);
  43. //Toggle controls to match settings.
  44. ImportSettings();
  45. //Update stuff
  46. CheckOncalcNames();
  47. UpdateVisibilities();
  48. }
  49. void ProjectOptions::destroy()
  50. {
  51. //Save settings
  52. if (result()==QDialog::Accepted)
  53. ExportSettings();
  54. delete(programoptions);
  55. }
  56. void ProjectOptions::ImportSettings(void)
  57. {
  58. Boolean isregular;
  59. //Tab: General
  60. OncalcVariableName_1->setText(settings.data_var);
  61. if (settings.copy_data_var)
  62. {
  63. if (settings.copy_data_var_arc)
  64. CreateCopyIfArchived->setChecked(TRUE);
  65. else
  66. CreateCopyAlways->setChecked(TRUE);
  67. }
  68. OncalcVariableName_2->setText(settings.pack_name);
  69. isregular=TRUE;
  70. if (settings.fargo)
  71. FargoProgram->setChecked(TRUE),isregular=FALSE;
  72. if (settings.flash_os)
  73. FlashOperatingSystem->setChecked(TRUE),isregular=FALSE;
  74. if (settings.archive)
  75. FunctionArchive->setChecked(TRUE),isregular=FALSE;
  76. if (isregular)
  77. {
  78. if (settings.use_data_var)
  79. {
  80. ExternalDataVariable->setChecked(TRUE);
  81. LOncalcVariableName_1->setEnabled(TRUE);
  82. OncalcVariableName_1->setEnabled(TRUE);
  83. LCreateCopyNever->setEnabled(TRUE);
  84. CreateCopyNever->setEnabled(TRUE);
  85. CreateCopyIfArchived->setEnabled(TRUE);
  86. CreateCopyAlways->setEnabled(TRUE);
  87. }
  88. if (settings.pack)
  89. {
  90. CompressProgram->setChecked(TRUE);
  91. LOncalcVariableName_2->setEnabled(TRUE);
  92. OncalcVariableName_2->setEnabled(TRUE);
  93. }
  94. }
  95. else
  96. {
  97. ExternalDataVariable->setEnabled(FALSE);
  98. CompressProgram->setEnabled(FALSE);
  99. }
  100. //Tab: Compilation
  101. GCCSwitches->setText(settings.cc_switches);
  102. AsSwitches->setText(settings.as_switches);
  103. A68kSwitches->setText(settings.a68k_switches);
  104. GenerateDebugInformation->setChecked(settings.debug_info);
  105. //Tab: Linking
  106. NOPs->setChecked(settings.optimize_nops);
  107. ReturnSequences->setChecked(settings.optimize_returns);
  108. Branches->setChecked(settings.optimize_branches);
  109. MoveLoadPushInstructions->setChecked(settings.optimize_moves);
  110. TestCompareInstructions->setChecked(settings.optimize_tests);
  111. CalculationInstructions->setChecked(settings.optimize_calcs);
  112. RemoveUnusedSections->setChecked(settings.remove_unused);
  113. ReorderSections->setChecked(settings.reorder_sections);
  114. CutUnusedRanges->setChecked(settings.cut_ranges);
  115. MergeConstants->setChecked(settings.merge_constants);
  116. LinkAgainstStandardLibrary->setChecked(settings.std_lib);
  117. InitializeBSSSection->setChecked(settings.initialize_bss);
  118. OutputVariableImageWithoutWrapper->setChecked(settings.outputbin);
  119. //Tab: Post-Build
  120. CallAfterBuilding->setText(settings.post_build);
  121. Parameters->setText(settings.cmd_line);
  122. programoptions->ImportSettings();
  123. }
  124. void ProjectOptions::ExportSettings(void)
  125. {
  126. //Tab: General
  127. settings.fargo=FALSE;
  128. settings.flash_os=FALSE;
  129. settings.archive=FALSE;
  130. settings.use_data_var=FALSE;
  131. settings.pack=FALSE;
  132. if (FargoProgram->isChecked())
  133. settings.fargo=TRUE;
  134. else if (FlashOperatingSystem->isChecked())
  135. settings.flash_os=TRUE;
  136. else if (FunctionArchive->isChecked())
  137. settings.archive=TRUE;
  138. 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
  139. {
  140. if (ExternalDataVariable->isChecked())
  141. settings.use_data_var=TRUE;
  142. if (CompressProgram->isChecked())
  143. settings.pack=TRUE;
  144. }
  145. //Subselections for External data variable and Compress program are always preserved.
  146. settings.data_var=OncalcVariableName_1->text();
  147. settings.copy_data_var_arc=FALSE;
  148. if (CreateCopyNever->isChecked())
  149. settings.copy_data_var=FALSE;
  150. else
  151. {
  152. settings.copy_data_var=TRUE;
  153. if (CreateCopyIfArchived->isChecked())
  154. settings.copy_data_var_arc=TRUE;
  155. }
  156. settings.pack_name=OncalcVariableName_2->text();
  157. //Tab: Compilation
  158. settings.cc_switches=GCCSwitches->text();
  159. settings.as_switches=AsSwitches->text();
  160. settings.a68k_switches=A68kSwitches->text();
  161. settings.debug_info=GenerateDebugInformation->isChecked();
  162. //Tab: Linking
  163. settings.optimize_nops=NOPs->isChecked();
  164. settings.optimize_returns=ReturnSequences->isChecked();
  165. settings.optimize_branches=Branches->isChecked();
  166. settings.optimize_moves=MoveLoadPushInstructions->isChecked();
  167. settings.optimize_tests=TestCompareInstructions->isChecked();
  168. settings.optimize_calcs=CalculationInstructions->isChecked();
  169. settings.remove_unused=RemoveUnusedSections->isChecked();
  170. settings.reorder_sections=ReorderSections->isChecked();
  171. settings.cut_ranges=CutUnusedRanges->isChecked();
  172. settings.merge_constants=MergeConstants->isChecked();
  173. settings.std_lib=LinkAgainstStandardLibrary->isChecked();
  174. settings.initialize_bss=InitializeBSSSection->isChecked();
  175. settings.outputbin=OutputVariableImageWithoutWrapper->isChecked();
  176. //Tab: Post-Build
  177. settings.post_build=CallAfterBuilding->text();
  178. settings.cmd_line=Parameters->text();
  179. programoptions->ExportSettings();
  180. }
  181. void ProjectOptions::RegularProgram_toggled(bool state)
  182. {
  183. if (!state)
  184. {
  185. ExternalDataVariable->setChecked(FALSE);
  186. CompressProgram->setChecked(FALSE);
  187. ExternalDataVariable_toggled(FALSE);
  188. CompressProgram_toggled(FALSE);
  189. }
  190. ExternalDataVariable->setEnabled(state);
  191. CompressProgram->setEnabled(state);
  192. }
  193. void ProjectOptions::ExternalDataVariable_toggled(bool state)
  194. {
  195. LOncalcVariableName_1->setEnabled(state);
  196. OncalcVariableName_1->setEnabled(state);
  197. LCreateCopyNever->setEnabled(state);
  198. CreateCopyNever->setEnabled(state);
  199. CreateCopyIfArchived->setEnabled(state);
  200. CreateCopyAlways->setEnabled(state);
  201. CheckOncalcNames();
  202. }
  203. void ProjectOptions::CompressProgram_toggled(bool state)
  204. {
  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->isChecked();
  223. Boolean functionarchive=FunctionArchive->isChecked();
  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. }
  235. void ProjectOptions::browseButton_clicked()
  236. {
  237. QString ret=KFileDialog::getOpenFileName("/usr/bin",
  238. "application/x-executable application/x-executable-script",this,
  239. "Choose executable");
  240. if (!ret.isEmpty())
  241. CallAfterBuilding->setText(KProcess::quote(ret)+" \"($TI89File)\" \"($TI92PlusFile)\" \"($V200File)\"");
  242. }