preferencesdlg.ui.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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) 2006 Kevin Kofler
  15. This program is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation; either version 2, or (at your option)
  18. any later version.
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. GNU General Public License for more details.
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software Foundation,
  25. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #include "preferences.h"
  28. #include <qcheckbox.h>
  29. #include <qradiobutton.h>
  30. #include <knuminput.h>
  31. #include <kfontdialog.h>
  32. #include <kcolordialog.h>
  33. #include "ktigcc.h"
  34. void Preferences::init()
  35. {
  36. // General
  37. stopAtFirstError->setChecked(preferences.stopAtFirstError);
  38. jumpToError->setChecked(preferences.jumpToError);
  39. successMessage->setChecked(preferences.successMessage);
  40. deleteAsmFiles->setChecked(preferences.deleteAsmFiles);
  41. deleteObjFiles->setChecked(preferences.deleteObjFiles);
  42. splitSourceFiles->setChecked(preferences.splitSourceFiles);
  43. allowImplicitDeclaration->setChecked(preferences.allowImplicitDeclaration);
  44. autoSave->setChecked(preferences.autoSave);
  45. downloadHeadlines->setChecked(preferences.downloadHeadlines);
  46. deleteOverwrittenErrors->setChecked(preferences.deleteOverwrittenErrors);
  47. useSystemIcons->setChecked(preferences.useSystemIcons);
  48. // Transfer
  49. switch (preferences.linkTarget) {
  50. default: // LT_NONE
  51. targetNone->setChecked(TRUE);
  52. break;
  53. case LT_TIEMU:
  54. targetTiEmu->setChecked(TRUE);
  55. break;
  56. case LT_REALCALC:
  57. targetRealCalc->setChecked(TRUE);
  58. break;
  59. }
  60. switch (preferences.linkPort) {
  61. default: // PORT_1
  62. port1->setChecked(TRUE);
  63. break;
  64. case PORT_2:
  65. port2->setChecked(TRUE);
  66. break;
  67. case PORT_3:
  68. port3->setChecked(TRUE);
  69. break;
  70. case PORT_4:
  71. port4->setChecked(TRUE);
  72. break;
  73. }
  74. switch (preferences.linkCable) {
  75. default: // CABLE_GRY
  76. grayLink->setChecked(TRUE);
  77. break;
  78. case CABLE_BLK:
  79. blackLink->setChecked(TRUE);
  80. break;
  81. case CABLE_PAR:
  82. parallelLink->setChecked(TRUE);
  83. break;
  84. case CABLE_SLV:
  85. silverLink->setChecked(TRUE);
  86. break;
  87. case CABLE_USB:
  88. directLink->setChecked(TRUE);
  89. break;
  90. }
  91. // Don't allow selecting a USB cable if libticables2 hasn't been compiled
  92. // without USB support or if USB support can't be used.
  93. if (!have_usb) {
  94. if (silverLink->isChecked() || directLink->isChecked()) {
  95. grayLink->setChecked(TRUE);
  96. targetNone->setChecked(TRUE);
  97. }
  98. silverLink->setEnabled(FALSE);
  99. directLink->setEnabled(FALSE);
  100. }
  101. // Editor
  102. tabWidthC->setValue(preferences.tabWidthC);
  103. tabWidthAsm->setValue(preferences.tabWidthAsm);
  104. useBgColor->setChecked(preferences.useBgColor);
  105. bgColor->setBackgroundColor(preferences.bgColor);
  106. editorFont->setFont(preferences.editorFont);
  107. editorFont->setText(preferences.editorFont.family());
  108. useCalcCharset->setChecked(preferences.useCalcCharset);
  109. lazyLoading->setChecked(preferences.lazyLoading);
  110. autoBlocks->setChecked(preferences.autoBlocks);
  111. removeTrailingSpaces->setChecked(preferences.removeTrailingSpaces);
  112. }
  113. void Preferences::destroy()
  114. {
  115. if (result()==Accepted) {
  116. // General
  117. preferences.stopAtFirstError=stopAtFirstError->isChecked();
  118. preferences.jumpToError=jumpToError->isChecked();
  119. preferences.successMessage=successMessage->isChecked();
  120. preferences.deleteAsmFiles=deleteAsmFiles->isChecked();
  121. preferences.deleteObjFiles=deleteObjFiles->isChecked();
  122. preferences.splitSourceFiles=splitSourceFiles->isChecked();
  123. preferences.allowImplicitDeclaration=allowImplicitDeclaration->isChecked();
  124. preferences.autoSave=autoSave->isChecked();
  125. preferences.downloadHeadlines=downloadHeadlines->isChecked();
  126. preferences.deleteOverwrittenErrors=deleteOverwrittenErrors->isChecked();
  127. preferences.useSystemIcons=useSystemIcons->isChecked();
  128. // Transfer
  129. preferences.linkTarget=targetTiEmu->isChecked()?LT_TIEMU
  130. :targetRealCalc->isChecked()?LT_REALCALC
  131. :LT_NONE;
  132. preferences.linkPort=port2->isChecked()?PORT_2
  133. :port3->isChecked()?PORT_3
  134. :port4->isChecked()?PORT_4
  135. :PORT_1;
  136. preferences.linkCable=blackLink->isChecked()?CABLE_BLK
  137. :parallelLink->isChecked()?CABLE_PAR
  138. :silverLink->isChecked()?CABLE_SLV
  139. :directLink->isChecked()?CABLE_USB
  140. :CABLE_GRY;
  141. // Editor
  142. preferences.tabWidthC=tabWidthC->value();
  143. preferences.tabWidthAsm=tabWidthAsm->value();
  144. preferences.useBgColor=useBgColor->isChecked();
  145. preferences.bgColor=bgColor->backgroundColor();
  146. preferences.editorFont=editorFont->font();
  147. preferences.useCalcCharset=useCalcCharset->isChecked();
  148. preferences.lazyLoading=lazyLoading->isChecked();
  149. preferences.autoBlocks=autoBlocks->isChecked();
  150. preferences.removeTrailingSpaces=removeTrailingSpaces->isChecked();
  151. }
  152. }
  153. #define unused_on on __attribute__((unused))
  154. void Preferences::linkTarget_toggled(bool unused_on)
  155. {
  156. bool isRealCalc=targetRealCalc->isChecked();
  157. linkPort->setEnabled(isRealCalc);
  158. linkCable->setEnabled(isRealCalc);
  159. }
  160. void Preferences::bgColorChange_pressed()
  161. {
  162. bgColorChange->setDown(FALSE);
  163. QColor color=bgColor->backgroundColor();
  164. if (KColorDialog::getColor(color,this) == KColorDialog::Accepted) {
  165. useBgColor->setChecked(TRUE);
  166. bgColor->setBackgroundColor(color);
  167. }
  168. }
  169. void Preferences::editorFontChange_pressed()
  170. {
  171. editorFontChange->setDown(FALSE);
  172. QFont font=editorFont->font();
  173. if (KFontDialog::getFont(font,TRUE,this) == KFontDialog::Accepted) {
  174. editorFont->setFont(font);
  175. editorFont->setText(font.family());
  176. }
  177. }