Bibletime – a bible study tool
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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. //BibleTime includes
  10. #include "cbtconfig.h"
  11. #include "backend/cswordmoduleinfo.h"
  12. #include "backend/cdisplaytemplatemgr.h"
  13. #include "util/cpointers.h"
  14. //TQt includes
  15. #include <tqapplication.h>
  16. #include <tqfontdatabase.h>
  17. #include <tqstring.h>
  18. #include <tqstringlist.h>
  19. #include <tqmap.h>
  20. //KDE includes
  21. #include <tdeversion.h>
  22. #include <kapplication.h>
  23. #if TDE_VERSION >= 0x030200
  24. #include <kactioncollection.h>
  25. #else
  26. #include <kaction.h>
  27. #endif
  28. #include <tdeconfig.h>
  29. #include <kcharsets.h>
  30. #include <kglobal.h>
  31. #include <klocale.h>
  32. #include <kaccel.h>
  33. #include <kstaticdeleter.h>
  34. #include <tdehtml_settings.h>
  35. //Sword includes
  36. #include <versekey.h>
  37. //init statics
  38. TQFont* CBTConfig::m_defaultFont = 0;
  39. CBTConfig::FontCache* CBTConfig::fontConfigMap = 0;
  40. /* No constructor and destructor, because this class only contains static methods.
  41. It won't be instantiated. */
  42. const TQString CBTConfig::getKey( const CBTConfig::strings ID) {
  43. switch ( ID ) {
  44. case bibletimeVersion: return "bibletimeVersion";
  45. case language: return "language";
  46. case displayStyle: return "displayStyle";
  47. case bookshelfCurrentItem: return "bookshelfCurrentItem";
  48. }
  49. return TQString();
  50. }
  51. const TQString CBTConfig::getDefault( const CBTConfig::strings ID) {
  52. switch ( ID ) {
  53. case bibletimeVersion: return "NOT YET INSTALLED"; // main() will realize this and set the value to VERSION
  54. case language: return (TDEGlobal::locale()->language()).local8Bit();
  55. case displayStyle: return CDisplayTemplateMgr::defaultTemplate();
  56. case bookshelfCurrentItem: return TQString();
  57. }
  58. return TQString();
  59. }
  60. const TQString CBTConfig::getKey( const CBTConfig::modules ID) {
  61. switch ( ID ) {
  62. case standardBible: return "standardBible";
  63. case standardCommentary: return "standardCommentary";
  64. case standardLexicon: return "standardLexicon";
  65. case standardDailyDevotional: return "standardDailyDevotional";
  66. case standardHebrewStrongsLexicon: return "standardHebrewLexicon";
  67. case standardGreekStrongsLexicon: return "standardGreekLexicon";
  68. case standardHebrewMorphLexicon: return "standardHebrewMorphLexicon";
  69. case standardGreekMorphLexicon: return "standardGreekMorphLexicon";
  70. }
  71. return TQString();
  72. }
  73. const TQString CBTConfig::getDefault( const CBTConfig::modules ID) {
  74. // CSwordBackend* b = CPointers::backend();
  75. switch ( ID ) {
  76. case standardBible: return "KJV";
  77. case standardCommentary: return "MHC";
  78. case standardLexicon: return "ISBE";
  79. case standardDailyDevotional: return ""; //no default
  80. case standardHebrewStrongsLexicon: return "StrongsHebrew";
  81. case standardGreekStrongsLexicon: return "StrongsGreek";
  82. case standardHebrewMorphLexicon: return "StrongsHebrew";
  83. case standardGreekMorphLexicon: return "StrongsGreek";
  84. }
  85. return TQString();
  86. }
  87. const TQString CBTConfig::getKey( const CBTConfig::bools ID) {
  88. switch ( ID ) {
  89. case firstSearchDialog: return "firstSearchDialog";
  90. case readOldBookmarks: return "readOldBookmarks";
  91. case toolbar: return "toolbar";
  92. case mainIndex: return "mainIndex";
  93. case infoDisplay: return "infoDisplay";
  94. case autoTileVertical: return "autoTileVertical";
  95. case autoTileHorizontal: return "autoTileHorizontal";
  96. case autoCascade: return "autoCascade";
  97. case lineBreaks: return "lineBreaks";
  98. case verseNumbers: return "verseNumbers";
  99. case tips: return "RunOnStart";
  100. case logo: return "logo";
  101. case autoDeleteOrphanedIndices: return "autoDeleteOrphanedIndices";
  102. case crashedLastTime: return "crashedLastTime";
  103. case crashedTwoTimes: return "crashedTwoTimes";
  104. }
  105. return TQString();
  106. }
  107. const TQString CBTConfig::getKey( const CBTConfig::ints ID) {
  108. switch ( ID ) {
  109. case footnotes: return "footnotes";
  110. case strongNumbers: return "strongNumbers";
  111. case headings: return "headings";
  112. case morphTags: return "morphTags";
  113. case lemmas: return "lemmas";
  114. case hebrewPoints: return "hebrewPoints";
  115. case hebrewCantillation: return "hebrewCantillation";
  116. case greekAccents: return "greekAccents";
  117. case textualVariants: return "textualVariants";
  118. case scriptureReferences: return "scriptureReferences";
  119. case morphSegmentation: return "morphSegmentation";
  120. case bookshelfContentsX: return "bookshelfContentsX";
  121. case bookshelfContentsY: return "bookshelfContentsY";
  122. case magDelay: return "magDelay";
  123. }
  124. return TQString();
  125. }
  126. const bool CBTConfig::getDefault( const CBTConfig::bools ID) {
  127. switch ( ID ) {
  128. case firstSearchDialog: return true;
  129. case readOldBookmarks: return false;
  130. case toolbar: return true;
  131. case mainIndex: return true;
  132. case infoDisplay: return true;
  133. case autoTileVertical: return true;
  134. case autoTileHorizontal: return false;
  135. case autoCascade: return false;
  136. case lineBreaks: return false;
  137. case verseNumbers: return true;
  138. case tips: return true;
  139. case logo: return true;
  140. case autoDeleteOrphanedIndices: return true;
  141. case crashedLastTime: return false;
  142. case crashedTwoTimes: return false;
  143. }
  144. return false;
  145. }
  146. const int CBTConfig::getDefault( const CBTConfig::ints ID) {
  147. switch ( ID ) {
  148. case footnotes: return int(true);
  149. case strongNumbers: return int(true);
  150. case headings: return int(true);
  151. case morphTags: return int(true);
  152. case lemmas: return int(true);
  153. case hebrewPoints: return int(true);
  154. case hebrewCantillation: return int(true);
  155. case greekAccents: return int(true);
  156. case textualVariants: return int(false);
  157. case scriptureReferences: return int(true);
  158. case morphSegmentation: return int(true);
  159. case bookshelfContentsX: return 0;
  160. case bookshelfContentsY: return 0;
  161. case magDelay: return 400;
  162. }
  163. return 0;
  164. }
  165. const TQString CBTConfig::getKey( const CBTConfig::intLists ID) {
  166. switch ( ID ) {
  167. case leftPaneSplitterSizes: return "leftPaneSplitterSizes";
  168. case mainSplitterSizes: return "mainSplitterSizes";
  169. }
  170. return TQString();
  171. }
  172. const TQValueList<int> CBTConfig::getDefault( const CBTConfig::intLists ID) {
  173. switch ( ID ) {
  174. case leftPaneSplitterSizes: //fall through
  175. case mainSplitterSizes: {
  176. return TQValueList<int>();
  177. }
  178. }
  179. return TQValueList<int>();
  180. }
  181. const TQString CBTConfig::getKey( const CBTConfig::stringLists ID) {
  182. switch ( ID ) {
  183. case searchCompletionTexts: return TQString("searchCompletionTexts");
  184. case searchTexts: return TQString("searchTexts");
  185. case bookshelfOpenGroups: return TQString("bookshelfOpenGroups");
  186. }
  187. return TQString();
  188. }
  189. const TQStringList CBTConfig::getDefault( const CBTConfig::stringLists ID) {
  190. switch ( ID ) {
  191. case searchTexts: {
  192. TQStringList list;
  193. list.append(TQString());
  194. return list;
  195. }
  196. case searchCompletionTexts:
  197. return TQStringList();
  198. case bookshelfOpenGroups:
  199. return TQStringList();
  200. }
  201. return TQStringList();
  202. }
  203. const TQString CBTConfig::getKey( const CBTConfig::stringMaps ID) {
  204. switch (ID) {
  205. case searchScopes:
  206. return TQString("SearchScopes");
  207. };
  208. return TQString();
  209. }
  210. const CBTConfig::StringMap CBTConfig::getDefault( const CBTConfig::stringMaps ID) {
  211. switch ( ID ) {
  212. case searchScopes: {
  213. CBTConfig::StringMap map;
  214. map.insert(i18n("Old testament"), TQString("Gen - Mal"));
  215. map.insert(i18n("Moses/Pentateuch/Torah"),TQString("Gen - Deut"));
  216. map.insert(i18n("History"), TQString("Jos - Est"));
  217. map.insert(i18n("Prophets"), TQString("Isa - Mal"));
  218. map.insert(i18n("New testament"), TQString("Mat - Rev"));
  219. map.insert(i18n("Gospels"), TQString("Mat - Joh"));
  220. map.insert(i18n("Letters/Epistles"), TQString("Rom - Jude"));
  221. map.insert(i18n("Paul's Epistles"), TQString("Rom - Phile"));
  222. //make the list to the current bookname language!
  223. CBTConfig::StringMap::Iterator it;
  224. sword::VerseKey vk;
  225. vk.setLocale("en_US");
  226. for (it = map.begin(); it != map.end(); ++it) {
  227. sword::ListKey list = vk.ParseVerseList(it.data().local8Bit(), "Genesis 1:1", true);
  228. TQString data;
  229. for (int i = 0; i < list.Count(); ++i) {
  230. data += TQString::fromUtf8(list.GetElement(i)->getRangeText()) + "; ";
  231. }
  232. map[it.key()] = data; //set the new data
  233. };
  234. return map;
  235. };
  236. default:
  237. return CBTConfig::StringMap();
  238. }
  239. return CBTConfig::StringMap();
  240. }
  241. const TQString CBTConfig::getKey( const CLanguageMgr::Language* const language ) {
  242. return language->name();
  243. }
  244. const TQFont& CBTConfig::getDefault( const CLanguageMgr::Language* const) {
  245. //language specific lookup of the font name
  246. //return TDEApplication::font();
  247. if (m_defaultFont) {
  248. return *m_defaultFont;
  249. }
  250. static KStaticDeleter<TQFont> sd;
  251. //TODO: We need a better way to get the KDE konqueror TDEHTML settings
  252. TDEConfig conf("konquerorrc");
  253. TDEHTMLSettings settings;
  254. settings.init(&conf);
  255. const TQString fontName = settings.stdFontName();
  256. const int fontSize = settings.mediumFontSize();
  257. sd.setObject(m_defaultFont, new TQFont(fontName, fontSize));
  258. return *m_defaultFont;
  259. }
  260. const TQString CBTConfig::get
  261. ( const CBTConfig::strings ID) {
  262. TDEConfig* config = CBTConfig::getConfig();
  263. TDEConfigGroupSaver groupSaver(config, "strings");
  264. return config->readEntry(getKey(ID),getDefault(ID));
  265. }
  266. CSwordModuleInfo* const CBTConfig::get
  267. ( const CBTConfig::modules ID) {
  268. TDEConfig* config = CBTConfig::getConfig();
  269. TDEConfigGroupSaver groupSaver(config, "modules");
  270. TQString name = config->readEntry(getKey(ID),getDefault(ID));
  271. return CPointers::backend()->findModuleByName(name);
  272. }
  273. const bool CBTConfig::get
  274. ( const CBTConfig::bools ID) {
  275. //special behaviour for the KTipDialog class
  276. TDEConfig* config = CBTConfig::getConfig();
  277. TDEConfigGroupSaver groupSaver(config, (ID == CBTConfig::tips) ? "TipOfDay" : "bools");
  278. return config->readBoolEntry(getKey(ID),getDefault(ID));
  279. }
  280. const int CBTConfig::get
  281. ( const CBTConfig::ints ID) {
  282. TDEConfig* config = CBTConfig::getConfig();
  283. TDEConfigGroupSaver groupSaver(config, "ints");
  284. return config->readNumEntry(getKey(ID), getDefault(ID));
  285. }
  286. const TQValueList<int> CBTConfig::get
  287. ( const CBTConfig::intLists ID ) {
  288. TDEConfig* config = CBTConfig::getConfig();
  289. TDEConfigGroupSaver groupSaver(config, "intlists");
  290. return config->readIntListEntry(getKey(ID));
  291. }
  292. const TQStringList CBTConfig::get
  293. ( const CBTConfig::stringLists ID ) {
  294. TDEConfig* config = CBTConfig::getConfig();
  295. TDEConfigGroupSaver groupSaver(config, "stringlists");
  296. return config->readListEntry(getKey(ID));
  297. }
  298. const CBTConfig::StringMap CBTConfig::get
  299. ( const CBTConfig::stringMaps ID ) {
  300. TDEConfig* config = CBTConfig::getConfig();
  301. TDEConfigGroupSaver groupSaver(config, getKey(ID));
  302. if (config->hasGroup(getKey(ID))) {
  303. CBTConfig::StringMap map = config->entryMap(getKey(ID));
  304. switch (ID) {
  305. case searchScopes: { //make sure we return the scopes in the chosen language. saved keys are in english
  306. CBTConfig::StringMap::Iterator it;
  307. sword::VerseKey vk;
  308. for (it = map.begin(); it != map.end(); ++it) {
  309. sword::ListKey list = vk.ParseVerseList(it.data().utf8(), "Genesis 1:1", true);
  310. TQString data;
  311. for (int i = 0; i < list.Count(); ++i) {
  312. data += TQString::fromUtf8(list.GetElement(i)->getRangeText()) + "; ";
  313. }
  314. map[it.key()] = data; //set the new data
  315. };
  316. return map;
  317. }
  318. default:
  319. return getDefault(ID);
  320. }
  321. }
  322. return getDefault(ID);
  323. }
  324. const CBTConfig::FontSettingsPair CBTConfig::get
  325. ( const CLanguageMgr::Language* const language ) {
  326. if (fontConfigMap && fontConfigMap->contains(language)) {
  327. return fontConfigMap->find(language).data();
  328. }
  329. if (!fontConfigMap) {
  330. static KStaticDeleter<FontCache> sd;
  331. sd.setObject(fontConfigMap, new FontCache());
  332. }
  333. TDEConfig* config = CBTConfig::getConfig();
  334. TDEConfigGroupSaver groupSaver(config, "font standard settings");
  335. FontSettingsPair settings;
  336. settings.first = config->readBoolEntry(getKey(language));
  337. config->setGroup("fonts");
  338. settings.second =
  339. settings.first
  340. ? config->readFontEntry(getKey(language))
  341. : getDefault(language);
  342. fontConfigMap->insert(language, settings); //cache the value
  343. return settings;
  344. }
  345. void CBTConfig::set
  346. ( const CBTConfig::strings ID, const TQString value ) {
  347. TDEConfig* config = CBTConfig::getConfig();
  348. TDEConfigGroupSaver groupSaver(config, "strings");
  349. config->writeEntry(getKey(ID), value);
  350. }
  351. void CBTConfig::set
  352. ( const CBTConfig::modules ID, CSwordModuleInfo* const value ) {
  353. TDEConfig* config = CBTConfig::getConfig();
  354. TDEConfigGroupSaver groupSaver(config, "modules");
  355. config->writeEntry(getKey(ID), value ? value->name() : TQString());
  356. }
  357. void CBTConfig::set
  358. ( const CBTConfig::modules ID, const TQString& value ) {
  359. CSwordModuleInfo* module = CPointers::backend()->findModuleByName(value);
  360. if (module) {
  361. CBTConfig::set
  362. (ID, module);
  363. }
  364. }
  365. void CBTConfig::set
  366. (const CBTConfig::bools ID,const bool value ) {
  367. TDEConfig* config = CBTConfig::getConfig();
  368. //special behaviour to work with KTipDialog class of KDE
  369. TDEConfigGroupSaver groupSaver(config, (ID == CBTConfig::tips) ? "TipOfDay" : "bools");
  370. config->writeEntry(getKey(ID), value);
  371. }
  372. void CBTConfig::set
  373. (const CBTConfig::ints ID, const int value ) {
  374. TDEConfig* config = CBTConfig::getConfig();
  375. TDEConfigGroupSaver groupSaver(config, "ints");
  376. config->writeEntry(getKey(ID), value);
  377. }
  378. void CBTConfig::set
  379. ( const CBTConfig::intLists ID, const TQValueList<int> value ) {
  380. TDEConfig* config = CBTConfig::getConfig();
  381. TDEConfigGroupSaver groupSaver(config, "intlists");
  382. config->writeEntry(getKey(ID), value);
  383. }
  384. void CBTConfig::set
  385. ( const CBTConfig::stringLists ID, const TQStringList value ) {
  386. TDEConfig* config = CBTConfig::getConfig();
  387. TDEConfigGroupSaver groupSaver(config, "stringlists");
  388. config->writeEntry(getKey(ID), value);
  389. }
  390. void CBTConfig::set
  391. ( const CBTConfig::stringMaps ID, const CBTConfig::StringMap value ) {
  392. TDEConfig* config = CBTConfig::getConfig();
  393. TDEConfigGroupSaver groupSaver(config, getKey(ID));
  394. config->deleteGroup(getKey(ID)); //make sure we only save the new entries and don't use old ones
  395. config->sync();
  396. config->setGroup(getKey(ID));
  397. switch (ID) {
  398. case searchScopes: {
  399. /**
  400. * We want to make sure that the search scopes are saved with english key names so loading them
  401. * will always work with each locale set.
  402. */
  403. CBTConfig::StringMap::ConstIterator it;
  404. TQString data;// = TQString();
  405. sword::VerseKey vk;
  406. for (it = value.begin(); it != value.end(); ++it) {
  407. sword::ListKey list = vk.ParseVerseList(it.data().utf8(), "Genesis 1:1", true);
  408. data = TQString();
  409. for (int i = 0; i < list.Count(); ++i) {
  410. if ( sword::VerseKey* range = dynamic_cast<sword::VerseKey*>(list.GetElement(i)) ) {
  411. range->setLocale("en");
  412. data += TQString::fromUtf8( range->getRangeText() ) + ";";
  413. }
  414. }
  415. config->writeEntry(it.key(), data);
  416. }
  417. break;
  418. }
  419. default: {
  420. for (CBTConfig::StringMap::ConstIterator it = value.begin(); it != value.end(); ++it) {
  421. config->writeEntry(it.key(), it.data());
  422. }
  423. break;
  424. }
  425. };
  426. }
  427. void CBTConfig::set
  428. ( const CLanguageMgr::Language* const language, const FontSettingsPair& value ) {
  429. TDEConfig* config = CBTConfig::getConfig();
  430. TDEConfigGroupSaver groupSaver(config, "fonts");
  431. config->writeEntry(getKey(language), value.second);
  432. config->setGroup("font standard settings");
  433. config->writeEntry(getKey(language), value.first);
  434. if (fontConfigMap && fontConfigMap->contains(language)) {
  435. fontConfigMap->remove
  436. (language); //remove it from the cache
  437. }
  438. }
  439. const CSwordBackend::DisplayOptions CBTConfig::getDisplayOptionDefaults() {
  440. CSwordBackend::DisplayOptions options;
  441. options.lineBreaks = get
  442. (CBTConfig::lineBreaks);
  443. options.verseNumbers = get
  444. (CBTConfig::verseNumbers);
  445. return options;
  446. }
  447. const CSwordBackend::FilterOptions CBTConfig::getFilterOptionDefaults() {
  448. CSwordBackend::FilterOptions options;
  449. options.footnotes = true; //required for the info display
  450. options.strongNumbers = true; //get(CBTConfig::strongNumbers);
  451. options.headings = get(CBTConfig::headings);
  452. options.morphTags = true;//required for the info display
  453. options.lemmas = true;//required for the info display
  454. options.hebrewPoints = get(CBTConfig::hebrewPoints);
  455. options.hebrewCantillation = get(CBTConfig::hebrewCantillation);
  456. options.greekAccents = get(CBTConfig::greekAccents);
  457. options.textualVariants = get(CBTConfig::textualVariants);
  458. options.scriptureReferences = get(CBTConfig::scriptureReferences);
  459. options.morphSegmentation = get(CBTConfig::morphSegmentation);
  460. return options;
  461. }
  462. void CBTConfig::setupAccelSettings(const CBTConfig::keys type, TDEActionCollection* const actionCollection) {
  463. TQString groupName;
  464. switch (type) {
  465. case allWindows : {
  466. groupName = "Displaywindow shortcuts";
  467. break;
  468. };
  469. case writeWindow : {
  470. groupName = "Writewindow shortcuts";
  471. break;
  472. };
  473. case readWindow : {
  474. groupName = "Readwindow shortcuts";
  475. break;
  476. };
  477. case bookWindow : {
  478. groupName = "Book shortcuts";
  479. break;
  480. };
  481. case bibleWindow : {
  482. groupName = "Bible shortcuts";
  483. break;
  484. };
  485. case commentaryWindow : {
  486. groupName = "Commentary shortcuts";
  487. break;
  488. };
  489. case lexiconWindow : {
  490. groupName = "Lexicon shortcuts";
  491. break;
  492. };
  493. case application : {
  494. groupName = "Application shortcuts";
  495. break;
  496. };
  497. };
  498. actionCollection->readShortcutSettings(groupName, CBTConfig::getConfig());
  499. }
  500. void CBTConfig::saveAccelSettings(const CBTConfig::keys type, TDEActionCollection* const actionCollection) {
  501. TQString groupName;
  502. switch (type) {
  503. case allWindows : {
  504. groupName = "Displaywindow shortcuts";
  505. break;
  506. };
  507. case writeWindow : {
  508. groupName = "Writewindow shortcuts";
  509. break;
  510. };
  511. case readWindow : {
  512. groupName = "Readwindow shortcuts";
  513. break;
  514. };
  515. case bookWindow : {
  516. groupName = "Book shortcuts";
  517. break;
  518. };
  519. case bibleWindow : {
  520. groupName = "Bible shortcuts";
  521. break;
  522. };
  523. case commentaryWindow : {
  524. groupName = "Commentary shortcuts";
  525. break;
  526. };
  527. case lexiconWindow : {
  528. groupName = "Lexicon shortcuts";
  529. break;
  530. };
  531. case application : {
  532. groupName = "Application shortcuts";
  533. break;
  534. };
  535. };
  536. actionCollection->writeShortcutSettings(groupName, CBTConfig::getConfig());
  537. }
  538. const TQString CBTConfig::getModuleEncryptionKey( const TQString& module ) {
  539. TDEConfig* config = CBTConfig::getConfig();
  540. TDEConfigGroupSaver groupSaver(config, "Module keys");
  541. return config->readEntry(module, TQString());
  542. }
  543. void CBTConfig::setModuleEncryptionKey( const TQString& module, const TQString& key ) {
  544. // if (CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(module) ) {
  545. // // if an empty key is set for an unencrypted module do nothing
  546. // if (key.isEmpty() && !mod->isEncrypted()) {
  547. // return;
  548. // }
  549. // }
  550. // else if (key.isEmpty()) {
  551. // return;
  552. // };
  553. TDEConfig* config = CBTConfig::getConfig();
  554. TDEConfigGroupSaver groupSaver(config, "Module keys");
  555. config->writeEntry(module, key);
  556. };
  557. TDEConfig* const CBTConfig::getConfig() {
  558. TDEConfig* config = TDEGlobal::config();
  559. if (TDEApplication::kApplication()->sessionSaving()) {
  560. tqWarning("Using session config");
  561. // config = TDEApplication::kApplication()->sessionConfig();
  562. }
  563. else if (TDEApplication::kApplication()->isRestored()) {
  564. tqWarning("isRestored(): Using session config");
  565. }
  566. return config;
  567. }