diff options
Diffstat (limited to 'src/bibletime_init.cpp')
-rw-r--r-- | src/bibletime_init.cpp | 303 |
1 files changed, 144 insertions, 159 deletions
diff --git a/src/bibletime_init.cpp b/src/bibletime_init.cpp index df8fdea..7a3c5b7 100644 --- a/src/bibletime_init.cpp +++ b/src/bibletime_init.cpp @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2011 by the BibleTime developers. +* Copyright 1999-2014 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -20,20 +20,24 @@ #include <QToolBar> #include <QToolButton> #include <QVBoxLayout> -#include "backend/config/cbtconfig.h" +#include "backend/config/btconfig.h" #include "backend/managers/btstringmgr.h" #include "backend/managers/clanguagemgr.h" #include "backend/managers/cswordbackend.h" +#include "bibletimeapp.h" #include "frontend/btbookshelfdockwidget.h" #include "frontend/btopenworkaction.h" #include "frontend/cinfodisplay.h" #include "frontend/cmdiarea.h" #include "frontend/cprinter.h" +#include "frontend/display/btfindwidget.h" #include "frontend/displaywindow/btactioncollection.h" #include "frontend/displaywindow/btmodulechooserbar.h" #include "frontend/bookmarks/cbookmarkindex.h" +#include "frontend/settingsdialogs/btlanguagesettings.h" #include "util/cresmgr.h" #include "util/directory.h" +#include "util/geticon.h" // Sword includes: #include <swlog.h> @@ -47,7 +51,6 @@ using namespace InfoDisplay; -using namespace Profile; /**Initializes the view of this widget*/ void BibleTime::initView() { @@ -55,8 +58,7 @@ void BibleTime::initView() { // Create menu and toolbar before the mdi area createMenuAndToolBar(); - m_mdi = new CMDIArea(this); - setCentralWidget(m_mdi); + createCentralWidget(); m_bookshelfDock = new BtBookshelfDockWidget(this); addDockWidget(Qt::LeftDockWidgetArea, m_bookshelfDock); @@ -85,11 +87,9 @@ void BibleTime::initView() { QAction* BibleTime::initAction(QAction* action, QString text, QString icon, QKeySequence accel, const QString& tooltip, const QString& actionName, const char* slot) { - namespace DU = util::directory; - action->setText(text); if ( ! icon.isEmpty() ) - action->setIcon(DU::getIcon(icon)); + action->setIcon(util::getIcon(icon)); action->setShortcut(accel); if (tooltip != QString::null) action->setToolTip(tooltip); m_actionCollection->addAction(actionName, action); @@ -100,18 +100,16 @@ QAction* BibleTime::initAction(QAction* action, QString text, QString icon, // Creates QAction's for all actions that can have keyboard shortcuts // Used in creating the main window and by the configuration dialog for setting shortcuts void BibleTime::insertKeyboardActions( BtActionCollection* const a ) { - namespace DU = util::directory; - QAction* action = new QAction(a); action->setText(tr("&Quit")); - action->setIcon(DU::getIcon("exit.svg")); + action->setIcon(util::getIcon("exit.svg")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); action->setToolTip(tr("Quit BibleTime")); a->addAction("quit", action); action = new QAction(a); action->setText(tr("&Fullscreen mode")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::showFullscreen::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::showFullscreen::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::showFullscreen::accel)); action->setToolTip(tr("Toggle fullscreen mode of the main window")); a->addAction("toggleFullscreen", action); @@ -123,132 +121,132 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) { action = new QAction(a); action->setText(tr("Search in &open works...")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::mainIndex::search::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::mainIndex::search::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::mainIndex::search::accel)); action->setToolTip(tr("Search in all works that are currently open")); a->addAction("searchOpenWorks", action); action = new QAction(a); action->setText(tr("Search in standard &Bible...")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::mainIndex::searchdefaultbible::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::mainIndex::searchdefaultbible::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::mainIndex::searchdefaultbible::accel)); action->setToolTip(tr("Search in the standard Bible")); a->addAction("searchStdBible", action); action = new QAction(a); action->setText(tr("Save as &new session...")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::saveToNewProfile::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::saveToNewProfile::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::saveToNewProfile::accel)); action->setToolTip(tr("Create and save a new session")); a->addAction("saveNewSession", action); action = new QAction(a); action->setText(tr("&Manual mode")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::manual::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::manual::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::manual::accel)); action->setToolTip(tr("Manually arrange the open windows")); a->addAction("manualArrangement", action); action = new QAction(a); action->setText(tr("Auto-tile &vertically")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileVertical::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileVertical::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoTileVertical::accel)); action->setToolTip(tr("Automatically tile the open windows vertically (arrange side by side)")); a->addAction("autoVertical", action); action = new QAction(a); action->setText(tr("Auto-tile &horizontally")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::accel)); action->setToolTip(tr("Automatically tile the open windows horizontally (arrange on top of each other)")); a->addAction("autoHorizontal", action); action = new QAction(a); action->setText(tr("Auto-&tile")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTile::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTile::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoTile::accel)); action->setToolTip(tr("Automatically tile the open windows")); a->addAction("autoTile", action); action = new QAction(a); action->setText(tr("Ta&bbed")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTabbed::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTabbed::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoTabbed::accel)); action->setToolTip(tr("Automatically tab the open windows")); a->addAction("autoTabbed", action); action = new QAction(a); action->setText(tr("Auto-&cascade")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoCascade::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::autoCascade::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoCascade::accel)); action->setToolTip(tr("Automatically cascade the open windows")); a->addAction("autoCascade", action); action = new QAction(a); action->setText(tr("&Cascade")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::cascade::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::cascade::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::cascade::accel)); action->setToolTip(tr("Cascade the open windows")); a->addAction("cascade", action); action = new QAction(a); action->setText(tr("&Tile")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::tile::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::tile::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::tile::accel)); action->setToolTip(tr("Tile the open windows")); a->addAction("tile", action); action = new QAction(a); action->setText(tr("Tile &vertically")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::tileVertical::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::tileVertical::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::tileVertical::accel)); action->setToolTip(tr("Vertically tile (arrange side by side) the open windows")); a->addAction("tileVertically", action); action = new QAction(a); action->setText(tr("Tile &horizontally")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::tileHorizontal::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::tileHorizontal::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::tileHorizontal::accel)); action->setToolTip(tr("Horizontally tile (arrange on top of each other) the open windows")); a->addAction("tileHorizontally", action); action = new QAction(a); action->setText(tr("Close &window")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::close::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::close::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::close::accel)); action->setToolTip(tr("Close the current open window")); a->addAction("closeWindow", action); action = new QAction(a); action->setText(tr("Cl&ose all windows")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::window::closeAll::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::window::closeAll::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::window::closeAll::accel)); action->setToolTip(tr("Close all open windows inside BibleTime")); a->addAction("closeAllWindows", action); action = new QAction(a); action->setText(tr("&Configure BibleTime...")); - action->setIcon(DU::getIcon("configure.svg")); + action->setIcon(util::getIcon("configure.svg")); action->setToolTip(tr("Set BibleTime's preferences")); a->addAction("setPreferences", action); action = new QAction(a); action->setText(tr("Bookshelf &Manager...")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::settings::swordSetupDialog::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::settings::swordSetupDialog::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::settings::swordSetupDialog::accel)); action->setToolTip(tr("Configure your bookshelf and install/update/remove/index works")); a->addAction("bookshelfManager", action); action = new QAction(a); action->setText(tr("&Handbook")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::help::handbook::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::help::handbook::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::help::handbook::accel)); action->setToolTip(tr("Open BibleTime's handbook")); a->addAction("openHandbook", action); action = new QAction(a); action->setText(tr("&Bible Study Howto")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::help::bibleStudyHowTo::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::help::bibleStudyHowTo::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::help::bibleStudyHowTo::accel)); action->setToolTip(tr("Open the Bible study HowTo included with BibleTime.<br/>This HowTo is an introduction on how to study the Bible in an efficient way.")); a->addAction("bibleStudyHowto", action); @@ -260,7 +258,7 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) { action = new QAction(a); action->setText(tr("&Tip of the day...")); - action->setIcon(DU::getIcon(CResMgr::mainMenu::help::tipOfTheDay::icon)); + action->setIcon(util::getIcon(CResMgr::mainMenu::help::tipOfTheDay::icon)); action->setShortcut(QKeySequence(CResMgr::mainMenu::help::tipOfTheDay::accel)); action->setToolTip(tr("Show tips about BibleTime")); a->addAction("tipOfTheDay", action); @@ -321,7 +319,7 @@ void BibleTime::createMenuAndToolBar() addToolBar(m_mainToolBar); // Set visibility of main window toolbars based on config - bool visible = ! CBTConfig::get(CBTConfig::showToolbarsInEachWindow); + bool visible = ! btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true); m_navToolBar = createToolBar("NavToolBar", this, visible); addToolBar(m_navToolBar); @@ -338,6 +336,36 @@ void BibleTime::createMenuAndToolBar() addToolBar(m_formatToolBar); } +void BibleTime::createCentralWidget() +{ + m_mdi = new CMDIArea(this); + m_findWidget = new BtFindWidget(this); + m_findWidget->setVisible(false); + + QVBoxLayout* layout = new QVBoxLayout(); + layout->addWidget(m_mdi); + layout->addWidget(m_findWidget); + + QWidget* widget = new QWidget(this); + widget->setLayout(layout); + setCentralWidget(widget); + + bool ok = connect(m_findWidget, SIGNAL(findNext(const QString&,bool)), + m_mdi, SLOT(findNextTextInActiveWindow(const QString &, bool))); + Q_ASSERT(ok); + + ok = connect(m_findWidget, SIGNAL(findPrevious(const QString&,bool)), + m_mdi, SLOT(findPreviousTextInActiveWindow(const QString &, bool))); + Q_ASSERT(ok); + ok = connect(m_findWidget, SIGNAL(highlightText(const QString&,bool)), + m_mdi, SLOT(highlightTextInActiveWindow(const QString &, bool))); + Q_ASSERT(ok); + + ok = connect(m_mdi, SIGNAL(subWindowActivated(QMdiSubWindow*)), + this, SLOT(slotActiveWindowChanged(QMdiSubWindow*))); + Q_ASSERT(ok); +} + /** Initializes the action objects of the GUI */ void BibleTime::initActions() { m_actionCollection = new BtActionCollection(this); @@ -349,11 +377,13 @@ void BibleTime::initActions() { this, SLOT(slotSetActiveSubWindow(QWidget*))); // File menu actions: - m_openWorkAction = new BtOpenWorkAction("GUI/MainWindow/OpenWorkAction/grouping", this); + m_openWorkAction = new BtOpenWorkAction("GUI/mainWindow/openWorkAction/grouping", this); + Q_ASSERT(m_openWorkAction != 0); connect(m_openWorkAction, SIGNAL(triggered(CSwordModuleInfo*)), this, SLOT(createReadDisplayWindow(CSwordModuleInfo*))); m_quitAction = m_actionCollection->action("quit"); + m_quitAction->setMenuRole(QAction::QuitRole); Q_ASSERT(m_quitAction != 0); connect(m_quitAction, SIGNAL(triggered()), this, SLOT(quit())); @@ -367,68 +397,68 @@ void BibleTime::initActions() { this, SLOT(toggleFullscreen())); // Special case these actions, overwrite those already in collection - namespace DU = util::directory; m_showBookshelfAction = m_bookshelfDock->toggleViewAction(); - m_showBookshelfAction->setIcon(DU::getIcon(CResMgr::mainMenu::view::showBookshelf::icon)); + m_showBookshelfAction->setIcon(util::getIcon(CResMgr::mainMenu::view::showBookshelf::icon)); m_showBookshelfAction->setToolTip(tr("Toggle visibility of the bookshelf window")); m_actionCollection->addAction("showBookshelf", m_showBookshelfAction); m_showBookmarksAction = m_bookmarksDock->toggleViewAction(); - m_showBookmarksAction->setIcon(DU::getIcon(CResMgr::mainMenu::view::showBookmarks::icon)); + m_showBookmarksAction->setIcon(util::getIcon(CResMgr::mainMenu::view::showBookmarks::icon)); m_showBookmarksAction->setToolTip(tr("Toggle visibility of the bookmarks window")); m_actionCollection->addAction("showBookmarks", m_showBookmarksAction); m_showMagAction = m_magDock->toggleViewAction(); - m_showMagAction->setIcon(DU::getIcon(CResMgr::mainMenu::view::showMag::icon)); + m_showMagAction->setIcon(util::getIcon(CResMgr::mainMenu::view::showMag::icon)); m_showMagAction->setToolTip(tr("Toggle visibility of the mag window")); m_actionCollection->addAction("showMag", m_showMagAction); m_showTextAreaHeadersAction = m_actionCollection->action("showParallelTextHeaders"); Q_ASSERT(m_showTextAreaHeadersAction != 0); m_showTextAreaHeadersAction->setCheckable(true); - m_showTextAreaHeadersAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowHeaders)); + m_showTextAreaHeadersAction->setChecked(btConfig().sessionValue<bool>("GUI/showTextWindowHeaders", true)); connect(m_showTextAreaHeadersAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleTextWindowHeader())); m_showMainWindowToolbarAction = m_actionCollection->action("showToolbar"); Q_ASSERT(m_showMainWindowToolbarAction != 0); m_showMainWindowToolbarAction->setCheckable(true); - m_showMainWindowToolbarAction->setChecked(CBTConfig::get(CBTConfig::showMainWindowToolbar)); + m_showMainWindowToolbarAction->setChecked(btConfig().sessionValue<bool>("GUI/showMainToolbar", true)); connect( m_showMainWindowToolbarAction, SIGNAL(triggered()), this, SLOT(slotToggleMainToolbar())); m_showTextWindowNavigationAction = m_actionCollection->action("showNavigation"); Q_ASSERT(m_showTextWindowNavigationAction != 0); m_showTextWindowNavigationAction->setCheckable(true); - m_showTextWindowNavigationAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowNavigator)); + m_showTextWindowNavigationAction->setChecked(btConfig().sessionValue<bool>("GUI/showTextWindowNavigator", true)); connect(m_showTextWindowNavigationAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleNavigatorToolbar())); m_showTextWindowModuleChooserAction = m_actionCollection->action("showWorks"); Q_ASSERT(m_showTextWindowModuleChooserAction != 0); m_showTextWindowModuleChooserAction->setCheckable(true); - m_showTextWindowModuleChooserAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons)); + m_showTextWindowModuleChooserAction->setChecked(btConfig().sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true)); connect(m_showTextWindowModuleChooserAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleWorksToolbar())); m_showTextWindowToolButtonsAction = m_actionCollection->action("showTools"); Q_ASSERT(m_showTextWindowToolButtonsAction != 0); m_showTextWindowToolButtonsAction->setCheckable(true); - m_showTextWindowToolButtonsAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowToolButtons)); + m_showTextWindowToolButtonsAction->setChecked(btConfig().sessionValue<bool>("GUI/showTextWindowToolButtons", true)); connect(m_showTextWindowToolButtonsAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleToolsToolbar())); m_showFormatToolbarAction = m_actionCollection->action("showFormat"); Q_ASSERT(m_showFormatToolbarAction != 0); m_showFormatToolbarAction->setCheckable(true); - m_showFormatToolbarAction->setChecked(CBTConfig::get(CBTConfig::showFormatToolbarButtons)); + m_showFormatToolbarAction->setChecked(btConfig().sessionValue<bool>("GUI/showFormatToolbarButtons", true)); bool ok = connect(m_showFormatToolbarAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleFormatToolbar())); + Q_ASSERT(ok); m_toolbarsInEachWindow = m_actionCollection->action("showToolbarsInTextWindows"); Q_ASSERT(m_toolbarsInEachWindow != 0); m_toolbarsInEachWindow->setCheckable(true); - m_toolbarsInEachWindow->setChecked(CBTConfig::get(CBTConfig::showToolbarsInEachWindow)); + m_toolbarsInEachWindow->setChecked(btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true)); ok = connect(m_toolbarsInEachWindow, SIGNAL(toggled(bool)), - this, SLOT(slotToggleToolBarsInEachWindow())); + this, SLOT(slotToggleToolBarsInEachWindow())); Q_ASSERT(ok); // Search menu actions: @@ -473,81 +503,56 @@ void BibleTime::initActions() { connect(m_windowTileHorizontalAction, SIGNAL(triggered()), this, SLOT(slotTileHorizontal())); + alignmentMode alignment = btConfig().sessionValue<alignmentMode>("GUI/alignmentMode", autoTileVertical); + m_windowManualModeAction = m_actionCollection->action("manualArrangement"); Q_ASSERT(m_windowManualModeAction != 0); m_windowManualModeAction->setCheckable(true); - m_windowManualModeAction->setChecked(true); - connect(m_windowManualModeAction, SIGNAL(triggered()), - this, SLOT(slotManualArrangementMode())); m_windowAutoTabbedAction = m_actionCollection->action("autoTabbed"); Q_ASSERT(m_windowAutoTabbedAction != 0); m_windowAutoTabbedAction->setCheckable(true); - if(CBTConfig::get(CBTConfig::autoTabbed) == true) { - m_windowManualModeAction->setChecked(false); - m_windowAutoTabbedAction->setChecked(true); - } - connect(m_windowAutoTabbedAction, SIGNAL(triggered()), - this, SLOT(slotAutoTabbed())); //: Vertical tiling means that windows are vertical, placed side by side m_windowAutoTileVerticalAction = m_actionCollection->action("autoVertical"); Q_ASSERT(m_windowAutoTileVerticalAction != 0); m_windowAutoTileVerticalAction->setCheckable(true); - if(CBTConfig::get(CBTConfig::autoTileVertical) == true) { - m_windowManualModeAction->setChecked(false); - m_windowAutoTileVerticalAction->setChecked(true); - } - connect(m_windowAutoTileVerticalAction, SIGNAL(triggered()), - this, SLOT(slotAutoTileVertical())); //: Horizontal tiling means that windows are horizontal, placed on top of each other m_windowAutoTileHorizontalAction = m_actionCollection->action("autoHorizontal"); Q_ASSERT(m_windowAutoTileHorizontalAction != 0); m_windowAutoTileHorizontalAction->setCheckable(true); - if(CBTConfig::get(CBTConfig::autoTileHorizontal) == true) { - m_windowManualModeAction->setChecked(false); - m_windowAutoTileHorizontalAction->setChecked(true); - } - connect(m_windowAutoTileHorizontalAction, SIGNAL(triggered()), - this, SLOT(slotAutoTileHorizontal())); m_windowAutoTileAction = m_actionCollection->action("autoTile"); Q_ASSERT(m_windowAutoTileAction != 0); m_windowAutoTileAction->setCheckable(true); - if(CBTConfig::get(CBTConfig::autoTile) == true) { - m_windowManualModeAction->setChecked(false); - m_windowAutoTileAction->setChecked(true); - } - connect(m_windowAutoTileAction, SIGNAL(triggered()), - this, SLOT(slotAutoTile())); m_windowAutoCascadeAction = m_actionCollection->action("autoCascade"); Q_ASSERT(m_windowAutoCascadeAction != 0); m_windowAutoCascadeAction->setCheckable(true); - if(CBTConfig::get(CBTConfig::autoCascade) == true) { - m_windowManualModeAction->setChecked(false); - m_windowAutoCascadeAction->setChecked(true); - } - connect(m_windowAutoCascadeAction, SIGNAL(triggered()), - this, SLOT(slotAutoCascade())); /* * All actions related to arrangement modes have to be initialized before calling a slot on them, * thus we call them afterwards now. */ - if(m_windowAutoTabbedAction->isChecked() == true) - slotAutoTabbed(); - else if(m_windowAutoTileVerticalAction->isChecked() == true) - slotAutoTileVertical(); - else if(m_windowAutoTileHorizontalAction->isChecked() == true) - slotAutoTileHorizontal(); - else if(m_windowAutoTileAction->isChecked() == true) - slotAutoTile(); - else if(m_windowAutoCascadeAction->isChecked() == true) - slotAutoCascade(); - else - slotManualArrangementMode(); + QAction * alignmentAction; + switch (alignment) { + case autoTabbed: + alignmentAction = m_windowAutoTabbedAction; break; + case autoTileVertical: + alignmentAction = m_windowAutoTileVerticalAction; break; + case autoTileHorizontal: + alignmentAction = m_windowAutoTileHorizontalAction; break; + case autoTile: + alignmentAction = m_windowAutoTileAction; break; + case autoCascade: + alignmentAction = m_windowAutoCascadeAction; break; + case manual: + default: + alignmentAction = m_windowManualModeAction; break; + } + alignmentAction->setChecked(true); + slotUpdateWindowArrangementActions(alignmentAction); m_windowSaveToNewProfileAction = m_actionCollection->action("saveNewSession"); Q_ASSERT(m_windowSaveToNewProfileAction != 0); @@ -556,11 +561,13 @@ void BibleTime::initActions() { m_setPreferencesAction = m_actionCollection->action("setPreferences"); Q_ASSERT(m_setPreferencesAction != 0); + m_setPreferencesAction->setMenuRole( QAction::PreferencesRole ); connect(m_setPreferencesAction, SIGNAL(triggered()), this, SLOT(slotSettingsOptions())); m_bookshelfManagerAction = m_actionCollection->action("bookshelfManager"); Q_ASSERT(m_bookshelfManagerAction != 0); + m_bookshelfManagerAction->setMenuRole( QAction::ApplicationSpecificRole ); connect(m_bookshelfManagerAction, SIGNAL(triggered()), this, SLOT(slotSwordSetupDialog())); @@ -576,6 +583,7 @@ void BibleTime::initActions() { m_aboutBibleTimeAction = m_actionCollection->action("aboutBibleTime"); Q_ASSERT(m_aboutBibleTimeAction != 0); + m_aboutBibleTimeAction->setMenuRole( QAction::AboutRole ); connect(m_aboutBibleTimeAction, SIGNAL(triggered()), this, SLOT(slotOpenAboutDialog()) ); @@ -641,25 +649,32 @@ void BibleTime::initMenubar() { m_windowMenu->addAction(m_windowTileVerticalAction); m_windowMenu->addAction(m_windowTileHorizontalAction); m_windowArrangementMenu = new QMenu(this); + m_windowArrangementActionGroup = new QActionGroup(m_windowArrangementMenu); m_windowArrangementMenu->addAction(m_windowManualModeAction); + m_windowArrangementActionGroup->addAction(m_windowManualModeAction); m_windowArrangementMenu->addAction(m_windowAutoTabbedAction); + m_windowArrangementActionGroup->addAction(m_windowAutoTabbedAction); m_windowArrangementMenu->addAction(m_windowAutoTileVerticalAction); + m_windowArrangementActionGroup->addAction(m_windowAutoTileVerticalAction); m_windowArrangementMenu->addAction(m_windowAutoTileHorizontalAction); + m_windowArrangementActionGroup->addAction(m_windowAutoTileHorizontalAction); m_windowArrangementMenu->addAction(m_windowAutoTileAction); + m_windowArrangementActionGroup->addAction(m_windowAutoTileAction); m_windowArrangementMenu->addAction(m_windowAutoCascadeAction); + m_windowArrangementActionGroup->addAction(m_windowAutoCascadeAction); + connect(m_windowArrangementActionGroup, SIGNAL(triggered(QAction *)), + this, SLOT(slotUpdateWindowArrangementActions(QAction *))); + m_windowMenu->addMenu(m_windowArrangementMenu); m_windowMenu->addSeparator(); - m_windowSaveProfileMenu = new QMenu(this); - m_windowMenu->addMenu(m_windowSaveProfileMenu); m_windowMenu->addAction(m_windowSaveToNewProfileAction); m_windowLoadProfileMenu = new QMenu(this); + m_windowLoadProfileActionGroup = new QActionGroup(m_windowLoadProfileMenu); m_windowMenu->addMenu(m_windowLoadProfileMenu); m_windowDeleteProfileMenu = new QMenu(this); m_windowMenu->addMenu(m_windowDeleteProfileMenu); connect(m_windowLoadProfileMenu, SIGNAL(triggered(QAction*)), this, SLOT(loadProfile(QAction*))); - connect(m_windowSaveProfileMenu, SIGNAL(triggered(QAction*)), - this, SLOT(saveProfile(QAction*))); connect(m_windowDeleteProfileMenu, SIGNAL(triggered(QAction*)), this, SLOT(deleteProfile(QAction*))); refreshProfileMenus(); @@ -667,12 +682,18 @@ void BibleTime::initMenubar() { connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowMenuAboutToShow())); - // Settings menu: + #ifndef Q_OS_MAC m_settingsMenu = new QMenu(this); m_settingsMenu->addAction(m_setPreferencesAction); m_settingsMenu->addSeparator(); m_settingsMenu->addAction(m_bookshelfManagerAction); menuBar()->addMenu(m_settingsMenu); + #else + // On MAC OS, the settings actions will be moved to a system menu item. + // Therefore the settings menu would be empty, so we do not show it. + m_fileMenu->addAction(m_setPreferencesAction); + m_fileMenu->addAction(m_bookshelfManagerAction); + #endif // Help menu: m_helpMenu = new QMenu(this); @@ -719,16 +740,20 @@ void BibleTime::retranslateUi() { m_fileMenu->setTitle(tr("&File")); m_viewMenu->setTitle(tr("&View")); - m_toolBarsMenu->setTitle(tr("Toolbars")); + m_toolBarsMenu->setTitle(tr("Toolbars")); m_searchMenu->setTitle(tr("&Search")); m_windowMenu->setTitle(tr("&Window")); - m_openWindowsMenu->setTitle(tr("O&pen windows")); - m_windowArrangementMenu->setTitle(tr("&Arrangement mode")); - m_windowSaveProfileMenu->setTitle(tr("&Save session")); - m_windowLoadProfileMenu->setTitle(tr("&Load session")); - m_windowDeleteProfileMenu->setTitle(tr("&Delete session")); + m_openWindowsMenu->setTitle(tr("O&pen windows")); + m_windowArrangementMenu->setTitle(tr("&Arrangement mode")); + m_windowLoadProfileMenu->setTitle(tr("Sw&itch session")); + m_windowDeleteProfileMenu->setTitle(tr("&Delete session")); + + #ifndef Q_OS_MAC + // This item is not present on Mac OS m_settingsMenu->setTitle(tr("Se&ttings")); + #endif + m_helpMenu->setTitle(tr("&Help")); #ifdef BT_DEBUG @@ -802,8 +827,7 @@ void BibleTime::initSwordConfigFile() { // It will contain the LocalePath which is used for sword locales // It also contains a DataPath to the %ALLUSERSPROFILE%\Sword directory // If this is not done here, the sword locales.d won't be found -#ifdef Q_WS_WIN - namespace DU = util::directory; +#ifdef Q_OS_WIN QString configFile = util::directory::getUserHomeSwordDir().filePath("sword.conf"); QFile file(configFile); if (file.exists()) { @@ -815,14 +839,13 @@ void BibleTime::initSwordConfigFile() { QTextStream out(&file); out << "\n"; out << "[Install]\n"; - out << "DataPath=" << DU::convertDirSeparators( DU::getSharedSwordDir().absolutePath()) << "\n"; - out << "LocalePath=" << DU::convertDirSeparators(DU::getApplicationSwordDir().absolutePath()) << "\n"; + out << "DataPath=" << util::directory::convertDirSeparators( util::directory::getSharedSwordDir().absolutePath()) << "\n"; + out << "LocalePath=" << util::directory::convertDirSeparators(util::directory::getApplicationSwordDir().absolutePath()) << "\n"; out << "\n"; file.close(); #endif -#ifdef Q_WS_MAC - namespace DU = util::directory; +#ifdef Q_OS_MAC QString configFile = util::directory::getUserHomeSwordDir().filePath("sword.conf"); QFile file(configFile); if (file.exists()) { @@ -834,7 +857,7 @@ void BibleTime::initSwordConfigFile() { QTextStream out(&file); out << "\n"; out << "[Install]\n"; - out << "DataPath=" << DU::convertDirSeparators( DU::getUserHomeSwordDir().absolutePath()) << "\n"; + out << "DataPath=" << util::directory::convertDirSeparators( util::directory::getUserHomeSwordDir().absolutePath()) << "\n"; out << "\n"; file.close(); #endif @@ -844,22 +867,31 @@ void BibleTime::initSwordConfigFile() { void BibleTime::initBackends() { initSwordConfigFile(); - sword::StringMgr::setSystemStringMgr( new BTStringMgr() ); + sword::StringMgr::setSystemStringMgr( new BtStringMgr() ); sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_ERROR); if (qApp->property("--debug").toBool()) { sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_DEBUG); } -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC // set a LocaleMgr with a fixed path to the locales.d of the DMG image on MacOS // note: this must be done after setting the BTStringMgr, because this will reset the LocaleMgr qDebug() << "Using sword locales dir: " << util::directory::getSwordLocalesDir().absolutePath().toUtf8(); sword::LocaleMgr::setSystemLocaleMgr(new sword::LocaleMgr(util::directory::getSwordLocalesDir().absolutePath().toUtf8())); #endif + /* + Set book names language if not set. This is a hack. We do this call here, + because we need to keep the setting displayed in BtLanguageSettingsPage in + sync with the language of the book names displayed, so that both would + always use the same setting. + */ + BtLanguageSettingsPage::resetLanguage(); /// \todo refactor this hack + + CSwordBackend *backend = CSwordBackend::createInstance(); - backend->booknameLanguage(CBTConfig::get(CBTConfig::language) ); + backend->booknameLanguage(btConfig().value<QString>("language", QLocale::system().name())); const CSwordBackend::LoadError errorCode = CSwordBackend::instance()->initModules(CSwordBackend::OtherChange); @@ -906,53 +938,6 @@ void BibleTime::initBackends() { } -void BibleTime::applyProfileSettings( CProfile* p ) { - Q_ASSERT(p); - if (!p) return; - - //first Main Window geometry - restoreGeometry(p->getMainwindowGeometry()); - restoreState(p->getMainwindowState()); - m_windowFullscreenAction->setChecked(isFullScreen()); - - const CMDIArea::MDIArrangementMode newArrangementMode = p->getMDIArrangementMode(); - //make sure actions are updated by calling the slot functions - //updatesEnabled in the MDI area is false atm, so changes won't actually be displayed yet - switch (newArrangementMode) { - case CMDIArea::ArrangementModeTileVertical: - slotAutoTileVertical(); - break; - case CMDIArea::ArrangementModeTileHorizontal: - slotAutoTileHorizontal(); - break; - case CMDIArea::ArrangementModeCascade: - slotAutoCascade(); - break; - case CMDIArea::ArrangementModeTile: - slotAutoTile(); - break; - case CMDIArea::ArrangementModeTabbed: - slotAutoTabbed(); - break; - case CMDIArea::ArrangementModeManual: - slotManualArrangementMode(); - break; - default: - slotAutoTileVertical(); - break; - } - layout()->invalidate(); -} - -void BibleTime::storeProfileSettings( CProfile* p ) { - Q_ASSERT(p && m_windowFullscreenAction); - if (!p || !m_windowFullscreenAction) return; - - p->setMainwindowState(saveState()); - p->setMainwindowGeometry(saveGeometry()); - p->setMDIArrangementMode(m_mdi->getMDIArrangementMode()); -} - #if BT_DEBUG QLabel *BibleTime::m_debugWindow = 0; |