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.

chtmlwritewindow.cpp 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 "chtmlwritewindow.h"
  10. //frontend includes
  11. #include "frontend/keychooser/ckeychooser.h"
  12. #include "frontend/cprofilewindow.h"
  13. #include "util/cresmgr.h"
  14. //TQt includes
  15. //KDE includes
  16. #include <tdeaction.h>
  17. #include <tdelocale.h>
  18. using namespace Profile;
  19. CHTMLWriteWindow::CHTMLWriteWindow(ListCSwordModuleInfo modules, CMDIArea* parent, const char *name)
  20. : CPlainWriteWindow(modules, parent, name) {}
  21. CHTMLWriteWindow::~CHTMLWriteWindow() {}
  22. void CHTMLWriteWindow::initView() {
  23. CWriteDisplay* writeDisplay = CDisplay::createWriteInstance(this, CDisplay::HTMLDisplay);
  24. Q_ASSERT(writeDisplay);
  25. setDisplayWidget( writeDisplay );
  26. setCentralWidget( displayWidget()->view() );
  27. setMainToolBar( new TDEToolBar(this) );
  28. mainToolBar()->setFullSize(true);
  29. addDockWindow(mainToolBar());
  30. setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
  31. mainToolBar()->insertWidget(0,keyChooser()->sizeHint().width(),keyChooser());
  32. mainToolBar()->setFullSize(false);
  33. };
  34. void CHTMLWriteWindow::initConnections() {
  35. CWriteWindow::initConnections();
  36. connect(keyChooser(), TQT_SIGNAL(keyChanged(CSwordKey*)),
  37. TQT_TQOBJECT(this), TQT_SLOT(lookup(CSwordKey*)));
  38. connect(displayWidget()->connectionsProxy(), TQT_SIGNAL(textChanged()),
  39. TQT_TQOBJECT(this), TQT_SLOT(textChanged()) );
  40. };
  41. void CHTMLWriteWindow::initToolbars() {
  42. //setup the toolbar
  43. m_actions.syncWindow = new TDEToggleAction(i18n("Sync with active Bible"),
  44. CResMgr::displaywindows::commentaryWindow::syncWindow::icon,
  45. CResMgr::displaywindows::commentaryWindow::syncWindow::accel,
  46. actionCollection(),
  47. CResMgr::displaywindows::commentaryWindow::syncWindow::actionName
  48. );
  49. m_actions.syncWindow->setToolTip(CResMgr::displaywindows::commentaryWindow::syncWindow::tooltip);
  50. m_actions.syncWindow->plug(mainToolBar());
  51. m_actions.saveText = new TDEAction( i18n("Save text"),
  52. CResMgr::displaywindows::writeWindow::saveText::icon,
  53. CResMgr::displaywindows::writeWindow::saveText::accel,
  54. TQT_TQOBJECT(this), TQT_SLOT( saveCurrentText() ),
  55. actionCollection(),
  56. CResMgr::displaywindows::writeWindow::saveText::actionName
  57. );
  58. m_actions.saveText->setToolTip( CResMgr::displaywindows::writeWindow::saveText::tooltip );
  59. m_actions.saveText->plug(mainToolBar());
  60. m_actions.deleteEntry = new TDEAction(i18n("Delete current entry"),
  61. CResMgr::displaywindows::writeWindow::deleteEntry::icon,
  62. CResMgr::displaywindows::writeWindow::deleteEntry::accel,
  63. TQT_TQOBJECT(this), TQT_SLOT(deleteEntry()),
  64. actionCollection(),
  65. CResMgr::displaywindows::writeWindow::deleteEntry::actionName
  66. );
  67. m_actions.deleteEntry->setToolTip( CResMgr::displaywindows::writeWindow::deleteEntry::tooltip );
  68. m_actions.deleteEntry->plug(mainToolBar());
  69. m_actions.restoreText = new TDEAction(i18n("Restore original text"),
  70. CResMgr::displaywindows::writeWindow::restoreText::icon,
  71. CResMgr::displaywindows::writeWindow::restoreText::accel,
  72. TQT_TQOBJECT(this), TQT_SLOT(restoreText()), actionCollection(),
  73. CResMgr::displaywindows::writeWindow::restoreText::actionName
  74. );
  75. m_actions.restoreText->setToolTip( CResMgr::displaywindows::writeWindow::restoreText::tooltip );
  76. m_actions.restoreText->plug(mainToolBar());
  77. TDEToolBar* bar = new TDEToolBar(this);
  78. bar->setFullSize(true);
  79. addDockWindow(bar);
  80. displayWidget()->setupToolbar( bar, actionCollection() );
  81. }
  82. void CHTMLWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
  83. CWriteWindow::storeProfileSettings(profileWindow);
  84. profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
  85. };
  86. void CHTMLWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
  87. CWriteWindow::applyProfileSettings(profileWindow);
  88. if (profileWindow->windowSettings()) {
  89. m_actions.syncWindow->setChecked(true);
  90. }
  91. };
  92. /** Is called when the current text was changed. */
  93. void CHTMLWriteWindow::textChanged() {
  94. m_actions.saveText->setEnabled( displayWidget()->isModified() );
  95. m_actions.restoreText->setEnabled( displayWidget()->isModified() );
  96. }
  97. /** Loads the original text from the module. */
  98. void CHTMLWriteWindow::restoreText() {
  99. lookup(key());
  100. displayWidget()->setModified(false);
  101. textChanged();
  102. }
  103. const bool CHTMLWriteWindow::syncAllowed() const {
  104. return m_actions.syncWindow->isChecked();
  105. }
  106. #include "chtmlwritewindow.moc"