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.

ccommentaryreadwindow.cpp 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 "ccommentaryreadwindow.h"
  11. #include "frontend/cprofilewindow.h"
  12. #include "frontend/cbtconfig.h"
  13. #include "frontend/keychooser/ckeychooser.h"
  14. #include "frontend/display/cdisplay.h"
  15. #include "frontend/display/creaddisplay.h"
  16. #include "util/ctoolclass.h"
  17. #include "util/cresmgr.h"
  18. //TQt includes
  19. //KDE includes
  20. #include <tdeaction.h>
  21. #include <tdeaccel.h>
  22. #include <tdelocale.h>
  23. #include <tdepopupmenu.h>
  24. using namespace Profile;
  25. CCommentaryReadWindow::CCommentaryReadWindow(ListCSwordModuleInfo modules, CMDIArea* parent, const char *name) : CLexiconReadWindow(modules, parent,name) {}
  26. void CCommentaryReadWindow::insertKeyboardActions( TDEActionCollection* const a ) {
  27. new TDEAction(
  28. i18n("Next book"), CResMgr::displaywindows::bibleWindow::nextBook::accel,
  29. a, "nextBook"
  30. );
  31. new TDEAction(
  32. i18n("Previous book"), CResMgr::displaywindows::bibleWindow::previousBook::accel,
  33. a, "previousBook"
  34. );
  35. new TDEAction(
  36. i18n("Next chapter"), CResMgr::displaywindows::bibleWindow::nextChapter::accel,
  37. a, "nextChapter"
  38. );
  39. new TDEAction(
  40. i18n("Previous chapter"), CResMgr::displaywindows::bibleWindow::previousChapter::accel,
  41. a, "previousChapter"
  42. );
  43. new TDEAction(
  44. i18n("Next verse"), CResMgr::displaywindows::bibleWindow::nextVerse::accel,
  45. a, "nextVerse"
  46. );
  47. new TDEAction(
  48. i18n("Previous verse"), CResMgr::displaywindows::bibleWindow::previousVerse::accel,
  49. a, "previousVerse"
  50. );
  51. }
  52. void CCommentaryReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
  53. CLexiconReadWindow::applyProfileSettings(profileWindow);
  54. if (profileWindow->windowSettings()) {
  55. m_syncButton->setChecked(true);
  56. }
  57. };
  58. void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
  59. CLexiconReadWindow::storeProfileSettings(profileWindow);
  60. profileWindow->setWindowSettings( m_syncButton->isChecked() );
  61. };
  62. void CCommentaryReadWindow::initToolbars() {
  63. CLexiconReadWindow::initToolbars();
  64. m_syncButton = new TDEToggleAction(i18n("Sync with active Bible"),
  65. CResMgr::displaywindows::commentaryWindow::syncWindow::icon,
  66. CResMgr::displaywindows::commentaryWindow::syncWindow::accel,
  67. actionCollection(),
  68. CResMgr::displaywindows::commentaryWindow::syncWindow::actionName
  69. );
  70. m_syncButton->setToolTip(CResMgr::displaywindows::commentaryWindow::syncWindow::tooltip);
  71. m_syncButton->plug(buttonsToolBar());
  72. }
  73. /** Reimplementation to handle the keychooser refresh. */
  74. void CCommentaryReadWindow::reload() {
  75. CLexiconReadWindow::reload();
  76. //refresh the book lists
  77. verseKey()->setLocale( backend()->booknameLanguage().latin1() );
  78. keyChooser()->refreshContent();
  79. }
  80. /** rapper around key() to return the right type of key. */
  81. CSwordVerseKey* CCommentaryReadWindow::verseKey() {
  82. CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
  83. Q_ASSERT(k);
  84. return k;
  85. }
  86. void CCommentaryReadWindow::initActions() {
  87. CLexiconReadWindow::initActions(); //make sure the predefined actions are available
  88. //cleanup, not a clean oo-solution
  89. actionCollection()->action("nextEntry")->setEnabled(false);
  90. actionCollection()->action("previousEntry")->setEnabled(false);
  91. new TDEAction(
  92. i18n("Next book"),
  93. CResMgr::displaywindows::bibleWindow::nextBook::accel,
  94. TQT_TQOBJECT(this), TQT_SLOT(nextBook()),
  95. actionCollection(), "nextBook"
  96. );
  97. new TDEAction(
  98. i18n("Previous book"),
  99. CResMgr::displaywindows::bibleWindow::previousBook::accel,
  100. TQT_TQOBJECT(this), TQT_SLOT(previousBook()),
  101. actionCollection(), "previousBook"
  102. );
  103. new TDEAction(
  104. i18n("Next chapter"),
  105. CResMgr::displaywindows::bibleWindow::nextChapter::accel,
  106. TQT_TQOBJECT(this), TQT_SLOT(nextChapter()),
  107. actionCollection(), "nextChapter"
  108. );
  109. new TDEAction(
  110. i18n("Previous chapter"),
  111. CResMgr::displaywindows::bibleWindow::previousChapter::accel,
  112. TQT_TQOBJECT(this), TQT_SLOT(previousChapter()),
  113. actionCollection(), "previousChapter"
  114. );
  115. new TDEAction(
  116. i18n("Next verse"),
  117. CResMgr::displaywindows::bibleWindow::nextVerse::accel,
  118. TQT_TQOBJECT(this), TQT_SLOT(nextVerse()),
  119. actionCollection(), "nextVerse"
  120. );
  121. new TDEAction(
  122. i18n("Previous verse"),
  123. CResMgr::displaywindows::bibleWindow::previousVerse::accel,
  124. TQT_TQOBJECT(this), TQT_SLOT(previousVerse()),
  125. actionCollection(), "previousVerse"
  126. );
  127. CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
  128. }
  129. /** Moves to the next book. */
  130. void CCommentaryReadWindow::nextBook() {
  131. if (verseKey()->next(CSwordVerseKey::UseBook))
  132. keyChooser()->setKey(key());
  133. }
  134. /** Moves one book behind. */
  135. void CCommentaryReadWindow::previousBook() {
  136. if (verseKey()->previous(CSwordVerseKey::UseBook))
  137. keyChooser()->setKey(key());
  138. }
  139. /** Moves to the next book. */
  140. void CCommentaryReadWindow::nextChapter() {
  141. if (verseKey()->next(CSwordVerseKey::UseChapter))
  142. keyChooser()->setKey(key());
  143. }
  144. /** Moves one book behind. */
  145. void CCommentaryReadWindow::previousChapter() {
  146. if (verseKey()->previous(CSwordVerseKey::UseChapter))
  147. keyChooser()->setKey(key());
  148. }
  149. /** Moves to the next book. */
  150. void CCommentaryReadWindow::nextVerse() {
  151. if (verseKey()->next(CSwordVerseKey::UseVerse))
  152. keyChooser()->setKey(key());
  153. }
  154. /** Moves one book behind. */
  155. void CCommentaryReadWindow::previousVerse() {
  156. if (verseKey()->previous(CSwordVerseKey::UseVerse))
  157. keyChooser()->setKey(key());
  158. }
  159. const bool CCommentaryReadWindow::syncAllowed() const {
  160. return m_syncButton->isChecked();
  161. }
  162. /*!
  163. \fn CCommentaryReadWindow::setupPopupMenu()
  164. */
  165. void CCommentaryReadWindow::setupPopupMenu() {
  166. CLexiconReadWindow::setupPopupMenu();
  167. popup()->changeTitle(-1, CToolClass::getIconForModule(modules().first()), i18n("Commentary window"));
  168. }
  169. #include "ccommentaryreadwindow.moc"