programoptions.ui.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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 <qapplication.h>
  29. #include <qevent.h>
  30. #include <qeventloop.h>
  31. #include <qtooltip.h>
  32. #include "ktigcc.h"
  33. #include "tpr.h"
  34. #include "assistant.h"
  35. void ProgramOptions::ImportSettings()
  36. {
  37. //Tab: Calculator
  38. TI89->setChecked(libopts.use_ti89);
  39. TI92Plus->setChecked(libopts.use_ti92p);
  40. V200->setChecked(libopts.use_v200);
  41. OptimizeCalcConsts->setChecked(libopts.opt_calc_consts);
  42. //Tab: Operating System
  43. if (libopts.use_preos)
  44. PreOS->setChecked(TRUE);
  45. else if (libopts.use_kernel)
  46. UseKernel->setChecked(TRUE);
  47. else
  48. Nostub->setChecked(TRUE);
  49. CMinimumAMSVersion->setChecked(libopts.use_minams);
  50. MinimumAMSVersion->setText(QString("%1.%2%3").arg(libopts.minams/100).arg((libopts.minams/10)%10).arg(libopts.minams%10));
  51. MinimumAMSVersion->setEnabled(libopts.use_minams);
  52. UnofficialOSSupport->setChecked(libopts.unofficial_os);
  53. //Tab: Reloc Format
  54. if (libopts.reloc_format==RT_KERNEL)
  55. RelocKernel->setChecked(TRUE);
  56. else if (libopts.reloc_format==RT_COMPRESSED)
  57. RelocCompressed->setChecked(TRUE);
  58. else if (libopts.reloc_format==RT_MLINK)
  59. RelocMlink->setChecked(TRUE);
  60. else
  61. RelocAMS->setChecked(TRUE);
  62. UseFLineJumps->setChecked(libopts.use_fline_jumps);
  63. Use4ByteFLineJumps->setChecked(libopts.use_4b_fline_jumps);
  64. if (libopts.rom_call_format==RT_KERNEL)
  65. ROMCallKernel->setChecked(TRUE);
  66. else if (libopts.rom_call_format==RT_COMPRESSED)
  67. ROMCallCompressed->setChecked(TRUE);
  68. else if (libopts.rom_call_format==RT_MLINK)
  69. ROMCallMlink->setChecked(TRUE);
  70. else if (libopts.rom_call_format==RT_FLINE)
  71. ROMCallFLine->setChecked(TRUE);
  72. else
  73. ROMCallDirect->setChecked(TRUE);
  74. OptimizeROMCalls->setChecked(libopts.opt_rom_calls);
  75. UseInternalFLineEmulator->setChecked(libopts.use_internal_fline_emu);
  76. //Tab: BSS/Data Format
  77. if (libopts.bss_ref_format==RT_KERNEL)
  78. BSSKernel->setChecked(TRUE);
  79. else if (libopts.bss_ref_format==RT_COMPRESSED)
  80. BSSCompressed->setChecked(TRUE);
  81. else if (libopts.bss_ref_format==RT_MLINK)
  82. BSSMlink->setChecked(TRUE);
  83. else
  84. BSSMerge->setChecked(TRUE);
  85. if (libopts.data_ref_format==RT_COMPRESSED)
  86. DataVarCompressed->setChecked(TRUE);
  87. else if (libopts.data_ref_format==RT_MLINK)
  88. DataVarMlink->setChecked(TRUE);
  89. else
  90. DataVarKernel->setChecked(TRUE);
  91. //Tab: Home Screen
  92. if (libopts.use_return_value)
  93. HomeCustomValue->setChecked(TRUE);
  94. else
  95. HomeDone->setChecked(TRUE);
  96. EnableReturningErrors->setChecked(libopts.enable_error_return);
  97. SaveScreen->setChecked(libopts.save_screen);
  98. }
  99. void ProgramOptions::ExportSettings()
  100. {
  101. //Tab: Calculator
  102. libopts.use_ti89=TI89->isChecked();
  103. libopts.use_ti92p=TI92Plus->isChecked();
  104. libopts.use_v200=V200->isChecked();
  105. libopts.opt_calc_consts=OptimizeCalcConsts->isChecked();
  106. //Tab: Operating System
  107. libopts.use_preos=PreOS->isChecked();
  108. libopts.use_kernel=UseKernel->isChecked();
  109. libopts.use_minams=CMinimumAMSVersion->isChecked();
  110. QString minams=MinimumAMSVersion->text();
  111. libopts.minams=minams.section('.',0,0).toUInt()*100+minams.section('.',1,1).toUInt();
  112. libopts.unofficial_os=UnofficialOSSupport->isChecked();
  113. //Tab: Reloc Format
  114. if (RelocKernel->isChecked())
  115. libopts.reloc_format=RT_KERNEL;
  116. else if (RelocCompressed->isChecked())
  117. libopts.reloc_format=RT_COMPRESSED;
  118. else if (RelocMlink->isChecked())
  119. libopts.reloc_format=RT_MLINK;
  120. else
  121. libopts.reloc_format=RT_AMS;
  122. libopts.use_fline_jumps=UseFLineJumps->isChecked();
  123. libopts.use_4b_fline_jumps=Use4ByteFLineJumps->isChecked();
  124. if (ROMCallKernel->isChecked())
  125. libopts.rom_call_format=RT_KERNEL;
  126. else if (ROMCallCompressed->isChecked())
  127. libopts.rom_call_format=RT_COMPRESSED;
  128. else if (ROMCallMlink->isChecked())
  129. libopts.rom_call_format=RT_MLINK;
  130. else if (ROMCallFLine->isChecked())
  131. libopts.rom_call_format=RT_FLINE;
  132. else
  133. libopts.rom_call_format=RT_DIRECT;
  134. libopts.opt_rom_calls=OptimizeROMCalls->isChecked();
  135. libopts.use_internal_fline_emu=UseInternalFLineEmulator->isChecked();
  136. //Tab: BSS/Data Format
  137. if (BSSKernel->isChecked())
  138. libopts.bss_ref_format=RT_KERNEL;
  139. else if (BSSCompressed->isChecked())
  140. libopts.bss_ref_format=RT_COMPRESSED;
  141. else if (BSSMlink->isChecked())
  142. libopts.bss_ref_format=RT_MLINK;
  143. else
  144. libopts.bss_ref_format=RT_NONE;
  145. if (DataVarCompressed->isChecked())
  146. libopts.data_ref_format=RT_COMPRESSED;
  147. else if (DataVarMlink->isChecked())
  148. libopts.data_ref_format=RT_MLINK;
  149. else
  150. libopts.data_ref_format=RT_KERNEL;
  151. //Tab: Home Screen
  152. libopts.use_return_value=HomeCustomValue->isChecked();
  153. libopts.enable_error_return=EnableReturningErrors->isChecked();
  154. libopts.save_screen=SaveScreen->isChecked();
  155. }
  156. void ProgramOptions::CMinimumAMSVersion_toggled(bool on)
  157. {
  158. MinimumAMSVersion->setEnabled(on);
  159. }
  160. #define on_unused on __attribute__((unused))
  161. void ProgramOptions::CalcCheckbox_toggled(bool on_unused)
  162. {
  163. static bool inEvent=FALSE;
  164. if (!inEvent) {
  165. inEvent=TRUE;
  166. unsigned numCalcs=TI89->isChecked()+TI92Plus->isChecked()+V200->isChecked();
  167. // OPTIMIZE_CALC_CONSTS makes no sense for only 1 calculator (calculator
  168. // constants are already optimized for that calculator at compile-time in
  169. // that case, no need to do it at link time).
  170. // Moreover, we can't enable it for old projects (no calculator checked,
  171. // calculators selected through int _ti89 and such in the code).
  172. OptimizeCalcConsts->setEnabled(numCalcs>=2);
  173. if (numCalcs<2) OptimizeCalcConsts->setChecked(numCalcs);
  174. inEvent=FALSE;
  175. }
  176. }
  177. void ProgramOptions::KernelRadiobutton_toggled(bool on_unused)
  178. {
  179. static bool inEvent=FALSE;
  180. if (!inEvent) {
  181. inEvent=TRUE;
  182. bool nostub=Nostub->isChecked();
  183. bool kernel=UseKernel->isChecked();
  184. bool preos=PreOS->isChecked();
  185. // SAVE_SCREEN is currently always on in kernel mode.
  186. SaveScreen->setEnabled(nostub);
  187. if (!nostub) SaveScreen->setChecked(TRUE);
  188. if (kernel) {
  189. // Kernel mode, enable kernel reloc types.
  190. RelocKernel->setEnabled(TRUE);
  191. ROMCallKernel->setEnabled(TRUE);
  192. BSSKernel->setEnabled(TRUE);
  193. // Default to them if an unsupported reloc type was selected.
  194. if (RelocAMS->isChecked() || RelocCompressed->isChecked()
  195. || RelocMlink->isChecked())
  196. RelocKernel->setChecked(TRUE);
  197. if (ROMCallDirect->isChecked() || ROMCallCompressed->isChecked()
  198. || ROMCallMlink->isChecked())
  199. ROMCallKernel->setChecked(TRUE);
  200. if (BSSCompressed->isChecked() || BSSMlink->isChecked())
  201. BSSKernel->setChecked(TRUE);
  202. // Now disable the unsupported types.
  203. RelocAMS->setEnabled(FALSE);
  204. RelocCompressed->setEnabled(FALSE);
  205. RelocMlink->setEnabled(FALSE);
  206. ROMCallDirect->setEnabled(FALSE);
  207. ROMCallCompressed->setEnabled(FALSE);
  208. ROMCallMlink->setEnabled(FALSE);
  209. BSSCompressed->setEnabled(FALSE);
  210. BSSMlink->setEnabled(FALSE);
  211. } else if (preos) {
  212. // Kernel with compressed reloc tables mode, enable compressed reloc types.
  213. RelocCompressed->setEnabled(TRUE);
  214. ROMCallCompressed->setEnabled(TRUE);
  215. BSSCompressed->setEnabled(TRUE);
  216. // Default to them if an unsupported reloc type was selected.
  217. if (RelocAMS->isChecked() || RelocKernel->isChecked()
  218. || RelocMlink->isChecked())
  219. RelocCompressed->setChecked(TRUE);
  220. if (ROMCallDirect->isChecked() || ROMCallKernel->isChecked()
  221. || ROMCallMlink->isChecked())
  222. ROMCallCompressed->setChecked(TRUE);
  223. if (BSSKernel->isChecked() || BSSMlink->isChecked())
  224. BSSCompressed->setChecked(TRUE);
  225. // Now disable the unsupported types.
  226. RelocAMS->setEnabled(FALSE);
  227. RelocKernel->setEnabled(FALSE);
  228. RelocMlink->setEnabled(FALSE);
  229. ROMCallDirect->setEnabled(FALSE);
  230. ROMCallKernel->setEnabled(FALSE);
  231. ROMCallMlink->setEnabled(FALSE);
  232. BSSKernel->setEnabled(FALSE);
  233. BSSMlink->setEnabled(FALSE);
  234. } else {
  235. // In _nostub mode, all reloc types are allowed.
  236. RelocAMS->setEnabled(TRUE);
  237. RelocKernel->setEnabled(TRUE);
  238. RelocCompressed->setEnabled(TRUE);
  239. RelocMlink->setEnabled(TRUE);
  240. ROMCallDirect->setEnabled(TRUE);
  241. ROMCallKernel->setEnabled(TRUE);
  242. ROMCallCompressed->setEnabled(TRUE);
  243. ROMCallMlink->setEnabled(TRUE);
  244. BSSKernel->setEnabled(TRUE);
  245. BSSCompressed->setEnabled(TRUE);
  246. BSSMlink->setEnabled(TRUE);
  247. }
  248. RelocSettings_toggled(0);
  249. inEvent=FALSE;
  250. }
  251. }
  252. void ProgramOptions::RelocSettings_toggled(bool on_unused)
  253. {
  254. static bool inEvent=FALSE;
  255. if (!inEvent) {
  256. inEvent=TRUE;
  257. // 4-byte F-Line jumps only make sense if F-Line jumps are enabled
  258. if (UseFLineJumps->isChecked())
  259. Use4ByteFLineJumps->setEnabled(TRUE);
  260. else {
  261. Use4ByteFLineJumps->setEnabled(FALSE);
  262. Use4ByteFLineJumps->setChecked(FALSE);
  263. }
  264. if (Use4ByteFLineJumps->isChecked()) {
  265. // 4-byte F-Line jumps require the internal emulator
  266. UseInternalFLineEmulator->setEnabled(FALSE);
  267. UseInternalFLineEmulator->setChecked(TRUE);
  268. } else if (UseFLineJumps->isChecked() || ROMCallFLine->isChecked()) {
  269. // using F-Line instructions where the internal emulator can be used
  270. UseInternalFLineEmulator->setEnabled(TRUE);
  271. } else {
  272. // no F-Line instructions to emulate, internally or otherwise
  273. UseInternalFLineEmulator->setEnabled(FALSE);
  274. UseInternalFLineEmulator->setChecked(FALSE);
  275. }
  276. // OPTIMIZE_ROM_CALLS only allowed with direct or F-Line ROM_CALLs in _nostub mode
  277. if (Nostub->isChecked() && (ROMCallDirect->isChecked() || ROMCallFLine->isChecked()))
  278. OptimizeROMCalls->setEnabled(TRUE);
  279. else {
  280. OptimizeROMCalls->setEnabled(FALSE);
  281. OptimizeROMCalls->setChecked(FALSE);
  282. }
  283. inEvent=FALSE;
  284. }
  285. }
  286. void ProgramOptions::mousePressEvent( QMouseEvent * e )
  287. {
  288. if (e->button()==Qt::RightButton) {
  289. QWidget *widgetUnderCursor=childAt(e->pos());
  290. if (!widgetUnderCursor) return;
  291. QString toolTip=QToolTip::textFor(widgetUnderCursor, widgetUnderCursor->mapFromParent(e->pos()));
  292. if (toolTip.isEmpty()) return;
  293. QString docFile=lookup_doc_keyword(toolTip);
  294. if (docFile.isEmpty()) return;
  295. force_qt_assistant_page(1);
  296. assistant->openAssistant(
  297. QString(tigcc_base)+QString("/doc/html/")+docFile);
  298. }
  299. }