preferencesdlg.ui.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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 <qaccel.h>
  31. #include <knuminput.h>
  32. #include <kfontdialog.h>
  33. #include <kcolordialog.h>
  34. #include <kcombobox.h>
  35. #include <klistview.h>
  36. #include "ktigcc.h"
  37. class RenamableKListViewItem : public KListViewItem {
  38. public:
  39. RenamableKListViewItem(QListViewItem *parent, QString text)
  40. : KListViewItem(parent, text)
  41. {
  42. setRenameEnabled(0,TRUE);
  43. }
  44. RenamableKListViewItem(QListViewItem *parent, QListViewItem *after,
  45. QString text)
  46. : KListViewItem(parent, after, text)
  47. {
  48. setRenameEnabled(0,TRUE);
  49. }
  50. virtual int rtti(void) const {return 0x716CC8;}
  51. // Work around gratuitous API difference. Why do I have to do this? That's
  52. // what startRename is a virtual method for. KListViewItem should do this.
  53. virtual void startRename(int col)
  54. {
  55. static_cast<KListView *>(listView())->rename(this,col);
  56. }
  57. };
  58. void Preferences::init()
  59. {
  60. // General
  61. stopAtFirstError->setChecked(preferences.stopAtFirstError);
  62. jumpToError->setChecked(preferences.jumpToError);
  63. successMessage->setChecked(preferences.successMessage);
  64. deleteAsmFiles->setChecked(preferences.deleteAsmFiles);
  65. deleteObjFiles->setChecked(preferences.deleteObjFiles);
  66. splitSourceFiles->setChecked(preferences.splitSourceFiles);
  67. allowImplicitDeclaration->setChecked(preferences.allowImplicitDeclaration);
  68. autoSave->setChecked(preferences.autoSave);
  69. downloadHeadlines->setChecked(preferences.downloadHeadlines);
  70. deleteOverwrittenErrors->setChecked(preferences.deleteOverwrittenErrors);
  71. useSystemIcons->setChecked(preferences.useSystemIcons);
  72. // Transfer
  73. switch (preferences.linkTarget) {
  74. default: // LT_NONE
  75. targetNone->setChecked(TRUE);
  76. break;
  77. case LT_TIEMU:
  78. targetTiEmu->setChecked(TRUE);
  79. break;
  80. case LT_REALCALC:
  81. targetRealCalc->setChecked(TRUE);
  82. break;
  83. }
  84. switch (preferences.linkPort) {
  85. default: // PORT_1
  86. port1->setChecked(TRUE);
  87. break;
  88. case PORT_2:
  89. port2->setChecked(TRUE);
  90. break;
  91. case PORT_3:
  92. port3->setChecked(TRUE);
  93. break;
  94. case PORT_4:
  95. port4->setChecked(TRUE);
  96. break;
  97. }
  98. switch (preferences.linkCable) {
  99. default: // CABLE_GRY
  100. grayLink->setChecked(TRUE);
  101. break;
  102. case CABLE_BLK:
  103. blackLink->setChecked(TRUE);
  104. break;
  105. case CABLE_PAR:
  106. parallelLink->setChecked(TRUE);
  107. break;
  108. case CABLE_SLV:
  109. silverLink->setChecked(TRUE);
  110. break;
  111. case CABLE_USB:
  112. directLink->setChecked(TRUE);
  113. break;
  114. }
  115. // Don't allow selecting a USB cable if libticables2 hasn't been compiled
  116. // without USB support or if USB support can't be used.
  117. if (!have_usb) {
  118. if (silverLink->isChecked() || directLink->isChecked()) {
  119. grayLink->setChecked(TRUE);
  120. targetNone->setChecked(TRUE);
  121. }
  122. silverLink->setEnabled(FALSE);
  123. directLink->setEnabled(FALSE);
  124. }
  125. // Editor
  126. tabWidthC->setValue(preferences.tabWidthC);
  127. tabWidthAsm->setValue(preferences.tabWidthAsm);
  128. useBgColor->setChecked(preferences.useBgColor);
  129. bgColor->setBackgroundColor(preferences.bgColor);
  130. editorFont->setFont(preferences.editorFont);
  131. editorFont->setText(preferences.editorFont.family());
  132. useCalcCharset->setChecked(preferences.useCalcCharset);
  133. lazyLoading->setChecked(preferences.lazyLoading);
  134. autoBlocks->setChecked(preferences.autoBlocks);
  135. removeTrailingSpaces->setChecked(preferences.removeTrailingSpaces);
  136. // Syntax
  137. if (preferences.haveA68k)
  138. syntaxLanguage->insertItem("A68k Assembly Files");
  139. if (preferences.haveQuill)
  140. syntaxLanguage->insertItem("Quill Files");
  141. preferences.tempSynC=preferences.synC;
  142. preferences.tempSynS=preferences.synS;
  143. preferences.tempSynAsm=preferences.synAsm;
  144. preferences.tempSynQll=preferences.synQll;
  145. syntaxLanguage_activated(syntaxLanguage->currentItem());
  146. syntaxListView->setSorting(-1);
  147. syntaxListView->setColumnWidthMode(0,QListView::Maximum);
  148. syntaxListView->header()->hide();
  149. QListViewItem *rootListItem=syntaxListView->firstChild();
  150. QListViewItem *customStylesItem=rootListItem->firstChild();
  151. customStylesItem->setOpen(TRUE);
  152. QListViewItem *wordListsItem=customStylesItem->nextSibling();
  153. wordListsItem->setOpen(TRUE);
  154. QAccel *syntaxListViewAccel=new QAccel(syntaxListView);
  155. syntaxListViewAccel->insertItem(Key_Delete,0);
  156. connect(syntaxListViewAccel,SIGNAL(activated(int)),
  157. this,SLOT(syntaxListViewAccel_activated(int)));
  158. }
  159. void Preferences::destroy()
  160. {
  161. if (result()==Accepted) {
  162. // General
  163. preferences.stopAtFirstError=stopAtFirstError->isChecked();
  164. preferences.jumpToError=jumpToError->isChecked();
  165. preferences.successMessage=successMessage->isChecked();
  166. preferences.deleteAsmFiles=deleteAsmFiles->isChecked();
  167. preferences.deleteObjFiles=deleteObjFiles->isChecked();
  168. preferences.splitSourceFiles=splitSourceFiles->isChecked();
  169. preferences.allowImplicitDeclaration=allowImplicitDeclaration->isChecked();
  170. preferences.autoSave=autoSave->isChecked();
  171. preferences.downloadHeadlines=downloadHeadlines->isChecked();
  172. preferences.deleteOverwrittenErrors=deleteOverwrittenErrors->isChecked();
  173. preferences.useSystemIcons=useSystemIcons->isChecked();
  174. // Transfer
  175. preferences.linkTarget=targetTiEmu->isChecked()?LT_TIEMU
  176. :targetRealCalc->isChecked()?LT_REALCALC
  177. :LT_NONE;
  178. preferences.linkPort=port2->isChecked()?PORT_2
  179. :port3->isChecked()?PORT_3
  180. :port4->isChecked()?PORT_4
  181. :PORT_1;
  182. preferences.linkCable=blackLink->isChecked()?CABLE_BLK
  183. :parallelLink->isChecked()?CABLE_PAR
  184. :silverLink->isChecked()?CABLE_SLV
  185. :directLink->isChecked()?CABLE_USB
  186. :CABLE_GRY;
  187. // Editor
  188. preferences.tabWidthC=tabWidthC->value();
  189. preferences.tabWidthAsm=tabWidthAsm->value();
  190. preferences.useBgColor=useBgColor->isChecked();
  191. preferences.bgColor=bgColor->backgroundColor();
  192. preferences.editorFont=editorFont->font();
  193. preferences.useCalcCharset=useCalcCharset->isChecked();
  194. preferences.lazyLoading=lazyLoading->isChecked();
  195. preferences.autoBlocks=autoBlocks->isChecked();
  196. preferences.removeTrailingSpaces=removeTrailingSpaces->isChecked();
  197. // Syntax
  198. preferences.synC=preferences.tempSynC;
  199. preferences.synS=preferences.tempSynS;
  200. preferences.synAsm=preferences.tempSynAsm;
  201. preferences.synQll=preferences.tempSynQll;
  202. }
  203. }
  204. #define unused_on on __attribute__((unused))
  205. void Preferences::linkTarget_toggled(bool unused_on)
  206. {
  207. bool isRealCalc=targetRealCalc->isChecked();
  208. linkPort->setEnabled(isRealCalc);
  209. linkCable->setEnabled(isRealCalc);
  210. }
  211. void Preferences::bgColorChange_pressed()
  212. {
  213. bgColorChange->setDown(FALSE);
  214. QColor color=bgColor->backgroundColor();
  215. if (KColorDialog::getColor(color,this) == KColorDialog::Accepted) {
  216. useBgColor->setChecked(TRUE);
  217. bgColor->setBackgroundColor(color);
  218. }
  219. }
  220. void Preferences::editorFontChange_pressed()
  221. {
  222. editorFontChange->setDown(FALSE);
  223. QFont font=editorFont->font();
  224. if (KFontDialog::getFont(font,TRUE,this) == KFontDialog::Accepted) {
  225. editorFont->setFont(font);
  226. editorFont->setText(font.family());
  227. }
  228. }
  229. void Preferences::syntaxLanguage_activated(int index)
  230. {
  231. if (!index) preferences.syn=&preferences.tempSynC;
  232. else if (!--index) preferences.syn=&preferences.tempSynS;
  233. else if (preferences.haveA68k && !--index)
  234. preferences.syn=&preferences.tempSynAsm;
  235. else if (preferences.haveQuill && !--index)
  236. preferences.syn=&preferences.tempSynQll;
  237. else {
  238. qWarning("Preferences::syntaxLanguage_activated: Invalid index.");
  239. preferences.syn=&preferences.tempSynC;
  240. }
  241. syntaxEnabled->setChecked(preferences.syn->enabled);
  242. QListViewItem *rootListItem=syntaxListView->firstChild();
  243. QListViewItem *item, *nextItem;
  244. QListViewItem *customStylesItem=rootListItem->firstChild();
  245. for (item=customStylesItem->firstChild(); item; item=nextItem) {
  246. nextItem=item->nextSibling();
  247. delete item;
  248. }
  249. item=static_cast<QListViewItem *>(NULL);
  250. for (QValueList<Syn_CustomStyle>::ConstIterator it=
  251. preferences.syn->customStyles.begin();
  252. it!=preferences.syn->customStyles.end(); ++it) {
  253. item=new RenamableKListViewItem(customStylesItem,item,(*it).name);
  254. }
  255. QListViewItem *wordListsItem=customStylesItem->nextSibling();
  256. for (item=wordListsItem->firstChild(); item; item=nextItem) {
  257. nextItem=item->nextSibling();
  258. delete item;
  259. }
  260. item=static_cast<QListViewItem *>(NULL);
  261. for (QValueList<Syn_WordList>::ConstIterator it=
  262. preferences.syn->wordLists.begin();
  263. it!=preferences.syn->wordLists.end(); ++it) {
  264. item=new RenamableKListViewItem(wordListsItem,item,(*it).name);
  265. }
  266. }
  267. void Preferences::syntaxEnabled_toggled(bool on)
  268. {
  269. preferences.syn->enabled=on;
  270. resetButton->setEnabled(on);
  271. numberColorButton->setEnabled(on);
  272. numberStyleButton->setEnabled(on);
  273. symbolColorButton->setEnabled(on);
  274. symbolStyleButton->setEnabled(on);
  275. parenthesisColorsButton->setEnabled(on);
  276. parenthesisStyleButton->setEnabled(on);
  277. syntaxListView->setEnabled(on);
  278. newStyleButton->setEnabled(on);
  279. newListButton->setEnabled(on);
  280. QListViewItem *selectedItem=syntaxListView->selectedItem();
  281. editButton->setEnabled(on&&selectedItem&&selectedItem->rtti()==0x716CC8);
  282. }
  283. void Preferences::resetButton_clicked()
  284. {
  285. }
  286. void Preferences::numberColorButton_clicked()
  287. {
  288. }
  289. void Preferences::numberStyleButton_clicked()
  290. {
  291. }
  292. void Preferences::symbolColorButton_clicked()
  293. {
  294. }
  295. void Preferences::symbolStyleButton_clicked()
  296. {
  297. }
  298. void Preferences::parenthesisColorsButton_clicked()
  299. {
  300. }
  301. void Preferences::parenthesisStyleButton_clicked()
  302. {
  303. }
  304. void Preferences::syntaxListView_selectionChanged()
  305. {
  306. QListViewItem *selectedItem=syntaxListView->selectedItem();
  307. editButton->setEnabled(syntaxEnabled->isChecked()
  308. && selectedItem && selectedItem->rtti()==0x716CC8);
  309. }
  310. #define unused_col col __attribute__((unused))
  311. void Preferences::syntaxListView_itemRenamed(QListViewItem *item, const QString &str, int unused_col)
  312. {
  313. QListViewItem *rootListItem=syntaxListView->firstChild();
  314. QListViewItem *customStylesItem=rootListItem->firstChild();
  315. QListViewItem *wordListsItem=customStylesItem->nextSibling();
  316. if (item->parent()==customStylesItem) {
  317. QListViewItem *i;
  318. QValueList<Syn_CustomStyle>::Iterator it;
  319. for (it=preferences.syn->customStyles.begin(), i=customStylesItem->firstChild();
  320. i!=item && it!=preferences.syn->customStyles.end() && i;
  321. ++it, i=i->nextSibling());
  322. if (it==preferences.syn->customStyles.end() || !i)
  323. qWarning("Preferences::syntaxListView_itemRenamed: Invalid item.");
  324. else
  325. (*it).name=str;
  326. } else if (item->parent()==wordListsItem) {
  327. QListViewItem *i;
  328. QValueList<Syn_WordList>::Iterator it;
  329. for (it=preferences.syn->wordLists.begin(), i=wordListsItem->firstChild();
  330. i!=item && it!=preferences.syn->wordLists.end() && i;
  331. ++it, i=i->nextSibling());
  332. if (it==preferences.syn->wordLists.end() || !i)
  333. qWarning("Preferences::syntaxListView_itemRenamed: Invalid item.");
  334. else
  335. (*it).name=str;
  336. } else qWarning("Preferences::syntaxListView_itemRenamed: Invalid parent.");
  337. }
  338. void Preferences::syntaxListViewAccel_activated(int id)
  339. {
  340. if (!id) {
  341. QListViewItem *currentItem=syntaxListView->currentItem();
  342. if (currentItem && currentItem->rtti()==0x716CC8) {
  343. QListViewItem *rootListItem=syntaxListView->firstChild();
  344. QListViewItem *customStylesItem=rootListItem->firstChild();
  345. QListViewItem *wordListsItem=customStylesItem->nextSibling();
  346. if (currentItem->parent()==customStylesItem) {
  347. QListViewItem *i;
  348. QValueList<Syn_CustomStyle>::Iterator it;
  349. for (it=preferences.syn->customStyles.begin(), i=customStylesItem->firstChild();
  350. i!=currentItem && it!=preferences.syn->customStyles.end() && i;
  351. ++it, i=i->nextSibling());
  352. if (it==preferences.syn->customStyles.end() || !i)
  353. qWarning("Preferences::syntaxListViewAccel_activated: Invalid item.");
  354. else {
  355. delete currentItem;
  356. preferences.syn->customStyles.remove(it);
  357. }
  358. } else if (currentItem->parent()==wordListsItem) {
  359. QListViewItem *i;
  360. QValueList<Syn_WordList>::Iterator it;
  361. for (it=preferences.syn->wordLists.begin(), i=wordListsItem->firstChild();
  362. i!=currentItem && it!=preferences.syn->wordLists.end() && i;
  363. ++it, i=i->nextSibling());
  364. if (it==preferences.syn->wordLists.end() || !i)
  365. qWarning("Preferences::syntaxListViewAccel_activated: Invalid item.");
  366. else {
  367. delete currentItem;
  368. preferences.syn->wordLists.remove(it);
  369. }
  370. } else qWarning("Preferences::syntaxListViewAccel_activated: Invalid parent.");
  371. }
  372. }
  373. }
  374. void Preferences::newStyleButton_clicked()
  375. {
  376. }
  377. void Preferences::newListButton_clicked()
  378. {
  379. }
  380. void Preferences::editButton_clicked()
  381. {
  382. }