programoptions.ui.h 12 KB

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