Bibletime – a bible study tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

coptionsdialog.cpp 37KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  1. /*********
  2. *
  3. * This file is part of BibleTime's source code, http://www.bibletime.info/.
  4. *
  5. * Copyright 1999-2006 by the BibleTime developers.
  6. * The BibleTime source code is licensed under the GNU General Public License version 2.0.
  7. *
  8. **********/
  9. #include "coptionsdialog.h"
  10. #include "cprofile.h"
  11. #include "backend/cswordbackend.h"
  12. #include "backend/cswordmoduleinfo.h"
  13. #include "backend/cdisplaytemplatemgr.h"
  14. #include "backend/cdisplayrendering.h"
  15. #include "frontend/displaywindow/cbiblereadwindow.h"
  16. #include "frontend/displaywindow/ccommentaryreadwindow.h"
  17. #include "frontend/displaywindow/clexiconreadwindow.h"
  18. #include "frontend/displaywindow/cbookreadwindow.h"
  19. #include "frontend/displaywindow/creadwindow.h"
  20. #include "util/cresmgr.h"
  21. #include "util/ctoolclass.h"
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. //QT includes
  25. #include <tqhbox.h>
  26. #include <tqlayout.h>
  27. #include <tqvbox.h>
  28. #include <tqdict.h>
  29. #include <tqcheckbox.h>
  30. #include <tqcombobox.h>
  31. #include <tqbuttongroup.h>
  32. #include <tqhbuttongroup.h>
  33. #include <tqradiobutton.h>
  34. #include <tqcolor.h>
  35. #include <tqtooltip.h>
  36. #include <tqwidgetstack.h>
  37. #include <tqstringlist.h>
  38. #include <tqinputdialog.h>
  39. #include <tqdir.h>
  40. //KDE includes
  41. #include <kapp.h>
  42. #include <klocale.h>
  43. #include <kglobal.h>
  44. #include <kstandarddirs.h>
  45. #include <kkeydialog.h>
  46. #include <tdehtml_part.h>
  47. #include <tdehtmlview.h>
  48. #include <kiconloader.h>
  49. #include <ktabctl.h>
  50. #include <kapp.h>
  51. #include <klistbox.h>
  52. #include <kkeydialog.h>
  53. #include <kaction.h>
  54. #include <tdeconfigbase.h>
  55. #include <tdeconfig.h>
  56. //Sword includes
  57. #include <localemgr.h>
  58. #include <swlocale.h>
  59. using std::string;
  60. using std::list;
  61. COptionsDialog::COptionsDialog(TQWidget *parent, const char *name, TDEActionCollection* actionCollection )
  62. : KDialogBase(IconList, i18n("Configure BibleTime"), Ok | Cancel | Apply, Ok, parent, name, true, true, TQString(), TQString(), TQString()) {
  63. m_settings.keys.application.actionCollection = actionCollection;
  64. setIconListAllVisible(true);
  65. initDisplay();
  66. initLanguages();
  67. initSword();
  68. initAccelerators();
  69. }
  70. COptionsDialog::~COptionsDialog() {
  71. //the actionCollections objects are deleted by their TQWidget parent
  72. }
  73. /** */
  74. void COptionsDialog::newDisplayWindowFontSelected(const TQFont &newFont) {
  75. CBTConfig::FontSettingsPair oldSettings = m_settings.fonts.fontMap[ m_settings.fonts.usage->currentText() ];
  76. m_settings.fonts.fontMap.replace( m_settings.fonts.usage->currentText(), CBTConfig::FontSettingsPair(oldSettings.first, newFont) );
  77. }
  78. /** Called when the combobox contents is changed */
  79. void COptionsDialog::newDisplayWindowFontAreaSelected(const TQString& usage) {
  80. useOwnFontClicked( m_settings.fonts.fontMap[usage].first );
  81. m_settings.fonts.useOwnFontBox->setChecked( m_settings.fonts.fontMap[usage].first );
  82. m_settings.fonts.fontChooser->setFont( m_settings.fonts.fontMap[usage].second );
  83. }
  84. /** Called if the OK button was clicked */
  85. void COptionsDialog::slotOk() {
  86. saveAccelerators();
  87. saveLanguages();
  88. saveSword();
  89. saveDisplay();
  90. KDialogBase::slotOk();
  91. emit signalSettingsChanged( );
  92. }
  93. /*called if the apply button was clicked*/
  94. void COptionsDialog::slotApply() {
  95. saveAccelerators();
  96. saveLanguages();
  97. saveSword();
  98. saveDisplay();
  99. KDialogBase::slotApply();
  100. emit signalSettingsChanged( );
  101. }
  102. /** Opens the page which contaisn the given part ID. */
  103. const bool COptionsDialog::showPart( COptionsDialog::Parts /*ID*/ ) {
  104. bool ret = false;
  105. /* switch (ID) {
  106. default:
  107. break;
  108. }*/
  109. return ret;
  110. }
  111. /** Initializes the startup section of the OD. */
  112. void COptionsDialog::initDisplay() {
  113. TQFrame* page = addPage(i18n("Display"), TQString(), DesktopIcon(CResMgr::settings::startup::icon,32));
  114. TQVBoxLayout* layout = new TQVBoxLayout(page);
  115. layout->setSpacing( 5 );
  116. {//daily tips
  117. m_settings.startup.showTips = new TQCheckBox(page);
  118. m_settings.startup.showTips->setText(i18n("Show tip of the day"));
  119. TQToolTip::add
  120. (m_settings.startup.showTips, CResMgr::settings::startup::dailyTip::tooltip );
  121. m_settings.startup.showTips->setChecked( CBTConfig::get
  122. (CBTConfig::tips) );
  123. }
  124. layout->addWidget(m_settings.startup.showTips);
  125. layout->addSpacing(5);
  126. { //startup logo
  127. m_settings.startup.showLogo = new TQCheckBox(page);
  128. m_settings.startup.showLogo->setText(i18n("Show startuplogo"));
  129. TQToolTip::add
  130. (m_settings.startup.showLogo, CResMgr::settings::startup::showLogo::tooltip);
  131. m_settings.startup.showLogo->setChecked(CBTConfig::get
  132. (CBTConfig::logo));
  133. layout->addWidget(m_settings.startup.showLogo);
  134. layout->addSpacing(20);
  135. }
  136. layout->addWidget(
  137. CToolClass::explanationLabel(page, i18n("Display templates"),
  138. i18n("Display templates define how text is displayed. Please choose a template you like.")
  139. )
  140. );
  141. layout->addSpacing( 5 );
  142. TQHBoxLayout* hboxlayout = new TQHBoxLayout();
  143. m_settings.displayStyle.styleChooser = new TQComboBox( page ); //create first to enable buddy for label
  144. connect( m_settings.displayStyle.styleChooser, TQT_SIGNAL( activated( int ) ),
  145. this, TQT_SLOT( updateStylePreview() ) );
  146. hboxlayout->addWidget(
  147. new TQLabel(m_settings.displayStyle.styleChooser, i18n("Available display styles:"), page)
  148. );
  149. hboxlayout->addWidget( m_settings.displayStyle.styleChooser );
  150. hboxlayout->addStretch();
  151. layout->addLayout( hboxlayout );
  152. m_settings.displayStyle.stylePreview = new TDEHTMLPart(page);
  153. layout->addWidget(
  154. new TQLabel(
  155. m_settings.displayStyle.stylePreview->view(),
  156. i18n("Style preview"), page
  157. )
  158. );
  159. layout->addWidget(m_settings.displayStyle.stylePreview->view());
  160. m_settings.displayStyle.styleChooser->insertStringList(
  161. CPointers::displayTemplateManager()->availableTemplates()
  162. );
  163. for (int i = 0; i < m_settings.displayStyle.styleChooser->count(); ++i) {
  164. if ( m_settings.displayStyle.styleChooser->text(i) == CBTConfig::get(CBTConfig::displayStyle) ) {
  165. m_settings.displayStyle.styleChooser->setCurrentItem( i );
  166. break;
  167. }
  168. }
  169. updateStylePreview(); //render it
  170. }
  171. /** Init fonts section. */
  172. void COptionsDialog::initLanguages() {
  173. TQFrame* page = addPage(i18n("Languages"), TQString(), DesktopIcon(CResMgr::settings::fonts::icon, 32));
  174. TQVBoxLayout* layout = new TQVBoxLayout(page,5);
  175. layout->setResizeMode( TQLayout::Minimum );
  176. { //Sword locales
  177. layout->addWidget(
  178. CToolClass::explanationLabel(page, i18n("Specify a language for names of Bible books"),
  179. i18n("Sword has a number of locales available which can be used to internationalize the \
  180. names of books of the Bible. You can specify which locale to use. If you want to \
  181. create a new locale, see http://www.crosswire.org/sword/develop for details."))
  182. );
  183. m_settings.fonts.swordLocaleCombo = new TQComboBox(page);
  184. TQLabel* label = new TQLabel(m_settings.fonts.swordLocaleCombo, i18n("Language for names of Bible books"), page);
  185. TQToolTip::add
  186. (m_settings.fonts.swordLocaleCombo, CResMgr::settings::sword::general::language::tooltip);
  187. TQHBoxLayout* hBoxLayout = new TQHBoxLayout();
  188. hBoxLayout->addWidget(label);
  189. hBoxLayout->addWidget(m_settings.fonts.swordLocaleCombo);
  190. hBoxLayout->addStretch();
  191. layout->addLayout(hBoxLayout);
  192. TQStringList languageNames;
  193. languageNames.append( languageMgr()->languageForAbbrev("en_US")->translatedName() );
  194. // languageNames.append( i18n("English") );
  195. list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
  196. // locales.push_back(SWBuf("en_US"));
  197. for (list<sword::SWBuf>::const_iterator it = locales.begin(); it != locales.end(); it++) {
  198. // tqWarning("working on %s", (*it).c_str());
  199. const CLanguageMgr::Language* const l = CPointers::languageMgr()->languageForAbbrev(
  200. sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName()
  201. );
  202. if (l->isValid()) {
  203. languageNames.append( l->translatedName() );
  204. }
  205. else {
  206. languageNames.append(
  207. sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getDescription()
  208. );
  209. }
  210. }
  211. languageNames.sort();
  212. m_settings.fonts.swordLocaleCombo->insertStringList( languageNames );
  213. const CLanguageMgr::Language* const l = CPointers::languageMgr()->languageForAbbrev(
  214. CBTConfig::get
  215. (CBTConfig::language)
  216. );
  217. TQString currentLanguageName;
  218. if ( l->isValid() && languageNames.contains(l->translatedName()) ) { //tranlated language name is in the box
  219. currentLanguageName = l->translatedName();
  220. }
  221. else { //a language like "German Abbrevs" might be the language to set
  222. sword::SWLocale* locale = sword::LocaleMgr::LocaleMgr::getSystemLocaleMgr()->getLocale(
  223. CBTConfig::get
  224. (CBTConfig::language).local8Bit()
  225. );
  226. if (locale) {
  227. currentLanguageName = TQString::fromLatin1(locale->getDescription());
  228. }
  229. }
  230. if (currentLanguageName.isEmpty()) { // set english as default if nothing was chosen
  231. // currentLanguageName = i18n("English");
  232. Q_ASSERT(languageMgr()->languageForAbbrev("en_US"));
  233. currentLanguageName = languageMgr()->languageForAbbrev("en_US")->translatedName();
  234. }
  235. //now set the item with the right name as current item
  236. for (int i = 0; i < m_settings.fonts.swordLocaleCombo->count(); ++i) {
  237. if (currentLanguageName == m_settings.fonts.swordLocaleCombo->text(i)) {
  238. m_settings.fonts.swordLocaleCombo->setCurrentItem(i);
  239. break; //item found, finish the loop
  240. }
  241. }
  242. layout->addSpacing( 20 );
  243. }
  244. { //Font settings
  245. layout->addWidget(
  246. CToolClass::explanationLabel(
  247. page,
  248. i18n("Select custom fonts per-language"),
  249. i18n("Here you find a list of all languages of the installed works. \
  250. You can specify a custom font for each language that needs a special font \
  251. to be displayed correctly.")
  252. )
  253. );
  254. layout->addSpacing(5);
  255. TQHBoxLayout* hLayout = new TQHBoxLayout();
  256. m_settings.fonts.usage = new TQComboBox(page);
  257. TQToolTip::add
  258. (m_settings.fonts.usage, CResMgr::settings::fonts::typeChooser::tooltip);
  259. hLayout->addWidget(m_settings.fonts.usage);
  260. CLanguageMgr::LangMap langMap = languageMgr()->availableLanguages();
  261. for ( CLanguageMgr::LangMapIterator it( langMap ); it.current(); ++it ) {
  262. const TQString name = it.current()->translatedName().isEmpty() ?
  263. it.current()->abbrev() : it.current()->translatedName();
  264. m_settings.fonts.fontMap.insert(name, CBTConfig::get
  265. (it.current()) );
  266. }
  267. for( TQMap<TQString, CBTConfig::FontSettingsPair>::Iterator it = m_settings.fonts.fontMap.begin(); it != m_settings.fonts.fontMap.end(); ++it ) {
  268. if ( m_settings.fonts.fontMap[it.key()].first ) { //show font icon
  269. m_settings.fonts.usage->insertItem(SmallIcon("fonts"), it.key() );
  270. }
  271. else { //don't show icon for font
  272. m_settings.fonts.usage->insertItem(it.key());
  273. }
  274. }
  275. m_settings.fonts.useOwnFontBox = new TQCheckBox(i18n("Use custom font"), page, "font checkbox");
  276. connect(m_settings.fonts.useOwnFontBox, TQT_SIGNAL(toggled(bool)), TQT_SLOT(useOwnFontClicked(bool)));
  277. hLayout->addWidget(m_settings.fonts.useOwnFontBox);
  278. layout->addLayout(hLayout);
  279. //#warning TODO: remember the last selected font and jump there.
  280. m_settings.fonts.fontChooser = new TDEFontChooser(page, "fonts", false, TQStringList(), true, 5);
  281. m_settings.fonts.fontChooser->setSampleText(i18n("The quick brown fox jumps over the lazy dog."));
  282. layout->addWidget(m_settings.fonts.fontChooser);
  283. connect(m_settings.fonts.fontChooser, TQT_SIGNAL(fontSelected(const TQFont&)), TQT_SLOT(newDisplayWindowFontSelected(const TQFont&)));
  284. connect(m_settings.fonts.usage, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(newDisplayWindowFontAreaSelected(const TQString&)));
  285. m_settings.fonts.fontChooser->setFont( m_settings.fonts.fontMap[m_settings.fonts.usage->currentText()].second );
  286. useOwnFontClicked( m_settings.fonts.fontMap[m_settings.fonts.usage->currentText()].first );
  287. m_settings.fonts.useOwnFontBox->setChecked( m_settings.fonts.fontMap[m_settings.fonts.usage->currentText()].first );
  288. m_settings.fonts.fontChooser->setMinimumSize(m_settings.fonts.fontChooser->sizeHint());
  289. }
  290. }
  291. /** Init accel key section. */
  292. void COptionsDialog::initAccelerators() {
  293. TQVBox* page = addVBoxPage(i18n("HotKeys"), TQString(), DesktopIcon(CResMgr::settings::keys::icon,32));
  294. CBTConfig::setupAccelSettings(
  295. CBTConfig::application,
  296. m_settings.keys.application.actionCollection
  297. );
  298. TQHBox* hbox = new TQHBox(page);
  299. TQLabel* label = new TQLabel(i18n("Choose type:"), hbox);
  300. m_settings.keys.typeChooser = new TQComboBox(hbox);
  301. connect(
  302. m_settings.keys.typeChooser, TQT_SIGNAL(activated(const TQString&)),
  303. TQT_SLOT(slotKeyChooserTypeChanged(const TQString&))
  304. );
  305. TQLabel* dummy = new TQLabel( hbox ); // empty label for stretch
  306. hbox->setStretchFactor(label, 0);
  307. hbox->setStretchFactor(m_settings.keys.typeChooser, 0);
  308. hbox->setStretchFactor(dummy, 1);
  309. page->setStretchFactor(hbox, 0);
  310. m_settings.keys.keyChooserStack = new TQWidgetStack(page);
  311. Q_ASSERT(m_settings.keys.keyChooserStack);
  312. page->setStretchFactor(m_settings.keys.keyChooserStack, 5);
  313. m_settings.keys.application.title = i18n("BibleTime"); //don't set the app action collection to NULL
  314. m_settings.keys.general = Settings::KeySettings::WindowType(i18n("All text windows"));
  315. m_settings.keys.bible = Settings::KeySettings::WindowType(i18n("Bible windows"));
  316. m_settings.keys.commentary = Settings::KeySettings::WindowType(i18n("Commentary windows"));
  317. m_settings.keys.lexicon = Settings::KeySettings::WindowType(i18n("Lexicon windows"));
  318. m_settings.keys.book = Settings::KeySettings::WindowType(i18n("Book windows"));
  319. m_settings.keys.typeChooser->insertItem(m_settings.keys.application.title);
  320. m_settings.keys.typeChooser->insertItem(m_settings.keys.general.title);
  321. m_settings.keys.typeChooser->insertItem(m_settings.keys.bible.title);
  322. m_settings.keys.typeChooser->insertItem(m_settings.keys.commentary.title);
  323. m_settings.keys.typeChooser->insertItem(m_settings.keys.lexicon.title);
  324. m_settings.keys.typeChooser->insertItem(m_settings.keys.book.title);
  325. Q_ASSERT(m_settings.keys.application.actionCollection);
  326. m_settings.keys.application.keyChooser = new KKeyChooser(
  327. m_settings.keys.application.actionCollection,
  328. m_settings.keys.keyChooserStack
  329. );
  330. // ----- All display windows ------ //
  331. m_settings.keys.general.actionCollection = new TDEActionCollection(this, "displayActions", 0);
  332. CDisplayWindow::insertKeyboardActions( m_settings.keys.general.actionCollection);
  333. CBTConfig::setupAccelSettings(
  334. CBTConfig::allWindows,
  335. m_settings.keys.general.actionCollection
  336. );
  337. m_settings.keys.general.keyChooser = new KKeyChooser(
  338. m_settings.keys.general.actionCollection,
  339. m_settings.keys.keyChooserStack
  340. );
  341. // ----- Bible windows ------ //
  342. m_settings.keys.bible.actionCollection = new TDEActionCollection(this, "bibleActions", 0);
  343. CBibleReadWindow::insertKeyboardActions( m_settings.keys.bible.actionCollection);
  344. CBTConfig::setupAccelSettings(
  345. CBTConfig::bibleWindow,
  346. m_settings.keys.bible.actionCollection
  347. );
  348. // ----- Commentary windows ------ //
  349. m_settings.keys.commentary.actionCollection= new TDEActionCollection(this, "commentaryActions", 0);
  350. CCommentaryReadWindow::insertKeyboardActions( m_settings.keys.commentary.actionCollection);
  351. CBTConfig::setupAccelSettings(
  352. CBTConfig::commentaryWindow,
  353. m_settings.keys.commentary.actionCollection
  354. );
  355. // ----- Lexicon windows ------ //
  356. m_settings.keys.lexicon.actionCollection = new TDEActionCollection(this, "lexiconActions", 0);
  357. CLexiconReadWindow::insertKeyboardActions( m_settings.keys.lexicon.actionCollection );
  358. CBTConfig::setupAccelSettings(
  359. CBTConfig::lexiconWindow,
  360. m_settings.keys.lexicon.actionCollection
  361. );
  362. // ----- Book windows ------ //
  363. m_settings.keys.book.actionCollection= new TDEActionCollection(this, "bookActions", 0);
  364. CBookReadWindow::insertKeyboardActions( m_settings.keys.book.actionCollection);
  365. CBTConfig::setupAccelSettings(
  366. CBTConfig::bookWindow,
  367. m_settings.keys.book.actionCollection
  368. );
  369. slotKeyChooserTypeChanged(m_settings.keys.application.title);
  370. }
  371. /** Init Sword section. */
  372. void COptionsDialog::initSword() {
  373. TQVBox* page = addVBoxPage(i18n("Desk"),TQString(), DesktopIcon(CResMgr::settings::sword::icon,32));
  374. KTabCtl* tabCtl = new KTabCtl(page);
  375. { //Standard works
  376. TQFrame* currentTab = new TQFrame(tabCtl);
  377. tabCtl->addTab(currentTab, i18n("Standard works"));
  378. TQGridLayout* gridLayout = new TQGridLayout(currentTab,10,2, 5,5); //the last row is for stretching available space
  379. gridLayout->setResizeMode(TQLayout::Minimum);
  380. gridLayout->addMultiCellWidget(
  381. CToolClass::explanationLabel(currentTab, i18n("Standard works"),
  382. i18n("Standard works are used when no particular work is specified, \
  383. for example when a hyperlink into a Bible or lexicon was clicked .")),
  384. 0,0,0,-1 /*fill the horizontal space*/
  385. );
  386. m_settings.swords.standardBible = new TQComboBox(currentTab);
  387. TQLabel* label = new TQLabel(m_settings.swords.standardBible, i18n("Standard Bible"), currentTab);
  388. label->setAutoResize(true);
  389. TQToolTip::add
  390. (m_settings.swords.standardBible, CResMgr::settings::sword::modules::bible::tooltip);
  391. gridLayout->addWidget(label,1,0);
  392. gridLayout->addWidget(m_settings.swords.standardBible,1,1);
  393. m_settings.swords.standardCommentary = new TQComboBox(currentTab);
  394. label = new TQLabel(m_settings.swords.standardCommentary, i18n("Standard Commentary"), currentTab);
  395. label->setAutoResize(true);
  396. TQToolTip::add
  397. (m_settings.swords.standardCommentary, CResMgr::settings::sword::modules::commentary::tooltip);
  398. gridLayout->addWidget(label,2,0);
  399. gridLayout->addWidget(m_settings.swords.standardCommentary,2,1);
  400. m_settings.swords.standardLexicon = new TQComboBox(currentTab);
  401. label = new TQLabel(m_settings.swords.standardLexicon, i18n("Standard Lexicon"), currentTab);
  402. label->setAutoResize(true);
  403. TQToolTip::add
  404. (m_settings.swords.standardLexicon, CResMgr::settings::sword::modules::lexicon::tooltip);
  405. gridLayout->addWidget(label,3,0);
  406. gridLayout->addWidget(m_settings.swords.standardLexicon,3,1);
  407. m_settings.swords.standardDailyDevotional = new TQComboBox(currentTab);
  408. label = new TQLabel(m_settings.swords.standardDailyDevotional, i18n("Standard Daily Devotional"), currentTab);
  409. label->setAutoResize(true);
  410. TQToolTip::add
  411. (m_settings.swords.standardDailyDevotional, CResMgr::settings::sword::modules::dailyDevotional::tooltip);
  412. gridLayout->addWidget(label,4,0);
  413. gridLayout->addWidget(m_settings.swords.standardDailyDevotional,4,1);
  414. m_settings.swords.standardHebrewStrong = new TQComboBox(currentTab);
  415. label = new TQLabel(m_settings.swords.standardHebrewStrong, i18n("Standard Hebrew Strong's Lexicon"), currentTab);
  416. label->setAutoResize(true);
  417. TQToolTip::add
  418. (m_settings.swords.standardHebrewStrong, CResMgr::settings::sword::modules::hebrewStrongs::tooltip);
  419. gridLayout->addWidget(label,5,0);
  420. gridLayout->addWidget(m_settings.swords.standardHebrewStrong,5,1);
  421. m_settings.swords.standardGreekStrong = new TQComboBox(currentTab);
  422. label = new TQLabel(m_settings.swords.standardGreekStrong, i18n("Standard Greek Strong's Lexicon"), currentTab);
  423. label->setAutoResize(true);
  424. TQToolTip::add
  425. (m_settings.swords.standardGreekStrong, CResMgr::settings::sword::modules::greekStrongs::tooltip);
  426. gridLayout->addWidget(label,6,0);
  427. gridLayout->addWidget(m_settings.swords.standardGreekStrong,6,1);
  428. m_settings.swords.standardHebrewMorph = new TQComboBox(currentTab);
  429. label = new TQLabel(m_settings.swords.standardHebrewMorph, i18n("Standard Hebrew Morphological Lexicon"), currentTab);
  430. TQToolTip::add
  431. (m_settings.swords.standardHebrewMorph, CResMgr::settings::sword::modules::hebrewMorph::tooltip);
  432. gridLayout->addWidget(label,7,0);
  433. gridLayout->addWidget(m_settings.swords.standardHebrewMorph,7,1);
  434. m_settings.swords.standardGreekMorph = new TQComboBox(currentTab);
  435. label = new TQLabel(m_settings.swords.standardGreekMorph, i18n("Standard Greek Morphological Lexicon"), currentTab);
  436. label->setAutoResize(true);
  437. TQToolTip::add
  438. (m_settings.swords.standardGreekMorph, CResMgr::settings::sword::modules::greekMorph::tooltip);
  439. gridLayout->addWidget(label,8,0);
  440. gridLayout->addWidget(m_settings.swords.standardGreekMorph,8,1);
  441. gridLayout->setRowStretch(9,5);
  442. //fill the comboboxes with the right modules
  443. ListCSwordModuleInfo& modules = backend()->moduleList();
  444. TQString modDescript;
  445. ListCSwordModuleInfo::iterator end_it = modules.end();
  446. for (ListCSwordModuleInfo::iterator it(modules.begin()); it != end_it; ++it) {
  447. modDescript = (*it)->config(CSwordModuleInfo::Description);
  448. switch ((*it)->type()) {
  449. case CSwordModuleInfo::Bible:
  450. m_settings.swords.standardBible->insertItem(modDescript);
  451. break;
  452. case CSwordModuleInfo::Commentary:
  453. m_settings.swords.standardCommentary->insertItem(modDescript);
  454. break;
  455. case CSwordModuleInfo::Lexicon: {
  456. bool inserted = false;
  457. if ((*it)->has(CSwordModuleInfo::HebrewDef)) {
  458. m_settings.swords.standardHebrewStrong->insertItem(modDescript);
  459. inserted = true;
  460. }
  461. if ((*it)->has(CSwordModuleInfo::GreekDef)) {
  462. m_settings.swords.standardGreekStrong->insertItem(modDescript);
  463. inserted = true;
  464. }
  465. if ((*it)->has(CSwordModuleInfo::HebrewParse)) {
  466. m_settings.swords.standardHebrewMorph->insertItem(modDescript);
  467. inserted = true;
  468. }
  469. if ((*it)->has(CSwordModuleInfo::GreekParse)) {
  470. m_settings.swords.standardGreekMorph->insertItem(modDescript);
  471. inserted = true;
  472. }
  473. if ((*it)->category() == CSwordModuleInfo::DailyDevotional) {
  474. m_settings.swords.standardDailyDevotional->insertItem(modDescript);
  475. inserted = true;
  476. }
  477. if (!inserted) {//daily dvotionals, striong lexicons etc. are not very useful for word lookups
  478. m_settings.swords.standardLexicon->insertItem(modDescript);
  479. }
  480. break;
  481. }
  482. default://unknown type
  483. break;
  484. }
  485. }
  486. //using two lists and one loop is better than six loops with almost the same code :)
  487. TQPtrList<TQComboBox> comboList;
  488. comboList.setAutoDelete(false);//don't delete the combos accidentally
  489. TQStringList moduleList;
  490. for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i) {
  491. //fill the combobox list in the right order (i.e. same order as the CBTConfig::module enum list)
  492. CBTConfig::modules moduleType = (CBTConfig::modules)(i);
  493. switch (moduleType) {
  494. case CBTConfig::standardBible:
  495. comboList.append(m_settings.swords.standardBible);
  496. break;
  497. case CBTConfig::standardCommentary:
  498. comboList.append(m_settings.swords.standardCommentary);
  499. break;
  500. case CBTConfig::standardLexicon:
  501. comboList.append(m_settings.swords.standardLexicon);
  502. break;
  503. case CBTConfig::standardDailyDevotional:
  504. comboList.append(m_settings.swords.standardDailyDevotional);
  505. break;
  506. case CBTConfig::standardHebrewStrongsLexicon:
  507. comboList.append(m_settings.swords.standardHebrewStrong);
  508. break;
  509. case CBTConfig::standardGreekStrongsLexicon:
  510. comboList.append(m_settings.swords.standardGreekStrong);
  511. break;
  512. case CBTConfig::standardHebrewMorphLexicon:
  513. comboList.append(m_settings.swords.standardHebrewMorph);
  514. break;
  515. case CBTConfig::standardGreekMorphLexicon:
  516. comboList.append(m_settings.swords.standardGreekMorph);
  517. break;
  518. };
  519. //fill the module list
  520. CSwordModuleInfo* const m = CBTConfig::get
  521. ( (CBTConfig::modules)(i) );
  522. if (m) {
  523. moduleList << m->config(CSwordModuleInfo::Description);
  524. }
  525. else {
  526. moduleList << TQString();
  527. }
  528. }
  529. TQString module = TQString();
  530. int item = 0;
  531. int count = 0;
  532. for (TQComboBox* combo = comboList.first(); combo; combo = comboList.next() ) {
  533. module = moduleList[comboList.at()];
  534. count = combo->count();
  535. combo->setMaximumWidth(300);
  536. for (item = 0; item < count; item++) {
  537. if (combo->text(item) == module ) {
  538. combo->setCurrentItem(item);
  539. break;
  540. }
  541. }
  542. }
  543. }
  544. { // ---------- new tab: filters -------- //
  545. TQFrame* currentTab = new TQFrame(tabCtl);
  546. tabCtl->addTab(currentTab, i18n("Text filters"));
  547. TQVBoxLayout* layout = new TQVBoxLayout(currentTab,5);
  548. layout->addWidget( CToolClass::explanationLabel(currentTab, i18n("Text filters"),
  549. i18n("Filters control the appearance of text. \
  550. Here you can specify default settings for all filters. \
  551. You can change the filter settings in each display window, of course.")) );
  552. layout->addSpacing(5);
  553. m_settings.swords.lineBreaks = new TQCheckBox(currentTab);
  554. m_settings.swords.lineBreaks->setText(i18n("Insert line break after each verse"));
  555. m_settings.swords.lineBreaks->setChecked(CBTConfig::get
  556. (CBTConfig::lineBreaks));
  557. layout->addWidget(m_settings.swords.lineBreaks);
  558. m_settings.swords.verseNumbers = new TQCheckBox(currentTab);
  559. m_settings.swords.verseNumbers->setText(i18n("Show verse numbers"));
  560. m_settings.swords.verseNumbers->setChecked(CBTConfig::get
  561. (CBTConfig::verseNumbers));
  562. layout->addWidget(m_settings.swords.verseNumbers);
  563. m_settings.swords.headings = new TQCheckBox(currentTab);
  564. m_settings.swords.headings->setText(i18n("Show section headings"));
  565. m_settings.swords.headings->setChecked(CBTConfig::get
  566. (CBTConfig::headings));
  567. layout->addWidget(m_settings.swords.headings);
  568. m_settings.swords.scriptureReferences = new TQCheckBox(currentTab);
  569. m_settings.swords.scriptureReferences->setText(i18n("Show scripture cross-references"));
  570. m_settings.swords.scriptureReferences->setChecked(CBTConfig::get
  571. (CBTConfig::scriptureReferences));
  572. layout->addWidget(m_settings.swords.scriptureReferences);
  573. m_settings.swords.greekAccents = new TQCheckBox(currentTab);
  574. m_settings.swords.greekAccents->setText(i18n("Show Greek accents"));
  575. m_settings.swords.greekAccents->setChecked(CBTConfig::get
  576. (CBTConfig::greekAccents));
  577. layout->addWidget(m_settings.swords.greekAccents);
  578. m_settings.swords.hebrewPoints = new TQCheckBox(currentTab);
  579. m_settings.swords.hebrewPoints->setText(i18n("Show Hebrew vowel points"));
  580. m_settings.swords.hebrewPoints->setChecked(CBTConfig::get
  581. (CBTConfig::hebrewPoints));
  582. layout->addWidget(m_settings.swords.hebrewPoints);
  583. m_settings.swords.hebrewCantillation = new TQCheckBox(currentTab);
  584. m_settings.swords.hebrewCantillation->setText(i18n("Show Hebrew cantillation marks"));
  585. m_settings.swords.hebrewCantillation->setChecked(CBTConfig::get
  586. (CBTConfig::hebrewCantillation));
  587. layout->addWidget(m_settings.swords.hebrewCantillation);
  588. m_settings.swords.morphSegmentation = new TQCheckBox(currentTab);
  589. m_settings.swords.morphSegmentation->setText(i18n("Show morph segmentation"));
  590. m_settings.swords.morphSegmentation->setChecked(CBTConfig::get
  591. (CBTConfig::morphSegmentation));
  592. layout->addWidget(m_settings.swords.morphSegmentation);
  593. m_settings.swords.textualVariants = new TQCheckBox(currentTab);
  594. m_settings.swords.textualVariants->setText(i18n("Use textual variants"));
  595. m_settings.swords.textualVariants->setChecked(CBTConfig::get
  596. (CBTConfig::textualVariants));
  597. layout->addWidget(m_settings.swords.textualVariants);
  598. layout->addStretch(4);
  599. }
  600. }
  601. void COptionsDialog::saveAccelerators() {
  602. if (m_settings.keys.general.keyChooser) {
  603. m_settings.keys.general.keyChooser->commitChanges();
  604. }
  605. if (m_settings.keys.bible.keyChooser) {
  606. m_settings.keys.bible.keyChooser->commitChanges();
  607. }
  608. if (m_settings.keys.commentary.keyChooser) {
  609. m_settings.keys.commentary.keyChooser->commitChanges();
  610. }
  611. if (m_settings.keys.lexicon.keyChooser) {
  612. m_settings.keys.lexicon.keyChooser->commitChanges();
  613. }
  614. if (m_settings.keys.book.keyChooser) {
  615. m_settings.keys.book.keyChooser->commitChanges();
  616. }
  617. CBTConfig::saveAccelSettings( //application
  618. CBTConfig::application,
  619. m_settings.keys.application.actionCollection
  620. );
  621. CBTConfig::saveAccelSettings( //read display windows
  622. CBTConfig::allWindows,
  623. m_settings.keys.general.actionCollection
  624. );
  625. CBTConfig::saveAccelSettings( //bible
  626. CBTConfig::bibleWindow,
  627. m_settings.keys.bible.actionCollection
  628. );
  629. CBTConfig::saveAccelSettings( //commentary
  630. CBTConfig::commentaryWindow,
  631. m_settings.keys.commentary.actionCollection
  632. );
  633. CBTConfig::saveAccelSettings( //lexicon
  634. CBTConfig::lexiconWindow,
  635. m_settings.keys.lexicon.actionCollection
  636. );
  637. CBTConfig::saveAccelSettings( //book
  638. CBTConfig::bookWindow,
  639. m_settings.keys.book.actionCollection
  640. );
  641. }
  642. /** No descriptions */
  643. void COptionsDialog::saveLanguages() {
  644. for(TQMap<TQString, CBTConfig::FontSettingsPair>::Iterator it = m_settings.fonts.fontMap.begin(); it != m_settings.fonts.fontMap.end(); ++it ) {
  645. const CLanguageMgr::Language* const lang = languageMgr()->languageForTranslatedName(it.key());
  646. if (!lang->isValid()) { //we probably use a language, for which we have only the abbrev
  647. CLanguageMgr::Language l(it.key(), it.key(), it.key()); //create a temp language
  648. CBTConfig::set(&l, it.data());
  649. }
  650. else {
  651. CBTConfig::set(lang, it.data());
  652. }
  653. }
  654. }
  655. /** No descriptions */
  656. void COptionsDialog::saveDisplay() {
  657. CBTConfig::set
  658. ( CBTConfig::logo, m_settings.startup.showLogo->isChecked() );
  659. CBTConfig::set
  660. ( CBTConfig::tips, m_settings.startup.showTips->isChecked() );
  661. CBTConfig::set
  662. ( CBTConfig::displayStyle, m_settings.displayStyle.styleChooser->currentText() );
  663. }
  664. /** No descriptions */
  665. void COptionsDialog::saveSword() {
  666. for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i) {
  667. TQString moduleDescription = TQString();
  668. CBTConfig::modules moduleType = (CBTConfig::modules)(i);
  669. switch (moduleType) {
  670. case CBTConfig::standardBible:
  671. moduleDescription = m_settings.swords.standardBible->currentText();
  672. break;
  673. case CBTConfig::standardCommentary:
  674. moduleDescription = m_settings.swords.standardCommentary->currentText();
  675. break;
  676. case CBTConfig::standardLexicon:
  677. moduleDescription = m_settings.swords.standardLexicon->currentText();
  678. break;
  679. case CBTConfig::standardDailyDevotional:
  680. moduleDescription = m_settings.swords.standardDailyDevotional->currentText();
  681. break;
  682. case CBTConfig::standardHebrewStrongsLexicon:
  683. moduleDescription = m_settings.swords.standardHebrewStrong->currentText();
  684. break;
  685. case CBTConfig::standardGreekStrongsLexicon:
  686. moduleDescription = m_settings.swords.standardGreekStrong->currentText();
  687. break;
  688. case CBTConfig::standardHebrewMorphLexicon:
  689. moduleDescription = m_settings.swords.standardHebrewMorph->currentText();
  690. break;
  691. case CBTConfig::standardGreekMorphLexicon:
  692. moduleDescription = m_settings.swords.standardGreekMorph->currentText();
  693. break;
  694. default:
  695. tqWarning("Unhandled module type.");
  696. };
  697. CSwordModuleInfo* const module = backend()->findModuleByDescription(moduleDescription);
  698. CBTConfig::set
  699. (moduleType, module);
  700. }
  701. TQString languageAbbrev;
  702. const TQString currentLanguageName = m_settings.fonts.swordLocaleCombo->currentText();
  703. const CLanguageMgr::Language* const l = CPointers::languageMgr()->languageForTranslatedName( currentLanguageName );
  704. if (l && l->isValid()) {
  705. languageAbbrev = l->abbrev();
  706. }
  707. else { //it can be the lang abbrev like de_abbrev or the Sword description
  708. list <sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
  709. for (list <sword::SWBuf>::iterator it = locales.begin(); it != locales.end(); it++) {
  710. SWLocale* locale = LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str());
  711. Q_ASSERT(locale);
  712. if ( locale && (TQString::fromLatin1(locale->getDescription()) == currentLanguageName) ) {
  713. languageAbbrev = TQString::fromLatin1(locale->getName()); //we found the abbrevation for the current language
  714. break;
  715. }
  716. }
  717. if (languageAbbrev.isEmpty()) {
  718. languageAbbrev = currentLanguageName; //probably a non-standard locale name like de_abbrev
  719. }
  720. }
  721. if (!languageAbbrev.isEmpty()) {
  722. CBTConfig::set
  723. (CBTConfig::language, languageAbbrev);
  724. }
  725. CBTConfig::set
  726. (CBTConfig::lineBreaks, m_settings.swords.lineBreaks->isChecked());
  727. CBTConfig::set
  728. (CBTConfig::verseNumbers, m_settings.swords.verseNumbers->isChecked());
  729. CBTConfig::set
  730. (CBTConfig::headings, m_settings.swords.headings->isChecked());
  731. CBTConfig::set
  732. (CBTConfig::scriptureReferences, m_settings.swords.scriptureReferences->isChecked());
  733. CBTConfig::set
  734. (CBTConfig::hebrewPoints, m_settings.swords.hebrewPoints->isChecked());
  735. CBTConfig::set
  736. (CBTConfig::hebrewCantillation, m_settings.swords.hebrewCantillation->isChecked());
  737. CBTConfig::set
  738. (CBTConfig::morphSegmentation, m_settings.swords.morphSegmentation->isChecked());
  739. CBTConfig::set
  740. (CBTConfig::greekAccents, m_settings.swords.greekAccents->isChecked());
  741. CBTConfig::set
  742. (CBTConfig::textualVariants, m_settings.swords.textualVariants->isChecked());
  743. }
  744. /** This slot is called when the "Use own font for language" bo was clicked. */
  745. void COptionsDialog::useOwnFontClicked( bool isOn ) {
  746. m_settings.fonts.fontChooser->setEnabled(isOn);
  747. m_settings.fonts.fontMap[ m_settings.fonts.usage->currentText() ].first = isOn;
  748. if (isOn) { //show font icon
  749. m_settings.fonts.usage->changeItem(
  750. SmallIcon("fonts"),
  751. m_settings.fonts.usage->currentText(),
  752. m_settings.fonts.usage->currentItem()
  753. );
  754. }
  755. else { //don't show
  756. m_settings.fonts.usage->changeItem(
  757. m_settings.fonts.usage->currentText(),
  758. m_settings.fonts.usage->currentItem()
  759. );
  760. }
  761. }
  762. void COptionsDialog::updateStylePreview() {
  763. //update the style preview widget
  764. using namespace Rendering;
  765. const TQString styleName = m_settings.displayStyle.styleChooser->currentText();
  766. CTextRendering::KeyTree tree;
  767. CTextRendering::KeyTreeItem::Settings settings;
  768. settings.highlight = false;
  769. tree.append( new CTextRendering::KeyTreeItem(
  770. TQString("\n<span class=\"entryname\"><a name=\"John316\" href=\"sword://Bible/WEB/John 3:16\">16</a></span>%1")
  771. .arg(i18n("For God so loved the world, that he gave his one and only Son, that whoever believes in him should not perish, but have eternal life.")),
  772. settings));
  773. tree.append( new CTextRendering::KeyTreeItem(
  774. TQString("\n<span class=\"entryname\"><a name=\"John317\" href=\"sword://Bible/WEB/John 3:17\">17</a></span>%1")
  775. .arg(i18n("For God didn't send his Son into the world to judge the world, but that the world should be saved through him.")),
  776. settings));
  777. settings.highlight = true;
  778. tree.append( new CTextRendering::KeyTreeItem(
  779. TQString("\n<span class=\"entryname\"><a name=\"John318\" href=\"sword://Bible/WEB/John 3:18\">18</a></span>%1")
  780. .arg(i18n("He who believes in him is not judged. He who doesn't believe has been judged already, because he has not believed in the name of the one and only Son of God.")),
  781. settings) );
  782. settings.highlight = false;
  783. tree.append( new CTextRendering::KeyTreeItem(
  784. TQString("\n<span class=\"entryname\"><a name=\"John319\" href=\"sword://Bible/WEB/John 3:19\">19</a></span>%1")
  785. .arg(i18n("This is the judgment, that the light has come into the world, and men loved the darkness rather than the light; for their works were evil.")),
  786. settings));
  787. tree.append( new CTextRendering::KeyTreeItem(
  788. TQString("\n<span class=\"entryname\"><a name=\"John320\" href=\"sword://Bible/WEB/John 3:20\">20</a></span>%1<br/>")
  789. .arg(i18n("For everyone who does evil hates the light, and doesn't come to the light, lest his works would be exposed.")),
  790. settings));
  791. tree.append( new CTextRendering::KeyTreeItem(
  792. TQString("\n<span class=\"entryname\"><a name=\"John321\" href=\"sword://Bible/WEB/John 3:21\">21</a></span>%1")
  793. .arg(i18n("But he who does the truth comes to the light, that his works may be revealed, that they have been done in God.")),
  794. settings));
  795. const TQString oldStyleName = CBTConfig::get
  796. (CBTConfig::displayStyle);
  797. CBTConfig::set
  798. (CBTConfig::displayStyle, styleName);
  799. CDisplayRendering render;
  800. m_settings.displayStyle.stylePreview->begin();
  801. m_settings.displayStyle.stylePreview->write( render.renderKeyTree(tree));
  802. m_settings.displayStyle.stylePreview->end();
  803. CBTConfig::set
  804. (CBTConfig::displayStyle, oldStyleName);
  805. }
  806. void COptionsDialog::slotKeyChooserTypeChanged(const TQString& title) {
  807. //delete all KKeyChoosers which may not share accels, because this class checks in all instances for key conflicts
  808. typedef TQPtrList<KKeyChooser> KeyChooserList;
  809. KeyChooserList list;
  810. list.append(m_settings.keys.bible.keyChooser);
  811. list.append(m_settings.keys.commentary.keyChooser);
  812. list.append(m_settings.keys.lexicon.keyChooser);
  813. list.append(m_settings.keys.book.keyChooser);
  814. //commit all changes in the keychoosers
  815. for (KeyChooserList::iterator it(list.begin()); it != list.end(); ++it) {
  816. if (*it) { //the list may contain NULL pointers
  817. (*it)->commitChanges();
  818. }
  819. }
  820. /* Delete all the keychoosers in the list,
  821. * the keychoosers are set to NULL, because they are TQGuardedPtr
  822. */
  823. list.setAutoDelete(true);
  824. list.clear();
  825. Settings::KeySettings::WindowType* t = 0;
  826. if (title == m_settings.keys.application.title) { //Application wide
  827. t = &m_settings.keys.application;
  828. }
  829. else if (title == m_settings.keys.general.title) { // All display windows
  830. t = &m_settings.keys.general;
  831. }
  832. else if (title == m_settings.keys.bible.title) { // Bible windows
  833. t = &m_settings.keys.bible;
  834. }
  835. else if (title == m_settings.keys.commentary.title) { // Commentary windows
  836. t = &m_settings.keys.commentary;
  837. }
  838. else if (title == m_settings.keys.lexicon.title) { // Lexicon windows
  839. t = &m_settings.keys.lexicon;
  840. }
  841. else if (title == m_settings.keys.book.title) { // Book windows
  842. t = &m_settings.keys.book;
  843. }
  844. Q_ASSERT(t);
  845. if (!t->keyChooser) { //was deleted, create a new one
  846. t->keyChooser = new KKeyChooser(
  847. m_settings.keys.keyChooserStack
  848. );
  849. t->keyChooser->insert(
  850. t->actionCollection,
  851. t->title
  852. );
  853. }
  854. m_settings.keys.keyChooserStack->raiseWidget(t->keyChooser);
  855. }