programoptions.ui.h 12 KB

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