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.

bibletime_init.cpp 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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 "bibletime.h"
  11. #include "backend/btstringmgr.h"
  12. #include "backend/cswordbackend.h"
  13. #include "frontend/mainindex/cmainindex.h"
  14. #include "frontend/cprofilemgr.h"
  15. #include "frontend/cprofile.h"
  16. #include "frontend/cmdiarea.h"
  17. #include "frontend/kstartuplogo.h"
  18. #include "frontend/cswordsetupdialog.h"
  19. #include "frontend/cprinter.h"
  20. #include "frontend/cmanageindiceswidget.h"
  21. #include "backend/clanguagemgr.h"
  22. #include "config.h"
  23. #include "frontend/cbtconfig.h"
  24. #include "frontend/cinfodisplay.h"
  25. #include "util/cpointers.h"
  26. #include "util/cresmgr.h"
  27. //system includes
  28. #include <stdlib.h>
  29. //QT includes
  30. #include <tqpopupmenu.h>
  31. #include <tqsplitter.h>
  32. #include <tqguardedptr.h>
  33. #include <tqlistview.h>
  34. #include <tqlayout.h>
  35. #include <tqlabel.h>
  36. #include <tqvbox.h>
  37. //KDE includes
  38. #include <tdeaboutdata.h>
  39. #include <tdeaccel.h>
  40. #include <tdeaction.h>
  41. #include <tdeapplication.h>
  42. #include <tdeconfigbase.h>
  43. #include <tdeversion.h>
  44. #include <tdeglobal.h>
  45. #include <khelpmenu.h>
  46. #include <kiconloader.h>
  47. #include <tdemenubar.h>
  48. #include <kstddirs.h>
  49. #include <kstdaction.h>
  50. #include <tdetoolbar.h>
  51. #include <tdelocale.h>
  52. #include <tdepopupmenu.h>
  53. #include <tdeversion.h>
  54. //Sword includes
  55. #include <swlog.h>
  56. using namespace InfoDisplay;
  57. using namespace Profile;
  58. /**Initializes the view of this widget*/
  59. void BibleTime::initView() {
  60. TDEStartupLogo::setStatusMessage(i18n("Creating BibleTime's GUI") + TQString("..."));
  61. m_mainSplitter = new TQSplitter(this, "mainsplitter");
  62. m_mainSplitter->setChildrenCollapsible(false);
  63. setCentralWidget(m_mainSplitter);
  64. m_leftPaneSplitter = new TQSplitter(Qt::Vertical, m_mainSplitter);
  65. m_leftPaneSplitter->setChildrenCollapsible(false);
  66. TQVBox* vBox = new TQVBox(m_leftPaneSplitter);
  67. vBox->setMinimumSize(100, 100);
  68. TQLabel* bookshelfLabel = new TQLabel( i18n("Bookshelf"), vBox );
  69. bookshelfLabel->setMargin(5);
  70. m_mainIndex = new CMainIndex(vBox);
  71. m_infoDisplay = new CInfoDisplay(m_leftPaneSplitter);
  72. CPointers::setInfoDisplay(m_infoDisplay);
  73. m_mdi = new CMDIArea(m_mainSplitter, "mdiarea" );
  74. m_mdi->setMinimumSize(100, 100);
  75. m_mdi->setFocusPolicy(TQ_ClickFocus);
  76. m_helpMenu = new KHelpMenu(this, TDEGlobal::instance()->aboutData(), true, actionCollection());
  77. }
  78. /** Initializes the action objects of the GUI */
  79. void BibleTime::initActions() {
  80. TDEStartupLogo::setStatusMessage(i18n("Initializing menu- and toolbars") + TQString("..."));
  81. TDEAction* action = 0;
  82. action = KStdAction::quit(TQT_TQOBJECT(kapp), TQT_SLOT( quit() ), actionCollection());
  83. action->setToolTip( CResMgr::mainMenu::file::quit::tooltip );
  84. #if TDE_VERSION_MINOR < 1
  85. action->plugAccel( accel() );
  86. #endif
  87. action = new TDEAction(i18n("Search in &open work(s)"),
  88. CResMgr::mainMenu::mainIndex::search::icon,
  89. CResMgr::mainMenu::mainIndex::search::accel,
  90. TQT_TQOBJECT(this), TQT_SLOT(slotSearchModules()), actionCollection(),
  91. CResMgr::mainMenu::mainIndex::search::actionName
  92. );
  93. action->setToolTip( CResMgr::mainMenu::mainIndex::search::tooltip );
  94. #if TDE_VERSION_MINOR < 1
  95. action->plugAccel( accel() );
  96. #endif
  97. action = new TDEAction(i18n("Search in standard &Bible"),
  98. CResMgr::mainMenu::mainIndex::searchdefaultbible::icon,
  99. CResMgr::mainMenu::mainIndex::searchdefaultbible::accel,
  100. TQT_TQOBJECT(this), TQT_SLOT(slotSearchDefaultBible()), actionCollection(),
  101. CResMgr::mainMenu::mainIndex::searchdefaultbible::actionName
  102. );
  103. action->setToolTip( CResMgr::mainMenu::mainIndex::searchdefaultbible::tooltip );
  104. #if TDE_VERSION_MINOR < 1
  105. action->plugAccel( accel() );
  106. #endif
  107. m_viewToolbar_action = KStdAction::showToolbar(TQT_TQOBJECT(this), TQT_SLOT( slotToggleToolbar() ), actionCollection());
  108. m_viewToolbar_action->setToolTip( CResMgr::mainMenu::view::showToolBar::tooltip );
  109. #if TDE_VERSION_MINOR < 1
  110. m_viewToolbar_action->plugAccel( accel() );
  111. #endif
  112. m_viewMainIndex_action = new TDEToggleAction(i18n("&Show bookshelf"),
  113. CResMgr::mainMenu::view::showMainIndex::icon,
  114. CResMgr::mainMenu::view::showMainIndex::accel,
  115. TQT_TQOBJECT(this), TQT_SLOT(slotToggleMainIndex()), actionCollection(),
  116. CResMgr::mainMenu::view::showMainIndex::actionName);
  117. m_viewMainIndex_action->setToolTip( CResMgr::mainMenu::view::showMainIndex::tooltip );
  118. #if TDE_VERSION_MINOR < 1
  119. m_viewMainIndex_action->plugAccel( accel() );
  120. #endif
  121. m_viewInfoDisplay_action = new TDEToggleAction(i18n("Show &mag"),
  122. CResMgr::mainMenu::view::showInfoDisplay::icon,
  123. CResMgr::mainMenu::view::showInfoDisplay::accel,
  124. TQT_TQOBJECT(this), TQT_SLOT(slotToggleInfoDisplay()), actionCollection(),
  125. CResMgr::mainMenu::view::showInfoDisplay::actionName);
  126. m_viewMainIndex_action->setToolTip( CResMgr::mainMenu::view::showInfoDisplay::tooltip );
  127. #if TDE_VERSION_MINOR < 1
  128. m_viewInfoDisplay_action->plugAccel( accel() );
  129. #endif
  130. action = KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT( slotSettingsOptions() ), actionCollection());
  131. action->setToolTip( CResMgr::mainMenu::settings::optionsDialog::tooltip );
  132. #if TDE_VERSION_MINOR < 1
  133. action->plugAccel( accel() );
  134. #endif
  135. action = new TDEAction(i18n("Bookshelf &Manager"),
  136. CResMgr::mainMenu::settings::swordSetupDialog::icon,
  137. CResMgr::mainMenu::settings::swordSetupDialog::accel,
  138. TQT_TQOBJECT(this), TQT_SLOT( slotSwordSetupDialog() ), actionCollection(),
  139. CResMgr::mainMenu::settings::swordSetupDialog::actionName
  140. );
  141. action->setToolTip( CResMgr::mainMenu::settings::swordSetupDialog::tooltip );
  142. #if TDE_VERSION_MINOR < 1
  143. action->plugAccel( accel() );
  144. #endif
  145. //delete help action if KDE created it
  146. if ( actionCollection()->action( KStdAction::stdName(KStdAction::ConfigureToolbars) )) {
  147. actionCollection()->remove
  148. (actionCollection()->action(
  149. KStdAction::stdName(KStdAction::ConfigureToolbars))
  150. );
  151. }
  152. action = KStdAction::configureToolbars(TQT_TQOBJECT(this), TQT_SLOT( slotSettingsToolbar() ), actionCollection());
  153. action->setToolTip( CResMgr::mainMenu::settings::editToolBar::tooltip );
  154. #if TDE_VERSION_MINOR < 1
  155. action->plugAccel( accel() );
  156. #endif
  157. m_windowArrangementMode_action = new TDEActionMenu(i18n("&Arrangement mode"),
  158. CResMgr::mainMenu::window::arrangementMode::icon,
  159. actionCollection(),
  160. CResMgr::mainMenu::window::arrangementMode::actionName);
  161. m_windowArrangementMode_action->setDelayed( false );
  162. m_windowManualMode_action = new TDEToggleAction(i18n("&Manual mode"),
  163. CResMgr::mainMenu::window::arrangementMode::manual::icon,
  164. CResMgr::mainMenu::window::arrangementMode::manual::accel,
  165. TQT_TQOBJECT(this), TQT_SLOT(slotManualArrangementMode()), actionCollection(),
  166. CResMgr::mainMenu::window::arrangementMode::manual::actionName
  167. );
  168. m_windowManualMode_action->setToolTip(
  169. CResMgr::mainMenu::window::arrangementMode::manual::tooltip
  170. );
  171. #if TDE_VERSION_MINOR < 1
  172. m_windowManualMode_action->plugAccel( accel() );
  173. #endif
  174. m_windowArrangementMode_action->insert( m_windowManualMode_action );
  175. m_windowAutoTileVertical_action = new TDEToggleAction(i18n("Auto-tile &vertically"),
  176. CResMgr::mainMenu::window::arrangementMode::autoTileVertical::icon,
  177. CResMgr::mainMenu::window::arrangementMode::autoTileVertical::accel,
  178. TQT_TQOBJECT(this), TQT_SLOT(slotAutoTileVertical()), actionCollection(),
  179. CResMgr::mainMenu::window::arrangementMode::autoTileVertical::actionName
  180. );
  181. m_windowAutoTileVertical_action->setToolTip(
  182. CResMgr::mainMenu::window::arrangementMode::autoTileVertical::tooltip
  183. );
  184. #if TDE_VERSION_MINOR < 1
  185. m_windowAutoTileVertical_action->plugAccel( accel() );
  186. #endif
  187. m_windowArrangementMode_action->insert( m_windowAutoTileVertical_action );
  188. m_windowAutoTileHorizontal_action = new TDEToggleAction(i18n("Auto-tile &horizontally"),
  189. CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::icon,
  190. CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::accel,
  191. TQT_TQOBJECT(this), TQT_SLOT(slotAutoTileHorizontal()), actionCollection(),
  192. CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::actionName
  193. );
  194. m_windowAutoTileHorizontal_action->setToolTip(
  195. CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::tooltip
  196. );
  197. #if TDE_VERSION_MINOR < 1
  198. m_windowAutoTileHorizontal_action->plugAccel( accel() );
  199. #endif
  200. m_windowArrangementMode_action->insert( m_windowAutoTileHorizontal_action );
  201. m_windowAutoCascade_action = new TDEToggleAction(i18n("Auto-&cascade"),
  202. CResMgr::mainMenu::window::arrangementMode::autoCascade::icon,
  203. CResMgr::mainMenu::window::arrangementMode::autoCascade::accel,
  204. TQT_TQOBJECT(this), TQT_SLOT(slotAutoCascade()), actionCollection(),
  205. CResMgr::mainMenu::window::arrangementMode::autoCascade::actionName
  206. );
  207. m_windowAutoCascade_action->setToolTip(
  208. CResMgr::mainMenu::window::arrangementMode::autoCascade::tooltip
  209. );
  210. #if TDE_VERSION_MINOR < 1
  211. // tqWarning("Plug accel");
  212. m_windowAutoCascade_action->plugAccel( accel() );
  213. #endif
  214. m_windowArrangementMode_action->insert( m_windowAutoCascade_action );
  215. m_windowCascade_action = new TDEAction(i18n("&Cascade"),
  216. CResMgr::mainMenu::window::cascade::icon,
  217. CResMgr::mainMenu::window::cascade::accel,
  218. TQT_TQOBJECT(this), TQT_SLOT(slotCascade()), actionCollection(),
  219. CResMgr::mainMenu::window::cascade::actionName
  220. );
  221. m_windowCascade_action->setToolTip( CResMgr::mainMenu::window::cascade::tooltip );
  222. #if TDE_VERSION_MINOR < 1
  223. m_windowCascade_action->plugAccel( accel() );
  224. #endif
  225. m_windowTileVertical_action = new TDEAction(i18n("Tile &vertically"),
  226. CResMgr::mainMenu::window::tileVertical::icon,
  227. CResMgr::mainMenu::window::tileVertical::accel,
  228. TQT_TQOBJECT(this), TQT_SLOT(slotTileVertical()), actionCollection(),
  229. CResMgr::mainMenu::window::tileVertical::actionName
  230. );
  231. m_windowTileVertical_action->setToolTip( CResMgr::mainMenu::window::tileVertical::tooltip );
  232. #if TDE_VERSION_MINOR < 1
  233. m_windowTileVertical_action->plugAccel( accel() );
  234. #endif
  235. m_windowTileHorizontal_action = new TDEAction(i18n("Tile &horizontally"),
  236. CResMgr::mainMenu::window::tileHorizontal::icon,
  237. CResMgr::mainMenu::window::tileHorizontal::accel,
  238. TQT_TQOBJECT(this), TQT_SLOT(slotTileHorizontal()), actionCollection(),
  239. CResMgr::mainMenu::window::tileHorizontal::actionName
  240. );
  241. m_windowTileHorizontal_action->setToolTip( CResMgr::mainMenu::window::tileHorizontal::tooltip );
  242. #if TDE_VERSION_MINOR < 1
  243. m_windowTileHorizontal_action->plugAccel( accel() );
  244. #endif
  245. m_windowCloseAll_action = new TDEAction(i18n("Cl&ose all"),
  246. CResMgr::mainMenu::window::closeAll::icon,
  247. CResMgr::mainMenu::window::closeAll::accel,
  248. TQT_TQOBJECT(m_mdi), TQT_SLOT(deleteAll()), actionCollection(),
  249. CResMgr::mainMenu::window::closeAll::actionName
  250. );
  251. m_windowCloseAll_action->setToolTip( CResMgr::mainMenu::window::closeAll::tooltip );
  252. #if TDE_VERSION_MINOR < 1
  253. m_windowCloseAll_action->plugAccel( accel() );
  254. #endif
  255. m_windowSaveProfile_action = new TDEActionMenu(i18n("&Save session"),
  256. CResMgr::mainMenu::window::saveProfile::icon,
  257. actionCollection(),
  258. CResMgr::mainMenu::window::saveProfile::actionName
  259. );
  260. m_windowSaveProfile_action->setToolTip( CResMgr::mainMenu::window::saveProfile::tooltip );
  261. m_windowSaveProfile_action->setDelayed( false );
  262. #if TDE_VERSION_MINOR < 1
  263. m_windowSaveProfile_action->plugAccel( accel() );
  264. #endif
  265. m_windowSaveToNewProfile_action = new TDEAction(i18n("Save as &new session"),
  266. CResMgr::mainMenu::window::saveToNewProfile::icon,
  267. CResMgr::mainMenu::window::saveToNewProfile::accel,
  268. TQT_TQOBJECT(this), TQT_SLOT(saveToNewProfile()), actionCollection(),
  269. CResMgr::mainMenu::window::saveToNewProfile::actionName
  270. );
  271. m_windowSaveToNewProfile_action->setToolTip( CResMgr::mainMenu::window::saveToNewProfile::tooltip );
  272. #if TDE_VERSION_MINOR < 1
  273. m_windowSaveToNewProfile_action->plugAccel( accel() );
  274. #endif
  275. m_windowLoadProfile_action = new TDEActionMenu(i18n("&Load session"),
  276. CResMgr::mainMenu::window::loadProfile::icon,
  277. actionCollection(),
  278. CResMgr::mainMenu::window::loadProfile::actionName
  279. );
  280. m_windowLoadProfile_action->setToolTip( CResMgr::mainMenu::window::loadProfile::tooltip );
  281. m_windowLoadProfile_action->setDelayed( false );
  282. #if TDE_VERSION_MINOR < 1
  283. m_windowLoadProfile_action->plugAccel( accel() );
  284. #endif
  285. m_windowDeleteProfile_action = new TDEActionMenu(i18n("&Delete session"),
  286. CResMgr::mainMenu::window::deleteProfile::icon,
  287. actionCollection(),
  288. CResMgr::mainMenu::window::deleteProfile::actionName
  289. );
  290. m_windowLoadProfile_action->setToolTip( CResMgr::mainMenu::window::deleteProfile::tooltip );
  291. m_windowLoadProfile_action->setDelayed( false );
  292. #if TDE_VERSION_MINOR < 1
  293. m_windowDeleteProfile_action->plugAccel( accel() );
  294. #endif
  295. m_windowFullscreen_action = new TDEToggleAction(i18n("&Fullscreen mode"),
  296. CResMgr::mainMenu::window::showFullscreen::icon,
  297. CResMgr::mainMenu::window::showFullscreen::accel,
  298. TQT_TQOBJECT(this), TQT_SLOT(toggleFullscreen()), actionCollection(),
  299. CResMgr::mainMenu::window::showFullscreen::actionName
  300. );
  301. m_windowFullscreen_action->setToolTip( CResMgr::mainMenu::window::showFullscreen::tooltip );
  302. m_windowFullscreen_action->setShortcutConfigurable(true);
  303. #if TDE_VERSION_MINOR < 1
  304. m_windowFullscreen_action->plugAccel( accel() );
  305. #endif
  306. //connect the profile popups to the right slots
  307. TDEPopupMenu* loadPopup = m_windowLoadProfile_action->popupMenu();
  308. TDEPopupMenu* savePopup = m_windowSaveProfile_action->popupMenu();
  309. TDEPopupMenu* deletePopup = m_windowDeleteProfile_action->popupMenu();
  310. connect(loadPopup, TQT_SIGNAL(activated(int)), TQT_SLOT(loadProfile(int)));
  311. connect(savePopup, TQT_SIGNAL(activated(int)), TQT_SLOT(saveProfile(int)));
  312. connect(deletePopup, TQT_SIGNAL(activated(int)), TQT_SLOT(deleteProfile(int)));
  313. refreshProfileMenus();
  314. if ( actionCollection()->action( KStdAction::stdName(KStdAction::HelpContents) )) { //delete help action if KDE created it
  315. actionCollection()->remove
  316. (actionCollection()->action(KStdAction::stdName(KStdAction::HelpContents)) );
  317. }
  318. action = new TDEAction(i18n("&Handbook"),
  319. CResMgr::mainMenu::help::handbook::icon,
  320. CResMgr::mainMenu::help::handbook::accel,
  321. TQT_TQOBJECT(this), TQT_SLOT(openOnlineHelp_Handbook()), actionCollection(),
  322. CResMgr::mainMenu::help::handbook::actionName
  323. );
  324. action->setToolTip( CResMgr::mainMenu::help::handbook::tooltip );
  325. #if TDE_VERSION_MINOR < 1
  326. action->plugAccel( accel() );
  327. #endif
  328. action = new TDEAction(i18n("&Bible Study Howto"),
  329. CResMgr::mainMenu::help::bibleStudyHowTo::icon,
  330. CResMgr::mainMenu::help::bibleStudyHowTo::accel,
  331. TQT_TQOBJECT(this), TQT_SLOT(openOnlineHelp_Howto()), actionCollection(),
  332. CResMgr::mainMenu::help::bibleStudyHowTo::actionName
  333. );
  334. action->setToolTip( CResMgr::mainMenu::help::bibleStudyHowTo::tooltip );
  335. #if TDE_VERSION_MINOR < 1
  336. action->plugAccel( accel() );
  337. #endif
  338. if ( actionCollection()->action( KStdAction::stdName( KStdAction::WhatsThis ) ) ) { //delete "What's this" action if KDE created it already
  339. TDEAction* action = actionCollection()->action(KStdAction::stdName( KStdAction::WhatsThis ));
  340. actionCollection()->remove
  341. ( action );
  342. }
  343. if ( actionCollection()->action( KStdAction::stdName( KStdAction::ReportBug ) ) ) { //delete Report Bug action if KDE created it
  344. actionCollection()->remove
  345. (actionCollection()->action(KStdAction::stdName( KStdAction::ReportBug )));
  346. }
  347. action = KStdAction::reportBug(m_helpMenu, TQT_SLOT(reportBug()), actionCollection());
  348. action->setToolTip(CResMgr::mainMenu::help::bugreport::tooltip);
  349. #if TDE_VERSION_MINOR < 1
  350. action->plugAccel( accel() );
  351. #endif
  352. action = new TDEAction(i18n("&Daily tip"),
  353. CResMgr::mainMenu::help::dailyTip::icon,
  354. CResMgr::mainMenu::help::dailyTip::accel,
  355. TQT_TQOBJECT(this), TQT_SLOT(slotHelpTipOfDay()), actionCollection(),
  356. CResMgr::mainMenu::help::dailyTip::actionName
  357. );
  358. action->setToolTip(CResMgr::mainMenu::help::dailyTip::tooltip);
  359. #if TDE_VERSION_MINOR < 1
  360. action->plugAccel( accel() );
  361. #endif
  362. if ( actionCollection()->action( KStdAction::stdName( KStdAction::AboutApp ) ) ) { //delete About KDE action if KDE created it
  363. actionCollection()->remove
  364. (actionCollection()->action(KStdAction::stdName( KStdAction::AboutApp )));
  365. }
  366. action = KStdAction::aboutApp(m_helpMenu, TQT_SLOT(aboutApplication()), actionCollection());
  367. action->setToolTip(CResMgr::mainMenu::help::aboutBibleTime::tooltip);
  368. //delete About KDE action if KDE created it already
  369. if ( actionCollection()->action( KStdAction::stdName( KStdAction::AboutKDE ) ) ) { //delete About KDE action if KDE created it
  370. actionCollection()->remove
  371. (actionCollection()->action(KStdAction::stdName( KStdAction::AboutKDE )));
  372. }
  373. action = KStdAction::aboutKDE(m_helpMenu, TQT_SLOT(aboutKDE()), actionCollection());
  374. action->setToolTip(CResMgr::mainMenu::help::aboutKDE::tooltip);
  375. }
  376. /** Initializes the menubar of BibleTime. */
  377. void BibleTime::initMenubar() {
  378. //get the window and edit menus using the actions and their properties
  379. m_windowMenu = dynamic_cast<TQPopupMenu*>(m_windowCloseAll_action->container(0));
  380. }
  381. /** Initializes the TQT_SIGNAL / TQT_SLOT connections */
  382. void BibleTime::initConnections() {
  383. connect(m_mdi, TQT_SIGNAL(sigSetToplevelCaption(const TQString&)),
  384. this, TQT_SLOT(setPlainCaption(const TQString&)));
  385. connect(m_mdi, TQT_SIGNAL(createReadDisplayWindow(ListCSwordModuleInfo, const TQString&)),
  386. this, TQT_SLOT(createReadDisplayWindow(ListCSwordModuleInfo, const TQString&)));
  387. Q_ASSERT(m_windowMenu);
  388. if (m_windowMenu) {
  389. connect(m_windowMenu, TQT_SIGNAL(aboutToShow()),
  390. this, TQT_SLOT(slotWindowMenuAboutToShow()));
  391. }
  392. else {
  393. tqWarning("Main window: can't find window menu");
  394. }
  395. connect(
  396. m_mainIndex, TQT_SIGNAL(createReadDisplayWindow(ListCSwordModuleInfo, const TQString&)),
  397. this, TQT_SLOT(createReadDisplayWindow(ListCSwordModuleInfo,const TQString&))
  398. );
  399. connect(
  400. m_mainIndex, TQT_SIGNAL(createWriteDisplayWindow(CSwordModuleInfo*, const TQString&, const CDisplayWindow::WriteWindowType&)),
  401. this, TQT_SLOT(createWriteDisplayWindow(CSwordModuleInfo*,const TQString&, const CDisplayWindow::WriteWindowType&))
  402. );
  403. connect(m_mainIndex, TQT_SIGNAL(signalSwordSetupChanged()), this, TQT_SLOT(slotSwordSetupChanged()));
  404. }
  405. /** Initializes the backend */
  406. void BibleTime::initBackends() {
  407. TDEStartupLogo::setStatusMessage(i18n("Initializing Sword") + TQString("..."));
  408. StringMgr::setSystemStringMgr( new BTStringMgr() );
  409. SWLog::getSystemLog()->setLogLevel(1);
  410. m_backend = new CSwordBackend();
  411. m_backend->booknameLanguage( CBTConfig::get
  412. (CBTConfig::language) );
  413. CPointers::setBackend(m_backend);
  414. const CSwordBackend::LoadError errorCode = m_backend->initModules();
  415. m_moduleList = 0;
  416. if ( errorCode == CSwordBackend::NoError ) { //no error
  417. m_moduleList = &(m_backend->moduleList());
  418. }
  419. else {
  420. m_moduleList = 0;
  421. //show error message that initBackend failed
  422. switch (errorCode) {
  423. case CSwordBackend::NoSwordConfig: //mods.d or mods.conf missing
  424. {
  425. TDEStartupLogo::hideSplash();
  426. BookshelfManager::CSwordSetupDialog dlg;
  427. dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword );
  428. dlg.exec();
  429. break;
  430. }
  431. case CSwordBackend::NoModules: //no modules installed, but config exists
  432. {
  433. TDEStartupLogo::hideSplash();
  434. BookshelfManager::CSwordSetupDialog dlg;
  435. dlg.showPart( BookshelfManager::CSwordSetupDialog::Install );
  436. dlg.exec();
  437. break;
  438. }
  439. default: //unknown error
  440. {
  441. TDEStartupLogo::hideSplash();
  442. BookshelfManager::CSwordSetupDialog dlg;
  443. dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword );
  444. dlg.exec();
  445. break;
  446. }
  447. }
  448. }
  449. TDEStartupLogo::setStatusMessage(i18n("Checking indices") + TQString("..."));
  450. //This function will
  451. // - delete all orphaned indexes (no module present) if autoDeleteOrphanedIndices is true
  452. // - delete all indices of modules where hasIndex() returns false
  453. BookshelfManager::CManageIndicesWidget::deleteOrphanedIndices();
  454. }
  455. /** Apply the settings given by the profile p*/
  456. void BibleTime::applyProfileSettings( CProfile* p ) {
  457. Q_ASSERT(p);
  458. if (!p) return;
  459. if (m_initialized) { //on startup KDE sets the main geometry
  460. //see polish(), where m_initialized is set and the KDE methods are called for window resize
  461. //first Main Window state
  462. m_windowFullscreen_action->setChecked( p->fullscreen() ); //set the fullscreen button state
  463. toggleFullscreen(); //either showFullscreen or showNormal
  464. if (p->maximized()) TDEMainWindow::showMaximized(); //if maximized, then also call showMaximized
  465. //Then Main Window geometry
  466. TDEMainWindow::resize( p->geometry().size() ); //Don't use TDEMainWindowInterface::resize
  467. TDEMainWindow::move( p->geometry().topLeft() );//Don't use TDEMainWindowInterface::move
  468. }
  469. }
  470. /** Stores the settings of the mainwindow in the profile p */
  471. void BibleTime::storeProfileSettings( CProfile* p ) {
  472. Q_ASSERT(p && m_windowFullscreen_action);
  473. if (!p || !m_windowFullscreen_action) return;
  474. p->setFullscreen( m_windowFullscreen_action->isChecked() );
  475. p->setMaximized( this->TDEMainWindow::isMaximized() );
  476. TQRect geometry;
  477. geometry.setTopLeft(pos());
  478. geometry.setSize(size());
  479. p->setGeometry(geometry);
  480. }