summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:25 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:25 -0400
commitb954e6dbcceaba3b50aca624e1bddc6db4830829 (patch)
tree31fa8e2579585c9626d56bc9beb55326cbd40ff2 /src
parent04e7ba8bf082e2b170595eef488834accd9d946e (diff)
Imported Upstream version 2.2
Diffstat (limited to 'src')
-rw-r--r--src/backend/config/cbtconfig.cpp1343
-rw-r--r--src/backend/config/cbtconfig.h334
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.cpp36
-rw-r--r--src/backend/filters/bt_osishtml.cpp14
-rw-r--r--src/backend/filters/bt_plainhtml.cpp2
-rw-r--r--src/backend/keys/cswordversekey.cpp16
-rw-r--r--src/backend/managers/cswordbackend.cpp4
-rw-r--r--src/bibletime.cpp37
-rw-r--r--src/bibletime.h55
-rw-r--r--src/bibletime_init.cpp448
-rw-r--r--src/bibletime_slots.cpp217
-rw-r--r--src/bibletimeapp.h4
-rw-r--r--src/display-templates/Blue.tmpl4
-rw-r--r--src/display-templates/Crazy.tmpl2
-rw-r--r--src/display-templates/Green.tmpl4
-rw-r--r--src/display-templates/HighContrast.tmpl7
-rw-r--r--src/display-templates/Simple.tmpl5
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.cpp6
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.h2
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp16
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.h11
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp1
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.cpp15
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.h3
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.cpp2
-rw-r--r--src/frontend/cinfodisplay.cpp19
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp126
-rw-r--r--src/frontend/displaywindow/btactioncollection.h22
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp29
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h7
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp262
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h2
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp67
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h8
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp136
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h7
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp255
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h219
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp133
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h12
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.cpp2
-rw-r--r--src/frontend/keychooser/cscrollbutton.cpp116
-rw-r--r--src/frontend/keychooser/cscrollbutton.h115
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp6
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp114
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h9
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp8
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp2
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp6
-rw-r--r--src/frontend/searchdialog/csearchdialog.h2
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.cpp115
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.h59
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp413
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.h96
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp278
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp.OFF268
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h83
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h.OFF72
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.cpp50
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.h11
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.cpp9
-rw-r--r--src/frontend/settingsdialogs/clanguagesettings.h15
-rw-r--r--src/main.cpp37
63 files changed, 3382 insertions, 2396 deletions
diff --git a/src/backend/config/cbtconfig.cpp b/src/backend/config/cbtconfig.cpp
index a0fb4f2..9dff6c1 100644
--- a/src/backend/config/cbtconfig.cpp
+++ b/src/backend/config/cbtconfig.cpp
@@ -7,714 +7,675 @@
*
**********/
-//BibleTime includes
#include "cbtconfig.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/clanguagemgr.h"
-#include "backend/managers/cdisplaytemplatemgr.h"
-#include "backend/btmoduletreeitem.h"
-#include "util/cpointers.h"
-#include "util/directoryutil.h"
-#include "frontend/searchdialog/btsearchoptionsarea.h"
-
-//Qt includes
-#include <QApplication>
-#include <QString>
-#include <QStringList>
-#include <QMap>
-#include <QList>
+// Qt includes
#include <QDebug>
-#include <QSettings>
#include <QLocale>
+#include <QSettings>
+#include <QVariant>
#include <QWebSettings>
-//Sword includes
-#include <versekey.h> //for range configuration
-
-//init statics
-QFont* CBTConfig::m_defaultFont = 0;
-CBTConfig::FontCache CBTConfig::fontConfigMap;
-
-/* No constructor and destructor, because this class only contains static methods.
- It won't be instantiated. */
-
-QString CBTConfig::getKey( const CBTConfig::strings ID) {
- switch ( ID ) {
- case bibletimeVersion: return "bibletimeVersion";
- case language: return "language";
- case displayStyle: return "displayStyle";
- case bookshelfCurrentItem: return "bookshelfCurrentItem";
- }
- Q_ASSERT(false);
- return QString::null;
-}
-
-QString CBTConfig::getDefault( const CBTConfig::strings ID) {
- switch ( ID ) {
- case bibletimeVersion: return "0.0"; // main() will realize this and set the value to VERSION
- case language: return QLocale::system().name();
- case displayStyle: return CDisplayTemplateMgr::defaultTemplate();
- case bookshelfCurrentItem: return QString();
- }
- return QString::null;
-}
-
-QString CBTConfig::getKey( const CBTConfig::modules ID) {
- switch ( ID ) {
- case standardBible: return "standardBible";
- case standardCommentary: return "standardCommentary";
- case standardLexicon: return "standardLexicon";
- case standardDailyDevotional: return "standardDailyDevotional";
- case standardHebrewStrongsLexicon: return "standardHebrewLexicon";
- case standardGreekStrongsLexicon: return "standardGreekLexicon";
- case standardHebrewMorphLexicon: return "standardHebrewMorphLexicon";
- case standardGreekMorphLexicon: return "standardGreekMorphLexicon";
- }
- Q_ASSERT(false);
- return QString::null;
-}
-
-QString CBTConfig::getDefault( const CBTConfig::modules ID) {
- // CSwordBackend* b = CPointers::backend();
- switch ( ID ) {
- case standardBible: return "KJV";
- case standardCommentary: return "MHC";
- case standardLexicon: return "ISBE";
- case standardDailyDevotional: return ""; //no default
-
- case standardHebrewStrongsLexicon: return "StrongsHebrew";
- case standardGreekStrongsLexicon: return "StrongsGreek";
- case standardHebrewMorphLexicon: return "StrongsHebrew";
- case standardGreekMorphLexicon: return "StrongsGreek";
- }
-
- return QString::null;
-}
-
-QString CBTConfig::getKey( const CBTConfig::bools ID) {
- switch ( ID ) {
- case firstSearchDialog: return "firstSearchDialog";
- case readOldBookmarks: return "readOldBookmarks";
-
- case toolbar: return "toolbar";
- case mainIndex: return "mainIndex";
- case infoDisplay: return "infoDisplay";
-
- case autoTileVertical: return "autoTileVertical";
- case autoTileHorizontal: return "autoTileHorizontal";
- case autoCascade: return "autoCascade";
-
- case lineBreaks: return "lineBreaks";
- case verseNumbers: return "verseNumbers";
-
- case logo: return "logo";
- case autoDeleteOrphanedIndices: return "autoDeleteOrphanedIndices";
- case crashedLastTime: return "crashedLastTime";
- case crashedTwoTimes: return "crashedTwoTimes";
-
- case bookshelfShowHidden: return "bookshelfShowHidden";
- case allowNetworkConnection: return "allowNetworkConnection";
- }
- Q_ASSERT(false);
- return false;
-}
-
-QString CBTConfig::getKey( const CBTConfig::ints ID) {
- switch ( ID ) {
- case footnotes: return "footnotes";
- case strongNumbers: return "strongNumbers";
- case headings: return "headings";
- case morphTags: return "morphTags";
- case lemmas: return "lemmas";
- case hebrewPoints: return "hebrewPoints";
- case hebrewCantillation: return "hebrewCantillation";
- case greekAccents: return "greekAccents";
- case textualVariants: return "textualVariants";
- case scriptureReferences: return "scriptureReferences";
- case morphSegmentation: return "morphSegmentation";
- case bookshelfContentsX: return "bookshelfContentsX";
- case bookshelfContentsY: return "bookshelfContentsY";
- case magDelay: return "magDelay";
- case bookshelfGrouping: return "bookshelfGrouping";
- case mainindexActiveTab: return "mainindexActiveTab";
- case searchDialogWidth: return "searchDialogWidth";
- case searchDialogHeight: return "searchDialogHeight";
- case searchDialogX: return "searchDialogX";
- case searchDialogY: return "searchDialogY";
- case searchType: return "searchType";
- case installPathIndex: return "installPathIndex";
- }
- Q_ASSERT(false);
- return QString::null;
-}
-
-bool CBTConfig::getDefault( const CBTConfig::bools ID) {
- switch ( ID ) {
- case firstSearchDialog: return true;
- case readOldBookmarks: return false;
-
- case toolbar: return true;
- case mainIndex: return true;
- case infoDisplay: return true;
-
- case autoTileVertical: return true;
- case autoTileHorizontal: return false;
- case autoCascade: return false;
-
- case lineBreaks: return false;
- case verseNumbers: return true;
-
- case logo: return true;
- case autoDeleteOrphanedIndices: return true;
- case crashedLastTime: return false;
- case crashedTwoTimes: return false;
- case bookshelfShowHidden: return false;
- case allowNetworkConnection: return false;
- }
- return false;
-}
-
-int CBTConfig::getDefault( const CBTConfig::ints ID) {
- switch ( ID ) {
- case footnotes: return int(true);
- case strongNumbers: return int(true);
- case headings: return int(true);
- case morphTags: return int(true);
- case lemmas: return int(true);
- case hebrewPoints: return int(true);
- case hebrewCantillation: return int(true);
- case greekAccents: return int(true);
- case textualVariants: return int(false);
- case scriptureReferences: return int(true);
- case morphSegmentation: return int(true);
- case bookshelfContentsX: return 0;
- case bookshelfContentsY: return 0;
- case magDelay: return 400;
- case bookshelfGrouping: return BTModuleTreeItem::CatLangMod;
- case searchDialogWidth: return 200;
- case searchDialogHeight: return 400;
- case searchDialogX: return 200;
- case searchDialogY: return 200;
- case searchType: return Search::BtSearchOptionsArea::AndType;
- case mainindexActiveTab: return 0;
- case installPathIndex: return 0;
- }
- return 0;
-}
-
-QString CBTConfig::getKey( const CBTConfig::intLists ID) {
- switch ( ID ) {
- case leftPaneSplitterSizes: return "leftPaneSplitterSizes";
- case mainSplitterSizes: return "mainSplitterSizes";
- case searchMainSplitterSizes: return "searchMainSplitterSizes";
- case searchResultSplitterSizes: return "searchResultSplitterSizes";
- }
- Q_ASSERT(false);
- return QString::null;
-}
-
-QList<int> CBTConfig::getDefault( const CBTConfig::intLists /*ID*/) {
- QList<int> result;
- /*switch ( ID ) {
- case leftPaneSplitterSizes: break;
- case mainSplitterSizes: break;
- case searchMainSplitterSizes: break;
- case searchResultSplitterSizes: break;*/
- return result;
-}
-
-QString CBTConfig::getKey( const CBTConfig::stringLists ID) {
- switch ( ID ) {
- case searchCompletionTexts: return QString("searchCompletionTexts");
- case searchTexts: return QString("searchTexts");
- case searchModulesHistory: return QString("searchModulesHistory");
- case bookshelfOpenGroups: return QString("bookshelfOpenGroups");
- case hiddenModules: return QString("hiddenModules");
- }
- Q_ASSERT(false);
- return QString::null;
-}
-
-QStringList CBTConfig::getDefault( const CBTConfig::stringLists ID) {
- switch ( ID ) {
- case searchTexts: {
- QStringList list;
- list.append(QString::null);
- return list;
- }
- case searchCompletionTexts: return QStringList();
- case bookshelfOpenGroups: return QStringList();
- case hiddenModules: return QStringList();
- case searchModulesHistory: return QStringList();
- }
- return QStringList();
-}
-
-QString CBTConfig::getKey( const CBTConfig::stringMaps ID) {
- switch (ID) {
- case searchScopes:
- return QString("SearchScopes");
- };
- Q_ASSERT(false);
- return QString::null;
-}
-
-CBTConfig::StringMap CBTConfig::getDefault( const CBTConfig::stringMaps ID) {
- switch ( ID ) {
- case searchScopes: {
- CBTConfig::StringMap map;
- map.insert(QObject::tr("Old testament"), QString("Gen - Mal"));
- map.insert(QObject::tr("Moses/Pentateuch/Torah"),QString("Gen - Deut"));
- map.insert(QObject::tr("History"), QString("Jos - Est"));
- map.insert(QObject::tr("Prophets"), QString("Isa - Mal"));
- map.insert(QObject::tr("New testament"), QString("Mat - Rev"));
- map.insert(QObject::tr("Gospels"), QString("Mat - Joh"));
- map.insert(QObject::tr("Letters/Epistles"), QString("Rom - Jude"));
- map.insert(QObject::tr("Paul's Epistles"), QString("Rom - Phile"));
-
- //make the list to the current bookname language!
- CBTConfig::StringMap::Iterator it;
- sword::VerseKey vk;
- vk.setLocale("en_US");
-
- for (it = map.begin(); it != map.end(); ++it) {
- sword::ListKey list = vk.ParseVerseList(it.value().toLocal8Bit(), "Genesis 1:1", true);
- QString data;
- for (int i = 0; i < list.Count(); ++i) {
- data += QString::fromUtf8(list.GetElement(i)->getRangeText()) + "; ";
- }
- map[it.key()] = data; //set the new data
- };
-
- return map;
- };
- default:
- return CBTConfig::StringMap();
- }
-
- return CBTConfig::StringMap();
-}
-
-
-QString CBTConfig::getKey( const CLanguageMgr::Language* const language ) {
- Q_ASSERT(!language->name().isEmpty());
- return language->name();
-}
-
-QFont& CBTConfig::getDefault( const CLanguageMgr::Language* const)
-{
- //language specific lookup of the font name
- if (m_defaultFont)
- {
- return *m_defaultFont;
- }
-
-// TODO - make the font name and size a configuration option
- //int fontSize = QWebSettings::globalSettings()->fontSize(QWebSettings::DefaultFontSize);
- int fontSize = 12;
- QString fontName = QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont);
-
- m_defaultFont = new QFont(fontName, fontSize); //TODO: there may be a mem leak here!
- return *m_defaultFont;
-}
-
-QString CBTConfig::get( const CBTConfig::strings ID)
-{
- QString result;
- getConfig()->beginGroup("strings");
- result = getConfig()->value(getKey(ID), getDefault(ID)).toString();
- getConfig()->endGroup();
- return result;
-
-}
-
-CSwordModuleInfo* CBTConfig::get( const CBTConfig::modules ID)
-{
- CSwordModuleInfo* result;
- getConfig()->beginGroup("modules");
- result = CPointers::backend()->findModuleByName( getConfig()->value(getKey(ID), getDefault(ID)).toString() );
- getConfig()->endGroup();
- return result;
-}
-
-bool CBTConfig::get( const CBTConfig::bools ID)
-{
- bool result;
- getConfig()->beginGroup("bools");
- result = getConfig()->value(getKey(ID), getDefault(ID)).toBool();
- getConfig()->endGroup();
- return result;
-}
-
-int CBTConfig::get( const CBTConfig::ints ID)
-{
- int result;
- getConfig()->beginGroup("ints");
- result = getConfig()->value(getKey(ID), getDefault(ID)).toInt();
- getConfig()->endGroup();
- return result;
-}
-
-QList<int> CBTConfig::get( const CBTConfig::intLists ID )
-{
- QList<int> result;
- getConfig()->beginGroup("intlists");
- result = StringToIntList( getConfig()->value(getKey(ID), IntListToString( getDefault(ID) )).toString() );
- getConfig()->endGroup();
- return result;
-}
-
-QStringList CBTConfig::get( const CBTConfig::stringLists ID )
-{
- QStringList result;
- getConfig()->beginGroup("stringlists");
- result = getConfig()->value(getKey(ID), getDefault(ID)).toStringList();
- getConfig()->endGroup();
- return result;
-}
-
-CBTConfig::StringMap CBTConfig::get( const CBTConfig::stringMaps ID )
-{
- getConfig()->beginGroup(getKey(ID));
- CBTConfig::StringMap map;
-
- QStringList keys(getConfig()->childKeys());
- if (!keys.isEmpty()) {
- switch (ID) {
- case searchScopes: { //make sure we return the scopes in the chosen language. saved keys are in english
- sword::VerseKey vk;
- foreach (QString key, keys) {
- Q_ASSERT(!key.isEmpty());
- sword::ListKey list = vk.ParseVerseList(getConfig()->value(key).toString().toUtf8(), "Genesis 1:1", true);
- QString data;
- for (int i = 0; i < list.Count(); ++i) {
- data += QString::fromUtf8(list.GetElement(i)->getRangeText()) + "; ";
- }
- map[key] = data; //set the new data
- }
- }
- default: break;
- }
- }
- else
- {
- map = getDefault(ID);
- }
- getConfig()->endGroup();
- return map;
-}
-
-CBTConfig::FontSettingsPair CBTConfig::get( const CLanguageMgr::Language* const language )
-{
- if (fontConfigMap.contains(language)) {
- return fontConfigMap.find(language).value();
- }
-
- FontSettingsPair settings;
-
- getConfig()->beginGroup("font standard settings");
- settings.first = getConfig()->value(getKey(language), QVariant(false)).toBool();
- getConfig()->endGroup();
- getConfig()->beginGroup("fonts");
-
- QFont font;
- if (settings.first)
- font.fromString(getConfig()->value(getKey(language), getDefault(language)).toString());
- else
- font = getDefault(language);
-
- settings.second = font;
- getConfig()->endGroup();
-
- fontConfigMap.insert(language, settings); //cache the value
- return settings;
-}
-
-void CBTConfig::set( const CBTConfig::strings ID, const QString value )
-{
-// KConfigGroup cg = CBTConfig::getConfig()->group("strings");
-// cg.writeEntry(getKey(ID), value);
- getConfig()->beginGroup("strings");
- getConfig()->setValue(getKey(ID), value);
- getConfig()->endGroup();
-}
-
-void CBTConfig::set( const CBTConfig::modules ID, CSwordModuleInfo* const value )
-{
-// KConfigGroup cg = CBTConfig::getConfig()->group("modules");
-// cg.writeEntry(getKey(ID), value ? value->name() : QString::null);
- getConfig()->beginGroup("modules");
- getConfig()->setValue(getKey(ID), value ? value->name() : QString::null);
- getConfig()->endGroup();
-}
-
-void CBTConfig::set( const CBTConfig::modules ID, const QString& value )
-{
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(value);
- if (module) {
- CBTConfig::set(ID, module);
- }
-}
-
-void CBTConfig::set(const CBTConfig::bools ID,const bool value )
-{
- getConfig()->beginGroup("bools");
- getConfig()->setValue(getKey(ID), value);
- getConfig()->endGroup();
-}
-
-void CBTConfig::set(const CBTConfig::ints ID, const int value )
-{
- getConfig()->beginGroup("ints");
- getConfig()->setValue(getKey(ID), value);
- getConfig()->endGroup();
-}
-
-void CBTConfig::set( const CBTConfig::intLists ID, const QList<int> value )
-{
- getConfig()->beginGroup("intlists");
- getConfig()->setValue(getKey(ID), IntListToString(value));
- getConfig()->endGroup();
-}
-
-void CBTConfig::set( const CBTConfig::stringLists ID, const QStringList value )
-{
- getConfig()->beginGroup("stringlists");
- getConfig()->setValue(getKey(ID), value);
- getConfig()->endGroup();
-}
-
-void CBTConfig::set( const CBTConfig::stringMaps ID, const CBTConfig::StringMap value )
-{
- getConfig()->beginGroup(getKey(ID));
- getConfig()->remove(""); //clear all entries of this group to make sure old stuff gets removed
-
- switch (ID) {
- case searchScopes: {
- /**
- * We want to make sure that the search scopes are saved with english key names so loading them
- * will always work with each locale set.
- */
- CBTConfig::StringMap::ConstIterator it;
- QString data;// = QString::null;
-
- sword::VerseKey vk;
- for (it = value.begin(); it != value.end(); ++it) {
- sword::ListKey list = vk.ParseVerseList(it.value().toUtf8(), "Genesis 1:1", true);
- data = QString::null;
- for (int i = 0; i < list.Count(); ++i) {
- if ( sword::VerseKey* range = dynamic_cast<sword::VerseKey*>(list.GetElement(i)) ) {
- range->setLocale("en");
- data += QString::fromUtf8( range->getRangeText() ) + ";";
- }
- }
- getConfig()->setValue(it.key(), data);
- }
- break;
- }
- default: {
- for (CBTConfig::StringMap::ConstIterator it = value.begin(); it != value.end(); ++it) {
- getConfig()->setValue(it.key(), it.value());
- }
- break;
- }
- }
- getConfig()->endGroup();
-}
-
-
-void CBTConfig::set( const CLanguageMgr::Language* const language, const FontSettingsPair& value )
-{
- getConfig()->beginGroup("fonts");
- getConfig()->setValue(getKey(language), value.second.toString());
- getConfig()->endGroup();
- getConfig()->beginGroup("font standard settings");
- getConfig()->setValue(getKey(language), value.first);
- getConfig()->endGroup();
+// Sword includes
+#include <versekey.h> // For range configuration
- if (fontConfigMap.contains(language)) {
- fontConfigMap.remove
- (language); //remove it from the cache
- }
-}
+// BibleTime includes
+#include "backend/btmoduletreeitem.h"
+#include "backend/managers/cdisplaytemplatemgr.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/searchdialog/btsearchoptionsarea.h"
+#include "util/cpointers.h"
+#include "util/directoryutil.h"
-CSwordBackend::DisplayOptions CBTConfig::getDisplayOptionDefaults()
+namespace CBTConfig {
+namespace {
+
+typedef QMap<const CLanguageMgr::Language*, FontSettingsPair> FontCacheMap;
+
+QFont *m_defaultFont = 0;
+FontCacheMap m_fontCache;
+
+QString getKey(const strings ID) {
+ switch (ID) {
+ case bibletimeVersion: return "bibletimeVersion";
+ case language: return "language";
+ case displayStyle: return "displayStyle";
+ case bookshelfCurrentItem: return "bookshelfCurrentItem";
+ }
+ Q_ASSERT(false);
+ return QString::null;
+}
+
+QString getKey(const modules ID) {
+ switch (ID) {
+ case standardBible: return "standardBible";
+ case standardCommentary: return "standardCommentary";
+ case standardLexicon: return "standardLexicon";
+ case standardDailyDevotional: return "standardDailyDevotional";
+ case standardHebrewStrongsLexicon: return "standardHebrewLexicon";
+ case standardGreekStrongsLexicon: return "standardGreekLexicon";
+ case standardHebrewMorphLexicon: return "standardHebrewMorphLexicon";
+ case standardGreekMorphLexicon: return "standardGreekMorphLexicon";
+ }
+ Q_ASSERT(false);
+ return QString::null;
+}
+
+QString getKey(const bools ID) {
+ switch (ID) {
+ case firstSearchDialog: return "firstSearchDialog";
+ case readOldBookmarks: return "readOldBookmarks";
+
+ case toolbar: return "toolbar";
+ case mainIndex: return "mainIndex";
+ case infoDisplay: return "infoDisplay";
+
+ case autoTileVertical: return "autoTileVertical";
+ case autoTileHorizontal: return "autoTileHorizontal";
+ case autoCascade: return "autoCascade";
+
+ case lineBreaks: return "lineBreaks";
+ case verseNumbers: return "verseNumbers";
+
+ case logo: return "logo";
+ case autoDeleteOrphanedIndices: return "autoDeleteOrphanedIndices";
+ case crashedLastTime: return "crashedLastTime";
+ case crashedTwoTimes: return "crashedTwoTimes";
+
+ case bookshelfShowHidden: return "bookshelfShowHidden";
+ case allowNetworkConnection: return "allowNetworkConnection";
+ }
+ Q_ASSERT(false);
+ return false;
+}
+
+QString getKey(const ints ID) {
+ switch (ID) {
+ case footnotes: return "footnotes";
+ case strongNumbers: return "strongNumbers";
+ case headings: return "headings";
+ case morphTags: return "morphTags";
+ case lemmas: return "lemmas";
+ case hebrewPoints: return "hebrewPoints";
+ case hebrewCantillation: return "hebrewCantillation";
+ case greekAccents: return "greekAccents";
+ case textualVariants: return "textualVariants";
+ case scriptureReferences: return "scriptureReferences";
+ case morphSegmentation: return "morphSegmentation";
+ case bookshelfContentsX: return "bookshelfContentsX";
+ case bookshelfContentsY: return "bookshelfContentsY";
+ case magDelay: return "magDelay";
+ case bookshelfGrouping: return "bookshelfGrouping";
+ case mainindexActiveTab: return "mainindexActiveTab";
+ case searchDialogWidth: return "searchDialogWidth";
+ case searchDialogHeight: return "searchDialogHeight";
+ case searchDialogX: return "searchDialogX";
+ case searchDialogY: return "searchDialogY";
+ case searchType: return "searchType";
+ case installPathIndex: return "installPathIndex";
+ case bookshelfPosX: return "bookshelfPosX";
+ case bookshelfPosY: return "bookshelfPosY";
+ case bookshelfHeight: return "bookshelfHeight";
+ case bookshelfWidth: return "bookshelfWidth";
+ case configDialogPosX: return "configDialogPosX";
+ case configDialogPosY: return "configDialogPosY";
+ case configDialogHeight: return "configDialogHeight";
+ case configDialogWidth: return "configDialogWidth";
+ }
+ Q_ASSERT(false);
+ return QString::null;
+}
+
+QString getKey(const intLists ID) {
+ switch (ID) {
+ case leftPaneSplitterSizes: return "leftPaneSplitterSizes";
+ case mainSplitterSizes: return "mainSplitterSizes";
+ case searchMainSplitterSizes: return "searchMainSplitterSizes";
+ case searchResultSplitterSizes: return "searchResultSplitterSizes";
+ }
+ Q_ASSERT(false);
+ return QString::null;
+}
+
+QString getKey(const stringLists ID) {
+ switch (ID) {
+ case searchCompletionTexts: return "searchCompletionTexts";
+ case searchTexts: return "searchTexts";
+ case searchModulesHistory: return "searchModulesHistory";
+ case bookshelfOpenGroups: return "bookshelfOpenGroups";
+ case hiddenModules: return "hiddenModules";
+ }
+ Q_ASSERT(false);
+ return QString::null;
+}
+
+QString getKey(const stringMaps ID) {
+ switch (ID) {
+ case searchScopes: return "SearchScopes";
+ };
+ Q_ASSERT(false);
+ return QString::null;
+}
+
+QString getKey(const CLanguageMgr::Language * const language) {
+ Q_ASSERT(!language->name().isEmpty());
+ return language->name();
+}
+
+} // anonymous namespace
+
+QString IntListToString(const QList<int> intList) {
+ QStringList intStrings;
+ foreach(int i, intList) {
+ intStrings << QString::number(i);
+ }
+ return intStrings.join(",");
+}
+
+QList<int> StringToIntList(const QString intListString) {
+ QList<int> intList;
+ if (!intListString.isEmpty() && intListString.contains(',')) {
+ foreach(QString intString, intListString.split(',')) {
+ intList << intString.trimmed().toInt();
+ }
+ }
+ return intList;
+}
+
+QString getDefault(const strings ID) {
+ switch (ID) {
+ case bibletimeVersion: return "0.0"; // main() will realize this and set the value to VERSION
+ case language: return QLocale::system().name();
+ case displayStyle: return CDisplayTemplateMgr::defaultTemplate();
+ case bookshelfCurrentItem: return QString();
+ }
+ return QString::null;
+}
+
+QString getDefault(const modules ID) {
+ // CSwordBackend *b = CPointers::backend();
+ switch (ID) {
+ case standardBible: return "KJV";
+ case standardCommentary: return "MHC";
+ case standardLexicon: return "ISBE";
+ case standardDailyDevotional: return ""; // No default
+
+ case standardHebrewStrongsLexicon: return "StrongsHebrew";
+ case standardGreekStrongsLexicon: return "StrongsGreek";
+ case standardHebrewMorphLexicon: return "StrongsHebrew";
+ case standardGreekMorphLexicon: return "StrongsGreek";
+ }
+
+ return QString::null;
+}
+
+bool getDefault(const bools ID) {
+ switch (ID) {
+ case firstSearchDialog: return true;
+ case readOldBookmarks: return false;
+
+ case toolbar: return true;
+ case mainIndex: return true;
+ case infoDisplay: return true;
+
+ case autoTileVertical: return true;
+ case autoTileHorizontal: return false;
+ case autoCascade: return false;
+
+ case lineBreaks: return false;
+ case verseNumbers: return true;
+
+ case logo: return true;
+ case autoDeleteOrphanedIndices: return true;
+ case crashedLastTime: return false;
+ case crashedTwoTimes: return false;
+ case bookshelfShowHidden: return false;
+ case allowNetworkConnection: return false;
+ }
+ return false;
+}
+
+int getDefault(const ints ID) {
+ switch (ID) {
+ case footnotes: return int(true);
+ case strongNumbers: return int(true);
+ case headings: return int(true);
+ case morphTags: return int(true);
+ case lemmas: return int(true);
+ case hebrewPoints: return int(true);
+ case hebrewCantillation: return int(true);
+ case greekAccents: return int(true);
+ case textualVariants: return int(false);
+ case scriptureReferences: return int(true);
+ case morphSegmentation: return int(true);
+ case bookshelfContentsX: return 0;
+ case bookshelfContentsY: return 0;
+ case magDelay: return 400;
+ case bookshelfGrouping: return BTModuleTreeItem::CatLangMod;
+ case searchDialogWidth: return 200;
+ case searchDialogHeight: return 400;
+ case searchDialogX: return 200;
+ case searchDialogY: return 200;
+ case searchType: return Search::BtSearchOptionsArea::AndType;
+ case mainindexActiveTab: return 0;
+ case installPathIndex: return 0;
+ case bookshelfPosX: return 1;
+ case bookshelfPosY: return 1;
+ case bookshelfHeight: return 1;
+ case bookshelfWidth: return 1;
+ case configDialogPosX: return 1;
+ case configDialogPosY: return 1;
+ case configDialogHeight: return 1;
+ case configDialogWidth: return 1;
+ }
+ return 0;
+}
+
+QList<int> getDefault(const intLists /*ID*/) {
+ QList<int> result;
+ /*switch ( ID ) {
+ case leftPaneSplitterSizes: break;
+ case mainSplitterSizes: break;
+ case searchMainSplitterSizes: break;
+ case searchResultSplitterSizes: break;*/
+ return result;
+}
+
+QStringList getDefault(const stringLists ID) {
+ switch (ID) {
+ case searchTexts: {
+ QStringList list;
+ list.append(QString::null);
+ return list;
+ }
+ case searchCompletionTexts: return QStringList();
+ case bookshelfOpenGroups: return QStringList();
+ case hiddenModules: return QStringList();
+ case searchModulesHistory: return QStringList();
+ }
+ return QStringList();
+}
+
+StringMap getDefault(const stringMaps ID) {
+ if (ID != searchScopes) return StringMap();
+
+ StringMap map;
+ map.insert(QObject::tr("Old testament"), QString("Gen - Mal"));
+ map.insert(QObject::tr("Moses/Pentateuch/Torah"), QString("Gen - Deut"));
+ map.insert(QObject::tr("History"), QString("Jos - Est"));
+ map.insert(QObject::tr("Prophets"), QString("Isa - Mal"));
+ map.insert(QObject::tr("New testament"), QString("Mat - Rev"));
+ map.insert(QObject::tr("Gospels"), QString("Mat - Joh"));
+ map.insert(QObject::tr("Letters/Epistles"), QString("Rom - Jude"));
+ map.insert(QObject::tr("Paul's Epistles"), QString("Rom - Phile"));
+
+ // Make the list to the current bookname language!
+ sword::VerseKey vk;
+ vk.setLocale("en_US");
+
+ for (StringMap::Iterator it(map.begin()); it != map.end(); it++) {
+ sword::ListKey list(vk.ParseVerseList(it.value().toLocal8Bit(), "Genesis 1:1", true));
+ QString data;
+ for (int i(0); i < list.Count(); i++) {
+ data.append(QString::fromUtf8(list.GetElement(i)->getRangeText()));
+ data.append("; ");
+ }
+ map[it.key()] = data;
+ };
+
+ return map;
+}
+
+QFont &getDefault(const CLanguageMgr::Language * const) {
+ // Language specific lookup of the font name
+ if (m_defaultFont) return *m_defaultFont;
+
+ /// \todo make the font name and size a configuration option
+ // int fontSize = QWebSettings::globalSettings()->fontSize(QWebSettings::DefaultFontSize);
+ int fontSize(12);
+ QString fontName(QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont));
+
+ m_defaultFont = new QFont(fontName, fontSize); /// \todo there may be a mem leak here!
+ return *m_defaultFont;
+}
+
+QString get(const strings ID) {
+ getConfig()->beginGroup("strings");
+ QString result(getConfig()->value(getKey(ID), getDefault(ID)).toString());
+ getConfig()->endGroup();
+ return result;
+}
+
+CSwordModuleInfo *get(const modules ID) {
+ getConfig()->beginGroup("modules");
+ CSwordModuleInfo *result(CPointers::backend()->findModuleByName(
+ getConfig()->value(getKey(ID), getDefault(ID)).toString()
+ ));
+ getConfig()->endGroup();
+ return result;
+}
+
+bool get(const bools ID) {
+ getConfig()->beginGroup("bools");
+ bool result(getConfig()->value(getKey(ID), getDefault(ID)).toBool());
+ getConfig()->endGroup();
+ return result;
+}
+
+int get(const ints ID) {
+ getConfig()->beginGroup("ints");
+ int result(getConfig()->value(getKey(ID), getDefault(ID)).toInt());
+ getConfig()->endGroup();
+ return result;
+}
+
+QList<int> get(const intLists ID) {
+ getConfig()->beginGroup("intlists");
+ QList<int> result(StringToIntList(
+ getConfig()->value(getKey(ID), IntListToString(getDefault(ID)))
+ .toString()
+ ));
+ getConfig()->endGroup();
+ return result;
+}
+
+QStringList get(const stringLists ID) {
+ getConfig()->beginGroup("stringlists");
+ QStringList result(
+ getConfig()->value(getKey(ID), getDefault(ID)).toStringList()
+ );
+ getConfig()->endGroup();
+ return result;
+}
+
+StringMap get(const stringMaps ID) {
+ StringMap map;
+
+ getConfig()->beginGroup(getKey(ID));
+ QStringList keys(getConfig()->childKeys());
+
+ if (!keys.isEmpty()) {
+ switch (ID) {
+ case searchScopes: {
+ /**
+ Make sure we return the scopes in the chosen language. saved
+ keys are in english.
+ */
+ sword::VerseKey vk;
+ foreach (QString key, keys) {
+ Q_ASSERT(!key.isEmpty());
+ QByteArray b(getConfig()->value(key).toString().toUtf8());
+ sword::ListKey list(vk.ParseVerseList(b, "Genesis 1:1", true));
+ QString data;
+ for (int i(0); i < list.Count(); i++) {
+ data.append(QString::fromUtf8(list.GetElement(i)->getRangeText()));
+ data.append("; ");
+ }
+ map[key] = data; // Set the new data
+ }
+ }
+ default: break;
+ }
+ } else {
+ map = getDefault(ID);
+ }
+ getConfig()->endGroup();
+ return map;
+}
+
+FontSettingsPair get(const CLanguageMgr::Language * const language) {
+ // Check the cache first:
+ FontCacheMap::const_iterator it(m_fontCache.find(language));
+ if (it != m_fontCache.end()) return *it;
+
+ FontSettingsPair settings;
+
+ getConfig()->beginGroup("font standard settings");
+ settings.first = getConfig()->value(getKey(language), false).toBool();
+ getConfig()->endGroup();
+
+ getConfig()->beginGroup("fonts");
+ QFont font;
+ if (settings.first) {
+ font.fromString(getConfig()->value(getKey(language), getDefault(language)).toString());
+ } else {
+ font = getDefault(language);
+ }
+ settings.second = font;
+ getConfig()->endGroup();
+
+ // Cache the value:
+ m_fontCache.insert(language, settings);
+
+ return settings;
+}
+
+void set(const strings ID, const QString value) {
+// KConfigGroup cg = getConfig()->group("strings");
+// cg.writeEntry(getKey(ID), value);
+ getConfig()->beginGroup("strings");
+ getConfig()->setValue(getKey(ID), value);
+ getConfig()->endGroup();
+}
+
+void set(const modules ID, CSwordModuleInfo * const value) {
+// KConfigGroup cg = getConfig()->group("modules");
+// cg.writeEntry(getKey(ID), value ? value->name() : QString::null);
+ getConfig()->beginGroup("modules");
+ getConfig()->setValue(getKey(ID), value ? value->name() : QString::null);
+ getConfig()->endGroup();
+}
+
+void set(const modules ID, const QString& value) {
+ CSwordModuleInfo *module(CPointers::backend()->findModuleByName(value));
+ if (module) {
+ set(ID, module);
+ }
+}
+
+void set(const bools ID, const bool value) {
+ getConfig()->beginGroup("bools");
+ getConfig()->setValue(getKey(ID), value);
+ getConfig()->endGroup();
+}
+
+void set(const ints ID, const int value) {
+ getConfig()->beginGroup("ints");
+ getConfig()->setValue(getKey(ID), value);
+ getConfig()->endGroup();
+}
+
+void set(const intLists ID, const QList<int> value) {
+ getConfig()->beginGroup("intlists");
+ getConfig()->setValue(getKey(ID), IntListToString(value));
+ getConfig()->endGroup();
+}
+
+void set(const stringLists ID, const QStringList value) {
+ getConfig()->beginGroup("stringlists");
+ getConfig()->setValue(getKey(ID), value);
+ getConfig()->endGroup();
+}
+
+void set(const stringMaps ID, const StringMap value) {
+ typedef StringMap::ConstIterator SMCI;
+ using namespace sword;
+
+ getConfig()->beginGroup(getKey(ID));
+
+ // Clear all entries of this group to make sure old stuff gets removed:
+ getConfig()->remove("");
+
+ switch (ID) {
+ case searchScopes: {
+ /**
+ We want to make sure that the search scopes are saved with english
+ key names so loading them will always work with each locale set.
+ */
+ VerseKey vk;
+ for (SMCI it(value.begin()); it != value.end(); it++) {
+ QString data;
+ ListKey list(vk.ParseVerseList(it.value().toUtf8(), "Genesis 1:1", true));
+ for (int i(0); i < list.Count(); i++) {
+ VerseKey *range(dynamic_cast<VerseKey*>(list.GetElement(i)));
+ if (range) {
+ range->setLocale("en");
+ data.append(QString::fromUtf8( range->getRangeText() ));
+ data.append(";");
+ }
+ }
+ getConfig()->setValue(it.key(), data);
+ }
+ break;
+ }
+ default: {
+ for (SMCI it(value.begin()); it != value.end(); it++) {
+ getConfig()->setValue(it.key(), it.value());
+ }
+ break;
+ }
+ }
+ getConfig()->endGroup();
+}
+
+void set(const CLanguageMgr::Language * const language,
+ const FontSettingsPair& value)
{
- CSwordBackend::DisplayOptions options;
- options.lineBreaks = get(CBTConfig::lineBreaks);
- options.verseNumbers = get(CBTConfig::verseNumbers);
+ getConfig()->beginGroup("fonts");
+ getConfig()->setValue(getKey(language), value.second.toString());
+ getConfig()->endGroup();
+ getConfig()->beginGroup("font standard settings");
+ getConfig()->setValue(getKey(language), value.first);
+ getConfig()->endGroup();
- return options;
+ // Remove language from the cache:
+ m_fontCache.remove(language);
}
-CSwordBackend::FilterOptions CBTConfig::getFilterOptionDefaults()
-{
- CSwordBackend::FilterOptions options;
-
- options.footnotes = true; //required for the info display
- options.strongNumbers = true; //get(CBTConfig::strongNumbers);
- options.headings = get(CBTConfig::headings);
- options.morphTags = true;//required for the info display
- options.lemmas = true;//required for the info display
- options.redLetterWords = true;
- options.hebrewPoints = get(CBTConfig::hebrewPoints);
- options.hebrewCantillation = get(CBTConfig::hebrewCantillation);
- options.greekAccents = get(CBTConfig::greekAccents);
- options.textualVariants = get(CBTConfig::textualVariants);
- options.scriptureReferences = get(CBTConfig::scriptureReferences);
- options.morphSegmentation = get(CBTConfig::morphSegmentation);
-
- return options;
-}
-
-//void CBTConfig::setupAccelSettings(const CBTConfig::keys /*type*/, KActionCollection* const /*actionCollection*/)
-//{
-// qDebug("CBTConfig::setupAccelSettings");
-// QString groupName;
-// switch (type) {
-// case allWindows : {
-// groupName = "Displaywindow shortcuts";
-// break;
-// };
-// case writeWindow : {
-// groupName = "Writewindow shortcuts";
-// break;
-// };
-// case readWindow : {
-// groupName = "Readwindow shortcuts";
-// break;
-// };
-// case bookWindow : {
-// groupName = "Book shortcuts";
-// break;
-// };
-// case bibleWindow : {
-// groupName = "Bible shortcuts";
-// break;
-// };
-// case commentaryWindow : {
-// groupName = "Commentary shortcuts";
-// break;
-// };
-// case lexiconWindow : {
-// groupName = "Lexicon shortcuts";
-// break;
-// };
-// case application : {
-// groupName = "Application shortcuts";
-// break;
-// };
-// };
-// qDebug() << groupName;
-// Q_ASSERT(CBTConfig::getConfig());
-// //buggy???
-// KConfigGroup* cg = &(CBTConfig::getConfig()->group(groupName));
-// //KConfigGroup* cg;
-//
-// Q_ASSERT(cg);
-// Q_ASSERT(actionCollection);
-// //actionCollection->readSettings(cg);
-// actionCollection->setConfigGroup(groupName);
-//
-// actionCollection->readSettings();
-// qDebug("CBTConfig::setupAccelSettings end");
-//}
-
-//void CBTConfig::saveAccelSettings(const CBTConfig::keys /*type*/, KActionCollection* const /*actionCollection*/)
-//{
-// qDebug("CBTConfig::saveAccelSettings");
-// QString groupName;
-// switch (type) {
-// case allWindows : {
-// groupName = "Displaywindow shortcuts";
-// break;
-// };
-// case writeWindow : {
-// groupName = "Writewindow shortcuts";
-// break;
-// };
-// case readWindow : {
-// groupName = "Readwindow shortcuts";
-// break;
-// };
-// case bookWindow : {
-// groupName = "Book shortcuts";
-// break;
-// };
-// case bibleWindow : {
-// groupName = "Bible shortcuts";
-// break;
-// };
-// case commentaryWindow : {
-// groupName = "Commentary shortcuts";
-// break;
-// };
-// case lexiconWindow : {
-// groupName = "Lexicon shortcuts";
-// break;
-// };
-// case application : {
-// groupName = "Application shortcuts";
-// break;
-// };
-// };
-//
-// // KConfigGroup* cg = &(CBTConfig::getConfig()->group(groupName));
-//
-// qDebug("NOT saving accelerators!");
-// //actionCollection->writeSettings(cg);
-// qDebug("CBTConfig::saveAccelSettings end");
-//}
-
-
-QString CBTConfig::getModuleEncryptionKey( const QString& module )
-{
- Q_ASSERT(!module.isEmpty());
- QString result;
- getConfig()->beginGroup("Module keys");
- result = getConfig()->value(module, QVariant(QString::null)).toString();
- getConfig()->endGroup();
- return result;
+CSwordBackend::DisplayOptions getDisplayOptionDefaults() {
+ CSwordBackend::DisplayOptions options;
+ options.lineBreaks = get(lineBreaks);
+ options.verseNumbers = get(verseNumbers);
+ return options;
}
-void CBTConfig::setModuleEncryptionKey( const QString& module, const QString& key )
-{
- getConfig()->beginGroup("Module keys");
- getConfig()->setValue(module, key);
- getConfig()->endGroup();
-}
+CSwordBackend::FilterOptions getFilterOptionDefaults() {
+ CSwordBackend::FilterOptions options;
-QSettings* CBTConfig::getConfig()
-{
- static QSettings config(util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bibletimerc", QSettings::IniFormat);
- return &config;
-}
+ options.footnotes = true; // Required for the info display
+ options.strongNumbers = true; // get(strongNumbers);
+ options.headings = get(headings);
+ options.morphTags = true; // Required for the info display
+ options.lemmas = true; // Required for the info display
+ options.redLetterWords = true;
+ options.hebrewPoints = get(hebrewPoints);
+ options.hebrewCantillation = get(hebrewCantillation);
+ options.greekAccents = get(greekAccents);
+ options.textualVariants = get(textualVariants);
+ options.scriptureReferences = get(scriptureReferences);
+ options.morphSegmentation = get(morphSegmentation);
-void CBTConfig::syncConfig()
-{
- CBTConfig::getConfig()->sync();
+ return options;
}
-QString CBTConfig::IntListToString( const QList<int> intList )
+void setupAccelSettings(const keys type,
+ BtActionCollection * const actionCollection)
{
- QStringList intStrings;
- foreach(int i, intList)
- {
- intStrings << QString::number(i);
- }
- return intStrings.join(",");
-}
-
-QList<int> CBTConfig::StringToIntList( const QString intListString )
+ qDebug("CBTConfig::setupAccelSettings begin");
+ QString groupName;
+ switch (type) {
+ case allWindows:
+ groupName = "Displaywindow shortcuts";
+ break;
+ case writeWindow:
+ groupName = "Writewindow shortcuts";
+ break;
+ case readWindow:
+ groupName = "Readwindow shortcuts";
+ break;
+ case bookWindow:
+ groupName = "Book shortcuts";
+ break;
+ case bibleWindow:
+ groupName = "Bible shortcuts";
+ break;
+ case commentaryWindow:
+ groupName = "Commentary shortcuts";
+ break;
+ case lexiconWindow:
+ groupName = "Lexicon shortcuts";
+ break;
+ case application:
+ groupName = "Application shortcuts";
+ break;
+ }
+ qDebug() << groupName;
+ Q_ASSERT(getConfig());
+
+ actionCollection->setConfigGroup(groupName);
+ actionCollection->readSettings();
+ qDebug("CBTConfig::setupAccelSettings end");
+}
+
+void saveAccelSettings(const keys type,
+ BtActionCollection * const actionCollection)
{
- QList<int> intList;
- if (!intListString.isEmpty() && intListString.contains(','))
- {
- foreach(QString intString, intListString.split(","))
- {
- intList << intString.trimmed().toInt();
- }
- }
- return intList;
-}
+ qDebug("CBTConfig::saveAccelSettings begin");
+ QString groupName;
+ switch (type) {
+ case allWindows:
+ groupName = "Displaywindow shortcuts";
+ break;
+ case writeWindow:
+ groupName = "Writewindow shortcuts";
+ break;
+ case readWindow:
+ groupName = "Readwindow shortcuts";
+ break;
+ case bookWindow:
+ groupName = "Book shortcuts";
+ break;
+ case bibleWindow:
+ groupName = "Bible shortcuts";
+ break;
+ case commentaryWindow:
+ groupName = "Commentary shortcuts";
+ break;
+ case lexiconWindow:
+ groupName = "Lexicon shortcuts";
+ break;
+ case application:
+ groupName = "Application shortcuts";
+ break;
+ }
+
+ actionCollection->setConfigGroup(groupName);
+ actionCollection->writeSettings();
+ qDebug("CBTConfig::saveAccelSettings end");
+}
+
+
+QString getModuleEncryptionKey(const QString &module) {
+ Q_ASSERT(!module.isEmpty());
+ getConfig()->beginGroup("Module keys");
+ QString result(getConfig()->value(module, QVariant(QString::null)).toString());
+ getConfig()->endGroup();
+ return result;
+}
+
+void setModuleEncryptionKey(const QString &module, const QString &key) {
+ getConfig()->beginGroup("Module keys");
+ getConfig()->setValue(module, key);
+ getConfig()->endGroup();
+}
+
+QSettings *getConfig() {
+ static QSettings config(util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bibletimerc", QSettings::IniFormat);
+ return &config;
+}
+
+void syncConfig() {
+ getConfig()->sync();
+}
+
+} // namespace CBTConfig
diff --git a/src/backend/config/cbtconfig.h b/src/backend/config/cbtconfig.h
index 0ded865..d4d075b 100644
--- a/src/backend/config/cbtconfig.h
+++ b/src/backend/config/cbtconfig.h
@@ -10,188 +10,182 @@
#ifndef CBTCONFIG_H
#define CBTCONFIG_H
-#include "backend/managers/cswordbackend.h"
-
-//Qt includes
#include <QString>
#include <QFont>
#include <QList>
#include <QMap>
+#include "backend/managers/cswordbackend.h"
-//Forward declarations
class QSettings;
-//class CLanguageMgr::Language;
+class BtActionCollection;
/**
* This class is the interface to the config object of BibleTime
* @author The BibleTime team
*/
-class CBTConfig {
-public:
- typedef QMap<QString, QString> StringMap;
-
- enum strings {
- bibletimeVersion,
- language,
- displayStyle,
- bookshelfCurrentItem
- };
- enum modules {
- standardBible = 0, //just to make sure, default is IMHO 0, so that's redundant here
- standardCommentary,
- standardLexicon,
- standardDailyDevotional,
- standardHebrewStrongsLexicon,
- standardGreekStrongsLexicon,
- standardHebrewMorphLexicon,
- standardGreekMorphLexicon,
- lastModuleType = standardGreekMorphLexicon
- };
- enum bools {
- firstSearchDialog,
- readOldBookmarks,
-
- toolbar,
- mainIndex,
- infoDisplay,
-
- autoTileVertical,
- autoTileHorizontal,
- autoCascade,
-
- lineBreaks,
- verseNumbers,
-
- logo,
- autoDeleteOrphanedIndices,
- crashedLastTime,
- crashedTwoTimes,
-
- bookshelfShowHidden,
-
- allowNetworkConnection
- };
- enum ints {
- footnotes,
- strongNumbers,
- headings,
- morphTags,
- lemmas,
- hebrewPoints,
- hebrewCantillation,
- greekAccents,
- textualVariants,
- scriptureReferences,
- morphSegmentation,
-
- bookshelfContentsX,
- bookshelfContentsY,
- magDelay, /* The delay until a mouse move makes the content appear in the mag */
- bookshelfGrouping,
- mainindexActiveTab,
-
- searchDialogWidth,
- searchDialogHeight,
- searchDialogX,
- searchDialogY,
- searchType,
-
- installPathIndex
- };
- enum intLists {
- leftPaneSplitterSizes,
- mainSplitterSizes,
- searchMainSplitterSizes,
- searchResultSplitterSizes
- };
- enum stringLists {
- searchCompletionTexts,
- searchTexts,
- searchModulesHistory,
- bookshelfOpenGroups,
- hiddenModules
- };
- enum keys {
- allWindows,
- readWindow,
- writeWindow,
- bookWindow,
- bibleWindow,
- commentaryWindow,
- lexiconWindow,
- application
- };
- enum stringMaps {
- searchScopes
- };
- typedef std::pair<bool, QFont> FontSettingsPair;
-
- static QString get( const CBTConfig::strings );
- static CSwordModuleInfo* get( const CBTConfig::modules );
- static bool get( const CBTConfig::bools );
- static int get( const CBTConfig::ints );
- static QList<int> get( const CBTConfig::intLists );
- static QStringList get( const CBTConfig::stringLists );
- static CBTConfig::StringMap get( const CBTConfig::stringMaps );
-
- static FontSettingsPair get( const CLanguageMgr::Language* const );
-
- static QString getDefault( const CBTConfig::strings );
- static QString getDefault( const CBTConfig::modules );
- static bool getDefault( const CBTConfig::bools );
- static int getDefault( const CBTConfig::ints );
- static QList<int> getDefault( const CBTConfig::intLists );
- static QStringList getDefault( const CBTConfig::stringLists );
- static CBTConfig::StringMap getDefault( const CBTConfig::stringMaps );
- static QFont& getDefault( const CLanguageMgr::Language* const );
-
- static void set( const CBTConfig::strings, const QString value );
- static void set( const CBTConfig::modules, CSwordModuleInfo* const module );
- static void set( const CBTConfig::modules, const QString& moduleName );
- static void set( const CBTConfig::bools, const bool value );
- static void set( const CBTConfig::ints, const int value );
- static void set( const CBTConfig::intLists, const QList<int> value );
- static void set( const CBTConfig::stringLists, const QStringList value);
- static void set( const CBTConfig::stringMaps, const CBTConfig::StringMap value);
- static void set( const CLanguageMgr::Language* const language, const FontSettingsPair& fontSettings );
-
- static CSwordBackend::FilterOptions getFilterOptionDefaults();
- static CSwordBackend::DisplayOptions getDisplayOptionDefaults();
-
-// static void setupAccelSettings(const CBTConfig::keys type, KActionCollection* const actionCollection);
-// static void saveAccelSettings(const CBTConfig::keys type, KActionCollection* const actionCollection);
-
- static QString getModuleEncryptionKey( const QString& name );
- static void setModuleEncryptionKey( const QString& name, const QString& key );
-
- /** Re-reads the config from disk */
- static void syncConfig();
-
-private:
- friend class BibleTimeTest;
- /** The config object.
- * @return A config object which is used currently, may be the global config or the session config
- */
- static QSettings* getConfig();
-
- static QString getKey( const CBTConfig::strings );
- static QString getKey( const CBTConfig::modules );
- static QString getKey( const CBTConfig::bools );
- static QString getKey( const CBTConfig::ints );
- static QString getKey( const CBTConfig::intLists );
- static QString getKey( const CBTConfig::stringLists );
- static QString getKey( const CBTConfig::stringMaps );
- static QString getKey( const CLanguageMgr::Language* const );
-
- static QString IntListToString( const QList<int> );
- static QList<int> StringToIntList( const QString );
-
- //static caches
- static QFont* m_defaultFont;
-
- typedef QMap<const CLanguageMgr::Language*, CBTConfig::FontSettingsPair> FontCache;
- static QMap<const CLanguageMgr::Language*, CBTConfig::FontSettingsPair> fontConfigMap;
+namespace CBTConfig {
+
+typedef QMap<QString, QString> StringMap;
+typedef std::pair<bool, QFont> FontSettingsPair;
+
+enum strings {
+ bibletimeVersion,
+ language,
+ displayStyle,
+ bookshelfCurrentItem
+};
+enum modules {
+ standardBible = 0, // Just to make sure, default is IMHO 0, so that's redundant here
+ standardCommentary,
+ standardLexicon,
+ standardDailyDevotional,
+ standardHebrewStrongsLexicon,
+ standardGreekStrongsLexicon,
+ standardHebrewMorphLexicon,
+ standardGreekMorphLexicon,
+ lastModuleType = standardGreekMorphLexicon
};
+enum bools {
+ firstSearchDialog,
+ readOldBookmarks,
+
+ toolbar,
+ mainIndex,
+ infoDisplay,
+
+ autoTileVertical,
+ autoTileHorizontal,
+ autoCascade,
+
+ lineBreaks,
+ verseNumbers,
+
+ logo,
+ autoDeleteOrphanedIndices,
+ crashedLastTime,
+ crashedTwoTimes,
+
+ bookshelfShowHidden,
+
+ allowNetworkConnection
+};
+enum ints {
+ footnotes,
+ strongNumbers,
+ headings,
+ morphTags,
+ lemmas,
+ hebrewPoints,
+ hebrewCantillation,
+ greekAccents,
+ textualVariants,
+ scriptureReferences,
+ morphSegmentation,
+
+ bookshelfContentsX,
+ bookshelfContentsY,
+ magDelay, /* The delay until a mouse move makes the content appear in the mag */
+ bookshelfGrouping,
+ mainindexActiveTab,
+
+ searchDialogWidth,
+ searchDialogHeight,
+ searchDialogX,
+ searchDialogY,
+ searchType,
+
+ installPathIndex,
+
+ bookshelfPosX,
+ bookshelfPosY,
+ bookshelfHeight,
+ bookshelfWidth,
+
+ configDialogPosX,
+ configDialogPosY,
+ configDialogHeight,
+ configDialogWidth
+};
+enum intLists {
+ leftPaneSplitterSizes,
+ mainSplitterSizes,
+ searchMainSplitterSizes,
+ searchResultSplitterSizes
+};
+enum stringLists {
+ searchCompletionTexts,
+ searchTexts,
+ searchModulesHistory,
+ bookshelfOpenGroups,
+ hiddenModules
+};
+enum keys {
+ allWindows,
+ readWindow,
+ writeWindow,
+ bookWindow,
+ bibleWindow,
+ commentaryWindow,
+ lexiconWindow,
+ application
+};
+enum stringMaps {
+ searchScopes
+};
+
+QString IntListToString(const QList<int> intList);
+QList<int> StringToIntList(const QString intListString);
+
+QString getDefault(const strings);
+QString getDefault(const modules);
+bool getDefault(const bools);
+int getDefault(const ints);
+QList<int> getDefault(const intLists);
+QStringList getDefault(const stringLists);
+StringMap getDefault(const stringMaps);
+QFont &getDefault(const CLanguageMgr::Language * const);
+
+QString get(const strings);
+CSwordModuleInfo *get(const modules);
+bool get(const bools);
+int get(const ints);
+QList<int> get(const intLists);
+QStringList get(const stringLists);
+StringMap get(const stringMaps);
+FontSettingsPair get(const CLanguageMgr::Language * const);
+
+void set(const strings, const QString value);
+void set(const modules, CSwordModuleInfo * const module);
+void set(const modules, const QString& moduleName);
+void set(const bools, const bool value);
+void set(const ints, const int value);
+void set(const intLists, const QList<int> value);
+void set(const stringLists, const QStringList value);
+void set(const stringMaps, const StringMap value);
+void set(const CLanguageMgr::Language * const language,
+ const FontSettingsPair &fontSettings);
+
+CSwordBackend::FilterOptions getFilterOptionDefaults();
+CSwordBackend::DisplayOptions getDisplayOptionDefaults();
+
+void setupAccelSettings(const keys type,
+ BtActionCollection * const actionCollection);
+void saveAccelSettings (const keys type,
+ BtActionCollection * const actionCollection);
+
+QString getModuleEncryptionKey(const QString &name);
+void setModuleEncryptionKey(const QString &name, const QString &key);
+
+/**
+ Re-reads the config from disk.
+*/
+void syncConfig();
+
+/**
+ Returns the config object.
+*/
+QSettings* getConfig();
+} // namespace CBTConfig
#endif
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp
index adf88b0..a7b89ba 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.cpp
+++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp
@@ -174,45 +174,9 @@ unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) {
boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
(*key) = sword::TOP;
-#ifdef SWORD_MULTIVERSE
key->setBookName(book.toUtf8().constData());
bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book();
-#else
- bool found = false;
- int min = 0;
- int max = 1;
-
- if ((m_hasOT>0 && m_hasNT>0) || (m_hasOT == -1 && m_hasNT == -1)) {
- min = 0;
- max = 1;
- bookNumber = 0;
- }
- else if (m_hasOT>0 && !m_hasNT) {
- min = 0;
- max = 0;
- bookNumber = 0;
- }
- else if (!m_hasOT && m_hasNT>0) {
- min = 1;
- max = 1;
- bookNumber = key->BMAX[0];
- }
- else if (!m_hasOT && !m_hasNT) {
- min = 0;
- max = -1; //no loop
- bookNumber = 0;
- }
-
- for (int i = min; i <= max && !found; ++i) {
- for ( int j = 0; j < key->BMAX[i] && !found; ++j) {
- ++bookNumber;
-
- if (book == QString::fromUtf8( key->books[i][j].name) )
- found = true;
- }
- }
-#endif
return bookNumber;
}
diff --git a/src/backend/filters/bt_osishtml.cpp b/src/backend/filters/bt_osishtml.cpp
index bbcf8e5..8ee0b40 100644
--- a/src/backend/filters/bt_osishtml.cpp
+++ b/src/backend/filters/bt_osishtml.cpp
@@ -114,7 +114,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
const int countSplit1 = tag.getAttributePartCount("lemma", '|');
const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon
int count = 0;
-
+
if (countSplit1 > countSplit2) { //| split char
splitChar = '|'; //TODO: not allowed, remove soon
count = countSplit1;
@@ -123,7 +123,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
splitChar = ' ';
count = countSplit2;
}
-
+
int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
attrValue = "";
@@ -155,7 +155,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
const int countSplit1 = tag.getAttributePartCount("morph", '|');
const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon
int count = 0;
-
+
if (countSplit1 > countSplit2) { //| split char
splitChar = '|';
count = countSplit1;
@@ -260,11 +260,9 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
}*/
buf.append("<span class=\"crossreference\">");
-#ifdef SWORD_SIMPLERENDER
sword::SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
sword::SWBuf footnoteBody = myUserData->entryAttributes["Footnote"][footnoteNumber]["body"];
buf += myModule->RenderText(footnoteBody);
-#endif
}
/* else if (type == "explanation") {
@@ -290,7 +288,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() ); //inefficient
const sword::SWBuf n = tag.getAttribute("n");
-
+
buf.append("\">");
buf.append( (n.length() > 0) ? n.c_str() : "*" );
buf.append("</span> ");
@@ -543,7 +541,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
}
//qWarning(QString("handled <seg> token. result: %1").arg(buf.c_str()).latin1());
}
-
+
//divine name, don't use simple tag replacing because it may have attributes
else if (!strcmp(tag.getName(), "divineName")) {
if (!tag.isEndTag()) {
@@ -553,7 +551,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
buf.append("</span></span>");
}
}
-
+
else { //all tokens handled by OSISHTMLHref will run through the filter now
return sword::OSISHTMLHREF::handleToken(buf, token, userData);
}
diff --git a/src/backend/filters/bt_plainhtml.cpp b/src/backend/filters/bt_plainhtml.cpp
index 67557cc..4ee98b4 100644
--- a/src/backend/filters/bt_plainhtml.cpp
+++ b/src/backend/filters/bt_plainhtml.cpp
@@ -50,7 +50,7 @@ char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey*
continue;
}
else if (*from == '{') { //footnote start
- text += "<FONT COLOR=\"#80000\"><SMALL> (";
+ text += "<FONT COLOR=\"#800000\"><SMALL> ("; /// \bug Possible color conflict
continue;
}
else if (*from == '}') //footnote end
diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp
index 424b268..8db5d74 100644
--- a/src/backend/keys/cswordversekey.cpp
+++ b/src/backend/keys/cswordversekey.cpp
@@ -81,23 +81,7 @@ QString CSwordVerseKey::book( const QString& newBook ) {
}
if (!newBook.isEmpty()) {
-
-#ifdef SWORD_MULTIVERSE
setBookName(newBook.toUtf8().constData());
-#else
-
- bool finished = false;
-
- for (int testament = min; testament <= max && !finished; ++testament) {
- for (int book = 0; book < BMAX[testament] && !finished; ++book) {
- if ( !strcmp(newBook.toUtf8().constData(), books[testament][book].name ) ) {
- Testament(testament+1);
- Book(book+1);
- finished = true;
- }
- }
- }
-#endif
}
if ( (Testament() >= min+1) && (Testament() <= max+1) && (Book() <= BMAX[min]) ) {
diff --git a/src/backend/managers/cswordbackend.cpp b/src/backend/managers/cswordbackend.cpp
index 0afe467..f17538a 100644
--- a/src/backend/managers/cswordbackend.cpp
+++ b/src/backend/managers/cswordbackend.cpp
@@ -494,11 +494,7 @@ void CSwordBackend::reloadModules(SetupChangedReason reason) {
delete myconfig;
config = myconfig = 0;
// we need to call findConfig to make sure that augPaths are reloaded
-#ifdef SWORD_SYSCONF_CHANGED
findConfig(&configType, &prefixPath, &configPath, &augPaths, &sysConfig);
-#else
- findConfig(&configType, &prefixPath, &configPath, &augPaths, sysconfig);
-#endif
// now re-read module configuration files
loadConfigDir(configPath);
}
diff --git a/src/bibletime.cpp b/src/bibletime.cpp
index 0877a8f..fdc9f48 100644
--- a/src/bibletime.cpp
+++ b/src/bibletime.cpp
@@ -11,6 +11,7 @@
#include "frontend/cmdiarea.h"
#include "frontend/mainindex/cmainindex.h"
#include "frontend/mainindex/bookshelf/cbookshelfindex.h"
+#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/cdisplaywindow.h"
#include "frontend/displaywindow/cdisplaywindowfactory.h"
#include "frontend/displaywindow/creadwindow.h"
@@ -45,17 +46,7 @@
using namespace Profile;
-BibleTime::BibleTime() :
- QMainWindow(0),
- m_dock0(0),
- m_dock1(0),
- m_dock2(0),
- m_initialized(false),
- m_moduleList(0),
- m_currentProfile(0),
- m_mdi(0),
- m_profileMgr()
-{
+BibleTime::BibleTime() {
QPixmap pm;
if ( !pm.load( util::filesystem::DirectoryUtil::getPicsDir().canonicalPath().append( "/startuplogo.png")) )
{
@@ -114,7 +105,7 @@ void BibleTime::readSettings()
{
qDebug("******************BibleTime::readSettings******************************");
// accel()->readSettings(CBTConfig::getConfig());
-// CBTConfig::setupAccelSettings(CBTConfig::application, actionCollection());
+ CBTConfig::setupAccelSettings(CBTConfig::application, m_actionCollection);
m_viewToolbar_action->setChecked( CBTConfig::get(CBTConfig::toolbar) );
slotToggleToolbar();
@@ -213,6 +204,12 @@ void BibleTime::refreshDisplayWindows()
}
}
+/** Refresh main window accelerators */
+void::BibleTime::refreshBibleTimeAccel()
+{
+ CBTConfig::setupAccelSettings(CBTConfig::application, m_actionCollection);
+}
+
/** Called before quit. */
void BibleTime::slot_aboutToQuit()
{
@@ -298,19 +295,3 @@ void BibleTime::processCommandline()
}
}
-bool BibleTime::event(QEvent* e)
-{
-// /* if (e->type() == QEvent::Polish) {
-// qWarning("BibleTime::event type Polish");
-// m_initialized = true;
-// }*/
- if (e->type() == QEvent::Close)
- {
- }
- return QMainWindow::event(e);
-}
-
-void BibleTime::closeEvent(QCloseEvent* e)
-{
- QMainWindow::closeEvent(e);
-}
diff --git a/src/bibletime.h b/src/bibletime.h
index bf27ccd..63d603d 100644
--- a/src/bibletime.h
+++ b/src/bibletime.h
@@ -19,6 +19,7 @@ class CSwordModuleInfo;
#include <QList>
#include <QMainWindow>
+class BtActionClass;
class CMDIArea;
class CDisplayWindow;
class CMainIndex;
@@ -130,7 +131,7 @@ public:
/**
* destructor of BibleTime
*/
- virtual ~BibleTime();
+ ~BibleTime();
/**
* Reads the settings from the configfile and sets the right properties.
@@ -152,6 +153,10 @@ public:
* Stores the settings of the mainwindow in the profile p
*/
void storeProfileSettings( Profile::CProfile* p );
+ /**
+ * Save the configuration dialog settings, don't open dialog
+ */
+ void saveConfigSettings();
public slots:
/**
@@ -173,11 +178,15 @@ public slots:
/**
* Sets the plain caption of the main window
*/
- virtual void setPlainCaption( const QString& );
+ void setPlainCaption( const QString& );
/**
* Processes the commandline options given to BibleTime.
*/
void processCommandline();
+ /**
+ * Creates QAction's that have keyboard shortcuts
+ */
+ static void insertKeyboardActions( BtActionCollection* const a );
protected: // Protected methods
/**
@@ -203,20 +212,21 @@ protected: // Protected methods
/**
* Initializes one action object
*/
- QAction* initAction(QAction* action, QString text, QString icon, QKeySequence accel, QString tooltip, const char* slot );
+ QAction* initAction(QAction* action, QString text, QString icon, QKeySequence accel,
+ const QString& tooltip, const QString& actionName, const char* slot );
/**
* Refreshes all presenter supporting at least in of the features given as parameter.
*/
void refreshDisplayWindows();
/**
+ * Refresh main window accelerators
+ */
+ void refreshBibleTimeAccel();
+ /**
* Called before a window is closed
*/
bool queryClose();
- virtual bool event(QEvent*);
-
- virtual void closeEvent(QCloseEvent* e);
-
protected slots:
/**
* Creates a new presenter in the MDI area according to the type of the module.
@@ -316,10 +326,14 @@ protected slots:
void slotOpenAboutDialog();
private:
- // docking widgets
- QDockWidget* m_dock0;
- QDockWidget* m_dock1;
- QDockWidget* m_dock2;
+ // Docking widgets and their respective content widgets:
+ QDockWidget* m_bookshelfDock;
+ CBookshelfIndex* m_bookshelfPage;
+ QDockWidget* m_bookmarksDock;
+ CBookmarkIndex* m_bookmarksPage;
+ QDockWidget* m_magDock;
+ InfoDisplay::CInfoDisplay* m_infoDisplay;
+
QToolBar* m_mainToolBar;
// VIEW menu actions
QAction* m_viewToolbar_action;
@@ -327,13 +341,13 @@ private:
/** WINDOW menu actions */
QAction* m_windowCascade_action;
QAction* m_windowTileHorizontal_action;
- QAction* m_windowTileVertical_action;
- QMenu* m_windowArrangementModeMenu;
+ QAction* m_windowTileVertical_action;
QAction* m_windowManualMode_action;
QAction* m_windowAutoCascade_action;
QAction* m_windowAutoTileVertical_action;
QAction* m_windowAutoTileHorizontal_action;
QAction* m_windowCloseAll_action;
+ BtActionCollection* m_actionCollection;
QMenu* m_windowSaveProfileMenu;
QAction* m_windowSaveToNewProfile_action;
@@ -341,24 +355,13 @@ private:
QMenu* m_windowDeleteProfileMenu;
QAction* m_windowFullscreen_action;
- QList<QAction*> m_windowOpenWindowsList;
-
- bool m_initialized;
- /**
- * The list of installed SWORD modules
- */
- QList<CSwordModuleInfo*>* m_moduleList;
+ /// \todo remove?
+ // QList<QAction*> m_windowOpenWindowsList;
- Profile::CProfile* m_currentProfile;
CMDIArea* m_mdi;
Profile::CProfileMgr m_profileMgr;
- // docking windows
- CBookmarkIndex* m_bookmarksPage;
- CBookshelfIndex* m_bookshelfPage;
- InfoDisplay::CInfoDisplay* m_infoDisplay;
-
protected: //DBUS interface implementation
void closeAllModuleWindows();
void syncAllBibles(const QString& key);
diff --git a/src/bibletime_init.cpp b/src/bibletime_init.cpp
index 5effe7e..c59964b 100644
--- a/src/bibletime_init.cpp
+++ b/src/bibletime_init.cpp
@@ -16,6 +16,7 @@
#include "backend/managers/cswordbackend.h"
#include "backend/managers/clanguagemgr.h"
#include "frontend/mainindex/cmainindex.h"
+#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/profile/cprofilemgr.h"
#include "frontend/profile/cprofile.h"
#include "frontend/cmdiarea.h"
@@ -49,147 +50,248 @@ void BibleTime::initView()
m_mdi = new CMDIArea(this);
setCentralWidget(m_mdi);
- m_dock0 = new QDockWidget(tr("Bookshelf"), this);
- m_dock0->setObjectName("BookshelfDock");
+ m_bookshelfDock = new QDockWidget(tr("Bookshelf"), this);
+ m_bookshelfDock->setObjectName("BookshelfDock");
m_bookshelfPage = new CBookshelfIndex(0);
- m_dock0->setWidget(m_bookshelfPage);
- addDockWidget(Qt::LeftDockWidgetArea, m_dock0);
+ m_bookshelfDock->setWidget(m_bookshelfPage);
+ addDockWidget(Qt::LeftDockWidgetArea, m_bookshelfDock);
- m_dock1 = new QDockWidget(tr("Bookmarks"), this);
- m_dock1->setObjectName("BookmarksDock");
+ m_bookmarksDock = new QDockWidget(tr("Bookmarks"), this);
+ m_bookmarksDock->setObjectName("BookmarksDock");
m_bookmarksPage = new CBookmarkIndex(0);
- m_dock1->setWidget(m_bookmarksPage);
- addDockWidget(Qt::LeftDockWidgetArea, m_dock1);
- tabifyDockWidget(m_dock1, m_dock0);
+ m_bookmarksDock->setWidget(m_bookmarksPage);
+ addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksDock);
+ tabifyDockWidget(m_bookmarksDock, m_bookshelfDock);
- m_dock2 = new QDockWidget(tr("Mag"), this);
- m_dock2->setObjectName("MagDock");
+ m_magDock = new QDockWidget(tr("Mag"), this);
+ m_magDock->setObjectName("MagDock");
m_infoDisplay = new CInfoDisplay(this);
m_infoDisplay->resize(150,150);
- m_dock2->setWidget(m_infoDisplay);
- addDockWidget(Qt::LeftDockWidgetArea, m_dock2);
+ m_magDock->setWidget(m_infoDisplay);
+ addDockWidget(Qt::LeftDockWidgetArea, m_magDock);
CPointers::setInfoDisplay(m_infoDisplay);
m_mdi->setMinimumSize(100, 100);
m_mdi->setFocusPolicy(Qt::ClickFocus);
}
-QAction* BibleTime::initAction(QAction* action, QString text, QString icon, QKeySequence accel, QString tooltip, const char* slot )
+QAction* BibleTime::initAction(QAction* action, QString text, QString icon, QKeySequence accel,
+ const QString& tooltip, const QString& actionName, const char* slot )
{
action->setText(text);
if ( ! icon.isEmpty() )
action->setIcon(util::filesystem::DirectoryUtil::getIcon(icon));
action->setShortcut(accel);
if (tooltip != QString::null) action->setToolTip(tooltip);
-// actionCollection()->addAction(actionName, action);
+ m_actionCollection->addAction(actionName, action);
if (slot) QObject::connect( action, SIGNAL(triggered()), this, slot );
return action;
}
+// 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 )
+{
+ QAction* action = new QAction(a);
+ action->setText(tr("&Quit"));
+ action->setIcon(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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);
+
+ action = new QAction(a);
+ action->setText(tr("&Show toolbar"));
+ action->setShortcut(QKeySequence(Qt::Key_F6));
+ a->addAction("showToolbar", action);
+
+ action = new QAction(a);
+ action->setText(tr("Search in &open works..."));
+ action->setIcon(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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-&cascade"));
+ action->setIcon(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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 &vertically"));
+ action->setIcon(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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("Cl&ose all windows"));
+ action->setIcon(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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(util::filesystem::DirectoryUtil::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);
+
+ action = new QAction(a);
+ action->setText(tr("&About BibleTime"));
+ action->setToolTip(tr("Information about the BibleTime program"));
+ a->addAction("aboutBibleTime", action);
+}
+
/** Initializes the action objects of the GUI */
void BibleTime::initActions()
{
- //:Main menu item
+ m_actionCollection = new BtActionCollection(this);
+
+ insertKeyboardActions(m_actionCollection);
+
+ // Main menus
QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
- //:Main menu item
QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
- //:Main menu item
QMenu* searchMenu = menuBar()->addMenu(tr("&Search"));
- //:Main menu item
m_windowMenu = menuBar()->addMenu(tr("&Window"));
- //:Main menu item
QMenu* settingsMenu = menuBar()->addMenu(tr("Se&ttings"));
- //:Main menu item
QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
- //:Name of the main toolbar
+ // Name of the main toolbar
m_mainToolBar = addToolBar(tr("Main Toolbar"));
m_mainToolBar->setObjectName("MainToolBar");
m_mainToolBar->setFloatable(false);
m_mainToolBar->setMovable(false);
- QAction* tmp = new QAction(this);
- initAction(
- tmp,
- tr("&Quit"),
- QString("exit.svg"),
- QKeySequence(Qt::CTRL + Qt::Key_Q),
- tr("Quit BibleTime"),
- SLOT( close() )
- );
+ QAction* tmp = m_actionCollection->action("quit");
fileMenu->addAction(tmp);
m_mainToolBar->addAction(tmp);
m_mainToolBar->addSeparator();
+ connect(tmp, SIGNAL(triggered()), this, SLOT(close()) );
- m_windowFullscreen_action = new QAction(this);
+ m_windowFullscreen_action = m_actionCollection->action("toggleFullscreen");
m_windowFullscreen_action->setCheckable(true);
- viewMenu->addAction(initAction(
- m_windowFullscreen_action,
- tr("&Fullscreen mode"),
- CResMgr::mainMenu::window::showFullscreen::icon,
- CResMgr::mainMenu::window::showFullscreen::accel,
- tr("Toggle fullscreen mode of the main window"),
- SLOT(toggleFullscreen()))
- );
+ viewMenu->addAction(m_windowFullscreen_action);
m_mainToolBar->addAction(m_windowFullscreen_action);
+ connect(m_windowFullscreen_action, SIGNAL(triggered()), this, SLOT(toggleFullscreen()) );
- m_viewToolbar_action = new QAction(this);
+ m_viewToolbar_action = m_actionCollection->action("showToolbar");
m_viewToolbar_action->setCheckable(true);
m_viewToolbar_action->setChecked(true);
- viewMenu->addAction(initAction(
- m_viewToolbar_action,
- tr("&Show toolbar"),
- "",
- QKeySequence(Qt::Key_F6),
- "",
- SLOT(slotToggleToolbar())));
+ viewMenu->addAction(m_viewToolbar_action);
+ connect(m_viewToolbar_action, SIGNAL(triggered()), this, SLOT(slotToggleToolbar()) );
+
- QAction* action = m_dock0->toggleViewAction();
+ QAction* action = m_bookshelfDock->toggleViewAction();
action->setText(tr("Show Bookshelf"));
viewMenu->addAction(action);
- action = m_dock1->toggleViewAction();
+ action = m_bookmarksDock->toggleViewAction();
action->setText(tr("Show Bookmarks"));
viewMenu->addAction(action);
- action = m_dock2->toggleViewAction();
+ action = m_magDock->toggleViewAction();
action->setText(tr("Show Mag"));
viewMenu->addAction(action);
m_mainToolBar->addSeparator();
- tmp = initAction(
- new QAction(this),
- tr("Search in &open works..."),
- CResMgr::mainMenu::mainIndex::search::icon,
- CResMgr::mainMenu::mainIndex::search::accel,
- tr("Search in all works that are currently open"),
- SLOT( slotSearchModules() )
- );
+ tmp = m_actionCollection->action("searchOpenWorks");
searchMenu->addAction(tmp);
m_mainToolBar->addAction(tmp);
m_mainToolBar->addSeparator();
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotSearchModules()) );
- searchMenu->addAction(initAction(
- new QAction(this),
- tr("Search in standard &Bible..."),
- CResMgr::mainMenu::mainIndex::searchdefaultbible::icon,
- CResMgr::mainMenu::mainIndex::searchdefaultbible::accel,
- tr("Search in the standard Bible"),
- SLOT(slotSearchDefaultBible())));
+ tmp = m_actionCollection->action("searchStdBible");
+ searchMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotSearchDefaultBible()) );
m_windowSaveProfileMenu = new QMenu(tr("&Save session"));
m_windowMenu->addMenu(m_windowSaveProfileMenu);
- m_windowSaveToNewProfile_action = new QAction(this);
- m_windowMenu->addAction(initAction(
- m_windowSaveToNewProfile_action,
- tr("Save as &new session..."),
- CResMgr::mainMenu::window::saveToNewProfile::icon,
- CResMgr::mainMenu::window::saveToNewProfile::accel,
- tr("Create and save a new session"),
- SLOT( saveToNewProfile() ))
- );
+ m_windowSaveToNewProfile_action = m_actionCollection->action("saveNewSession");
+ m_windowMenu->addAction(m_windowSaveToNewProfile_action);
+ connect(m_windowSaveToNewProfile_action, SIGNAL(triggered()), this, SLOT(saveToNewProfile()) );
+
m_windowLoadProfileMenu = new QMenu(tr("&Load session"));
m_windowMenu->addMenu(m_windowLoadProfileMenu);
@@ -210,146 +312,74 @@ void BibleTime::initActions()
QMenu* arrangementMenu = new QMenu(tr("&Arrangement mode"));
m_windowMenu->addMenu(arrangementMenu);
- m_windowManualMode_action = new QAction(this);
+ m_windowManualMode_action = m_actionCollection->action("manualArrangement");
m_windowManualMode_action->setCheckable(true);
- arrangementMenu->addAction(initAction(
- m_windowManualMode_action,
- tr("&Manual mode"),
- CResMgr::mainMenu::window::arrangementMode::manual::icon,
- CResMgr::mainMenu::window::arrangementMode::manual::accel,
- "",
- SLOT( slotManualArrangementMode() ))
- );
-
- m_windowAutoTileVertical_action = new QAction(this);
- m_windowAutoTileVertical_action->setCheckable(true);
+ arrangementMenu->addAction(m_windowManualMode_action);
+ connect(m_windowManualMode_action, SIGNAL(triggered()), this, SLOT(slotManualArrangementMode()) );
+
//: Vertical tiling means that windows are vertical, placed side by side
- arrangementMenu->addAction(initAction(
- m_windowAutoTileVertical_action,
- tr("Auto-tile &vertically"),
- CResMgr::mainMenu::window::arrangementMode::autoTileVertical::icon,
- CResMgr::mainMenu::window::arrangementMode::autoTileVertical::accel,
- tr("Automatically tile the open windows vertically (arrange side by side)"),
- SLOT( slotAutoTileVertical() ))
- );
-
- m_windowAutoTileHorizontal_action = new QAction(this);
+ m_windowAutoTileVertical_action = m_actionCollection->action("autoVertical");
+ m_windowAutoTileVertical_action->setCheckable(true);
+ arrangementMenu->addAction(m_windowAutoTileVertical_action);
+ connect(m_windowAutoTileVertical_action, SIGNAL(triggered()), this, SLOT(slotAutoTileVertical()) );
+
+ //: Horizontal tiling means that windows are horizontal, placed on top of each other
+ m_windowAutoTileHorizontal_action = m_actionCollection->action("autoHorizontal");
m_windowAutoTileHorizontal_action->setCheckable(true);
- arrangementMenu->addAction(initAction(
- m_windowAutoTileHorizontal_action,
- //: Horizontal tiling means that windows are horizontal, placed on top of each other
- tr("Auto-tile &horizontally"),
- CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::icon,
- CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::accel,
- tr("Automatically tile the open windows horizontally (arrange on top of each other)"),
- SLOT( slotAutoTileHorizontal() ))
- );
-
- m_windowAutoCascade_action = new QAction(this);
+ arrangementMenu->addAction(m_windowAutoTileHorizontal_action);
+ connect(m_windowAutoTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotAutoTileHorizontal()) );
+
+ m_windowAutoCascade_action = m_actionCollection->action("autoCascade");
m_windowAutoCascade_action->setCheckable(true);
- arrangementMenu->addAction(initAction(
- m_windowAutoCascade_action,
- //: Cascading means that only one window is visible, others are behind that
- tr("Auto-&cascade"),
- CResMgr::mainMenu::window::arrangementMode::autoCascade::icon,
- CResMgr::mainMenu::window::arrangementMode::autoCascade::accel,
- tr("Automatically cascade the open windows"),
- SLOT( slotAutoCascade() ))
- );
-
- m_windowCascade_action = new QAction(this);
- m_windowMenu->addAction(initAction(
- m_windowCascade_action,
- tr("&Cascade"),
- CResMgr::mainMenu::window::cascade::icon,
- CResMgr::mainMenu::window::cascade::accel,
- tr("Cascade the open windows"),
- SLOT( slotCascade() ))
- );
-
- m_windowTileVertical_action = new QAction(this);
- m_windowMenu->addAction(initAction(
- m_windowTileVertical_action,
- tr("Tile &vertically"),
- CResMgr::mainMenu::window::tileVertical::icon,
- CResMgr::mainMenu::window::tileVertical::accel,
- tr("Vertically tile (arrange side by side) the open windows"),
- SLOT( slotTileVertical() ))
- );
-
- m_windowTileHorizontal_action = new QAction(this);
- m_windowMenu->addAction(initAction(
- m_windowTileHorizontal_action,
- tr("Tile &horizontally"),
- CResMgr::mainMenu::window::tileHorizontal::icon,
- CResMgr::mainMenu::window::tileHorizontal::accel,
- tr("Horizontally tile (arrange on top of each other) the open windows"),
- SLOT( slotTileHorizontal() ))
- );
-
- m_windowCloseAll_action = new QAction(this);
- m_windowMenu->addAction(initAction(
- m_windowCloseAll_action,
- tr("Cl&ose all windows"),
- CResMgr::mainMenu::window::closeAll::icon,
- CResMgr::mainMenu::window::closeAll::accel,
- tr("Close all open windows inside BibleTime"),
- 0)
- );
- QObject::connect(m_windowCloseAll_action, SIGNAL(triggered()), m_mdi, SLOT( deleteAll() ) );
-
- settingsMenu->addAction(initAction(
- new QAction(this),
- tr("&Configure BibleTime..."),
- "configure.svg",
- QKeySequence(),
- tr("Set BibleTime's preferences"),
- SLOT( slotSettingsOptions() )));
+ arrangementMenu->addAction(m_windowAutoCascade_action);
+ connect(m_windowAutoCascade_action, SIGNAL(triggered()), this, SLOT(slotAutoCascade()) );
+
+ m_windowCascade_action = m_actionCollection->action("cascade");
+ m_windowMenu->addAction(m_windowCascade_action);
+ connect(m_windowCascade_action, SIGNAL(triggered()), this, SLOT(slotCascade()) );
+
+ m_windowTileVertical_action = m_actionCollection->action("tileVertically");
+ m_windowMenu->addAction(m_windowTileVertical_action);
+ connect(m_windowTileVertical_action, SIGNAL(triggered()), this, SLOT(slotTileVertical()) );
+
+ m_windowTileHorizontal_action = m_actionCollection->action("tileHorizontally");
+ m_windowMenu->addAction(m_windowTileHorizontal_action);
+ connect(m_windowTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotTileHorizontal()) );
+
+ m_windowCloseAll_action = m_actionCollection->action("closeAllWindows");
+ m_windowMenu->addAction(m_windowCloseAll_action);
+ connect(m_windowCloseAll_action, SIGNAL(triggered()), m_mdi, SLOT(deleteAll()));
+
+
+ tmp = m_actionCollection->action("setPreferences");
+ settingsMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotSettingsOptions()) );
+
settingsMenu->addSeparator();
- settingsMenu->addAction(initAction(
- new QAction(this),
- tr("Bookshelf &Manager..."),
- CResMgr::mainMenu::settings::swordSetupDialog::icon,
- CResMgr::mainMenu::settings::swordSetupDialog::accel,
- tr("Configure your bookshelf and install/update/remove/index works"),
- SLOT( slotSwordSetupDialog() )));
-
- tmp = initAction(
- new QAction(this),
- tr("&Handbook"),
- CResMgr::mainMenu::help::handbook::icon,
- CResMgr::mainMenu::help::handbook::accel,
- tr("Open BibleTime's handbook"),
- SLOT( openOnlineHelp_Handbook() )
- );
+ tmp = m_actionCollection->action("bookshelfManager");
+ settingsMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotSwordSetupDialog()) );
+
+ tmp = m_actionCollection->action("openHandbook");
helpMenu->addAction(tmp);
m_mainToolBar->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(openOnlineHelp_Handbook()) );
+
+ tmp = m_actionCollection->action("bibleStudyHowto");
+ helpMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(openOnlineHelp_Howto()) );
- helpMenu->addAction(initAction(
- new QAction(this),
- //: "Howto" is a guide; if there's no natural translation for HowTo, translate it as Guide
- tr("&Bible Study Howto"),
- CResMgr::mainMenu::help::bibleStudyHowTo::icon,
- CResMgr::mainMenu::help::bibleStudyHowTo::accel,
- 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."),
- SLOT( openOnlineHelp_Howto() ))
- );
-
helpMenu->addSeparator();
- helpMenu->addAction( initAction(
- new QAction(this),
- tr("&About BibleTime"),
- "",
- QKeySequence(),
- "",
- SLOT(slotOpenAboutDialog()))
- );
+ tmp = m_actionCollection->action("aboutBibleTime");
+ helpMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotOpenAboutDialog()) );
}
/** Initializes the SIGNAL / SLOT connections */
-void BibleTime::initConnections() {
+void BibleTime::initConnections()
+{
QObject::connect(m_mdi, SIGNAL(sigSetToplevelCaption(const QString&)),
this, SLOT(setPlainCaption(const QString&)));
QObject::connect(m_mdi, SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
@@ -377,7 +407,8 @@ void BibleTime::initConnections() {
}
/** Initializes the backend */
-void BibleTime::initBackends() {
+void BibleTime::initBackends()
+{
qDebug("BibleTime::initBackends");
sword::StringMgr::setSystemStringMgr( new BTStringMgr() );
@@ -389,12 +420,7 @@ void BibleTime::initBackends() {
CPointers::setBackend(backend);
const CSwordBackend::LoadError errorCode = CPointers::backend()->initModules(CSwordBackend::OtherChange);
- m_moduleList = 0;
- if ( errorCode == CSwordBackend::NoError ) { //no error
- m_moduleList = &(CPointers::backend()->moduleList());
- }
- else {
- m_moduleList = 0;
+ if (errorCode != CSwordBackend::NoError) {
//show error message that initBackend failed
//TODO:
// switch (errorCode) {
@@ -438,7 +464,8 @@ void BibleTime::initBackends() {
}
-void BibleTime::applyProfileSettings( CProfile* p ) {
+void BibleTime::applyProfileSettings( CProfile* p )
+{
qDebug("BibleTime::applyProfileSettings");
Q_ASSERT(p);
if (!p) return;
@@ -463,7 +490,8 @@ void BibleTime::applyProfileSettings( CProfile* p ) {
}
}
-void BibleTime::storeProfileSettings( CProfile* p ) {
+void BibleTime::storeProfileSettings( CProfile* p )
+{
Q_ASSERT(p && m_windowFullscreen_action);
if (!p || !m_windowFullscreen_action) return;
diff --git a/src/bibletime_slots.cpp b/src/bibletime_slots.cpp
index 3e054af..471c96f 100644
--- a/src/bibletime_slots.cpp
+++ b/src/bibletime_slots.cpp
@@ -69,21 +69,30 @@ using namespace Profile;
// };
/** Opens the optionsdialog of BibleTime. */
-void BibleTime::slotSettingsOptions() {
+void BibleTime::slotSettingsOptions()
+{
qDebug("BibleTime::slotSettingsOptions");
- CConfigurationDialog *dlg = new CConfigurationDialog(this, 0 /*actionCollection()*/);
+ CConfigurationDialog *dlg = new CConfigurationDialog(this, m_actionCollection);
QObject::connect(dlg, SIGNAL(signalSettingsChanged()), this, SLOT(slotSettingsChanged()) );
dlg->show();
}
+/** Save the settings, used when no settings have been saved before **/
+void BibleTime::saveConfigSettings()
+{
+ CConfigurationDialog* dlg = new CConfigurationDialog(this, 0);
+ dlg->save();
+ delete dlg;
+}
+
/** Is called when settings in the optionsdialog were changed (ok or apply) */
-void BibleTime::slotSettingsChanged() {
+void BibleTime::slotSettingsChanged()
+{
qDebug("BibleTime::slotSettingsChanged");
- const QString language = CBTConfig::get
- (CBTConfig::language);
- //m_backend->booknameLanguage(language);
+ const QString language = CBTConfig::get(CBTConfig::language);
CPointers::backend()->booknameLanguage(language);
+
// TODO: update the bookmarks after Bible bookname language has been changed
// QTreeWidgetItemIterator it(m_mainIndex);
// while (*it) {
@@ -94,13 +103,15 @@ void BibleTime::slotSettingsChanged() {
// ++it;
// }
+ refreshBibleTimeAccel();
refreshDisplayWindows();
refreshProfileMenus();
qDebug("BibleTime::slotSettingsChanged");
}
/** Opens the sword setup dialog of BibleTime. */
-void BibleTime::slotSwordSetupDialog() {
+void BibleTime::slotSwordSetupDialog()
+{
//TODO: nonmodal dialog, memory management (one instance only!
//BtModuleManagerDialog *dlg = new BtModuleManagerDialog(this);
BtModuleManagerDialog* dlg = BtModuleManagerDialog::getInstance(this);
@@ -115,7 +126,8 @@ void BibleTime::slotSwordSetupDialog() {
}
/** Is called when settings in the sword setup dialog were changed (ok or apply) */
-void BibleTime::slotSwordSetupChanged() {
+void BibleTime::slotSwordSetupChanged()
+{
/*
Refresh everything here what might have changed
these are the mainindex, the searchdialog, the displaywindows
@@ -140,41 +152,48 @@ void BibleTime::slotSwordSetupChanged() {
}
/** Is called just before the window menu is ahown. */
-void BibleTime::slotWindowMenuAboutToShow() {
+void BibleTime::slotWindowMenuAboutToShow()
+{
Q_ASSERT(m_windowMenu);
- if (!m_windowMenu) {
+ if (!m_windowMenu)
+ {
return;
}
- if ( m_mdi->subWindowList().isEmpty() ) {
+ if ( m_mdi->subWindowList().isEmpty() )
+ {
m_windowCascade_action->setEnabled(false);
m_windowTileVertical_action->setEnabled(false);
m_windowTileHorizontal_action->setEnabled(false);
m_windowCloseAll_action->setEnabled(false);
}
- else if (m_mdi->subWindowList().count() == 1) {
+ else if (m_mdi->subWindowList().count() == 1)
+ {
m_windowTileVertical_action->setEnabled( false );
m_windowTileHorizontal_action->setEnabled( false );
m_windowCascade_action->setEnabled( false );
m_windowCloseAll_action->setEnabled( true );
// m_windowMenu->insertSeparator();
}
- else {
+ else
+ {
slotUpdateWindowArrangementActions(0); //update the window tile/cascade states
m_windowCloseAll_action->setEnabled( true );
}
- QList<QAction*>::iterator end = m_windowOpenWindowsList.end();
- for (QList<QAction*>::iterator it = m_windowOpenWindowsList.begin(); it != end; ++it ) {
+ // QList<QAction*>::iterator end = m_windowOpenWindowsList.end();
+ // for (QList<QAction*>::iterator it = m_windowOpenWindowsList.begin(); it != end; ++it )
+ // {
//(*it)->unplugAll(); //see kde porting doc
- foreach (QWidget *w, (*it)->associatedWidgets() ) {
- w->removeAction(*it);
- }
- }
+ // foreach (QWidget *w, (*it)->associatedWidgets() )
+ // {
+ // w->removeAction(*it);
+ // }
+ // }
//m_windowOpenWindowsList.setAutoDelete(true);
- qDeleteAll(m_windowOpenWindowsList);
- m_windowOpenWindowsList.clear();
+ // qDeleteAll(m_windowOpenWindowsList);
+ // m_windowOpenWindowsList.clear();
// if (!m_windowActionCollection) {
// m_windowActionCollection = new KActionCollection(this, KComponentData());
@@ -197,7 +216,8 @@ void BibleTime::slotWindowMenuAboutToShow() {
}
/** This slot is connected with the windowAutoTile_action object */
-void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction ) {
+void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction )
+{
/* If a toggle action was clicked we see if it checked ot unchecked and
* enable/disable the simple cascade and tile options accordingly
*/
@@ -205,7 +225,8 @@ void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction ) {
m_windowTileHorizontal_action->setEnabled( m_windowManualMode_action->isChecked() );
m_windowCascade_action->setEnabled( m_windowManualMode_action->isChecked() );
- if (clickedAction) {
+ if (clickedAction)
+ {
m_windowManualMode_action->setEnabled(
m_windowManualMode_action != clickedAction
&& m_windowTileHorizontal_action != clickedAction
@@ -217,81 +238,97 @@ void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction ) {
m_windowAutoCascade_action->setEnabled( m_windowAutoCascade_action != clickedAction );
}
- if (clickedAction == m_windowManualMode_action) {
+ if (clickedAction == m_windowManualMode_action)
+ {
m_windowAutoTileVertical_action->setChecked(false);
m_windowAutoTileHorizontal_action->setChecked(false);
m_windowAutoCascade_action->setChecked(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
}
- else if (clickedAction == m_windowAutoTileVertical_action) {
+ else if (clickedAction == m_windowAutoTileVertical_action)
+ {
m_windowManualMode_action->setChecked(false);
m_windowAutoTileHorizontal_action->setChecked(false);
m_windowAutoCascade_action->setChecked(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileVertical );
}
- else if (clickedAction == m_windowAutoTileHorizontal_action) {
+ else if (clickedAction == m_windowAutoTileHorizontal_action)
+ {
m_windowManualMode_action->setChecked(false);
m_windowAutoTileVertical_action->setChecked(false);
m_windowAutoCascade_action->setChecked(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileHorizontal );
}
- else if (clickedAction == m_windowAutoCascade_action) {
+ else if (clickedAction == m_windowAutoCascade_action)
+ {
m_windowManualMode_action->setChecked(false);
m_windowAutoTileHorizontal_action->setChecked(false);
m_windowAutoTileVertical_action->setChecked(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeCascade );
}
- else if (clickedAction == m_windowCascade_action) {
+ else if (clickedAction == m_windowCascade_action)
+ {
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
m_mdi->myCascade();
}
- else if (clickedAction == m_windowTileVertical_action) {
+ else if (clickedAction == m_windowTileVertical_action)
+ {
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
m_mdi->myTileVertical();
}
- else if (clickedAction == m_windowTileHorizontal_action) {
+ else if (clickedAction == m_windowTileHorizontal_action)
+ {
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
m_mdi->myTileHorizontal();
}
}
-void BibleTime::slotManualArrangementMode() {
+void BibleTime::slotManualArrangementMode()
+{
slotUpdateWindowArrangementActions( m_windowManualMode_action );
}
/** This slot is connected with the windowAutoTile_action object */
-void BibleTime::slotAutoTileHorizontal() {
+void BibleTime::slotAutoTileHorizontal()
+{
slotUpdateWindowArrangementActions( m_windowAutoTileHorizontal_action );
}
/** This slot is connected with the windowAutoTile_action object */
-void BibleTime::slotAutoTileVertical() {
+void BibleTime::slotAutoTileVertical()
+{
slotUpdateWindowArrangementActions( m_windowAutoTileVertical_action );
}
-void BibleTime::slotCascade() {
+void BibleTime::slotCascade()
+{
slotUpdateWindowArrangementActions( m_windowCascade_action );
}
-void BibleTime::slotTileVertical() {
+void BibleTime::slotTileVertical()
+{
slotUpdateWindowArrangementActions( m_windowTileVertical_action );
}
-void BibleTime::slotTileHorizontal() {
+void BibleTime::slotTileHorizontal()
+{
slotUpdateWindowArrangementActions( m_windowTileHorizontal_action );
}
/** This slot is connected with the windowAutoCascade_action object */
-void BibleTime::slotAutoCascade() {
+void BibleTime::slotAutoCascade()
+{
slotUpdateWindowArrangementActions( m_windowAutoCascade_action );
}
-void BibleTime::slotWindowMenuActivated() {
- if (!m_windowMenu) {
+void BibleTime::slotWindowMenuActivated()
+{
+ if (!m_windowMenu)
+ {
return;
}
@@ -307,22 +344,28 @@ void BibleTime::slotWindowMenuActivated() {
}
/** Shows/hides the toolbar */
-void BibleTime::slotToggleToolbar() {
+void BibleTime::slotToggleToolbar()
+{
Q_ASSERT(m_mainToolBar);
- if (m_viewToolbar_action->isChecked()) {
+ if (m_viewToolbar_action->isChecked())
+ {
m_mainToolBar->show();
}
- else {
+ else
+ {
m_mainToolBar->hide();
}
}
-void BibleTime::slotSearchModules() {
+void BibleTime::slotSearchModules()
+{
//get the modules of the open windows
QList<CSwordModuleInfo*> modules;
- foreach(QMdiSubWindow* subWindow, m_mdi->subWindowList()){
- if (CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget())) {
+ foreach(QMdiSubWindow* subWindow, m_mdi->subWindowList())
+ {
+ if (CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget()))
+ {
modules << w->modules();
}
}
@@ -332,10 +375,12 @@ void BibleTime::slotSearchModules() {
/* Search default Bible slot
* Call CSearchDialog::openDialog with only the default bible module
*/
-void BibleTime::slotSearchDefaultBible() {
+void BibleTime::slotSearchDefaultBible()
+{
QList<CSwordModuleInfo*> module;
CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
- if (bible) {
+ if (bible)
+ {
module.append(bible);
}
Search::CSearchDialog::openDialog(module, QString::null);
@@ -360,30 +405,36 @@ void BibleTime::slotOpenAboutDialog()
}
/** Saves the current settings into the currently activated profile. */
-void BibleTime::saveProfile(QAction* action) {
+void BibleTime::saveProfile(QAction* action)
+{
m_mdi->setUpdatesEnabled(false);
const QString profileName = action->text().remove("&");
CProfile* p = m_profileMgr.profile( profileName );
Q_ASSERT(p);
- if ( p ) {
+ if ( p )
+ {
saveProfile(p);
}
m_mdi->setUpdatesEnabled(true);
}
-void BibleTime::saveProfile(CProfile* profile) {
- if (!profile) {
+void BibleTime::saveProfile(CProfile* profile)
+{
+ if (!profile)
+ {
return;
}
//save mainwindow settings
storeProfileSettings(profile);
QList<CProfileWindow*> profileWindows;
- foreach (QMdiSubWindow* w, m_mdi->subWindowList()) {
+ foreach (QMdiSubWindow* w, m_mdi->subWindowList())
+ {
CDisplayWindow* displayWindow = dynamic_cast<CDisplayWindow*>(w->widget());
- if (!displayWindow) {
+ if (!displayWindow)
+ {
continue;
}
@@ -399,18 +450,22 @@ void BibleTime::saveProfile(CProfile* profile) {
profileWindows.clear();
}
-void BibleTime::loadProfile(QAction* action) {
+void BibleTime::loadProfile(QAction* action)
+{
const QString profileName = action->text().remove("&");
CProfile* p = m_profileMgr.profile( profileName );
Q_ASSERT(p);
- if ( p ) {
+ if ( p )
+ {
m_mdi->deleteAll();
loadProfile(p);
}
}
-void BibleTime::loadProfile(CProfile* p) {
- if (!p) return;
+void BibleTime::loadProfile(CProfile* p)
+{
+ if (!p)
+ return;
QList<CProfileWindow*> windows = p->load();
@@ -422,31 +477,39 @@ void BibleTime::loadProfile(CProfile* p) {
QWidget* focusWindow = 0;
// for (CProfileWindow* w = windows.last(); w; w = windows.prev()) { //from the last one to make sure the order is right in the mdi area
- foreach (CProfileWindow* w, windows) {
+ foreach (CProfileWindow* w, windows)
+ {
const QString key = w->key();
QStringList usedModules = w->modules();
QList<CSwordModuleInfo*> modules;
- for ( QStringList::Iterator it = usedModules.begin(); it != usedModules.end(); ++it ) {
- if (CSwordModuleInfo* m = CPointers::backend()->findModuleByName(*it)) {
+ for ( QStringList::Iterator it = usedModules.begin(); it != usedModules.end(); ++it )
+ {
+ if (CSwordModuleInfo* m = CPointers::backend()->findModuleByName(*it))
+ {
modules.append(m);
}
}
- if (!modules.count()) { //are the modules still installed? If not continue wih next session window
+ if (!modules.count())
+ { //are the modules still installed? If not continue wih next session window
continue;
}
//is w->isWriteWindow is false we create a write window, otherwise a read window
CDisplayWindow* displayWindow = 0;
- if (w->writeWindowType() > 0) { //create a write window
+ if (w->writeWindowType() > 0)
+ { //create a write window
displayWindow = createWriteDisplayWindow(modules.first(), key, CDisplayWindow::WriteWindowType(w->writeWindowType()) );
}
- else { //create a read window
+ else
+ { //create a read window
displayWindow = createReadDisplayWindow(modules, key);
}
- if (displayWindow) { //if a window was created initialize it.
- if (w->hasFocus()) {
+ if (displayWindow)
+ { //if a window was created initialize it.
+ if (w->hasFocus())
+ {
focusWindow = displayWindow;
}
@@ -457,12 +520,14 @@ void BibleTime::loadProfile(CProfile* p) {
m_mdi->setUpdatesEnabled(true);
m_mdi->triggerWindowUpdate();
- if (focusWindow) {
+ if (focusWindow)
+ {
focusWindow->setFocus();
}
}
-void BibleTime::deleteProfile(QAction* action) {
+void BibleTime::deleteProfile(QAction* action)
+{
//HACK: work around the inserted & char by KPopupMenu
const QString profileName = action->text().remove("&");
CProfile* p = m_profileMgr.profile( profileName );
@@ -471,16 +536,20 @@ void BibleTime::deleteProfile(QAction* action) {
refreshProfileMenus();
}
-void BibleTime::toggleFullscreen() {
+void BibleTime::toggleFullscreen()
+{
m_windowFullscreen_action->isChecked() ? showFullScreen() : showNormal();
m_mdi->triggerWindowUpdate();
}
/** Saves current settings into a new profile. */
-void BibleTime::saveToNewProfile() {
+void BibleTime::saveToNewProfile()
+{
bool ok = false;
- const QString name = QInputDialog::getText(this, tr("New Session"), tr("Please enter a name for the new session."), QLineEdit::Normal, QString::null, &ok);
- if (ok && !name.isEmpty()) {
+ const QString name = QInputDialog::getText(this, tr("New Session"),
+ tr("Please enter a name for the new session."), QLineEdit::Normal, QString::null, &ok);
+ if (ok && !name.isEmpty())
+ {
CProfile* profile = m_profileMgr.create(name);
saveProfile(profile);
}
@@ -488,7 +557,8 @@ void BibleTime::saveToNewProfile() {
}
/** Slot to refresh the save profile and load profile menus. */
-void BibleTime::refreshProfileMenus() {
+void BibleTime::refreshProfileMenus()
+{
m_windowSaveProfileMenu->clear();
m_windowLoadProfileMenu->clear();
m_windowDeleteProfileMenu->clear();
@@ -502,7 +572,8 @@ void BibleTime::refreshProfileMenus() {
m_windowLoadProfileMenu->setEnabled(enableActions);
m_windowDeleteProfileMenu->setEnabled(enableActions);
- foreach (CProfile* p, profiles) {
+ foreach (CProfile* p, profiles)
+ {
m_windowSaveProfileMenu->addAction(p->name());
m_windowLoadProfileMenu->addAction(p->name());
m_windowDeleteProfileMenu->addAction(p->name());
diff --git a/src/bibletimeapp.h b/src/bibletimeapp.h
index b4036a3..74f0ea5 100644
--- a/src/bibletimeapp.h
+++ b/src/bibletimeapp.h
@@ -20,8 +20,8 @@
*/
class BibleTimeApp : public QApplication, public CPointers {
public:
- BibleTimeApp( int & argc, char ** argv );
- virtual ~BibleTimeApp();
+ BibleTimeApp(int &argc, char **argv);
+ ~BibleTimeApp();
protected:
// void initDCOP();
diff --git a/src/display-templates/Blue.tmpl b/src/display-templates/Blue.tmpl
index 881ce1c..df78897 100644
--- a/src/display-templates/Blue.tmpl
+++ b/src/display-templates/Blue.tmpl
@@ -11,6 +11,10 @@
/* <![CDATA[ */
#LANG_CSS#
+body {
+ background-color: white;
+ color: black;
+}
#content {
margin:10px;
}
diff --git a/src/display-templates/Crazy.tmpl b/src/display-templates/Crazy.tmpl
index df3133c..1ef3bff 100644
--- a/src/display-templates/Crazy.tmpl
+++ b/src/display-templates/Crazy.tmpl
@@ -11,6 +11,8 @@
<style type="text/css">
/* <![CDATA[ */
body {
+ background-color: white;
+ color: black;
margin:0px;
padding:0;
padding:1em;
diff --git a/src/display-templates/Green.tmpl b/src/display-templates/Green.tmpl
index 8dda232..f0d433d 100644
--- a/src/display-templates/Green.tmpl
+++ b/src/display-templates/Green.tmpl
@@ -10,6 +10,10 @@
<style type="text/css">
/* <![CDATA[ */
+body {
+ background-color: white;
+ color: black;
+}
#content {
margin:10px;
}
diff --git a/src/display-templates/HighContrast.tmpl b/src/display-templates/HighContrast.tmpl
index 820e832..f70590a 100644
--- a/src/display-templates/HighContrast.tmpl
+++ b/src/display-templates/HighContrast.tmpl
@@ -15,9 +15,12 @@
/* background-color:white; #this seems to break*/
}
+body {
+ background-color: white;
+ color: black;
+}
#content {
- background-color:white;
- margin:10px;
+ margin: 10px;
}
#content > table {
margin: 0;
diff --git a/src/display-templates/Simple.tmpl b/src/display-templates/Simple.tmpl
index 9d9e6c8..756de3e 100644
--- a/src/display-templates/Simple.tmpl
+++ b/src/display-templates/Simple.tmpl
@@ -10,10 +10,11 @@
<style type="text/css">
/* <![CDATA[ */
body {
- margin:5px;
+ background-color: white;
+ color: black;
}
#content {
- background-color:white;
+ margin: 5px;
}
#content table {
margin:0;
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp
index d0bc760..976250f 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.cpp
+++ b/src/frontend/bookshelfmanager/btinstallmgr.cpp
@@ -34,10 +34,6 @@ BtInstallMgr::BtInstallMgr()
{ //use this class also as status reporter
qDebug("BtInstallMgr::BtInstallMgr");
this->setFTPPassive(true);
-#ifdef SWORD_INTERNET_WARNING
- // this was in 1.6RC1, removed in RC2. To be removed from here soon - uncomment this and comment out the isUserDisclaimerConfirmed if you need to use RC1.
- //setUserDisclaimerConfirmed(true);
-#endif
}
BtInstallMgr::~BtInstallMgr() {
@@ -45,14 +41,12 @@ BtInstallMgr::~BtInstallMgr() {
terminate(); //make sure to close the connection
}
-#ifdef SWORD_INTERNET_WARNING
bool BtInstallMgr::isUserDisclaimerConfirmed() const
{
// TODO: Check from config if it's been confirmed with "don't show this anymore" checked.
// Create a dialog with the message, checkbox and Continue/Cancel, Cancel as default.
return true;
}
-#endif
void BtInstallMgr::statusUpdate(double dltotal, double dlnow)
{
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.h b/src/frontend/bookshelfmanager/btinstallmgr.h
index 5607981..1420079 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.h
+++ b/src/frontend/bookshelfmanager/btinstallmgr.h
@@ -41,10 +41,8 @@ public:
*/
void slotRefreshCanceled();
-#ifdef SWORD_INTERNET_WARNING
/** Re-implemented from sword::InstallMgr. */
virtual bool isUserDisclaimerConfirmed() const;
-#endif
protected:
/* Reimplementations of methods in StatusReporter */
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
index 5e3dc41..c26de6f 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
@@ -16,6 +16,7 @@
#include "util/cpointers.h"
#include "util/dialogutil.h"
#include "backend/managers/cswordbackend.h"
+#include "backend/config/cbtconfig.h"
#include <QDialogButtonBox>
@@ -57,10 +58,13 @@ BtModuleManagerDialog::BtModuleManagerDialog(QWidget* parent)
util::prepareDialogBox(bbox);
addButtonBox(bbox);
connect(bbox, SIGNAL(rejected()), SLOT(close()));
+
+ loadDialogSettings();
}
BtModuleManagerDialog::~BtModuleManagerDialog()
{
+ saveDialogSettings();
m_staticModuleManagerDialog = 0;
}
@@ -70,4 +74,16 @@ void BtModuleManagerDialog::closeEvent(QCloseEvent*)
qDebug("BtModuleManagerDialog::closeEvent");
}
+void BtModuleManagerDialog::loadDialogSettings()
+{
+ resize(CBTConfig::get(CBTConfig::bookshelfWidth), CBTConfig::get(CBTConfig::bookshelfHeight));
+ move(CBTConfig::get(CBTConfig::bookshelfPosX), CBTConfig::get(CBTConfig::bookshelfPosY));
+}
+void BtModuleManagerDialog::saveDialogSettings()
+{
+ CBTConfig::set(CBTConfig::bookshelfWidth, size().width());
+ CBTConfig::set(CBTConfig::bookshelfHeight, size().height());
+ CBTConfig::set(CBTConfig::bookshelfPosX, x());
+ CBTConfig::set(CBTConfig::bookshelfPosY, y());
+}
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
index 52c3e71..ffb7169 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
@@ -30,11 +30,20 @@ public:
//void slotClose();
protected:
- /** Reimplementation from QWidget. */
+ /** Reimplementation from QWidget. */
virtual void closeEvent(QCloseEvent* event);
+
/** Adds the pages and the button box. */
BtModuleManagerDialog(QWidget* parent);
+private:
+ // Load the settings from the resource file
+ void loadDialogSettings();
+
+ // Save the settings to the resource file
+ void saveDialogSettings();
+
+
//signals:
// void swordSetupChanged();
};
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index 6c45f9c..8b2b335 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -21,7 +21,6 @@
#include "backend/managers/cswordbackend.h"
//Qt includes
-#include <QString>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTreeWidget>
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
index adab4fa..d2570ff 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
@@ -30,9 +30,7 @@ BtInstallThread::BtInstallThread(QObject* parent, QString moduleName, QString so
m_module(moduleName),
m_destination(destinationName),
m_source(sourceName),
- m_cancelled(false),
- m_installSource(instbackend::source(sourceName)),
- m_backendForSource(instbackend::backend(m_installSource))
+ m_cancelled(false)
{
m_iMgr = new BtInstallMgr();
}
@@ -50,6 +48,9 @@ void BtInstallThread::run()
emit preparingInstall(m_module, m_source);
+ m_installSource.reset(new sword::InstallSource(instbackend::source(m_source)));
+ m_backendForSource.reset(instbackend::backend(*m_installSource));
+
//make sure target/mods.d and target/modules exist
//TODO: move this to some common precondition
QDir dir(m_destination);
@@ -76,9 +77,9 @@ void BtInstallThread::run()
// manager for the destination path
sword::SWMgr lMgr( m_destination.toLatin1() );
- if (instbackend::isRemote(m_installSource)) {
+ if (instbackend::isRemote(*m_installSource)) {
qDebug() << "calling install";
- int status = m_iMgr->installModule(&lMgr, 0, m_module.toLatin1(), &m_installSource);
+ int status = m_iMgr->installModule(&lMgr, 0, m_module.toLatin1(), m_installSource.get());
if (status != 0) {
qWarning() << "Error with install: " << status << "module:" << m_module;
}
@@ -89,7 +90,7 @@ void BtInstallThread::run()
}
else { //local source
emit statusUpdated(m_module, 0);
- int status = m_iMgr->installModule(&lMgr, m_installSource.directory.c_str(), m_module.toLatin1());
+ int status = m_iMgr->installModule(&lMgr, m_installSource->directory.c_str(), m_module.toLatin1());
if (status > 0) {
qWarning() << "Error with install: " << status << "module:" << m_module;
}
@@ -188,7 +189,7 @@ void BtInstallThread::removeTempFiles()
// take the absolute path of the InstallMgr)
//sword::InstallSource is = instbackend::source(m_source);
- if (instbackend::isRemote(m_installSource)) {
+ if (instbackend::isRemote(*m_installSource)) {
// get the path for the module temp files
CSwordModuleInfo* mInfo = m_backendForSource->findModuleByName(m_module);
QString dataPath = mInfo->config(CSwordModuleInfo::AbsoluteDataPath);
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.h b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
index d10db95..a9a998a 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
@@ -77,9 +77,8 @@ protected:
QString m_source;
bool m_cancelled;
BtInstallMgr* m_iMgr;
- //sword::InstallSource m_installSource;
//BtInstallMgr m_iMgr;
- sword::InstallSource m_installSource;
+ boost::scoped_ptr<sword::InstallSource> m_installSource;
//TODO: it would be best to get the backend from the bookshelf manager install page
// where it has already been created. Could fasten the progress dialog startup.
boost::scoped_ptr<CSwordBackend> m_backendForSource;
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp b/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
index 2f8de1a..45bfe0f 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
@@ -195,7 +195,7 @@ void BtSourceArea::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem
//state: installable (no indicator)
//else: status: newly added, color yellow
} else { // the module is already installed
- QBrush bg(QColor(255,153,153));
+ QBrush bg(QColor(255,153,153)); /// \bug Possible color conflict
widgetItem->setBackground(0, bg);
widgetItem->setBackground(1, bg);
installedV = QString(installedModule->config(CSwordModuleInfo::ModuleVersion).toLatin1());
diff --git a/src/frontend/cinfodisplay.cpp b/src/frontend/cinfodisplay.cpp
index a8ad60d..ff93287 100644
--- a/src/frontend/cinfodisplay.cpp
+++ b/src/frontend/cinfodisplay.cpp
@@ -44,6 +44,7 @@ namespace InfoDisplay {
CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent)
{
QVBoxLayout* layout = new QVBoxLayout(this);
+ layout->setContentsMargins(2, 2, 2, 2); // Leave small border
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
m_htmlPart = CDisplay::createReadInstance(0, this);
@@ -61,8 +62,22 @@ CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent)
);
layout->addWidget(m_htmlPart->view());
- QString initialMagText = tr("<small>This is the Mag viewer area. Hover the mouse over links or other items which include some data and the contents appear in the Mag after a short delay. Move the mouse into Mag rapidly or lock the view by pressing and holding Shift while moving the mouse.</small>");
- m_htmlPart->setText(initialMagText);
+
+ CDisplayTemplateMgr *mgr(CPointers::displayTemplateManager());
+ CDisplayTemplateMgr::Settings settings;
+ settings.pageCSS_ID = "infodisplay";
+ QString divText("<div class=\"infodisplay\">%1</div>");
+ QString initialMagText(tr("<small>This is the Mag viewer area. Hover the "
+ "mouse over links or other items which include "
+ "some data and the contents appear in the Mag "
+ "after a short delay. Move the mouse into Mag "
+ "rapidly or lock the view by pressing and "
+ "holding Shift while moving the mouse.</small>"));
+ QString content(mgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle),
+ divText.arg(initialMagText),
+ settings)
+ );
+ m_htmlPart->setText(content);
}
diff --git a/src/frontend/displaywindow/btactioncollection.cpp b/src/frontend/displaywindow/btactioncollection.cpp
index f71709a..046c3c0 100644
--- a/src/frontend/displaywindow/btactioncollection.cpp
+++ b/src/frontend/displaywindow/btactioncollection.cpp
@@ -7,7 +7,25 @@
*
**********/
+#include "util/directoryutil.h"
+#include "backend/config/cbtconfig.h"
#include "btactioncollection.h"
+#include <QAction>
+#include <QKeySequence>
+#include <QSettings>
+#include <QString>
+#include <QStringList>
+
+class BtActionItem : public QObject
+{
+public:
+ BtActionItem(QObject* parent)
+ : QObject(parent)
+ {
+ }
+ QKeySequence defaultKeys;
+ QAction* action;
+};
BtActionCollection::BtActionCollection(QObject* parent)
: QObject(parent)
@@ -18,21 +36,119 @@ BtActionCollection::~BtActionCollection()
{
}
+QList<QAction*> BtActionCollection::actions()
+{
+ QList<QAction*> actionList;
+
+ QMap<QString, BtActionItem*>::const_iterator iter = m_actions.constBegin();
+ while (iter != m_actions.constEnd())
+ {
+ QAction* action = iter.value()->action;
+ actionList.append(action);
+ ++iter;
+ }
+ return actionList;
+}
+
QAction* BtActionCollection::action(const QString& name)
{
Q_ASSERT(m_actions[name] != 0);
- return m_actions[name];
+ QAction* action = m_actions[name]->action;
+ Q_ASSERT(action != 0);
+ return action;
}
-void BtActionCollection::addAction(const QString& name, QAction* action)
+QAction* BtActionCollection::addAction(const QString& name, QAction* action)
{
Q_ASSERT(action != 0);
-// Q_ASSERT(m_actions[name] == 0); // TODO - replacing actions is ok???
- m_actions[name] = action;
+ Q_ASSERT(m_actions[name] == 0); // TODO - replacing actions is ok???
+ int count;
+ count = m_actions.count();
+ BtActionItem* item = new BtActionItem(this);
+ item->action = action;
+ item->defaultKeys = action->shortcut();
+ m_actions[name] = item;
+ return action;
+}
+
+QAction* BtActionCollection::addAction(const QString &name, const QObject *receiver, const char* member)
+{
+ QAction* action = new QAction(name, this);
+ if (receiver && member)
+ {
+ bool ok = connect(action, SIGNAL(triggered()), receiver, SLOT(triggered()));
+ Q_ASSERT(ok);
+ }
+ return addAction(name, action);
}
-void BtActionCollection::addAction(const QString &name, const QObject *receiver)
+QKeySequence BtActionCollection::getDefaultShortcut(QAction* action)
{
+ QMap<QString, BtActionItem*>::const_iterator iter = m_actions.constBegin();
+ while (iter != m_actions.constEnd())
+ {
+ if ( iter.value()->action == action)
+ {
+ return iter.value()->defaultKeys;
+ }
+ iter++;
+ }
+ return QKeySequence();
}
+void BtActionCollection::setConfigGroup(const QString &group)
+{
+ m_groupName = group;
+}
+
+void BtActionCollection::readSettings()
+{
+ QSettings* settings = CBTConfig::getConfig();
+ settings->beginGroup(m_groupName);
+ QStringList keyList = settings->childKeys();
+ for (int i=0; i<keyList.size(); i++)
+ {
+ QString key = keyList.at(i);
+ QVariant variant = settings->value(key);
+ QList<QKeySequence> shortcuts;
+ if ( variant != QVariant())
+ {
+ QList<QVariant> varShortcuts = variant.toList();
+ for (int i=0; i<varShortcuts.count(); i++)
+ {
+ QString keys = varShortcuts.at(i).toString();
+ QKeySequence shortcut(keys);
+ shortcuts.append(shortcut);
+ }
+ }
+ action(key)->setShortcuts(shortcuts);
+ }
+ settings->endGroup();
+}
+static QList<QVariant> keyListToVariantList(const QList<QKeySequence>& keyList)
+{
+ QList<QVariant> varList;
+ for (int i=0; i<keyList.count(); i++)
+ {
+ QKeySequence keySeq = keyList.at(i);
+ varList.append(keySeq.toString());
+ }
+ return varList;
+}
+
+void BtActionCollection::writeSettings()
+{
+ QSettings* settings = CBTConfig::getConfig();
+ settings->beginGroup(m_groupName);
+ QMap<QString, BtActionItem*>::const_iterator iter = m_actions.constBegin();
+ while (iter != m_actions.constEnd())
+ {
+ QString actionName = iter.key();
+ QList<QKeySequence> keyList = iter.value()->action->shortcuts();
+ QList<QVariant> varList = keyListToVariantList(keyList);
+ settings->setValue(actionName, varList);
+ iter++;
+ }
+ settings->endGroup();
+}
diff --git a/src/frontend/displaywindow/btactioncollection.h b/src/frontend/displaywindow/btactioncollection.h
index 23ee1cf..48e6b10 100644
--- a/src/frontend/displaywindow/btactioncollection.h
+++ b/src/frontend/displaywindow/btactioncollection.h
@@ -6,14 +6,18 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#ifndef BT_ACTION_COLLECTION_S
-#define BT_ACTION_COLLECTION_S
+#ifndef BT_ACTION_COLLECTION_H
+#define BT_ACTION_COLLECTION_H
-#include <QObject>
#include <QMap>
+#include <QObject>
+#include <QList>
+
class QString;
class QAction;
+class QKeySequence;
+class BtActionItem;
class BtActionCollection : public QObject
{
@@ -21,12 +25,18 @@ class BtActionCollection : public QObject
public:
BtActionCollection(QObject* parent);
~BtActionCollection();
- void addAction(const QString& name, QAction* action);
- void addAction(const QString &name, const QObject *receiver);
+ QAction* addAction(const QString& name, QAction* action);
+ QAction* addAction(const QString &name, const QObject *receiver, const char* member=0);
+ QList<QAction*> actions();
QAction* action(const QString& name);
+ void setConfigGroup(const QString &group);
+ void readSettings();
+ void writeSettings();
+ QKeySequence getDefaultShortcut(QAction* action);
private:
- QMap<QString, QAction*> m_actions;
+ QMap<QString, BtActionItem*> m_actions;
+ QString m_groupName;
};
#endif
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.cpp b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
index 907a779..ffa672a 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.cpp
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
@@ -11,6 +11,20 @@
#include <QMenu>
#include <QToolButton>
#include <QAction>
+#include <QEvent>
+
+class BtToolButton : public QToolButton
+{
+public:
+ BtToolButton(QWidget* parent=0) : QToolButton(parent)
+ {
+ }
+private:
+ void nextCheckState()
+ {
+ }
+};
+
// This class provides a toolbar widget that has a icon plus a right side down arrow
// The icon is typically set to a back or forward arrow and the down arrow has a popup
@@ -18,6 +32,7 @@
BtToolBarPopupAction::BtToolBarPopupAction(const QIcon& icon, const QString& text, QObject* parent)
: QWidgetAction(parent), m_icon(icon), m_text(text)
{
+ setText(text);
m_menu = new QMenu();
}
@@ -26,6 +41,7 @@ BtToolBarPopupAction::~BtToolBarPopupAction()
delete m_menu;
}
+// return the QMenu object so a popup menu can be constructed
QMenu* BtToolBarPopupAction::popupMenu() const
{
return m_menu;
@@ -33,7 +49,7 @@ QMenu* BtToolBarPopupAction::popupMenu() const
QWidget* BtToolBarPopupAction::createWidget(QWidget* parent)
{
- m_button = new QToolButton(parent);
+ m_button = new BtToolButton(parent);
setIcon(m_icon);
setToolTip(m_text);
m_button->setDefaultAction(this);
@@ -44,8 +60,19 @@ QWidget* BtToolBarPopupAction::createWidget(QWidget* parent)
return m_button;
}
+// Slot to emit a triggered signal when the toolbar button is pressed
void BtToolBarPopupAction::buttonPressed()
{
emit triggered();
}
+// Function to catch the Shortcut event and emit the triggered signal
+bool BtToolBarPopupAction::event(QEvent *event)
+{
+ if (event->type() == QEvent::Shortcut)
+ {
+ emit triggered();
+ return true;
+ }
+ return QWidgetAction::event(event);
+}
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.h b/src/frontend/displaywindow/bttoolbarpopupaction.h
index 63ed491..7615c02 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.h
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.h
@@ -24,7 +24,12 @@ public:
BtToolBarPopupAction(const QIcon& icon, const QString& text, QObject* parent);
~BtToolBarPopupAction();
+
+// return the QMenu object so a popup menu can be constructed
QMenu* popupMenu() const;
+
+// Function to catch the Shortcut event and emit the triggered signal
+ virtual bool event(QEvent* e);
signals:
void triggered();
@@ -33,6 +38,8 @@ protected:
QWidget* createWidget(QWidget* parent);
private slots:
+
+// Slot to emit a triggered signal when the toolbar button is pressed
void buttonPressed();
private:
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
index 15354fa..9b59544 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.cpp
+++ b/src/frontend/displaywindow/cbiblereadwindow.cpp
@@ -2,29 +2,24 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-
#include "cbiblereadwindow.h"
#include "btactioncollection.h"
-
#include "ccommentaryreadwindow.h"
#include "cbuttons.h"
-
#include "backend/keys/cswordversekey.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
-
#include "frontend/profile/cprofilewindow.h"
#include "frontend/cexportmanager.h"
#include "backend/config/cbtconfig.h"
#include "frontend/cmdiarea.h"
#include "frontend/display/creaddisplay.h"
#include "frontend/keychooser/ckeychooser.h"
-
#include "util/ctoolclass.h"
#include "util/cresmgr.h"
#include "util/directoryutil.h"
@@ -50,32 +45,40 @@ CBibleReadWindow::CBibleReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea
qDebug("CBibleReadWindow::CBibleReadWindow");
}
-CBibleReadWindow::~CBibleReadWindow() {}
+CBibleReadWindow::~CBibleReadWindow()
+{
+}
-void CBibleReadWindow::applyProfileSettings( CProfileWindow* const settings ) {
+void CBibleReadWindow::applyProfileSettings( CProfileWindow* const settings )
+{
CLexiconReadWindow::applyProfileSettings(settings);
const int count = displaySettingsButton()->menuItemCount();
int result = settings->windowSettings();
- for (int i = count-1; i>=1; i--) {
- if (result-(int)pow((double)2,i-1)>= 0) { //2^i was added before, so item with index i is set
+ for (int i = count-1; i>=1; i--)
+ {
+ if (result-(int)pow((double)2,i-1)>= 0)
+ { //2^i was added before, so item with index i is set
result -= (int)pow((double)2,i-1);
displaySettingsButton()->setItemStatus(i,true);
}
- else {
+ else
+ {
displaySettingsButton()->setItemStatus(i,false);
}
}
displaySettingsButton()->setChanged();
}
-void CBibleReadWindow::storeProfileSettings( CProfileWindow* const settings ) {
+void CBibleReadWindow::storeProfileSettings( CProfileWindow* const settings )
+{
CLexiconReadWindow::storeProfileSettings(settings);
const int count = displaySettingsButton()->menuItemCount();
int result = 0;
//now check every item
- for (int i = 1; i < count; i++) { //first item is a title
+ for (int i = 1; i < count; i++)
+ { //first item is a title
if (displaySettingsButton()->itemStatus(i)) //item is checked
result += (int)pow((double)2,i-1);//add 2^i (the i. digit in binary)
}
@@ -84,8 +87,8 @@ void CBibleReadWindow::storeProfileSettings( CProfileWindow* const settings ) {
/** Reimplementation. */
-void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
-
+void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a )
+{
QAction* qaction;
qaction = new QAction(tr("Next book"), a);
@@ -112,153 +115,151 @@ void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
a->addAction("previousVerse", qaction);
-
//popup menu items
- // new KAction(tr("Select all"), KStdAccel::selectAll(), a, "selectAll");
-
- //copy menu items
- // new KAction(tr("Copy reference only"), KShortcut(0), a, "copyReferenceOnly");
- // new KAction(tr("Text of reference"), KShortcut(0), a, "copyTextOfReference");
- // new KAction(tr("Reference with text"), KShortcut(0), a, "copyReferenceWithText");
qaction = new QAction(tr("Copy chapter"), a);
a->addAction("copyChapter", qaction);
- // new KAction(tr("Copy selected text"), KStdAccel::copy(), a, "copySelectedText");
- //save menu
- // new KAction(tr("Reference with text"), KShortcut(0), a, "saveReferenceWithText");
qaction = new QAction(tr("Save chapter as plain text"), a);
a->addAction("saveChapterAsPlainText", qaction);
qaction = new QAction(tr("Save chapter as HTML"), a);
a->addAction("saveChapterAsHTML", qaction);
- // new KAction(tr("Reference with text"), KShortcut(0), a, "saveReferenceWithText");
- //print
qaction = new QAction(tr("Print chapter"), a);
qaction->setShortcut(QKeySequence::Print);
a->addAction("printChapter", qaction);
+
+// qaction = new QAction( /* QIcon(CResMgr::displaywindows::general::findStrongs::icon), */ tr("Strong's search"), a);
+// qaction->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
+// qaction->setToolTip(tr("Find all occurences of the Strong number currently under the mouse cursor"));
+// a->addAction(CResMgr::displaywindows::general::findStrongs::actionName, qaction);
+
+// qaction = new QAction(tr("Reference only"), a );
+// a->addAction("copyReferenceOnly", qaction);
+
+ qaction = new QAction(tr("Text of reference"), a);
+ a->addAction("copyTextOfReference", qaction);
+
+ qaction = new QAction(tr("Reference with text"), a);
+ a->addAction( "copyReferenceWithText", qaction);
+
+ qaction = new QAction(tr("Reference with text"), a);
+ a->addAction("saveReferenceWithText", qaction);
}
-void CBibleReadWindow::initActions() {
+void CBibleReadWindow::initActions()
+{
qDebug("CBibleReadWindow::initActions");
BtActionCollection* ac = actionCollection();
- CBibleReadWindow::insertKeyboardActions(ac);
+
CLexiconReadWindow::initActions(); //make sure the predefined actions are available
+ CBibleReadWindow::insertKeyboardActions(ac);
+
//cleanup, not a clean oo-solution
ac->action("nextEntry")->setEnabled(false);
ac->action("previousEntry")->setEnabled(false);
QAction* qaction;
- qaction = new QAction(tr("Next book"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
+ qaction = m_actionCollection->action("nextBook");
QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextBook()) );
- ac->addAction("nextBook", qaction);
+ addAction(qaction);
- qaction = new QAction(tr("Previous book"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousBook::accel);
+ qaction = m_actionCollection->action("previousBook");
QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousBook()) );
- ac->addAction("previousBook", qaction);
+ addAction(qaction);
- qaction = new QAction(tr("Next chapter"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
+ qaction = m_actionCollection->action("nextChapter");
QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextChapter()) );
- ac->addAction("nextChapter", qaction);
+ addAction(qaction);
- qaction = new QAction(tr("Previous chapter"),ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
+ qaction = m_actionCollection->action("previousChapter");
QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousChapter()) );
- ac->addAction("previousChapter", qaction);
+ addAction(qaction);
- qaction = new QAction(tr("Next verse"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
+ qaction = m_actionCollection->action("nextVerse");
QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextVerse()) );
- ac->addAction("nextVerse", qaction);
+ addAction(qaction);
- qaction = new QAction(tr("Previous verse"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
+ qaction = m_actionCollection->action("previousVerse");
QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
- ac->addAction("previousVerse", qaction);
+ addAction(qaction);
- m_actions.selectAll = qobject_cast<QAction*>(ac->action("selectAll"));
+ m_actions.selectAll = ac->action("selectAll");
Q_ASSERT(m_actions.selectAll);
- m_actions.findText = qobject_cast<QAction*>(ac->action("findText"));
+ m_actions.findText = ac->action("findText");
Q_ASSERT(m_actions.findText);
- m_actions.findStrongs = new QAction(
-// QIcon(CResMgr::displaywindows::general::findStrongs::icon),
- tr("Strong's search"),
- ac
- );
- m_actions.findStrongs->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
- m_actions.findStrongs->setToolTip(tr("Find all occurences of the Strong number currently under the mouse cursor"));
- QObject::connect(m_actions.findStrongs, SIGNAL(triggered()), this, SLOT(openSearchStrongsDialog()) );
- ac->addAction(CResMgr::displaywindows::general::findStrongs::actionName, m_actions.findStrongs);
-
- m_actions.copy.referenceOnly = new QAction(tr("Reference only"), ac );
- QObject::connect(m_actions.copy.referenceOnly, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()));
- ac->addAction("copyReferenceOnly", m_actions.copy.referenceOnly);
-
- m_actions.copy.referenceTextOnly = new QAction(tr("Text of reference"), ac);
+ m_actions.findStrongs = m_actionCollection->action(CResMgr::displaywindows::general::findStrongs::actionName);
+
+ m_actions.copy.referenceOnly = m_actionCollection->action("copyReferenceOnly");
+
+ m_actions.copy.referenceTextOnly = m_actionCollection->action("copyTextOfReference");
QObject::connect(m_actions.copy.referenceTextOnly, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorTextOnly()) );
- ac->addAction("copyTextOfReference", m_actions.copy.referenceTextOnly);
+ addAction(m_actions.copy.referenceTextOnly);
- m_actions.copy.referenceAndText = new QAction(tr("Reference with text"), ac);
+ m_actions.copy.referenceAndText = m_actionCollection->action("copyReferenceWithText");
QObject::connect(m_actions.copy.referenceAndText, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorWithText()) );
- ac->addAction( "copyReferenceWithText", m_actions.copy.referenceAndText);
+ addAction(m_actions.copy.referenceAndText);
- m_actions.copy.chapter = new QAction(tr("Chapter"), ac);
+ m_actions.copy.chapter = m_actionCollection->action("copyChapter");
QObject::connect(m_actions.copy.chapter, SIGNAL(triggered()), this, SLOT(copyDisplayedText()) );
- ac->addAction("copyChapter", m_actions.copy.chapter);
+ addAction(m_actions.copy.chapter);
- m_actions.copy.selectedText = qobject_cast<QAction*>(ac->action("copySelectedText"));
+ m_actions.copy.selectedText = ac->action("copySelectedText");
Q_ASSERT(m_actions.copy.selectedText);
- m_actions.save.referenceAndText = new QAction(tr("Reference with text"), ac );
+ m_actions.save.referenceAndText = m_actionCollection->action("saveReferenceWithText");
QObject::connect(m_actions.save.referenceAndText, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(saveAnchorWithText()) );
- ac->addAction("saveReferenceWithText", m_actions.save.referenceAndText);
+ addAction(m_actions.copy.chapter);
- m_actions.save.chapterAsPlain = new QAction(tr("Chapter as plain text"), ac);
+ m_actions.save.chapterAsPlain = m_actionCollection->action("saveChapterAsPlainText");
QObject::connect(m_actions.save.chapterAsPlain, SIGNAL(triggered()), this, SLOT(saveChapterPlain()) );
- ac->addAction("saveChapterAsPlainText", m_actions.save.chapterAsPlain);
+ addAction(m_actions.save.referenceAndText);
- m_actions.save.chapterAsHTML = new QAction(tr("Chapter as HTML"), ac);
+ m_actions.save.chapterAsHTML = m_actionCollection->action("saveChapterAsHTML");
QObject::connect(m_actions.save.chapterAsHTML, SIGNAL(triggered()), this, SLOT(saveChapterHTML()) );
- ac->addAction("saveChapterAsHTML", m_actions.save.chapterAsHTML);
+ addAction(m_actions.save.chapterAsHTML);
- m_actions.print.reference = new QAction(tr("Reference with text"), ac);
+ m_actions.print.reference = m_actionCollection->action("saveReferenceWithText");
QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()) );
- ac->addAction("saveReferenceWithText", m_actions.print.reference);
+ addAction(m_actions.print.reference);
- m_actions.print.chapter = new QAction(tr("Chapter"), ac);
+ m_actions.print.chapter = m_actionCollection->action("printChapter");
QObject::connect(m_actions.print.chapter, SIGNAL(triggered()), this, SLOT(printAll()) );
- ac->addAction("printChapter", m_actions.print.chapter);
+ addAction(m_actions.print.chapter);
-// CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, ac);
+ CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, ac);
}
-void CBibleReadWindow::initConnections() {
+void CBibleReadWindow::initConnections()
+{
CLexiconReadWindow::initConnections();
}
-void CBibleReadWindow::initToolbars() {
+void CBibleReadWindow::initToolbars()
+{
CLexiconReadWindow::initToolbars();
}
-void CBibleReadWindow::initView() {
+void CBibleReadWindow::initView()
+{
CLexiconReadWindow::initView();
- parentWidget()->installEventFilter( this );
+ parentWidget()->installEventFilter(this);
}
/** Reimplementation. */
-void CBibleReadWindow::setupPopupMenu() {
+void CBibleReadWindow::setupPopupMenu()
+{
popup()->setTitle(tr("Bible window"));
popup()->setIcon(CToolClass::getIconForModule(modules().first()) );
popup()->addAction(m_actions.findText);
+ QKeySequence ks = m_actions.findText->shortcut();
+ QString keys = ks.toString();
popup()->addAction(m_actions.findStrongs);
popup()->addAction(m_actions.selectAll);
@@ -279,8 +280,10 @@ void CBibleReadWindow::setupPopupMenu() {
m_actions.saveMenu->addAction(m_actions.save.referenceAndText);
m_actions.saveMenu->addAction(m_actions.save.chapterAsPlain);
m_actions.saveMenu->addAction(m_actions.save.chapterAsHTML);
+
// Save raw HTML action for debugging purposes
- if (qApp->property("--debug").toBool()) {
+ if (qApp->property("--debug").toBool())
+ {
QAction* debugAction = new QAction("Raw HTML", this);
QObject::connect(debugAction, SIGNAL(triggered()), this, SLOT(saveRawHTML()));
m_actions.saveMenu->addAction(debugAction);
@@ -294,22 +297,11 @@ void CBibleReadWindow::setupPopupMenu() {
}
/** Reimplemented. */
-void CBibleReadWindow::updatePopupMenu() {
+void CBibleReadWindow::updatePopupMenu()
+{
qWarning("CBibleReadWindow::updatePopupMenu()");
- //enable the action depending on the supported module features
-// bool hasStrongs = false;
-// QList<CSwordModuleInfo*> mods = modules();
-// for (QList<CSwordModuleInfo*>::iterator it = mods.begin(); it != mods.end(); ++it) {
-// if ( (*it)->has( CSwordModuleInfo::strongNumbers ) ) {
-// hasStrongs = true;
-// break;
-// }
-// }
-//
-// m_actions.findStrongs->setEnabled( hasStrongs );
m_actions.findStrongs->setEnabled( displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null );
-
m_actions.copy.referenceOnly->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
m_actions.copy.referenceTextOnly->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
@@ -322,49 +314,61 @@ void CBibleReadWindow::updatePopupMenu() {
}
/** Moves to the next book. */
-void CBibleReadWindow::nextBook() {
- if (verseKey()->next(CSwordVerseKey::UseBook)) {
+void CBibleReadWindow::nextBook()
+{
+ if (verseKey()->next(CSwordVerseKey::UseBook))
+ {
keyChooser()->setKey(key());
}
}
/** Moves one book behind. */
void CBibleReadWindow::previousBook() {
- if (verseKey()->previous(CSwordVerseKey::UseBook)) {
+ if (verseKey()->previous(CSwordVerseKey::UseBook))
+ {
keyChooser()->setKey(key());
}
}
/** Moves to the next book. */
-void CBibleReadWindow::nextChapter() {
- if (verseKey()->next(CSwordVerseKey::UseChapter)) {
+void CBibleReadWindow::nextChapter()
+{
+ if (verseKey()->next(CSwordVerseKey::UseChapter))
+ {
keyChooser()->setKey(key());
}
}
/** Moves one book behind. */
-void CBibleReadWindow::previousChapter() {
- if (verseKey()->previous(CSwordVerseKey::UseChapter)) {
+void CBibleReadWindow::previousChapter()
+{
+ if (verseKey()->previous(CSwordVerseKey::UseChapter))
+ {
keyChooser()->setKey(key());
}
}
/** Moves to the next book. */
-void CBibleReadWindow::nextVerse() {
- if (verseKey()->next(CSwordVerseKey::UseVerse)) {
+void CBibleReadWindow::nextVerse()
+{
+ if (verseKey()->next(CSwordVerseKey::UseVerse))
+ {
keyChooser()->setKey(key());
}
}
/** Moves one book behind. */
-void CBibleReadWindow::previousVerse() {
- if (verseKey()->previous(CSwordVerseKey::UseVerse)) {
+void CBibleReadWindow::previousVerse()
+{
+ if (verseKey()->previous(CSwordVerseKey::UseVerse))
+ {
keyChooser()->setKey(key());
}
}
/** rapper around key() to return the right type of key. */
-CSwordVerseKey* CBibleReadWindow::verseKey() {
+CSwordVerseKey* CBibleReadWindow::verseKey()
+{
CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
Q_ASSERT(k);
@@ -372,7 +376,8 @@ CSwordVerseKey* CBibleReadWindow::verseKey() {
}
/** Copies the current chapter into the clipboard. */
-void CBibleReadWindow::copyDisplayedText() {
+void CBibleReadWindow::copyDisplayedText()
+{
CSwordVerseKey dummy(*verseKey());
dummy.Verse(1);
@@ -388,7 +393,8 @@ void CBibleReadWindow::copyDisplayedText() {
}
/** Saves the chapter as valid HTML page. */
-void CBibleReadWindow::saveChapterHTML() {
+void CBibleReadWindow::saveChapterHTML()
+{
//saves the complete chapter to disk
CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
Q_ASSERT(bible);
@@ -409,7 +415,8 @@ void CBibleReadWindow::saveChapterHTML() {
}
/** Saves the chapter as valid HTML page. */
-void CBibleReadWindow::saveChapterPlain() {
+void CBibleReadWindow::saveChapterPlain()
+{
//saves the complete chapter to disk
CSwordVerseKey vk(*verseKey());
@@ -426,30 +433,32 @@ void CBibleReadWindow::saveChapterPlain() {
mgr.saveKey(&vk, CExportManager::Text, true);
}
-void CBibleReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
+void CBibleReadWindow::reload(CSwordBackend::SetupChangedReason reason)
+{
CLexiconReadWindow::reload(reason);
- if (m_modules.count() == 0) {
+ if (m_modules.count() == 0)
+ {
close();
return;
}
//refresh the book lists
-// qDebug("lang is %s",backend()->booknameLanguage().latin1());
verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
-// CBTConfig::setupAccelSettings(CBTConfig::readWindow, actionCollection()); //setup the predefined actions
-// CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, actionCollection());
+ CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, actionCollection());
}
/** No descriptions */
-bool CBibleReadWindow::eventFilter( QObject* o, QEvent* e) {
+bool CBibleReadWindow::eventFilter( QObject* o, QEvent* e)
+{
const bool ret = CLexiconReadWindow::eventFilter(o,e);
// Q_ASSERT(o->inherits("CDisplayWindow"));
// qWarning("class: %s", o->className());
- if (e && (e->type() == QEvent::FocusIn)) { //sync other windows to this active
+ if (e && (e->type() == QEvent::FocusIn))
+ { //sync other windows to this active
/* This is a hack to work around a KHTML problem (similair to the Drag&Drop problem we had):
* If new HTML content is loaded from inside a kHTML event handler
@@ -465,13 +474,16 @@ bool CBibleReadWindow::eventFilter( QObject* o, QEvent* e) {
return ret;
}
-void CBibleReadWindow::lookupSwordKey( CSwordKey* newKey ) {
+void CBibleReadWindow::lookupSwordKey( CSwordKey* newKey )
+{
CLexiconReadWindow::lookupSwordKey(newKey);
syncWindows();
}
-void CBibleReadWindow::syncWindows() {
- foreach (QMdiSubWindow* subWindow, mdi()->subWindowList()) {
+void CBibleReadWindow::syncWindows()
+{
+ foreach (QMdiSubWindow* subWindow, mdi()->subWindowList())
+ {
CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget());
if (w && w->syncAllowed()) {
w->lookupKey( key()->key() );
diff --git a/src/frontend/displaywindow/cbiblereadwindow.h b/src/frontend/displaywindow/cbiblereadwindow.h
index e044463..3a5f64f 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.h
+++ b/src/frontend/displaywindow/cbiblereadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
index 657238f..40f737d 100644
--- a/src/frontend/displaywindow/cbookreadwindow.cpp
+++ b/src/frontend/displaywindow/cbookreadwindow.cpp
@@ -2,27 +2,21 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-
-
#include "cbookreadwindow.h"
#include "bttoolbarpopupaction.h"
#include "btactioncollection.h"
-
#include "cmodulechooserbar.h"
#include "cbuttons.h"
-
#include "backend/keys/cswordtreekey.h"
-
#include "frontend/display/cdisplay.h"
#include "frontend/keychooser/cbooktreechooser.h"
#include "frontend/profile/cprofilewindow.h"
#include "backend/config/cbtconfig.h"
-
#include "util/ctoolclass.h"
#include "util/cresmgr.h"
@@ -33,9 +27,14 @@
using namespace Profile;
-CBookReadWindow::CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent) : CLexiconReadWindow(modules, parent) {}
+CBookReadWindow::CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
+ : CLexiconReadWindow(modules, parent), m_treeAction(0), m_treeChooser(0)
+{
+}
-CBookReadWindow::~CBookReadWindow() {}
+CBookReadWindow::~CBookReadWindow()
+{
+}
void CBookReadWindow::applyProfileSettings( CProfileWindow* profileWindow )
{
@@ -59,50 +58,30 @@ void CBookReadWindow::initActions()
{
CLexiconReadWindow::initActions();
BtActionCollection* ac = actionCollection();
+ insertKeyboardActions(ac);
+
//cleanup, not a clean oo-solution
Q_ASSERT(ac->action("nextEntry"));
Q_ASSERT(ac->action("previousEntry"));
ac->action("nextEntry")->setEnabled(false);
ac->action("previousEntry")->setEnabled(false);
- m_treeAction = new QAction(
- QIcon(CResMgr::displaywindows::bookWindow::toggleTree::icon),
- tr("Toggle tree view"),
- ac
- );
- m_treeAction->setCheckable(true);
- m_treeAction->setShortcut(CResMgr::displaywindows::bookWindow::toggleTree::accel);
+ m_treeAction = ac->action("toggleTree");
QObject::connect(m_treeAction, SIGNAL(triggered()), this, SLOT(treeToggled()) );
- ac->addAction("toggleTree", m_treeAction);
+ addAction(m_treeAction);
-// CBTConfig::setupAccelSettings(CBTConfig::bookWindow, ac);
+ CBTConfig::setupAccelSettings(CBTConfig::bookWindow, ac);
}
void CBookReadWindow::insertKeyboardActions( BtActionCollection* const a )
{
QAction* qaction;
- qaction = new QAction(
- QIcon(CResMgr::displaywindows::bookWindow::toggleTree::icon),
- tr("Toggle tree view"),
- a
- );
+ qaction = new QAction( /* QIcon(CResMgr::displaywindows::bookWindow::toggleTree::icon), */
+ tr("Toggle tree view"), a);
qaction->setCheckable(true);
qaction->setShortcut(CResMgr::displaywindows::bookWindow::toggleTree::accel);
a->addAction("toggleTree", qaction);
-
- // new QAction(tr("Copy reference only"), KShortcut(0), a, "copyReferenceOnly");
- qaction = new QAction(tr("Copy entry with text"), a);
- a->addAction("copyEntryWithText", qaction);
- // new QAction(tr("Copy selected text"), KShortcut(0), a, "copySelectedText");
- qaction = new QAction(tr("Save entry as plain text"), a);
- a->addAction("saveEntryAsPlainText", qaction);
- qaction = new QAction(tr("Save entry as HTML"),a);
- a->addAction("saveEntryAsHTML", qaction);
- // new QAction(tr("Print reference only"), KShortcut(0), a, "printReferenceOnly");
- qaction = new QAction(tr("Print entry with text"), a);
- a->addAction("printEntryWithText", qaction);
-
}
/** No descriptions */
@@ -122,7 +101,6 @@ void CBookReadWindow::initView()
setMainToolBar( new QToolBar(this) );
addToolBar(mainToolBar());
- //addDockWindow(mainToolBar());
m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
@@ -132,15 +110,12 @@ void CBookReadWindow::initView()
setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
moduleChooserBar()->setButtonLimit(1);
addToolBar(moduleChooserBar());
- //addDockWindow( moduleChooserBar() );
setButtonsToolBar( new QToolBar(this) );
- //addDockWindow( buttonsToolBar() );
setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
addToolBar(buttonsToolBar());
m_treeChooser->hide();
- //splitter->setResizeMode(m_treeChooser, QSplitter::Stretch);
setCentralWidget( splitter );
setWindowIcon(CToolClass::getIconForModule(modules().first()));
}
@@ -165,16 +140,13 @@ void CBookReadWindow::initToolbars()
if (action) {
buttonsToolBar()->addAction(action);
}
-
- //#if KDE_VERSION_MINOR < 1
- //action->plugAccel( accel() );
- //#endif
}
/** Is called when the action was executed to toggle the tree view. */
void CBookReadWindow::treeToggled()
{
- if (m_treeAction->isChecked()) {
+ if (m_treeAction->isChecked())
+ {
m_treeChooser->show();
}
else {
@@ -193,3 +165,8 @@ void CBookReadWindow::setupPopupMenu()
{
CLexiconReadWindow::setupPopupMenu();
}
+
+void CBookReadWindow::reload(CSwordBackend::SetupChangedReason reason)
+{
+ CLexiconReadWindow::reload(reason);
+}
diff --git a/src/frontend/displaywindow/cbookreadwindow.h b/src/frontend/displaywindow/cbookreadwindow.h
index eaa0c15..a2a2219 100644
--- a/src/frontend/displaywindow/cbookreadwindow.h
+++ b/src/frontend/displaywindow/cbookreadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's BtActionCollection code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime BtActionCollection code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -41,6 +41,12 @@ public:
*/
virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+public slots:
+ /**
+ * Refreshes the content of this display window and the content of the keychooser.
+ */
+ virtual void reload(CSwordBackend::SetupChangedReason reason);
+
protected:
virtual void initActions();
virtual void initToolbars();
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.cpp b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
index 9228c2d..7ead206 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.cpp
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,15 +10,12 @@
//BibleTime includes
#include "ccommentaryreadwindow.h"
#include "btactioncollection.h"
-
#include "frontend/profile/cprofilewindow.h"
#include "backend/config/cbtconfig.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/display/cdisplay.h"
#include "frontend/display/creaddisplay.h"
-
#include "backend/keys/cswordversekey.h"
-
#include "util/ctoolclass.h"
#include "util/cresmgr.h"
#include "util/directoryutil.h"
@@ -30,10 +27,12 @@
using namespace Profile;
-CCommentaryReadWindow::CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent) : CLexiconReadWindow(modules, parent) {}
-
-void CCommentaryReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
+CCommentaryReadWindow::CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent) : CLexiconReadWindow(modules, parent)
+{
+}
+void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a)
+{
QAction* qaction;
qaction = new QAction(tr("Next book"), a);
@@ -59,22 +58,63 @@ void CCommentaryReadWindow::insertKeyboardActions( BtActionCollection* const a )
qaction = new QAction(tr("Previous verse"), a);
qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
a->addAction("previousVerse", qaction);
+}
+
+void CCommentaryReadWindow::initActions()
+{
+ CLexiconReadWindow::initActions(); //make sure the predefined actions are available
+ BtActionCollection* ac = actionCollection();
+ insertKeyboardActions(ac);
+
+ //cleanup, not a clean oo-solution
+ ac->action("nextEntry")->setEnabled(false);
+ ac->action("previousEntry")->setEnabled(false);
+
+ QAction* qaction;
+ qaction = ac->action("nextBook");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextBook()) );
+ addAction(qaction);
+
+ qaction = ac->action("previousBook");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousBook()) );
+ addAction(qaction);
+
+ qaction = ac->action("nextChapter");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextChapter()) );
+ addAction(qaction);
+
+ qaction = ac->action("previousChapter");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousChapter()) );
+ addAction(qaction);
+
+ qaction = ac->action("nextVerse");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextVerse()) );
+ addAction(qaction);
+
+ qaction = ac->action("previousVerse");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
+ addAction(qaction);
+
+ CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
}
-void CCommentaryReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
+void CCommentaryReadWindow::applyProfileSettings( CProfileWindow* profileWindow )
+{
CLexiconReadWindow::applyProfileSettings(profileWindow);
if (profileWindow->windowSettings()) {
m_syncButton->setChecked(true);
}
}
-void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
+void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow )
+{
CLexiconReadWindow::storeProfileSettings(profileWindow);
profileWindow->setWindowSettings( m_syncButton->isChecked() );
}
-void CCommentaryReadWindow::initToolbars() {
+void CCommentaryReadWindow::initToolbars()
+{
CLexiconReadWindow::initToolbars();
m_syncButton = new QAction(
@@ -90,102 +130,69 @@ void CCommentaryReadWindow::initToolbars() {
}
/** Reimplementation to handle the keychooser refresh. */
-void CCommentaryReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
+void CCommentaryReadWindow::reload(CSwordBackend::SetupChangedReason reason)
+{
CLexiconReadWindow::reload(reason);
//refresh the book lists
verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
+
+ CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
}
/** rapper around key() to return the right type of key. */
-CSwordVerseKey* CCommentaryReadWindow::verseKey() {
+CSwordVerseKey* CCommentaryReadWindow::verseKey()
+{
CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
Q_ASSERT(k);
return k;
}
-void CCommentaryReadWindow::initActions() {
- CLexiconReadWindow::initActions(); //make sure the predefined actions are available
-
- BtActionCollection* ac = actionCollection();
-
- //cleanup, not a clean oo-solution
- ac->action("nextEntry")->setEnabled(false);
- ac->action("previousEntry")->setEnabled(false);
-
- QAction* qaction;
-
- qaction = new QAction(tr("Next book"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextBook()) );
- ac->addAction("nextBook", qaction);
-
- qaction = new QAction(tr("Previous book"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousBook::accel);
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousBook()) );
- ac->addAction("previousBook", qaction);
-
- qaction = new QAction(tr("Next chapter"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextChapter()) );
- ac->addAction("nextChapter", qaction);
-
- qaction = new QAction(tr("Previous chapter"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousChapter()) );
- ac->addAction("previousChapter", qaction);
-
- qaction = new QAction(tr("Next verse"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextVerse()) );
- ac->addAction("nextVerse", qaction);
-
- qaction = new QAction(tr("Previous verse"), ac);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
- ac->addAction("previousVerse", qaction);
-
-// CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
-}
-
/** Moves to the next book. */
-void CCommentaryReadWindow::nextBook() {
+void CCommentaryReadWindow::nextBook()
+{
if (verseKey()->next(CSwordVerseKey::UseBook))
keyChooser()->setKey(key());
}
/** Moves one book behind. */
-void CCommentaryReadWindow::previousBook() {
+void CCommentaryReadWindow::previousBook()
+{
if (verseKey()->previous(CSwordVerseKey::UseBook))
keyChooser()->setKey(key());
}
/** Moves to the next book. */
-void CCommentaryReadWindow::nextChapter() {
+void CCommentaryReadWindow::nextChapter()
+{
if (verseKey()->next(CSwordVerseKey::UseChapter))
keyChooser()->setKey(key());
}
/** Moves one book behind. */
-void CCommentaryReadWindow::previousChapter() {
+void CCommentaryReadWindow::previousChapter()
+{
if (verseKey()->previous(CSwordVerseKey::UseChapter))
keyChooser()->setKey(key());
}
/** Moves to the next book. */
-void CCommentaryReadWindow::nextVerse() {
+void CCommentaryReadWindow::nextVerse()
+{
if (verseKey()->next(CSwordVerseKey::UseVerse))
keyChooser()->setKey(key());
}
/** Moves one book behind. */
-void CCommentaryReadWindow::previousVerse() {
+void CCommentaryReadWindow::previousVerse()
+{
if (verseKey()->previous(CSwordVerseKey::UseVerse))
keyChooser()->setKey(key());
}
-bool CCommentaryReadWindow::syncAllowed() const {
+bool CCommentaryReadWindow::syncAllowed() const
+{
return m_syncButton->isChecked();
}
@@ -193,6 +200,7 @@ bool CCommentaryReadWindow::syncAllowed() const {
/*!
\fn CCommentaryReadWindow::setupPopupMenu()
*/
-void CCommentaryReadWindow::setupPopupMenu() {
+void CCommentaryReadWindow::setupPopupMenu()
+{
CLexiconReadWindow::setupPopupMenu();
}
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.h b/src/frontend/displaywindow/ccommentaryreadwindow.h
index 1bac735..333b48f 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.h
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.h
@@ -2,23 +2,18 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-
#ifndef CCOMMENTARYREADWINDOW_H
#define CCOMMENTARYREADWINDOW_H
//BibleTime includes
#include "cbiblereadwindow.h"
-//Qt includes
-//#include <qwidget.h>
-
-
class QAction;
class CSwordVerseKey;
class BtActionCollection;
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 59fccab..6cf160d 100644
--- a/src/frontend/displaywindow/cdisplaywindow.cpp
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -10,7 +10,6 @@
#include "cdisplaywindow.h"
#include "bttoolbarpopupaction.h"
#include "btactioncollection.h"
-
#include "cmodulechooserbar.h"
#include "cbuttons.h"
#include "backend/keys/cswordkey.h"
@@ -54,21 +53,24 @@ CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *paren
// Connect this to the backend module list changes
connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(reload(CSwordBackend::SetupChangedReason)));
- //KMainWindow::setAttribute(Qt::WA_DeleteOnClose); //what about QMdiSubWindow?
}
-CDisplayWindow::~CDisplayWindow() {
+CDisplayWindow::~CDisplayWindow()
+{
delete m_swordKey;
m_swordKey = 0;
}
-CMDIArea* CDisplayWindow::mdi() const {
+CMDIArea* CDisplayWindow::mdi() const
+{
return m_mdi;
}
/** Returns the right window caption. */
-const QString CDisplayWindow::windowCaption() {
- if (!m_modules.count()) {
+const QString CDisplayWindow::windowCaption()
+{
+ if (!m_modules.count())
+ {
return QString::null;
}
@@ -76,12 +78,15 @@ const QString CDisplayWindow::windowCaption() {
}
/** Returns the used modules as a QPtrList */
-QList<CSwordModuleInfo*> CDisplayWindow::modules() {
+QList<CSwordModuleInfo*> CDisplayWindow::modules()
+{
QList<CSwordModuleInfo*> mods;
- for (QStringList::iterator it = m_modules.begin(); it != m_modules.end(); ++it) {
+ for (QStringList::iterator it = m_modules.begin(); it != m_modules.end(); ++it)
+ {
Q_ASSERT(backend()->findModuleByName(*it));
- if (CSwordModuleInfo* m = backend()->findModuleByName(*it)) {
+ if (CSwordModuleInfo* m = backend()->findModuleByName(*it))
+ {
mods.append(m);
}
}
@@ -90,38 +95,39 @@ QList<CSwordModuleInfo*> CDisplayWindow::modules() {
}
/** Set the window caption. */
-void CDisplayWindow::setCaption( const QString& ) {
+void CDisplayWindow::setCaption( const QString& )
+{
QWidget::setWindowTitle( windowCaption() );
m_mdi->emitWindowCaptionChanged();
}
-void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
+void CDisplayWindow::insertKeyboardActions( BtActionCollection* a )
+{
qDebug() << "CDisplayWindow::insertKeyboardActions: ac: " << a;
QAction* actn = new QAction(QIcon(), tr("Zoom in"), 0);
actn->setShortcut(QKeySequence::ZoomIn);
a->addAction("zoomIn", actn);
- //a->addAction(KStandardAction::ZoomIn, "zoomIn", 0, 0);
+
actn = new QAction(QIcon(), tr("Zoom out"), 0);
actn->setShortcut(QKeySequence::ZoomOut);
- a->addAction("zoomIn", actn);
- //a->addAction(KStandardAction::ZoomOut, "zoomOut", 0, 0);
+ a->addAction("zoomOut", actn);
+
actn = new QAction(QIcon(), tr("Close"), 0);
actn->setShortcut(QKeySequence::Close);
a->addAction("closeWindow", actn);
- //a->addAction(KStandardAction::Close, "closeWindow", 0, 0);
+
actn = new QAction(QIcon(), tr("Select all"), 0);
actn->setShortcut(QKeySequence::SelectAll);
a->addAction("selectAll", actn);
- //a->addAction(KStandardAction::SelectAll, "selectAll", 0, 0);
+
actn = new QAction(QIcon(), tr("Copy"), 0);
actn->setShortcut(QKeySequence::Copy);
a->addAction("copySelectedText", actn);
- //a->addAction(KStandardAction::Copy, "copySelectedText", 0, 0);
+
actn = new QAction(QIcon(), tr("Find..."), 0);
actn->setShortcut(QKeySequence::Find);
a->addAction("findText", actn);
- //a->addAction(KStandardAction::Find, "findText", 0, 0);
BtToolBarPopupAction* action = new BtToolBarPopupAction(
QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
@@ -146,85 +152,70 @@ void CDisplayWindow::initActions()
BtActionCollection* ac = actionCollection();
- QAction* kaction = new QAction(
+ CDisplayWindow::insertKeyboardActions(ac);
+
+ QAction* qaction = new QAction(
QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::search::icon)),
tr("Open the search dialog with the works of this window"),
ac
);
- kaction->setShortcut(CResMgr::displaywindows::general::search::accel);
- QObject::connect(kaction, SIGNAL(triggered()), this, SLOT(slotSearchInModules()));
- ac->addAction(CResMgr::displaywindows::general::search::actionName, kaction);
+ qaction->setShortcut(CResMgr::displaywindows::general::search::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(slotSearchInModules()));
+ ac->addAction(CResMgr::displaywindows::general::search::actionName, qaction);
CDisplayConnections* conn = displayWidget()->connectionsProxy();
- QAction* actn = new QAction(QIcon(), tr("Zoom in"), ac);
- actn->setShortcut(QKeySequence::ZoomIn);
+ QAction* actn = ac->action("zoomIn");
QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomIn()));
- ac->addAction("zoomIn", actn);
addAction(actn);
- //a->addAction(KStandardAction::ZoomIn, "zoomIn", 0, 0);
- actn = new QAction(QIcon(), tr("Zoom out"), ac);
- actn->setShortcut(QKeySequence::ZoomOut);
+
+ actn = ac->action("zoomOut");
QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomOut()));
- ac->addAction("zoomOut", actn);
addAction(actn);
- //a->addAction(KStandardAction::ZoomOut, "zoomOut", 0, 0);
- actn = new QAction(QIcon(), tr("Close"), ac);
- actn->setShortcut(QKeySequence::Close);
+
+ actn = ac->action("closeWindow");
QObject::connect(actn, SIGNAL(triggered()), this, SLOT(close()));
- ac->addAction("closeWindow", actn);
addAction(actn);
- //a->addAction(KStandardAction::Close, "closeWindow", 0, 0);
- actn = new QAction(QIcon(), tr("Select all"), ac);
- actn->setShortcut(QKeySequence::SelectAll);
+
+ actn = ac->action("selectAll");
QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(selectAll()));
- ac->addAction("selectAll", actn);
addAction(actn);
- //a->addAction(KStandardAction::SelectAll, "selectAll", 0, 0);
- actn = new QAction(QIcon(), tr("Copy"), ac);
- actn->setShortcut(QKeySequence::Copy);
+
+ actn = ac->action("copySelectedText");
QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(copySelection()));
- ac->addAction("copySelectedText", actn);
addAction(actn);
- //a->addAction(KStandardAction::Copy, "copySelectedText", 0, 0);
- actn = new QAction(QIcon(), tr("Find..."), ac);
- actn->setShortcut(QKeySequence::Find);
+
+ actn = ac->action("findText");
QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(openFindTextDialog()));
- ac->addAction("findText", actn);
addAction(actn);
- //a->addAction(KStandardAction::Find, "findText", 0, 0);
- BtToolBarPopupAction* popupaction = new BtToolBarPopupAction(
- QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
- tr("Back in history"),
- ac
- );
+ QAction* popupaction = ac->action(CResMgr::displaywindows::general::backInHistory::actionName);
bool ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(back()));
Q_ASSERT(ok);
- ac->addAction(CResMgr::displaywindows::general::backInHistory::actionName, popupaction);
+ addAction(popupaction);
- popupaction = new BtToolBarPopupAction(
- QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
- tr("Forward in history"),
- ac
- );
+ popupaction = ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName);
ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(fw()) );
Q_ASSERT(ok);
- ac->addAction(CResMgr::displaywindows::general::forwardInHistory::actionName, popupaction);
+ addAction(popupaction);
+ CBTConfig::setupAccelSettings(CBTConfig::allWindows,ac);
}
/** Refresh the settings of this window. */
-void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
+void CDisplayWindow::reload(CSwordBackend::SetupChangedReason)
+{
//first make sure all used Sword modules are still present
QMutableStringListIterator it(m_modules);
while (it.hasNext()) {
- if (!backend()->findModuleByName(it.next())) {
+ if (!backend()->findModuleByName(it.next()))
+ {
it.remove();
}
}
- if (m_modules.count() == 0){
+ if (m_modules.count() == 0)
+ {
close();
return;
}
@@ -236,75 +227,93 @@ void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
}
modulesChanged();
lookup();
+
+ CBTConfig::setupAccelSettings(CBTConfig::allWindows,actionCollection());
+ CBTConfig::setupAccelSettings(CBTConfig::readWindow, actionCollection());
}
/** Returns the filter options used by this window. */
-CSwordBackend::FilterOptions& CDisplayWindow::filterOptions() {
+CSwordBackend::FilterOptions& CDisplayWindow::filterOptions()
+{
return m_filterOptions;
}
/** Returns the display options used by this display window. */
-CSwordBackend::DisplayOptions& CDisplayWindow::displayOptions() {
+CSwordBackend::DisplayOptions& CDisplayWindow::displayOptions()
+{
return m_displayOptions;
}
/** Sets the new display options for this window. */
-void CDisplayWindow::setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions ) {
+void CDisplayWindow::setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions )
+{
m_displayOptions = displayOptions;
}
/** Sets the new filter options of this window. */
-void CDisplayWindow::setFilterOptions( CSwordBackend::FilterOptions& filterOptions ) {
+void CDisplayWindow::setFilterOptions( CSwordBackend::FilterOptions& filterOptions )
+{
m_filterOptions = filterOptions;
}
/** Returns true if the widget is ready for use. */
-bool CDisplayWindow::isReady() const {
+bool CDisplayWindow::isReady() const
+{
return m_isReady;
}
/** Set the ready status */
-void CDisplayWindow::setReady( const bool& ready ) {
+void CDisplayWindow::setReady( const bool& ready )
+{
m_isReady = ready;
}
/** Returns true if the window may be closed. */
-bool CDisplayWindow::queryClose() {
+bool CDisplayWindow::queryClose()
+{
return true;
}
/** Returns the keychooser widget of this display window. */
-CKeyChooser* CDisplayWindow::keyChooser() const {
+CKeyChooser* CDisplayWindow::keyChooser() const
+{
return m_keyChooser;
}
/** Sets the keychooser widget for this display window. */
-void CDisplayWindow::setKeyChooser( CKeyChooser* ck ) {
+void CDisplayWindow::setKeyChooser( CKeyChooser* ck )
+{
m_keyChooser = ck;
}
/** Returns the key of this display window. */
-CSwordKey* CDisplayWindow::key() const {
+CSwordKey* CDisplayWindow::key() const
+{
Q_ASSERT( m_swordKey );
return m_swordKey;
}
/** Sets the new sword key. */
-void CDisplayWindow::setKey( CSwordKey* key ) {
+void CDisplayWindow::setKey( CSwordKey* key )
+{
Q_ASSERT( key );
m_swordKey = key;
}
-void CDisplayWindow::modulesChanged() {
+void CDisplayWindow::modulesChanged()
+{
if (moduleChooserBar()) { //necessary for write windows
setModules( m_moduleChooserBar->getModuleList() );
}
- if (!modules().count()) {
+ if (!modules().count())
+ {
close();
}
- else {
- if (displaySettingsButton()) {
+ else
+ {
+ if (displaySettingsButton())
+ {
displaySettingsButton()->reset(modules());
}
@@ -314,35 +323,42 @@ void CDisplayWindow::modulesChanged() {
}
/** Returns the module chooser bar. */
-CModuleChooserBar* CDisplayWindow::moduleChooserBar() const {
+CModuleChooserBar* CDisplayWindow::moduleChooserBar() const
+{
return m_moduleChooserBar;
}
/** Sets the module chooser bar. */
-void CDisplayWindow::setModuleChooserBar( CModuleChooserBar* bar ) {
- if (m_moduleChooserBar) {
+void CDisplayWindow::setModuleChooserBar( CModuleChooserBar* bar )
+{
+ if (m_moduleChooserBar)
+ {
disconnect(m_moduleChooserBar, SIGNAL(sigChanged()), this, SLOT(modulesChanged()));
}
//if a new bar should be set!
- if (bar) {
+ if (bar)
+ {
m_moduleChooserBar = bar;
connect(bar, SIGNAL(sigChanged()), SLOT(modulesChanged()));
}
}
/** Sets the modules. */
-void CDisplayWindow::setModules( const QList<CSwordModuleInfo*>& newModules ) {
+void CDisplayWindow::setModules( const QList<CSwordModuleInfo*>& newModules )
+{
qDebug("CDisplayWindow::setModules");
m_modules.clear();
- foreach (CSwordModuleInfo* mod, newModules) {
+ foreach (CSwordModuleInfo* mod, newModules)
+ {
m_modules.append(mod->name());
}
}
/** Initialize the window. Call this method from the outside, because calling this in the constructor is not possible! */
-bool CDisplayWindow::init() {
+bool CDisplayWindow::init()
+{
qDebug("CDisplayWindow::init");
initView();
setMinimumSize( 100,100 );
@@ -367,32 +383,38 @@ bool CDisplayWindow::init() {
}
/** Returns the main toolbar. */
-QToolBar* CDisplayWindow::mainToolBar() const {
+QToolBar* CDisplayWindow::mainToolBar() const
+{
return m_mainToolBar;
}
/** Returns the main toolbar. */
-QToolBar* CDisplayWindow::buttonsToolBar() const {
+QToolBar* CDisplayWindow::buttonsToolBar() const
+{
return m_buttonsToolBar;
}
/** Sets the main toolbar. */
-void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
+void CDisplayWindow::setMainToolBar( QToolBar* bar )
+{
m_mainToolBar = bar;
}
/** Sets the main toolbar. */
-void CDisplayWindow::setButtonsToolBar( QToolBar* bar ) {
+void CDisplayWindow::setButtonsToolBar( QToolBar* bar )
+{
m_buttonsToolBar = bar;
}
/** Returns the display settings button */
-CDisplaySettingsButton* CDisplayWindow::displaySettingsButton() const {
+CDisplaySettingsButton* CDisplayWindow::displaySettingsButton() const
+{
return m_displaySettingsButton;
}
/** Sets the display settings button. */
-void CDisplayWindow::setDisplaySettingsButton( CDisplaySettingsButton* button ) {
+void CDisplayWindow::setDisplaySettingsButton( CDisplaySettingsButton* button )
+{
if (m_displaySettingsButton)
disconnect(m_displaySettingsButton, SIGNAL( sigChanged() ),this, SLOT(lookup() ));
@@ -401,27 +423,33 @@ void CDisplayWindow::setDisplaySettingsButton( CDisplaySettingsButton* button )
}
/** Lookup the current key. Used to refresh the display. */
-void CDisplayWindow::lookup() {
+void CDisplayWindow::lookup()
+{
lookupSwordKey( key() );
}
-void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& keyName ) {
- if (!isReady()) {
+void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& keyName )
+{
+ if (!isReady())
+ {
return;
}
CSwordModuleInfo* m = backend()->findModuleByName(moduleName);
Q_ASSERT(m);
- if (!m) {
+ if (!m)
+ {
return;
}
//ToDo: check for containsRef compat
- if (m && modules().contains(m)) {
+ if (m && modules().contains(m))
+ {
key()->key(keyName);
keyChooser()->setKey(key()); //the key chooser does send an update signal
}
- else { //given module not displayed in this window
+ else
+ { //given module not displayed in this window
//if the module is displayed in another display window we assume a wrong drop
//create a new window for the given module
QList<CSwordModuleInfo*> mList;
@@ -430,7 +458,8 @@ void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& key
}
}
-void CDisplayWindow::lookupKey( const QString& keyName ) {
+void CDisplayWindow::lookupKey( const QString& keyName )
+{
/* This function is called for example after a bookmark was dropped on this window
*/
Q_ASSERT(modules().first());
@@ -440,16 +469,21 @@ void CDisplayWindow::lookupKey( const QString& keyName ) {
}
/** Update the status of the popup menu entries. */
-void CDisplayWindow::updatePopupMenu() {}
+void CDisplayWindow::updatePopupMenu()
+{
+}
///** Returns the installed popup menu. */
-QMenu* CDisplayWindow::popup() {
+QMenu* CDisplayWindow::popup()
+{
// qWarning("CReadWindow::popup()");
- if (!m_popupMenu) {
+ if (!m_popupMenu)
+ {
m_popupMenu = new QMenu(this);
connect(m_popupMenu, SIGNAL(aboutToShow()), this, SLOT(updatePopupMenu()));
- if (displayWidget()) {
+ if (displayWidget())
+ {
displayWidget()->installPopup(m_popupMenu);
}
/* else {
@@ -460,18 +494,22 @@ QMenu* CDisplayWindow::popup() {
}
/** Returns the display widget used by this implementation of CDisplayWindow. */
-CDisplay* CDisplayWindow::displayWidget() const {
+CDisplay* CDisplayWindow::displayWidget() const
+{
Q_ASSERT(m_displayWidget);
return m_displayWidget;
}
/** Sets the display widget used by this display window. */
-void CDisplayWindow::setDisplayWidget( CDisplay* newDisplay ) {
+void CDisplayWindow::setDisplayWidget( CDisplay* newDisplay )
+{
m_displayWidget = newDisplay;
}
-void CDisplayWindow::closeEvent(QCloseEvent* e) {
- if (!queryClose()) {
+void CDisplayWindow::closeEvent(QCloseEvent* e)
+{
+ if (!queryClose())
+ {
e->ignore();
}
else {
@@ -479,15 +517,18 @@ void CDisplayWindow::closeEvent(QCloseEvent* e) {
}
}
-void CDisplayWindow::slotSearchInModules() {
+void CDisplayWindow::slotSearchInModules()
+{
Search::CSearchDialog::openDialog(modules());
}
-void CDisplayWindow::printAll() {
+void CDisplayWindow::printAll()
+{
m_displayWidget->connectionsProxy()->printAll( m_displayOptions, m_filterOptions);
}
-void CDisplayWindow::printAnchorWithText() {
+void CDisplayWindow::printAnchorWithText()
+{
m_displayWidget->connectionsProxy()->printAnchorWithText( m_displayOptions, m_filterOptions);
}
diff --git a/src/frontend/displaywindow/cdisplaywindow.h b/src/frontend/displaywindow/cdisplaywindow.h
index 1eb7d06..80877fb 100644
--- a/src/frontend/displaywindow/cdisplaywindow.h
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,10 +12,8 @@
//BibleTime includes
#include "util/cpointers.h"
-
class CSwordModuleInfo;
#include "backend/managers/cswordbackend.h"
-
#include "frontend/profile/cprofilewindow.h"
//Qt includes
@@ -41,145 +39,117 @@ class BtActionCollection;
* @author The BibleTime team
*/
-class CDisplayWindow : public QMainWindow, public CPointers {
+class CDisplayWindow : public QMainWindow, public CPointers
+{
Q_OBJECT
public:
- enum WriteWindowType {
+ enum WriteWindowType
+ {
HTMLWindow = 1,
PlainTextWindow = 2
};
- /**
- * Insert the keyboard accelerators of this window into the given KAccel object.
- */
- // static void insertKeyboardActions( KAccel* const accel );
+ // Insert the keyboard accelerators of this window into the given KAccel object.
static void insertKeyboardActions( BtActionCollection* const a );
CMDIArea* mdi() const;
- /**
- * Returns the right window caption.
- */
+
+ // Returns the right window caption.
const QString windowCaption();
- /**
- * Returns the used modules as a QPtrList
- */
+
+ // Returns the used modules as a QPtrList
QList<CSwordModuleInfo*> modules();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
+
+ // Store the settings of this window in the given CProfileWindow object.
virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
- /**
- * Store the settings of this window in the given profile window.
- */
+
+ // Store the settings of this window in the given profile window.
virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
- /**
- * Set the window caption.
- */
+
+ // Set the window caption.
virtual void setCaption( const QString& );
- /**
- * Sets the new filter options of this window.
- */
+
+ // Sets the new filter options of this window.
void setFilterOptions( CSwordBackend::FilterOptions& filterOptions );
- /**
- * Sets the new display options for this window.
- */
+
+ // Sets the new display options for this window.
void setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions );
- /**
- * Returns the display options used by this display window.
- */
+
+ // Returns the display options used by this display window.
CSwordBackend::DisplayOptions& displayOptions();
- /**
- * Returns the filter options used by this window.
- */
+
+ // Returns the filter options used by this window.
CSwordBackend::FilterOptions& filterOptions();
- /**
- * Set the ready status
- */
+
+ // Set the ready status
void setReady( const bool& ready );
- /**
- * Returns true if the widget is ready for use.
- */
+
+ // Returns true if the widget is ready for use.
bool isReady() const;
- /**
- * Returns true if the window may be closed.
- */
+
+ // Returns true if the window may be closed.
virtual bool queryClose();
- /**
- * Returns the keychooser widget of this display window.
- */
+
+ // Returns the keychooser widget of this display window.
CKeyChooser* keyChooser() const;
- /**
- * Sets the new sword key.
- */
+
+ // Sets the new sword key.
void setKey( CSwordKey* key );
- /**
- * Returns the key of this display window.
- */
+
+ // Returns the key of this display window.
CSwordKey* key() const;
- /**
- * Initialize the window. Call this method from the outside, because calling this in the constructor is not possible!
- */
+
+ // Initialize the window. Call this method from the outside, because calling this in the constructor is not possible!
virtual bool init();
- /**
- * Sets the main toolbar.
- */
+
+ // Sets the main toolbar.
void setMainToolBar( QToolBar* bar );
- /**
- * Sets the buttons toolbar.
- */
+
+ // Sets the buttons toolbar.
void setButtonsToolBar( QToolBar* bar );
- /**
- * Returns the main toolbar.
- */
+
+ // Returns the main toolbar.
QToolBar* mainToolBar() const;
- /**
- * Returns the buttons toolbar.
- */
+
+ // Returns the buttons toolbar.
QToolBar* buttonsToolBar() const;
- /**
- * Initialize the toolbars
- */
+
+ // Initialize the toolbars
virtual void initToolbars() = 0;
- /**
- * Returns the display settings button
- */
+
+ // Returns the display settings button
CDisplaySettingsButton* displaySettingsButton() const;
- /**
- * Sets the display settings button.
- */
+
+ // Sets the display settings button.
void setDisplaySettingsButton( CDisplaySettingsButton* button );
+
virtual void setupPopupMenu() = 0;
- /**
- * Returns the display widget used by this implementation of CDisplayWindow.
- */
+
+ // Returns the display widget used by this implementation of CDisplayWindow.
virtual CDisplay* displayWidget() const;
- /**
- * Sets the display widget used by this display window.
- */
+
+ // Sets the display widget used by this display window.
virtual void setDisplayWidget( CDisplay* newDisplay );
- /** Returns whether syncs to the active window are allowed at this time for this display window
- * @return boolean value whether sync is allowed
- */
- virtual bool syncAllowed() const {
+ // Returns whether syncs to the active window are allowed at this time for this display window
+ // @return boolean value whether sync is allowed
+ virtual bool syncAllowed() const
+ {
return false;
};
BtActionCollection* actionCollection();
public slots:
- /**
- * Lookup the specified key in the given module. If the module is not chosen withing
- * this display window create a new displaywindow with the right module in it.
- */
+
+ // Lookup the specified key in the given module. If the module is not chosen withing
+ // this display window create a new displaywindow with the right module in it.
virtual void lookupModKey( const QString& module, const QString& key );
- /**
- * Lookup the key in the chosen modules.
- */
+
+ // Lookup the key in the chosen modules.
virtual void lookupKey( const QString& key );
- /**
- * Refresh the settings of this window.
- */
+
+ // Refresh the settings of this window.
virtual void reload(CSwordBackend::SetupChangedReason reason);
protected:
@@ -188,55 +158,48 @@ protected:
CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
virtual ~CDisplayWindow();
- /**
- * Initializes the intern keyboard actions.
- */
+
+ // Initializes the intern keyboard actions.
virtual void initActions();
- /**
- * Sets the keychooser widget for this display window.
- */
+
+ // Sets the keychooser widget for this display window.
void setKeyChooser( CKeyChooser* ck );
- /**
- * Returns the module chooser bar.
- */
+
+ // Returns the module chooser bar.
CModuleChooserBar* moduleChooserBar() const;
- /**
- * Lookup the given key.
- */
+
+ // Lookup the given key.
virtual void lookupSwordKey( CSwordKey* ) = 0;
- /**
- * Sets the module chooser bar.
- */
+
+ // Sets the module chooser bar.
void setModuleChooserBar( CModuleChooserBar* bar );
- /**
- * Sets the modules.
- */
+
+ // Sets the modules.
void setModules( const QList<CSwordModuleInfo*>& modules );
- /**
- * Initializes the signal / slot connections of this display window.
- */
+
+ // Initializes the signal / slot connections of this display window.
virtual void initConnections() = 0;
- /**
- * Initialize the view of this display window.
- */
+
+ // Initialize the view of this display window.
virtual void initView() = 0;
- /**
- * Returns the installed popup menu.
- */
+
+ // Returns the installed popup menu.
QMenu* popup();
+
virtual void closeEvent(QCloseEvent* e);
protected slots:
virtual void modulesChanged();
- /**
- * Lookup the current key. Used to refresh the display.
- */
+
+ // Lookup the current key. Used to refresh the display.
void lookup();
+
virtual void updatePopupMenu();
void slotSearchInModules();
void printAll();
+
void printAnchorWithText();
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index 703e40c..8ceb326 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.cpp
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -2,24 +2,19 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-
-
//BibleTime includes
#include "clexiconreadwindow.h"
#include "btactioncollection.h"
-
#include "cmodulechooserbar.h"
#include "cbuttons.h"
#include "bttoolbarpopupaction.h"
-
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordldkey.h"
-
#include "backend/config/cbtconfig.h"
#include "frontend/cexportmanager.h"
#include "frontend/display/cdisplay.h"
@@ -27,7 +22,6 @@
#include "frontend/display/bthtmlreaddisplay.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/keychooser/bthistory.h"
-
#include "util/ctoolclass.h"
#include "util/cresmgr.h"
#include "util/directoryutil.h"
@@ -46,31 +40,43 @@ CLexiconReadWindow::CLexiconReadWindow(QList<CSwordModuleInfo*> moduleList, CMDI
setKey( CSwordKey::createInstance(moduleList.first()) );
}
-CLexiconReadWindow::~CLexiconReadWindow() {}
+CLexiconReadWindow::~CLexiconReadWindow()
+{
+}
void CLexiconReadWindow::insertKeyboardActions( BtActionCollection* const a )
{
qDebug("CLexiconReadWindow::insertKeyboardActions");
- QAction* kaction;
- kaction = new QAction( tr("Next entry"), a);
- kaction->setShortcut(CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
- a->addAction("nextEntry", kaction);
-
- kaction = new QAction( tr("Previous entry"), a);
- kaction->setShortcut( CResMgr::displaywindows::lexiconWindow::previousEntry::accel);
- a->addAction("previousEntry", kaction);
+ QAction* qaction;
+ qaction = new QAction( tr("Next entry"), a);
+ qaction->setShortcut(CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
+ a->addAction("nextEntry", qaction);
+
+ qaction = new QAction( tr("Previous entry"), a);
+ qaction->setShortcut( CResMgr::displaywindows::lexiconWindow::previousEntry::accel);
+ a->addAction("previousEntry", qaction);
- kaction = new QAction(tr("Copy reference only"), a);
- a->addAction("copyReferenceOnly", kaction);
+ qaction = new QAction(tr("Copy reference only"), a);
+ a->addAction("copyReferenceOnly", qaction);
+
+ qaction = new QAction(tr("Save entry as HTML"), a);
+ a->addAction("saveHtml", qaction);
- kaction = new QAction(tr("Copy selected text"), a);
- a->addAction("copySelectedText", kaction);
+ qaction = new QAction(tr("Print reference only"), a);
+ a->addAction("printReferenceOnly", qaction);
- kaction = new QAction(tr("Save entry as HTML"), a);
- a->addAction("saveHtml", kaction);
+ qaction = new QAction(tr("Entry with text"), a);
+ a->addAction("copyEntryWithText", qaction);
- kaction = new QAction(tr("Print reference only"), a);
- a->addAction("printReferenceOnly", kaction);
+ qaction = new QAction(tr("Entry as plain text"), a);
+ a->addAction("saveEntryAsPlain", qaction);
+
+ qaction = new QAction(tr("Entry with text"), a);
+ a->addAction("printEntryWithText", qaction);
+
+ qaction = new QAction( /* QIcon(CResMgr::displaywindows::general::findStrongs::icon), */ tr("Strong's Search"), a);
+ qaction->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
+ a->addAction(CResMgr::displaywindows::general::findStrongs::actionName, qaction);
}
void CLexiconReadWindow::initActions()
@@ -78,74 +84,69 @@ void CLexiconReadWindow::initActions()
qDebug("CLexiconReadWindow::initActions");
BtActionCollection* ac = actionCollection();
- CLexiconReadWindow::insertKeyboardActions(ac);
CReadWindow::initActions();
+ CLexiconReadWindow::insertKeyboardActions(ac);
m_actions.backInHistory = dynamic_cast<BtToolBarPopupAction*>(
ac->action(CResMgr::displaywindows::general::backInHistory::actionName) );
Q_ASSERT(m_actions.backInHistory);
+ addAction(m_actions.backInHistory);
m_actions.forwardInHistory = dynamic_cast<BtToolBarPopupAction*>(
ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName) );
Q_ASSERT(m_actions.forwardInHistory);
+ addAction(m_actions.forwardInHistory);
- QAction* kaction;
+ QAction* qaction;
- kaction = new QAction(tr("Next entry"), ac );
- kaction->setShortcut( CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
- QObject::connect(kaction, SIGNAL(triggered()), this, SLOT( nextEntry() ) );
- ac->addAction("nextEntry", kaction);
+ qaction = ac->action("nextEntry");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( nextEntry() ) );
+ addAction(qaction);
- kaction = new QAction(tr("Previous entry"), ac );
- kaction->setShortcut( CResMgr::displaywindows::lexiconWindow::previousEntry::accel);
- QObject::connect(kaction, SIGNAL(triggered()), this, SLOT( previousEntry() ) );
- ac->addAction("previousEntry", kaction);
+ qaction = ac->action("previousEntry");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( previousEntry() ) );
+ addAction(qaction);
- m_actions.selectAll = qobject_cast<QAction*>(ac->action("selectAll"));
- //TODO: Q_ASSERT(m_actions.selectAll);
+ m_actions.selectAll = ac->action("selectAll");
+ Q_ASSERT(m_actions.selectAll);
- m_actions.findText = qobject_cast<QAction*>(ac->action("findText"));
- //TODO: Q_ASSERT(m_actions.findText);
+ m_actions.findText = ac->action("findText");
+ Q_ASSERT(m_actions.findText);
- m_actions.findStrongs = new QAction(
-// QIcon(CResMgr::displaywindows::general::findStrongs::icon),
- tr("Strong's Search"),
- ac
- );
- m_actions.findStrongs->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
+ m_actions.findStrongs = ac->action(CResMgr::displaywindows::general::findStrongs::actionName);
QObject::connect(m_actions.findStrongs, SIGNAL(triggered()), this, SLOT(openSearchStrongsDialog()) );
- ac->addAction(CResMgr::displaywindows::general::findStrongs::actionName, m_actions.findStrongs);
+ addAction(m_actions.findStrongs);
- m_actions.copy.reference = new QAction(tr("Reference only"), ac );
+ m_actions.copy.reference = ac->action("copyReferenceOnly");
QObject::connect(m_actions.copy.reference, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()) );
- ac->addAction("copyReferenceOnly", m_actions.copy.reference);
+ addAction(m_actions.copy.reference);
- m_actions.copy.entry = new QAction(tr("Entry with text"), ac );
+ m_actions.copy.entry = ac->action("copyEntryWithText");
QObject::connect(m_actions.copy.entry, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAll()) );
- ac->addAction("copyEntryWithText", m_actions.copy.entry);
+ addAction(m_actions.copy.entry);
Q_ASSERT(ac->action("copySelectedText"));
- m_actions.copy.selectedText = qobject_cast<QAction*>(ac->action("copySelectedText"));
+ m_actions.copy.selectedText = ac->action("copySelectedText");
m_actions.save.entryAsPlain = new QAction(tr("Entry as plain text"), ac );
QObject::connect(m_actions.save.entryAsPlain, SIGNAL(triggered()), this, SLOT(saveAsPlain()) );
- ac->addAction("saveEntryAsPlain", m_actions.save.entryAsPlain);
+ addAction(m_actions.save.entryAsPlain);
- m_actions.save.entryAsHTML = new QAction(tr("Entry as HTML"), ac );
+ m_actions.save.entryAsHTML = ac->action("saveHtml");
QObject::connect(m_actions.save.entryAsHTML, SIGNAL(triggered()), this, SLOT(saveAsHTML()));
- ac->addAction("saveEntryAsHTML", m_actions.save.entryAsHTML);
+ addAction(m_actions.save.entryAsHTML);
- m_actions.print.reference = new QAction(tr("Reference only"), ac);
+ m_actions.print.reference = ac->action("printReferenceOnly");
QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()));
- ac->addAction("printReferenceOnly", m_actions.print.reference);
+ addAction(m_actions.print.reference);
- m_actions.print.entry = new QAction(tr("Entry with text"), ac);
+ m_actions.print.entry = ac->action("printEntryWithText");
QObject::connect(m_actions.print.entry, SIGNAL(triggered()), this, SLOT(printAll()));
- ac->addAction("printEntryWithText", m_actions.print.entry);
+ addAction(m_actions.print.entry);
// init with the user defined settings
qDebug("call CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac); and end CLexiconReadWindow::initActions");
-// CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
+ CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
}
/** No descriptions */
@@ -273,6 +274,13 @@ void CLexiconReadWindow::updatePopupMenu()
m_actions.print.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
}
+void CLexiconReadWindow::reload(CSwordBackend::SetupChangedReason reason)
+{
+ CReadWindow::reload(reason);
+
+ CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, actionCollection());
+}
+
/** No descriptions */
void CLexiconReadWindow::nextEntry()
{
@@ -306,7 +314,8 @@ void CLexiconReadWindow::saveRawHTML()
QFile file(savefilename);
BtHtmlReadDisplay* disp = dynamic_cast<BtHtmlReadDisplay*>(displayWidget());
if (disp) {
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ {
qDebug("could not open file");
return;
}
@@ -337,7 +346,8 @@ void CLexiconReadWindow::slotFillBackHistory()
//TODO: take the history list and fill the menu
QListIterator<QAction*> it(keyChooser()->history()->getBackList());
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
menu->addAction(it.next());
}
}
@@ -350,7 +360,8 @@ void CLexiconReadWindow::slotFillForwardHistory()
menu->clear();
//TODO: take the history list and fill the menu using addAction
QListIterator<QAction*> it(keyChooser()->history()->getFwList());
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
menu->addAction(it.next());
}
}
diff --git a/src/frontend/displaywindow/clexiconreadwindow.h b/src/frontend/displaywindow/clexiconreadwindow.h
index cea9096..45e9ceb 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.h
+++ b/src/frontend/displaywindow/clexiconreadwindow.h
@@ -2,13 +2,12 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-
#ifndef CLEXICONREADWINDOW_H
#define CLEXICONREADWINDOW_H
@@ -16,11 +15,8 @@
#include "creadwindow.h"
#include "frontend/keychooser/ckeychooser.h"
class BtToolBarPopupAction;
-
class CSwordKey;
class CSwordLDKey;
-
-class KToolBarPopupAction;
class BtActionCollection;
class QAction;
class QMenu;
@@ -48,6 +44,12 @@ public:
// static void insertKeyboardActions( KAccel* a );
static void insertKeyboardActions( BtActionCollection* const a );
+public slots:
+ /**
+ * Refreshes the content of this display window and the content of the keychooser.
+ */
+ virtual void reload(CSwordBackend::SetupChangedReason reason);
+
protected:
virtual void initActions();
virtual void initToolbars();
diff --git a/src/frontend/htmldialogs/btaboutdialog.cpp b/src/frontend/htmldialogs/btaboutdialog.cpp
index 5e0bc91..0f783e9 100644
--- a/src/frontend/htmldialogs/btaboutdialog.cpp
+++ b/src/frontend/htmldialogs/btaboutdialog.cpp
@@ -103,6 +103,7 @@ void BtAboutDialog::init_contributors_tab()
// sorted alphabetically (last name)
content += "<ul>";
content += "<li>Horatiu Alexe</li>";
+ content += "<li>Jan B&ecarron;lohoubek</li>";
content += "<li>Chun-shek Chan</li>";
content += "<li>Ilpo Kantonen</li>";
content += "<li>Pavel Laukko</li>";
@@ -110,6 +111,7 @@ void BtAboutDialog::init_contributors_tab()
content += "<li>G&eacute;za Nov&aacute;k</li>";
content += "<li>Gabriel P&eacute;rez</li>";
content += "<li>Igor Plisco</li>";
+ content += "<li>Zdenko Podobn&yacute;</li>";
content += "<li>Jaak Ristioja</li>";
content += "<li>Igor Rykhlin</li>";
content += "<li>Vlad Savitsky</li>";
diff --git a/src/frontend/keychooser/cscrollbutton.cpp b/src/frontend/keychooser/cscrollbutton.cpp
index 742bc53..3287eef 100644
--- a/src/frontend/keychooser/cscrollbutton.cpp
+++ b/src/frontend/keychooser/cscrollbutton.cpp
@@ -2,20 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-
-
#include "cscrollbutton.h"
-
-#include <stdlib.h>
-#include <math.h>
-
-//Qt includes
+#include <cmath>
#include <QEvent>
#include <QApplication>
#include <QCursor>
@@ -23,63 +17,67 @@
#include <QMouseEvent>
#include <QWheelEvent>
-CScrollButton::CScrollButton(QWidget *parent) : QToolButton(parent) {
- setFocusPolicy(Qt::WheelFocus);
- setCursor(Qt::SplitVCursor );
-
- m_isLocked = false;
- connect(this, SIGNAL(pressed() ), SLOT(was_pressed() ));
- connect(this, SIGNAL(released()), SLOT(was_released()));
-}
-
-bool CScrollButton::isLocked( ) const {
- return m_isLocked;
+CScrollButton::CScrollButton(QWidget *parent)
+ : QToolButton(parent), m_isLocked(false)
+{
+ setFocusPolicy(Qt::WheelFocus);
+ setCursor(Qt::SplitVCursor);
}
-void CScrollButton::was_pressed( ) {
- QApplication::setOverrideCursor(Qt::BlankCursor);
- m_isLocked = true;
- lock_Point = get_lock_Point();
-
- emit lock()
- ;
+CScrollButton::~CScrollButton() {
+ // Intentionally empty
}
-void CScrollButton::was_released( ) {
- QApplication::restoreOverrideCursor();
- m_isLocked = false;
-
- emit unlock();
+void CScrollButton::mousePressEvent(QMouseEvent *e) {
+ if (m_isLocked) return;
+ if (e->button() != Qt::LeftButton) return;
+ m_isLocked = true;
+ grabMouse(Qt::BlankCursor);
+ emit lock();
}
-const QPoint CScrollButton::get_lock_Point() const {
- return mapToGlobal( QPoint( width()/2, height()/2 ) );
+void CScrollButton::mouseReleaseEvent(QMouseEvent *e) {
+ if (!m_isLocked) return;
+ if (e->button() != Qt::LeftButton) return;
+ m_isLocked = false;
+ releaseMouse();
+ emit unlock();
}
-void CScrollButton::mouseMoveEvent( QMouseEvent* e ) {
- if (m_isLocked) {
- int vchange = (QCursor::pos().y() - lock_Point.y());
-
- if (abs(vchange) < 10) {
- vchange = (int)((vchange>0 ? 1 : -1) * pow(abs(vchange), 0.3));
- }
- else if (abs(vchange) < 30) {
- vchange = (int)((vchange>0 ? 1 : -1) * pow(abs(vchange), 0.6));
- }
- else if (abs(vchange) < 40) {
- vchange = (int)((vchange>0 ? 1 : -1) * pow(abs(vchange), 1.2));
- }
- else {
- vchange = (int)((vchange>0 ? 1 : -1) * pow(abs(vchange), 2.0));
- }
-
- if (vchange) { //not emit 0
- emit change_requested( vchange );
- }
-
- QCursor::setPos( lock_Point );
- }
- else {
- QToolButton::mouseMoveEvent(e);
- }
+void CScrollButton::mouseMoveEvent(QMouseEvent *e) {
+ if (m_isLocked) {
+ // Recalculate the center of the widget (might change during grab):
+ QPoint center(mapToGlobal(QPoint(width() / 2, height() / 2)));
+
+ // Calculate movement change:
+ int vchange = (e->globalY() - center.y());
+
+ if (vchange != 0) {
+ // Calculate the real change we are going to emit:
+ int avchange(vchange >= 0 ? vchange : -vchange);
+ if (avchange < 10) {
+ avchange = (int) pow(avchange, 0.3);
+ } else if (avchange < 30) {
+ avchange = (int) pow(avchange, 0.6);
+ } else if (avchange < 40) {
+ avchange = (int) pow(avchange, 1.2);
+ } else {
+ avchange = (int) pow(avchange, 2.0);
+ }
+
+ // Emit the change request signal only when necessary:
+ if (avchange != 0) {
+ if (vchange > 0) {
+ emit change_requested(avchange);
+ } else if (vchange < 0) {
+ emit change_requested(-avchange);
+ }
+ }
+ }
+
+ // Move the mouse cursor to the center of this widget:
+ QCursor::setPos(center);
+ } else {
+ QToolButton::mouseMoveEvent(e);
+ }
}
diff --git a/src/frontend/keychooser/cscrollbutton.h b/src/frontend/keychooser/cscrollbutton.h
index 3a38f37..3af4ca8 100644
--- a/src/frontend/keychooser/cscrollbutton.h
+++ b/src/frontend/keychooser/cscrollbutton.h
@@ -2,84 +2,79 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-
-
#ifndef CSRCOLLBUTTON_H
#define CSRCOLLBUTTON_H
-
#include <QToolButton>
-
class QMouseEvent;
class QWidget;
class QMouseEvent;
class QWheelEvent;
-/** This Class implements the direct chooser button used in the KeyChooser Widget
- * @author The BibleTime team
- */
-class CScrollButton : public QToolButton {
- Q_OBJECT
-public:
- /**
- * The constructor
- */
- CScrollButton(QWidget *parent=0);
- bool isLocked() const;
+/**
+* This Class implements the direct chooser button used in the KeyChooser Widget.
+* \author The BibleTime team.
+*/
+class CScrollButton: public QToolButton {
+ Q_OBJECT
+ public:
+ CScrollButton(QWidget *parent = 0);
+ virtual ~CScrollButton();
+
+ signals:
+ /**
+ * \brief The lock() signal is emitted when the button grabs the mouse
+ * and enters the locked state.
+ */
+ void lock();
+
+ /**
+ * \brief The unlock() signal is emitted when the button releases the
+ * leaves the locked state.
+ */
+ void unlock();
+
+ /**
+ * \brief Indicates a change the user made by moving the mouse.
+ *
+ * \param count the number of items to be changed in the KeyChooser
+ * ComboBox.
+ */
+ void change_requested(int count);
-signals:
- /**
- * is emitted when the button enters locked state
- */
- void lock()
- ;
- /**
- * is emitted when the button leaves locked state
- */
- void unlock();
- /**
- * indicates a change the user made by moving the mouse
- * @param count the number of items to be changed in the KeyChooser ComboBox
- */
- void change_requested(int count);
+ protected:
+ /**
+ * \brief Grabs the mouse on left button click and emits lock().
+ */
+ virtual void mousePressEvent(QMouseEvent *e);
-protected slots:
- /*
- * used to process the button press events
- */
- void was_pressed();
- /**
- * used to process the button release events
- */
- void was_released();
+ /**
+ * \brief If the mouse is grabbed and we release the left mouse button,
+ * releases the mouse and emits unlock().
+ */
+ virtual void mouseReleaseEvent(QMouseEvent *e);
-protected:
- /**
- * Reimplementation from @ref QWidget#mouseMoveEvent - processes
- * the mouse move events
- */
- virtual void mouseMoveEvent( QMouseEvent* e );
- /**
- * used to find the lock point - the middle of the button
- * @return the lock point
- */
- const QPoint get_lock_Point() const;
+ /**
+ * \brief Reimplementation from \ref QWidget#mouseMoveEvent - processes
+ * the mouse move events
+ */
+ virtual void mouseMoveEvent(QMouseEvent *e);
-private:
- /**
- * Indicates whether the button is in locked state or not
- */
- bool m_isLocked;
- /**
- * stores the lock point
- */
- QPoint lock_Point;
+ protected:
+ /**
+ * \brief Indicates whether the button is in locked state or not.
+ *
+ * If the button is in the locked state, this means the mouse is grabbed
+ * and any mouse move events invoke calculation about whether to emit the
+ * \ref CScrollButton#change_requested signal.
+ */
+ bool m_isLocked;
};
#endif
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
index e4b05c3..c738353 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
@@ -14,15 +14,15 @@
#include <QWheelEvent>
#include <QDebug>
-const unsigned int ARROW_HEIGHT = 12;
+const unsigned int ARROW_HEIGHT = 15;
BtDropdownChooserButton::BtDropdownChooserButton(CKeyReferenceWidget* ref)
: QToolButton(),
m_ref(ref)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-
- setAutoRaise(true);
+
+ setAutoRaise(false);
setArrowType(Qt::NoArrow);
setFixedHeight(ARROW_HEIGHT);
setFocusPolicy(Qt::NoFocus);
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
index 0815a89..11c5ddc 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
@@ -21,21 +21,23 @@
#include "util/directoryutil.h"
//Qt includes
-#include <QString>
-#include <QStringList>
-#include <QEvent>
-#include <QPixmap>
#include <QApplication>
-#include <QHBoxLayout>
-#include <QToolButton>
#include <QDebug>
+#include <QHBoxLayout>
#include <QLineEdit>
+#include <QEvent>
+#include <QMouseEvent>
+#include <QPixmap>
+#include <QString>
+#include <QStringList>
+#include <QToolButton>
CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVerseKey *key, QWidget *parent, const char* /*name*/) :
QWidget(parent),
- m_key(new CSwordVerseKey(mod))
+ m_key(new CSwordVerseKey(mod)),
+ m_dropDownHoverTimer(this)
{
updatelock = false;
@@ -52,7 +54,7 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
m_bookScroller = new CScrollerWidgetSet(this);
m_textbox = new QLineEdit( this );
- m_textbox->setStyleSheet("QLineEdit{margin:0px;}");
+ m_textbox->setContentsMargins(0, 0, 0, 0);
setKey(key); // The order of these two functions is important.
setModule();
@@ -60,34 +62,39 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
m_chapterScroller = new CScrollerWidgetSet(this);
m_verseScroller = new CScrollerWidgetSet(this);
- m_bookDropdownButton = new BtBookDropdownChooserButton(this);
- m_chapterDropdownButton = new BtChapterDropdownChooserButton(this);
- m_verseDropdownButton = new BtVerseDropdownChooserButton(this);
-
- QHBoxLayout* dropdownButtonsLayout = new QHBoxLayout();
- QVBoxLayout* editorAndButtonsLayout = new QVBoxLayout();
- dropdownButtonsLayout->setContentsMargins(0,0,0,0);
- editorAndButtonsLayout->setContentsMargins(0,0,0,0);
- dropdownButtonsLayout->setSpacing(0);
- editorAndButtonsLayout->setSpacing(0);
-
- dropdownButtonsLayout->addWidget(m_bookDropdownButton, 2);
- dropdownButtonsLayout->addWidget(m_chapterDropdownButton,1);
- dropdownButtonsLayout->addWidget(m_verseDropdownButton,1);
- editorAndButtonsLayout->addWidget(m_textbox);
- editorAndButtonsLayout->addLayout(dropdownButtonsLayout);
-
QHBoxLayout* m_mainLayout = new QHBoxLayout( this );
m_mainLayout->setContentsMargins(0,0,0,0);
m_mainLayout->setSpacing(0);
m_mainLayout->addWidget(clearRef);
m_mainLayout->addWidget(m_bookScroller);
- m_mainLayout->addLayout(editorAndButtonsLayout);
+ m_mainLayout->addWidget(m_textbox);
m_mainLayout->addWidget(m_chapterScroller);
m_mainLayout->addWidget(m_verseScroller);
setTabOrder(m_textbox, 0);
+ m_dropDownButtons = new QWidget(0);
+ m_dropDownButtons->setWindowFlags(Qt::Popup);
+ m_dropDownButtons->setAttribute(Qt::WA_WindowPropagation);
+ m_dropDownButtons->setCursor(Qt::ArrowCursor);
+ QHBoxLayout *dropDownButtonsLayout(new QHBoxLayout(m_dropDownButtons));
+ m_bookDropdownButton = new BtBookDropdownChooserButton(this);
+ dropDownButtonsLayout->addWidget(m_bookDropdownButton, 2);
+ m_chapterDropdownButton = new BtChapterDropdownChooserButton(this);
+ dropDownButtonsLayout->addWidget(m_chapterDropdownButton, 1);
+ m_verseDropdownButton = new BtVerseDropdownChooserButton(this);
+ dropDownButtonsLayout->addWidget(m_verseDropdownButton, 1);
+ dropDownButtonsLayout->setContentsMargins(0, 0, 0, 0);
+ dropDownButtonsLayout->setSpacing(0);
+ m_dropDownButtons->setLayout(dropDownButtonsLayout);
+ m_dropDownButtons->hide();
+
+ m_dropDownButtons->installEventFilter(this);
+
+ m_dropDownHoverTimer.setInterval(500);
+ m_dropDownHoverTimer.setSingleShot(true);
+ connect(&m_dropDownHoverTimer, SIGNAL(timeout()),
+ m_dropDownButtons, SLOT(hide()));
QString scrollButtonToolTip(tr("Scroll through the entries of the list. Press the button and move the mouse to increase or decrease the item."));
m_bookScroller->setToolTips(
@@ -120,6 +127,10 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
}
+CKeyReferenceWidget::~CKeyReferenceWidget() {
+ delete m_dropDownButtons;
+}
+
void CKeyReferenceWidget::setModule(CSwordBibleModuleInfo *m)
{
if (m) //can be null
@@ -129,6 +140,48 @@ void CKeyReferenceWidget::setModule(CSwordBibleModuleInfo *m)
}
}
+bool CKeyReferenceWidget::eventFilter(QObject *o, QEvent *e) {
+ if (o != m_dropDownButtons) return false;
+ switch (e->type()) {
+ case QEvent::Enter:
+ m_dropDownHoverTimer.stop();
+ return true;
+ case QEvent::Leave:
+ m_dropDownHoverTimer.start();
+ return true;
+ default:
+ return false;
+ }
+}
+
+void CKeyReferenceWidget::enterEvent(QEvent *) {
+ m_dropDownHoverTimer.stop();
+
+ resetDropDownButtons();
+
+ m_dropDownButtons->raise();
+ m_dropDownButtons->show();
+}
+
+void CKeyReferenceWidget::leaveEvent(QEvent *) {
+ m_dropDownHoverTimer.start();
+}
+
+void CKeyReferenceWidget::resizeEvent(QResizeEvent *event) {
+ if (m_dropDownButtons->isVisible()) {
+ resetDropDownButtons();
+ }
+ QWidget::resizeEvent(event);
+}
+
+void CKeyReferenceWidget::resetDropDownButtons() {
+ m_dropDownButtons->setParent(window());
+ int h(m_dropDownButtons->layout()->minimumSize().height());
+ QPoint topLeft(mapTo(window(), QPoint(m_textbox->x(), height())));
+ m_dropDownButtons->setGeometry(topLeft.x(), topLeft.y(),
+ m_textbox->width(), h);
+}
+
void CKeyReferenceWidget::slotClearRef( )
{
m_textbox->setText("");
@@ -137,7 +190,14 @@ void CKeyReferenceWidget::slotClearRef( )
void CKeyReferenceWidget::updateText()
{
- m_textbox->setText(m_key->key());
+ QString text(m_key->key());
+ m_textbox->setText(text);
+ QFontMetrics fm(m_textbox->font());
+ int nw(m_textbox->minimumSizeHint().width() + fm.width(text));
+ if (nw > m_textbox->minimumWidth()) {
+ m_textbox->setMinimumWidth(nw);
+ m_textbox->updateGeometry();
+ }
}
bool CKeyReferenceWidget::setKey(CSwordVerseKey *key)
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
index d6d5eee..0ecb7a9 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
@@ -16,6 +16,7 @@
#include <QWidget>
#include <boost/scoped_ptr.hpp>
+#include <QTimer>
class CLexiconKeyChooser;
@@ -32,14 +33,20 @@ public:
* the constructor
*/
CKeyReferenceWidget(CSwordBibleModuleInfo *, CSwordVerseKey*, QWidget *parent=0, const char *name=0);
+ ~CKeyReferenceWidget();
bool setKey(CSwordVerseKey* key);
QLineEdit* textbox();
void setModule(CSwordBibleModuleInfo *m = 0);
+ bool eventFilter(QObject *o, QEvent *e);
signals:
void changed(CSwordVerseKey* key);
protected:
+ void enterEvent(QEvent *event);
+ void leaveEvent(QEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void resetDropDownButtons();
void updateText();
protected slots: // Protected slots
@@ -74,6 +81,8 @@ private:
CScrollerWidgetSet *m_chapterScroller;
CScrollerWidgetSet *m_verseScroller;
+ QWidget *m_dropDownButtons;
+ QTimer m_dropDownHoverTimer;
BtDropdownChooserButton* m_bookDropdownButton;
BtDropdownChooserButton* m_chapterDropdownButton;
BtDropdownChooserButton* m_verseDropdownButton;
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
index d37cb1d..7ce07e8 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
@@ -32,15 +32,15 @@ CSearchAnalysisDialog::CSearchAnalysisDialog( QList<CSwordModuleInfo*> modules,
initView();
m_analysis->reset();
m_analysis->analyse(modules);
-
+
// Set initial width based on the search data, but limit to the
// width of the desktop
- int width = m_analysis->width()+DIALOG_BORDER;
+ int width = (int)( m_analysis->width()+DIALOG_BORDER );
int desktopWidth = QApplication::desktop()->screenGeometry(this).width();
if (width > desktopWidth)
width = desktopWidth;
resize(width, DIALOG_HEIGHT);
-
+
}
/** Initializes this dialog. */
@@ -58,7 +58,7 @@ void CSearchAnalysisDialog::initView()
m_buttonBox->setOrientation(Qt::Horizontal);
m_buttonBox->setStandardButtons(QDialogButtonBox::Close);
m_buttonBox->addButton(QDialogButtonBox::Save);
- //tr("Save as HTML"),
+ //tr("Save as HTML"),
util::prepareDialogBox(m_buttonBox);
vboxLayout->addWidget(m_buttonBox);
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
index be667e0..461e65a 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
@@ -51,7 +51,7 @@ void CSearchAnalysisLegendItem::paint(QPainter* painter, const QStyleOptionGraph
//the outer rectangle
QPoint p1( (int)(rect().x()), (int)(rect().y()) );
- QPoint p2( (int)(rect().x()+rect().width()), (int)(rect().y()) + rect().height() );
+ QPoint p2( (int)(rect().x() + rect().width() ), (int)(rect().y() + rect().height()));
QRect r(p1, p2);
r = r.normalized();
painter->drawRect(r);
diff --git a/src/frontend/searchdialog/csearchdialog.cpp b/src/frontend/searchdialog/csearchdialog.cpp
index 947e669..5fd590e 100644
--- a/src/frontend/searchdialog/csearchdialog.cpp
+++ b/src/frontend/searchdialog/csearchdialog.cpp
@@ -263,12 +263,12 @@ void CSearchDialog::showModulesSelector() {
/** Initializes the signal slot connections */
void CSearchDialog::initConnections() {
// Search button is clicked
- bool ok = connect(m_searchOptionsArea->searchButton(), SIGNAL(pressed()),this, SLOT(startSearch()));
+ bool ok = connect(m_searchOptionsArea->searchButton(), SIGNAL(clicked()),this, SLOT(startSearch()));
Q_ASSERT(ok);
// Return/Enter is pressed in the search text field
ok = connect(m_searchOptionsArea, SIGNAL(sigStartSearch()), this, SLOT(startSearch()) );
Q_ASSERT(ok);
- ok = connect(m_closeButton, SIGNAL(pressed()), this, SLOT(closeButtonPressed()));
+ ok = connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
Q_ASSERT(ok);
connect(m_analyseButton, SIGNAL(clicked()), m_searchResultArea, SLOT(showAnalysis()));
@@ -281,7 +281,7 @@ void CSearchDialog::reset() {
m_searchResultArea->reset();
}
-void CSearchDialog::closeButtonPressed() {
+void CSearchDialog::closeButtonClicked() {
// With Qt::WA_DeleteOnClose set, the dialog will be deleted now
m_staticDialog->close();
}
diff --git a/src/frontend/searchdialog/csearchdialog.h b/src/frontend/searchdialog/csearchdialog.h
index 639ca26..de46ad3 100644
--- a/src/frontend/searchdialog/csearchdialog.h
+++ b/src/frontend/searchdialog/csearchdialog.h
@@ -117,7 +117,7 @@ protected slots:
*/
void initConnections();
- void closeButtonPressed();
+ void closeButtonClicked();
private:
QPushButton* m_analyseButton;
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.cpp b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
new file mode 100644
index 0000000..399b5b1
--- /dev/null
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
@@ -0,0 +1,115 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "btshortcutsdialog.h"
+
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QRadioButton>
+#include <QLabel>
+#include <QDialogButtonBox>
+#include <QKeyEvent>
+
+// *************** BtShortcutsDialog ***************************************************************************
+// A dialog to allow the user to input a shortcut for a primary and alternate key
+
+// dialog constructor
+BtShortcutsDialog::BtShortcutsDialog(QWidget* parent)
+ : QDialog(parent), m_primaryLabel(0), m_alternateLabel(0), m_primaryButton(0), m_alternateButton(0)
+{
+ setWindowTitle(tr("Configure shortcuts"));
+ setMinimumWidth(350);
+
+ QVBoxLayout* vLayout = new QVBoxLayout(this);
+ setLayout(vLayout);
+
+ QGridLayout* gridLayout = new QGridLayout();
+ vLayout->addLayout(gridLayout);
+
+ m_primaryButton = new QRadioButton(tr("First shortcut"));
+ m_primaryButton->setChecked(true);
+ gridLayout->addWidget(m_primaryButton, 0, 0);
+
+ m_alternateButton = new QRadioButton(tr("Second shortcut"));
+ gridLayout->addWidget(m_alternateButton, 1, 0);
+
+ m_primaryLabel = new QLabel();
+ m_primaryLabel->setMinimumWidth(100);
+ m_primaryLabel->setFrameShape(QFrame::Panel);
+ gridLayout->addWidget(m_primaryLabel, 0, 1);
+
+ m_alternateLabel = new QLabel();
+ m_alternateLabel->setMinimumWidth(100);
+ m_alternateLabel->setFrameShape(QFrame::Panel);
+ gridLayout->addWidget(m_alternateLabel, 1, 1);
+
+ QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ vLayout->addWidget(buttons);
+
+ connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+// get new primary key from dialog
+QString BtShortcutsDialog::getFirstKeys()
+{
+ return m_primaryLabel->text();
+}
+
+// set the initial value of the primary key
+void BtShortcutsDialog::setFirstKeys(const QString& keys)
+{
+ m_primaryLabel->setText(keys);
+}
+
+ // get new second keys from dialog
+QString BtShortcutsDialog::getSecondKeys()
+{
+ return m_alternateLabel->text();
+}
+
+// set the initial value of the second keys
+void BtShortcutsDialog::setSecondKeys(const QString& keys)
+{
+ m_alternateLabel->setText(keys);
+}
+
+// get key from users input, put into primary or alternate label for display to user
+void BtShortcutsDialog::keyReleaseEvent(QKeyEvent* event)
+{
+ int key = event->key();
+ if ( (key == Qt::Key_Shift) || (key == Qt::Key_Control) || (key == Qt::Key_Meta) || (key == Qt::Key_Alt) )
+ return;
+
+ QKeySequence keys(key);
+ QString keyStr = keys.toString();
+ if ( (event->modifiers() & Qt::AltModifier) == Qt::AltModifier)
+ keyStr = "Alt+" + keyStr;
+ if ( (event->modifiers() & Qt::ShiftModifier) == Qt::ShiftModifier)
+ keyStr = "Shift+" + keyStr;
+ if ( (event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier)
+ keyStr = "Ctrl+" + keyStr;
+
+ QKeySequence completeKeys(keyStr);
+ QString completeStr = completeKeys.toString();
+
+ keyChangeRequest(completeStr);
+}
+
+// complete the keyChangeRequest
+void BtShortcutsDialog::changeSelectedShortcut(const QString& keys)
+{
+ if (m_primaryButton->isChecked())
+ m_primaryLabel->setText(keys);
+
+ if (m_alternateButton->isChecked())
+ m_alternateLabel->setText(keys);
+}
+
+
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.h b/src/frontend/settingsdialogs/btshortcutsdialog.h
new file mode 100644
index 0000000..b9cd6f0
--- /dev/null
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.h
@@ -0,0 +1,59 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BT_SHORTCUTS_DIALOG_H
+#define BT_SHORTCUTS_DIALOG_H
+
+#include <QDialog>
+
+// forwards
+class QLabel;
+class QRadioButton;
+
+// *************** BtShortcutsDialog ***************************************************************************
+// A dialog to allow the user to input a shortcut for a primary and alternate key
+
+class BtShortcutsDialog : public QDialog
+{
+ Q_OBJECT;
+public:
+ BtShortcutsDialog(QWidget* parent);
+
+
+ // get new first keys from dialog
+ QString getFirstKeys();
+
+ // set the initial value of the first keys
+ void setFirstKeys(const QString& keys);
+
+ // get new second keys from dialog
+ QString getSecondKeys();
+
+ // set the initial value of the second keys
+ void setSecondKeys(const QString& keys);
+
+ // change the First or Second shortcut in the dialog
+ void changeSelectedShortcut(const QString& keys);
+
+signals:
+ // make a keyChangeRequest back to the application
+ void keyChangeRequest(const QString& keys);
+
+protected:
+ // get key from users input, put into primary or alternate label for display to user
+ void keyReleaseEvent(QKeyEvent* event);
+
+private:
+ QLabel* m_primaryLabel;
+ QLabel* m_alternateLabel;
+ QRadioButton* m_primaryButton;
+ QRadioButton* m_alternateButton;
+};
+
+#endif
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.cpp b/src/frontend/settingsdialogs/btshortcutseditor.cpp
new file mode 100644
index 0000000..7d50247
--- /dev/null
+++ b/src/frontend/settingsdialogs/btshortcutseditor.cpp
@@ -0,0 +1,413 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "btshortcutseditor.h"
+#include "btshortcutsdialog.h"
+
+#include "frontend/displaywindow/btactioncollection.h"
+
+#include <QTableWidget>
+#include <QTableWidgetItem>
+#include <QKeySequence>
+#include <QVBoxLayout>
+#include <QHeaderView>
+#include <QAction>
+#include <QGroupBox>
+#include <QRadioButton>
+#include <QLabel>
+#include <QSpacerItem>
+#include <QPushButton>
+
+// *************** BtShortcutsEditorItem *******************************************************************
+// BtShortcutsEditorItem is the widget for the first column of the BtShortcutsEditor
+// It holds extra information about the action
+
+class BtShortcutsEditorItem : public QTableWidgetItem
+{
+public:
+ BtShortcutsEditorItem(QAction* action);
+ ~BtShortcutsEditorItem();
+ void commitChanges();
+ QKeySequence getDefaultKeys();
+ void setDefaultKeys(QKeySequence keys);
+ void setFirstHotkey(QKeySequence keys);
+ void setSecondHotkey(const QString& keys);
+ QAction* getAction();
+ void deleteHotkeys();
+
+private:
+ QAction *m_action;
+ QKeySequence *m_newFirstHotkey;
+ QKeySequence *m_newSecondHotkey;
+ QKeySequence m_defaultKeys;
+};
+
+BtShortcutsEditorItem::BtShortcutsEditorItem(QAction* action)
+ : m_action(action), m_newFirstHotkey(0), m_newSecondHotkey(0)
+{
+ QList<QKeySequence> list = m_action->shortcuts();
+ if (list.count()>0)
+ m_newFirstHotkey = new QKeySequence(list.at(0));
+ if (list.count()>1)
+ m_newSecondHotkey = new QKeySequence(list.at(1));
+}
+
+BtShortcutsEditorItem::~BtShortcutsEditorItem()
+{
+ delete m_newFirstHotkey;
+ delete m_newSecondHotkey;
+}
+
+QAction* BtShortcutsEditorItem::getAction()
+{
+ return m_action;
+}
+
+QKeySequence BtShortcutsEditorItem::getDefaultKeys()
+{
+ return m_defaultKeys;
+}
+
+void BtShortcutsEditorItem::setDefaultKeys(QKeySequence keys)
+{
+ m_defaultKeys = keys;
+}
+
+void BtShortcutsEditorItem::setFirstHotkey(QKeySequence keys)
+{
+ if (m_newFirstHotkey == 0)
+ m_newFirstHotkey = new QKeySequence();
+ *m_newFirstHotkey = keys;
+}
+
+void BtShortcutsEditorItem::setSecondHotkey(const QString& keys)
+{
+ if (m_newSecondHotkey == 0)
+ m_newSecondHotkey = new QKeySequence();
+ *m_newSecondHotkey = QKeySequence(keys);
+}
+
+// Deletes hotkey information
+void BtShortcutsEditorItem::deleteHotkeys()
+{
+ delete m_newFirstHotkey;
+ m_newFirstHotkey = 0;
+ delete m_newSecondHotkey;
+ m_newSecondHotkey = 0;
+}
+
+// Moves the hotkey information into the QAction variable
+void BtShortcutsEditorItem::commitChanges()
+{
+ QString actionName = text();
+ QList<QKeySequence> list;
+ if ( (m_newFirstHotkey != 0) && (*m_newFirstHotkey != QKeySequence()) )
+ {
+ list << *m_newFirstHotkey;
+ }
+ if ( (m_newSecondHotkey != 0) && (*m_newSecondHotkey != QKeySequence()) )
+ list << *m_newSecondHotkey;
+
+ if (m_action != 0)
+ m_action->setShortcuts(list);
+}
+
+
+// ******************* BtShortcutsEditor *******************************************************
+
+BtShortcutsEditor::BtShortcutsEditor(BtActionCollection* collection, QWidget* parent)
+ : QWidget(parent), m_dlg(new BtShortcutsDialog(this)), m_table(0), m_shortcutChooser(0), m_noneButton(0), m_defaultButton(0),
+ m_customButton(0), m_defaultLabelValue(0), m_currentRow(-1)
+{
+ init();
+ addCollection(collection);
+ bool ok = connect(m_dlg, SIGNAL(keyChangeRequest(const QString&)), this, SLOT(makeKeyChangeRequest(const QString&)) );
+ Q_ASSERT(ok);
+}
+
+BtShortcutsEditor::BtShortcutsEditor(QWidget* parent)
+ : QWidget(parent), m_table(0)
+{
+ init();
+}
+
+// initialize this widget
+void BtShortcutsEditor::init()
+{
+ QVBoxLayout* vBox = new QVBoxLayout(this);
+ setLayout(vBox);
+
+ m_table = createShortcutsTable();
+ vBox->addWidget(m_table);
+
+ m_shortcutChooser = createShortcutChooser();
+ vBox->addWidget(m_shortcutChooser);
+}
+
+// get the shortcut editor item from the zeroth column of the table
+BtShortcutsEditorItem* BtShortcutsEditor::getShortcutsEditor(int row)
+{
+ QTableWidgetItem* item = m_table->item(row,0);
+ BtShortcutsEditorItem* btItem = dynamic_cast<BtShortcutsEditorItem*>(item);
+ return btItem;
+}
+
+// saves shortcut keys into the QAction
+void BtShortcutsEditor::commitChanges()
+{
+ int rows = m_table->rowCount();
+ for (int row=0; row<rows; row++)
+ {
+ BtShortcutsEditorItem* btItem = getShortcutsEditor(row);
+ if (btItem != 0)
+ btItem->commitChanges();
+ }
+}
+
+// puts actions and shortcut keys into QTableWidget
+void BtShortcutsEditor::addCollection(BtActionCollection* collection, const QString& title)
+{
+ QList<QAction*> actionList = collection->actions();
+ int count;
+ count = actionList.count();
+ foreach (QAction *action, collection->actions())
+ {
+ if (action)
+ {
+ int count = m_table->rowCount();
+ m_table->insertRow(count);
+
+ QString name = action->text().remove('&');
+ QList<QKeySequence> keys = action->shortcuts();
+ QIcon icon = action->icon();
+ QKeySequence defaultKeys = collection->getDefaultShortcut(action);
+
+ BtShortcutsEditorItem* item = new BtShortcutsEditorItem(action);
+ item->setText(name);
+ item->setIcon(icon);
+ item->setDefaultKeys(defaultKeys);
+ item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
+ m_table->setItem(count, 0, item);
+
+ QTableWidgetItem* item1 = new QTableWidgetItem();
+ item1->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
+ item1->setToolTip(tr("Select to change key"));
+ if (keys.count() > 0)
+ item1->setText(keys[0].toString());
+ m_table->setItem(count,1,item1);
+
+ QTableWidgetItem* item2 = new QTableWidgetItem();
+ item2->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
+ item2->setToolTip(tr("Select to change key"));
+ if (keys.count() > 1)
+ item2->setText(keys[1].toString());
+ m_table->setItem(count,2,item2);
+ }
+ }
+ m_table->sortItems(0);
+ m_table->selectRow(0);
+ changeRow(0,0);
+}
+
+// create the action and shortcuts table
+QTableWidget* BtShortcutsEditor::createShortcutsTable()
+{
+ QTableWidget* table = new QTableWidget(this);
+ table->setColumnCount(3);
+ table->setAlternatingRowColors(true);
+ table->setSelectionBehavior(QAbstractItemView::SelectRows);
+ QStringList headerList;
+ headerList << tr("Action\nname") << tr("First\nshortcut") << tr("Second\nshortcut");
+ table->setHorizontalHeaderLabels(headerList);
+ table->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+ table->horizontalHeader()->resizeSection(0, 180);
+ table->horizontalHeader()->resizeSection(1, 100);
+ table->horizontalHeader()->setStretchLastSection(true);
+ table->verticalHeader()->setVisible(false);
+ table->setShowGrid(false);
+ bool ok = connect(table, SIGNAL(cellClicked(int,int)), this, SLOT(changeRow(int,int)));
+ Q_ASSERT(ok);
+ return table;
+}
+
+// called when a different action name row is selected
+void BtShortcutsEditor::changeRow(int row, int column)
+{
+ BtShortcutsEditorItem* item = getShortcutsEditor(row);
+ m_currentRow = row;
+ QKeySequence defaultKeys = item->getDefaultKeys();
+
+ m_defaultLabelValue->setText(defaultKeys);
+
+ QTableWidgetItem* item1 = m_table->item(row,1);
+ QString shortcut = item1->text();
+
+ QTableWidgetItem* item2 = m_table->item(row,2);
+ QString alternate = item2->text();
+
+ QString bothKeys = shortcut;
+ if (!alternate.isEmpty())
+ bothKeys = bothKeys + "; " + alternate;
+ m_customPushButton->setText(bothKeys);
+
+ if ( bothKeys == defaultKeys.toString())
+ m_defaultButton->setChecked(true);
+ else if (bothKeys.isEmpty())
+ m_noneButton->setChecked(true);
+ else
+ m_customButton->setChecked(true);
+}
+
+// create the area below the table where the shortcuts are edited
+QWidget* BtShortcutsEditor::createShortcutChooser()
+{
+ QGroupBox* box = new QGroupBox(tr("Shortcut for selected action name"), this);
+ box->setFlat(false);
+ QVBoxLayout* vLayout = new QVBoxLayout(box);
+ QHBoxLayout* hLayout = new QHBoxLayout();
+ vLayout->addLayout(hLayout);
+
+ m_noneButton = new QRadioButton(tr("None"), box);
+ hLayout->addWidget(m_noneButton);
+ bool ok = connect(m_noneButton, SIGNAL(clicked(bool)), this, SLOT(noneButtonClicked(bool)));
+ Q_ASSERT(ok);
+
+ m_defaultButton = new QRadioButton(tr("Default"), box);
+ hLayout->addWidget(m_defaultButton);
+ ok = connect(m_defaultButton, SIGNAL(clicked(bool)), this, SLOT(defaultButtonClicked(bool)));
+ Q_ASSERT(ok);
+
+ m_customButton = new QRadioButton(tr("Custom"), box);
+ hLayout->addWidget(m_customButton);
+ ok = connect(m_customButton, SIGNAL(clicked(bool)), this, SLOT(customButtonClicked(bool)));
+ Q_ASSERT(ok);
+
+ m_customPushButton = new QPushButton(box);
+ m_customPushButton->setMinimumWidth(140);
+ hLayout->addWidget(m_customPushButton);
+
+ QSpacerItem* spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ hLayout->addItem(spacer);
+
+ QHBoxLayout* hLayout2 = new QHBoxLayout();
+ vLayout->addLayout(hLayout2);
+
+ QLabel* defaultLabel = new QLabel(tr("Default key:"), box);
+ hLayout2->addWidget(defaultLabel);
+
+ m_defaultLabelValue = new QLabel(box);
+ hLayout2->addWidget(m_defaultLabelValue);
+
+ QSpacerItem* spacer2 = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ hLayout2->addItem(spacer2);
+
+ return box;
+}
+
+
+// called when the none radio button is clicked
+void BtShortcutsEditor::noneButtonClicked(bool checked)
+{
+ if (m_currentRow < 0)
+ return;
+ BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
+ m_customPushButton->setText("");
+ item->deleteHotkeys();
+ item->setFirstHotkey(QKeySequence(""));
+ m_table->item(m_currentRow,1)->setText("");
+ m_table->item(m_currentRow,2)->setText("");
+}
+
+// called when the default radio button is clicked
+void BtShortcutsEditor::defaultButtonClicked(bool checked)
+{
+ if (m_currentRow < 0)
+ return;
+ BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
+ QKeySequence defaultKeys = item->getDefaultKeys();
+ item->deleteHotkeys();
+ item->setFirstHotkey(defaultKeys);
+ m_customPushButton->setText(defaultKeys);
+ m_table->item(m_currentRow,1)->setText(defaultKeys);
+ m_table->item(m_currentRow,2)->setText("");
+}
+
+// called when the custom radio button is clicked
+void BtShortcutsEditor::customButtonClicked(bool checked)
+{
+ if (m_currentRow < 0)
+ return;
+
+ QString priKeys = m_table->item(m_currentRow,1)->text();
+ QString altKeys = m_table->item(m_currentRow,2)->text();
+ m_dlg->setSecondKeys(altKeys);
+ m_dlg->setFirstKeys(priKeys);
+ int code = m_dlg->exec();
+ if (code == QDialog::Accepted)
+ {
+ QString newPriKeys = m_dlg->getFirstKeys();
+ QString newAltKeys = m_dlg->getSecondKeys();
+ if (newPriKeys == newAltKeys)
+ newAltKeys = "";
+ BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
+ item->setFirstHotkey(newPriKeys);
+ item->setSecondHotkey(newAltKeys);
+ m_table->item(m_currentRow,1)->setText(newPriKeys);
+ m_table->item(m_currentRow,2)->setText(newAltKeys);
+ }
+}
+
+// complete the keyChangeRequest
+void BtShortcutsEditor::makeKeyChangeRequest(const QString& keys)
+{
+ // signal the application that this BtShortcutsEditor wants to change this shortcut (keys)
+ // The application will check other BtShortcutsEditors and put out a message if the shortcut
+ // is already in use. If the user requests reassignment, the application calls the BtShortcutsEditors to
+ // reassign and set the shortcut.
+ keyChangeRequest(this, keys);
+}
+
+// used by application to complete the keyChangeRequest signal
+// stores "keys" into the custom shortcuts dialog field
+void BtShortcutsEditor::changeShortcutInDialog(const QString& keys)
+{
+ m_dlg->changeSelectedShortcut(keys);
+}
+
+// clears any shortcut keys in the table matching the specified keys
+void BtShortcutsEditor::clearConflictWithKeys(const QString& keys)
+{
+ QString conflict;
+ for (int row=0; row<m_table->rowCount(); row++)
+ {
+ BtShortcutsEditorItem* item = getShortcutsEditor(row);
+ if (m_table->item(row,1)->text() == keys)
+ {
+ m_table->item(row,1)->setText("");
+ item->setFirstHotkey(QKeySequence(""));
+ }
+ if (m_table->item(row,2)->text() == keys)
+ {
+ m_table->item(row,2)->setText("");
+ item->setSecondHotkey(QKeySequence(""));
+ }
+ }
+}
+
+// finds any shortcut keys in the table matching the specified keys - returns the Action Name for it.
+QString BtShortcutsEditor::findConflictWithKeys(const QString& keys)
+{
+ QString conflict;
+ for (int i=0; i<m_table->rowCount(); i++)
+ {
+ if ( (m_table->item(i,1)->text() == keys) || (m_table->item(i,2)->text() == keys) )
+ return m_table->item(i,0)->text();
+ }
+ return conflict;
+}
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.h b/src/frontend/settingsdialogs/btshortcutseditor.h
new file mode 100644
index 0000000..5003d6d
--- /dev/null
+++ b/src/frontend/settingsdialogs/btshortcutseditor.h
@@ -0,0 +1,96 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+#ifndef BT_SHORTCUTS_EDITOR_H
+#define BT_SHORTCUTS_EDITOR_H
+
+#include <QWidget>
+
+// forwards
+class BtActionCollection;
+class BtShortcutsEditorItem;
+class BtShortcutsDialog;
+class QPushButton;
+class QRadioButton;
+class QTableWidget;
+class QLabel;
+
+// This class is the table in the center of the Shortcuts page of the config dialog
+class BtShortcutsEditor : public QWidget
+{
+ Q_OBJECT
+public:
+ BtShortcutsEditor(BtActionCollection* collection, QWidget* parent);
+ BtShortcutsEditor(QWidget* parent);
+
+ // saves shortcut keys into the QAction
+ void commitChanges();
+
+ // puts actions and shortcut keys into QTableWidget
+ void addCollection(BtActionCollection* collection, const QString& title = QString());
+
+ // clears any shortcut keys in the table matching the specified keys
+ void clearConflictWithKeys(const QString& keys);
+
+ // finds any shortcut keys in the table matching the specified keys - returns the Action Name for it.
+ QString findConflictWithKeys(const QString& keys);
+
+ // used by application to complete the keyChangeRequest signal
+ // stores "keys" into the custom shortcuts dialog field
+ void changeShortcutInDialog(const QString& keys);
+
+signals:
+ // make a keyChangeRequest back to the application
+ void keyChangeRequest(BtShortcutsEditor*, const QString& keys);
+
+private slots:
+
+ // called when a different action name row is selected
+ void changeRow(int row, int column);
+
+ // called when the none radio button is clicked
+ void noneButtonClicked(bool checked);
+
+ // called when the default radio button is clicked
+ void defaultButtonClicked(bool checked);
+
+ // called when the custom radio button is clicked
+ void customButtonClicked(bool checked);
+
+ // makes the keyChangeRequest
+ void makeKeyChangeRequest(const QString& keys);
+
+private:
+
+ // create the action and shortcuts table
+ QTableWidget* createShortcutsTable();
+
+ // create the area below the table where the shortcuts are edited
+ QWidget* createShortcutChooser();
+
+ // get the shortcut editor item from the zeroth column of the table
+ BtShortcutsEditorItem* getShortcutsEditor(int row);
+
+ // initialize this widget
+ void init();
+
+ BtShortcutsDialog* m_dlg;
+ QTableWidget* m_table;
+ QWidget* m_shortcutChooser;
+ QRadioButton* m_noneButton;
+ QRadioButton* m_defaultButton;
+ QRadioButton* m_customButton;
+ QPushButton* m_customPushButton;
+ QLabel* m_defaultLabelValue;
+ int m_currentRow;
+};
+
+#endif
+
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.cpp b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
new file mode 100644
index 0000000..df54571
--- /dev/null
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
@@ -0,0 +1,278 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "cacceleratorsettings.h"
+
+#include "bibletime.h"
+#include "backend/config/cbtconfig.h"
+#include "frontend/displaywindow/cbiblereadwindow.h"
+#include "frontend/displaywindow/ccommentaryreadwindow.h"
+#include "frontend/displaywindow/clexiconreadwindow.h"
+#include "frontend/displaywindow/cbookreadwindow.h"
+#include "frontend/displaywindow/creadwindow.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "util/cresmgr.h"
+
+#include <QWidget>
+#include <QComboBox>
+#include <QStackedWidget>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QList>
+#include <QMessageBox>
+
+CAcceleratorSettingsPage::CAcceleratorSettingsPage(QWidget* /* parent */ )
+ : BtConfigPage()
+{
+ QVBoxLayout* mainLayout = new QVBoxLayout(this);
+ this->setLayout(mainLayout);
+
+ QHBoxLayout* layoutForWindowTypeChooser = new QHBoxLayout();
+ mainLayout->addLayout(layoutForWindowTypeChooser);
+
+ QLabel* label = new QLabel(tr("Choose action group:"), this);
+ layoutForWindowTypeChooser->addWidget(label);
+
+ m_typeChooser = new QComboBox(this);
+ layoutForWindowTypeChooser->addWidget(m_typeChooser);
+
+ bool ok = connect(m_typeChooser, SIGNAL(activated(const QString&)),
+ SLOT(slotKeyChooserTypeChanged(const QString&)) );
+ Q_ASSERT(ok);
+
+ m_keyChooserStack = new QStackedWidget(this);
+
+ m_application.title = tr("Main Window");
+ m_general = WindowType(tr("All text windows"));
+ m_bible = WindowType(tr("Bible windows"));
+ m_commentary = WindowType(tr("Commentary windows"));
+ m_lexicon = WindowType(tr("Lexicon windows"));
+ m_book = WindowType(tr("Book windows"));
+
+ m_typeChooser->addItem(m_application.title);
+ m_typeChooser->addItem(m_general.title);
+ m_typeChooser->addItem(m_bible.title);
+ m_typeChooser->addItem(m_commentary.title);
+ m_typeChooser->addItem(m_lexicon.title);
+ m_typeChooser->addItem(m_book.title);
+
+ // create shortcuteditors
+
+ // ------ Application -------------- //
+ m_application.actionCollection = new BtActionCollection(this);
+ BibleTime::insertKeyboardActions( m_application.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::application, m_application.actionCollection);
+ m_application.keyChooser = new BtShortcutsEditor(m_application.actionCollection,m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_application.keyChooser);
+ ok = connect(m_application.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- All display windows ------ //
+ m_general.actionCollection = new BtActionCollection(this);
+ CDisplayWindow::insertKeyboardActions( m_general.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::allWindows,m_general.actionCollection);
+ m_general.keyChooser = new BtShortcutsEditor(m_general.actionCollection, m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_general.keyChooser);
+ ok = connect(m_general.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- Bible windows ------ //
+ m_bible.actionCollection = new BtActionCollection(this);
+ CBibleReadWindow::insertKeyboardActions( m_bible.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::bibleWindow,m_bible.actionCollection);
+ m_bible.keyChooser = new BtShortcutsEditor(m_bible.actionCollection, m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_bible.keyChooser);
+ ok = connect(m_bible.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- Commentary windows ------ //
+ m_commentary.actionCollection = new BtActionCollection(this);
+ CCommentaryReadWindow::insertKeyboardActions( m_commentary.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection);
+ m_commentary.keyChooser = new BtShortcutsEditor(m_commentary.actionCollection, m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_commentary.keyChooser);
+ ok = connect(m_commentary.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- Lexicon windows ------ //
+ m_lexicon.actionCollection = new BtActionCollection(this);
+ CLexiconReadWindow::insertKeyboardActions( m_lexicon.actionCollection );
+ CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection);
+ m_lexicon.keyChooser = new BtShortcutsEditor(m_lexicon.actionCollection, m_keyChooserStack );
+ m_keyChooserStack->addWidget(m_lexicon.keyChooser);
+ ok = connect(m_lexicon.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- Book windows ------ //
+ m_book.actionCollection= new BtActionCollection(this);
+ CBookReadWindow::insertKeyboardActions( m_book.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::bookWindow, m_book.actionCollection);
+ m_book.keyChooser = new BtShortcutsEditor(m_book.actionCollection, m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_book.keyChooser);
+ ok = connect(m_book.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ mainLayout->addWidget(m_keyChooserStack);
+ slotKeyChooserTypeChanged(m_application.title);
+
+ m_typeChooser->setFocus(Qt::MouseFocusReason);
+ qDebug("CAcceleratorSettingsPage::CAcceleratorSettingsPage end");
+}
+
+CAcceleratorSettingsPage::~CAcceleratorSettingsPage()
+{
+}
+
+// complete the keyChangeRequest
+void CAcceleratorSettingsPage::completeKeyChangeRequest(BtShortcutsEditor* shortcutsEditor, const QString& keys)
+{
+ // check the BtShortcutsEditor's for shortcut conflicts
+ // Either clear the conflicts and set the new shortcut or do nothing.
+
+ QList<BtShortcutsEditor*> list = getShortcutsEditorListForGroup(shortcutsEditor);
+ QString conflicts = findConflictsWithKeys(keys, list);
+ if (!conflicts.isEmpty())
+ {
+ QString message = QObject::tr("This shortcut conflicts with the shortcut for the following actions:");
+ message.append("\n");
+ message.append(conflicts);
+
+ QMessageBox msgBox(this);
+ msgBox.setIcon(QMessageBox::Question);
+ msgBox.setText(message);
+ msgBox.setInformativeText(QObject::tr("Do you want to clear the conflicting shortcuts and continue?"));
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+ msgBox.setDefaultButton(QMessageBox::Yes);
+ int ret = msgBox.exec();
+ if ( ret == QMessageBox::Yes)
+ {
+ clearConflictsWithKeys(keys,list);
+ shortcutsEditor->changeShortcutInDialog(keys);
+ }
+ }
+ else
+ {
+ shortcutsEditor->changeShortcutInDialog(keys);
+ }
+}
+
+void CAcceleratorSettingsPage::clearConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list)
+{
+ QString conflicts;
+ for (int i=0; i<list.count(); i++)
+ {
+ list.at(i)->clearConflictWithKeys(keys);
+ }
+}
+
+QString CAcceleratorSettingsPage::findConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list)
+{
+ QString conflicts;
+ for (int i=0; i<list.count(); i++)
+ {
+ QString conflict = list.at(i)->findConflictWithKeys(keys);
+ if (!conflict.isEmpty())
+ {
+ QString conflictMsg(tr("\n \"%1\" in the \"%2\" group").arg(conflict).arg(getTitleForEditor(list.at(i))));
+ conflicts.append(conflictMsg);
+ }
+ }
+ return conflicts;
+}
+
+QString CAcceleratorSettingsPage::getTitleForEditor(BtShortcutsEditor* editor)
+{
+ if (editor == m_application.keyChooser)
+ return m_application.title;
+ if (editor == m_general.keyChooser)
+ return m_general.title;
+ if (editor == m_bible.keyChooser)
+ return m_bible.title;
+ if (editor == m_commentary.keyChooser)
+ return m_commentary.title;
+ if (editor == m_application.keyChooser)
+ return m_lexicon.title;
+ if (editor == m_book.keyChooser)
+ return m_book.title;
+ return QString();
+}
+
+// Gets list of shortcuts editors that can conflict with a key change in the current shortcut editor
+QList<BtShortcutsEditor*> CAcceleratorSettingsPage::getShortcutsEditorListForGroup(BtShortcutsEditor* currentEditor)
+{
+ QList<BtShortcutsEditor*> list;
+
+ list.append(m_application.keyChooser);
+ list.append(m_general.keyChooser);
+ if ( (currentEditor == m_application.keyChooser) || (currentEditor == m_general.keyChooser) )
+ {
+ list.append(m_bible.keyChooser);
+ list.append(m_commentary.keyChooser);
+ list.append(m_lexicon.keyChooser);
+ list.append(m_book.keyChooser);
+ }
+ else
+ {
+ list.append(currentEditor);
+ }
+ return list;
+}
+
+void CAcceleratorSettingsPage::save()
+{
+ if (m_application.keyChooser)
+ m_application.keyChooser->commitChanges();
+ if (m_general.keyChooser)
+ m_general.keyChooser->commitChanges();
+ if (m_bible.keyChooser)
+ m_bible.keyChooser->commitChanges();
+ if (m_commentary.keyChooser)
+ m_commentary.keyChooser->commitChanges();
+ if (m_lexicon.keyChooser)
+ m_lexicon.keyChooser->commitChanges();
+ if (m_book.keyChooser)
+ m_book.keyChooser->commitChanges();
+
+ CBTConfig::saveAccelSettings(CBTConfig::application, m_application.actionCollection); //application
+ CBTConfig::saveAccelSettings(CBTConfig::allWindows, m_general.actionCollection); //read display windows
+ CBTConfig::saveAccelSettings(CBTConfig::bibleWindow, m_bible.actionCollection); //bible
+ CBTConfig::saveAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection); //commentary
+ CBTConfig::saveAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection); //lexicon
+ CBTConfig::saveAccelSettings(CBTConfig::bookWindow, m_book.actionCollection); //book
+}
+
+void CAcceleratorSettingsPage::slotKeyChooserTypeChanged(const QString& title)
+{
+ int index = m_typeChooser->currentIndex();
+ m_keyChooserStack->setCurrentIndex(index);
+
+}
+
+QString CAcceleratorSettingsPage::iconName()
+{
+ return CResMgr::settings::keys::icon;
+}
+
+QString CAcceleratorSettingsPage::label()
+{
+ //: Empty string, don't translate
+ return tr("");
+}
+
+QString CAcceleratorSettingsPage::header()
+{
+ return tr("Shortcuts");
+}
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.cpp.OFF b/src/frontend/settingsdialogs/cacceleratorsettings.cpp.OFF
deleted file mode 100644
index 66fa9dc..0000000
--- a/src/frontend/settingsdialogs/cacceleratorsettings.cpp.OFF
+++ /dev/null
@@ -1,268 +0,0 @@
-//
-// C++ Implementation: cacceleratorsettings
-//
-// Description:
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2008
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-
-#include "cacceleratorsettings.h"
-#include "cacceleratorsettings.moc"
-
-#include "backend/config/cbtconfig.h"
-
-#include "frontend/displaywindow/cbiblereadwindow.h"
-#include "frontend/displaywindow/ccommentaryreadwindow.h"
-#include "frontend/displaywindow/clexiconreadwindow.h"
-#include "frontend/displaywindow/cbookreadwindow.h"
-#include "frontend/displaywindow/creadwindow.h"
-
-#include <QWidget>
-#include <QComboBox>
-#include <QStackedWidget>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <QLabel>
-#include <QList>
-
-#include <kactioncollection.h>
-
-
-
-CAcceleratorSettingsPage::CAcceleratorSettingsPage(QWidget *parent)
- : QWidget(parent)
-{
- qDebug("CAcceleratorSettingsPage::CAcceleratorSettingsPage");
- //TODO: widget layout may not work. Maybe it would be easier to use .ui file.
-
- QVBoxLayout* mainLayout = new QVBoxLayout(this);
- this->setLayout(mainLayout);
- //TODO: actionCollection must exist, but is this the right way?
- m_application.actionCollection = new KActionCollection(this);
- CBTConfig::setupAccelSettings(
- CBTConfig::application,
- m_application.actionCollection
- );
- qDebug("create layout for window type chooser");
- QHBoxLayout* layoutForWindowTypeChooser = new QHBoxLayout(this);
- mainLayout->addLayout(layoutForWindowTypeChooser);
- QLabel* label = new QLabel(tr("Choose type:"), this);
- layoutForWindowTypeChooser->addWidget(label);
- m_typeChooser = new QComboBox(this);
- layoutForWindowTypeChooser->addWidget(m_typeChooser);
-
- connect(
- m_typeChooser, SIGNAL(activated(const QString&)),
- SLOT(slotKeyChooserTypeChanged(const QString&))
- );
- //too ugly! change!
- //QLabel* dummy = new QLabel( this); // empty label for stretch
- //hbox->addWidget(dummy);
-
- //hbox->setStretchFactor(label, 0);
- //hbox->setStretchFactor(m_typeChooser, 0);
- //hbox->setStretchFactor(dummy, 1);
-
- //mainLayout->setStretchFactor(hbox, 0);
- qDebug("create stack");
- m_keyChooserStack = new QStackedWidget(this);
-
- //mainLayout->setStretchFactor(m_keyChooserStack, 5);
-
- m_application.title = tr("BibleTime"); //don't set the app action collection to NULL
- m_general = WindowType(tr("All text windows"));
- m_bible = WindowType(tr("Bible windows"));
- m_commentary = WindowType(tr("Commentary windows"));
- m_lexicon = WindowType(tr("Lexicon windows"));
- m_book = WindowType(tr("Book windows"));
-
- m_typeChooser->addItem(m_application.title);
- m_typeChooser->addItem(m_general.title);
- m_typeChooser->addItem(m_bible.title);
- m_typeChooser->addItem(m_commentary.title);
- m_typeChooser->addItem(m_lexicon.title);
- m_typeChooser->addItem(m_book.title);
-
- qDebug("create shortcuteditors");
- Q_ASSERT(m_application.actionCollection);
- m_application.keyChooser = new KShortcutsEditor(
- m_application.actionCollection,
- m_keyChooserStack
- );
- qDebug("add first w");
- m_keyChooserStack->addWidget(m_application.keyChooser);
-
- // ----- All display windows ------ //
- m_general.actionCollection = new KActionCollection(this);
- CDisplayWindow::insertKeyboardActions( m_general.actionCollection);
- CBTConfig::setupAccelSettings(
- CBTConfig::allWindows,
- m_general.actionCollection
- );
- m_general.keyChooser = new KShortcutsEditor(
- m_general.actionCollection,
- m_keyChooserStack
- );
- qDebug("add second w");
- m_keyChooserStack->addWidget(m_general.keyChooser);
-
- // ----- Bible windows ------ //
- m_bible.actionCollection = new KActionCollection(this);
- CBibleReadWindow::insertKeyboardActions( m_bible.actionCollection);
- CBTConfig::setupAccelSettings(
- CBTConfig::bibleWindow,
- m_bible.actionCollection
- );
- //m_keyChooserStack->addWidget(m_bible.keyChooser);
-
- // ----- Commentary windows ------ //
- m_commentary.actionCollection = new KActionCollection(this);
- CCommentaryReadWindow::insertKeyboardActions( m_commentary.actionCollection);
- CBTConfig::setupAccelSettings(
- CBTConfig::commentaryWindow,
- m_commentary.actionCollection
- );
- //m_keyChooserStack->addWidget(m_commentary.keyChooser);
-
- // ----- Lexicon windows ------ //
- m_lexicon.actionCollection = new KActionCollection(this);
- CLexiconReadWindow::insertKeyboardActions( m_lexicon.actionCollection );
- CBTConfig::setupAccelSettings(
- CBTConfig::lexiconWindow,
- m_lexicon.actionCollection
- );
- //m_keyChooserStack->addWidget(m_lexicon.keyChooser);
-
- // ----- Book windows ------ //
- m_book.actionCollection= new KActionCollection(this);
- CBookReadWindow::insertKeyboardActions( m_book.actionCollection);
- CBTConfig::setupAccelSettings(
- CBTConfig::bookWindow,
- m_book.actionCollection
- );
- //m_keyChooserStack->addWidget(m_book.keyChooser);
-
- mainLayout->addWidget(m_keyChooserStack);
- slotKeyChooserTypeChanged(m_application.title);
-
- qDebug("CAcceleratorSettingsPage::CAcceleratorSettingsPage end");
-}
-
-
-CAcceleratorSettingsPage::~CAcceleratorSettingsPage()
-{
-}
-
-void CAcceleratorSettingsPage::save()
-{
- /* //TODO: does kde4 work without commitChanges?
- if (m_general.keyChooser) {
- m_general.keyChooser->commitChanges();
- }
-
- if (m_bible.keyChooser) {
- m_bible.keyChooser->commitChanges();
- }
-
- if (m_commentary.keyChooser) {
- m_commentary.keyChooser->commitChanges();
- }
-
- if (m_lexicon.keyChooser) {
- m_lexicon.keyChooser->commitChanges();
- }
-
- if (m_book.keyChooser) {
- m_book.keyChooser->commitChanges();
- }
- */
- CBTConfig::saveAccelSettings( //application
- CBTConfig::application,
- m_application.actionCollection
- );
- CBTConfig::saveAccelSettings( //read display windows
- CBTConfig::allWindows,
- m_general.actionCollection
- );
- CBTConfig::saveAccelSettings( //bible
- CBTConfig::bibleWindow,
- m_bible.actionCollection
- );
- CBTConfig::saveAccelSettings( //commentary
- CBTConfig::commentaryWindow,
- m_commentary.actionCollection
- );
- CBTConfig::saveAccelSettings( //lexicon
- CBTConfig::lexiconWindow,
- m_lexicon.actionCollection
- );
- CBTConfig::saveAccelSettings( //book
- CBTConfig::bookWindow,
- m_book.actionCollection
- );
-}
-
-
-void CAcceleratorSettingsPage::slotKeyChooserTypeChanged(const QString& title)
-{
- qDebug("CAcceleratorSettingsPage::slotKeyChooserTypeChanged");
- //delete all KShortcutsEditors which may not share accels, because this class checks in all instances for key conflicts
- typedef QList<KShortcutsEditor*> KeyChooserList;
- KeyChooserList list;
- list.append(m_bible.keyChooser);
- list.append(m_commentary.keyChooser);
- list.append(m_lexicon.keyChooser);
- list.append(m_book.keyChooser);
-
- //commit all changes in the keychoosers
- //for (KeyChooserList::iterator it(list.begin()); it != list.end(); ++it) {
- // if (*it) { //the list may contain NULL pointers
- // (*it)->commitChanges();
- // }
- //}
-
- /* Delete all the keychoosers in the list,
- * the keychoosers are set to NULL, because they are QGuardedPtr
- */
- //list.setAutoDelete(true);
- qDeleteAll(list);
- list.clear();
-
- WindowType* t = 0;
- if (title == m_application.title) { //Application wide
- t = &m_application;
- }
- else if (title == m_general.title) { // All display windows
- t = &m_general;
- }
- else if (title == m_bible.title) { // Bible windows
- t = &m_bible;
- }
- else if (title == m_commentary.title) { // Commentary windows
- t = &m_commentary;
- }
- else if (title == m_lexicon.title) { // Lexicon windows
- t = &m_lexicon;
- }
- else if (title == m_book.title) { // Book windows
- t = &m_book;
- }
-
- Q_ASSERT(t);
- if (!t->keyChooser) { //was deleted, create a new one
- t->keyChooser = new KShortcutsEditor(
- m_keyChooserStack
- );
- t->keyChooser->addCollection(
- t->actionCollection,
- t->title
- );
- }
-
- m_keyChooserStack->setCurrentWidget(t->keyChooser);
- qDebug("CAcceleratorSettingsPage::slotKeyChooserTypeChanged end");
-}
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.h b/src/frontend/settingsdialogs/cacceleratorsettings.h
new file mode 100644
index 0000000..4af867b
--- /dev/null
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.h
@@ -0,0 +1,83 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef CACCELERATORSETTINGS_H
+#define CACCELERATORSETTINGS_H
+
+#include "btshortcutseditor.h"
+
+#include "util/cpointers.h"
+//#include "backend/config/cbtconfig.h"
+#include "frontend/bookshelfmanager/btconfigdialog.h"
+
+#include <QWidget>
+#include <QPointer>
+
+class QComboBox;
+class QStackedWidget;
+class BtActionCollection;
+class BtShortcutsEditor;
+
+/**
+ @author The BibleTime team <info@bibletime.info>
+*/
+class CAcceleratorSettingsPage : public BtConfigPage, CPointers
+{
+ Q_OBJECT
+
+public:
+ CAcceleratorSettingsPage(QWidget *parent);
+ ~CAcceleratorSettingsPage();
+ void save();
+ QString iconName();
+ QString label();
+ QString header();
+
+protected slots:
+
+ void slotKeyChooserTypeChanged(const QString& title);
+
+ // complete the keyChangeRequest
+ void completeKeyChangeRequest(BtShortcutsEditor* shortcutsEditor, const QString& keys);
+
+private:
+ struct WindowType {
+ QPointer<BtShortcutsEditor> keyChooser;
+ BtActionCollection* actionCollection;
+ QString title;
+
+ WindowType() {
+ keyChooser = 0;
+ actionCollection = 0;
+ };
+ WindowType(const QString& newTitle) {
+ title = newTitle;
+ keyChooser = 0;
+ actionCollection = 0;
+ }
+ };
+
+ void clearConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list);
+ QString findConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list);
+ QList<BtShortcutsEditor*> getShortcutsEditorListForGroup(BtShortcutsEditor* currentEditor);
+ QString getTitleForEditor(BtShortcutsEditor* editor);
+
+ WindowType m_application;
+ WindowType m_general;
+ WindowType m_bible;
+ WindowType m_commentary;
+ WindowType m_lexicon;
+ WindowType m_book;
+
+ QComboBox* m_typeChooser;
+ QStackedWidget* m_keyChooserStack;
+
+};
+
+#endif
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.h.OFF b/src/frontend/settingsdialogs/cacceleratorsettings.h.OFF
deleted file mode 100644
index adf0b95..0000000
--- a/src/frontend/settingsdialogs/cacceleratorsettings.h.OFF
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// C++ Interface: cacceleratorsettings
-//
-// Description:
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2008
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-#ifndef CACCELERATORSETTINGS_H
-#define CACCELERATORSETTINGS_H
-
-#include <QWidget>
-#include <QPointer>
-
-#include <kshortcutseditor.h>
-
-class QComboBox;
-class QStackedWidget;
-class KActionCollection;
-
-/**
- @author The BibleTime team <info@bibletime.info>
-*/
-class CAcceleratorSettingsPage : public QWidget
-{
- Q_OBJECT
-
-public:
- CAcceleratorSettingsPage(QWidget *parent);
-
- ~CAcceleratorSettingsPage();
-
- void save();
-
-protected slots:
-
- void slotKeyChooserTypeChanged(const QString& title);
-
-private:
-
- struct WindowType {
- QPointer<KShortcutsEditor> keyChooser;
- KActionCollection* actionCollection;
- QString title;
-
- WindowType() {
- keyChooser = 0;
- actionCollection = 0;
- };
- WindowType(const QString& newTitle) {
- title = newTitle;
- keyChooser = 0;
- actionCollection = 0;
- }
- };
-
- WindowType m_application;
- WindowType m_general;
- WindowType m_bible;
- WindowType m_commentary;
- WindowType m_lexicon;
- WindowType m_book;
-
- QComboBox* m_typeChooser;
- QStackedWidget* m_keyChooserStack;
-
-};
-
-#endif
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.cpp b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
index f3bf536..d942915 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.cpp
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,7 @@
#include "cdisplaysettings.h"
#include "cswordsettings.h"
#include "clanguagesettings.h"
-//#include "cacceleratorsettings.h"
+#include "cacceleratorsettings.h"
#include "util/cpointers.h"
#include "util/cresmgr.h"
@@ -49,13 +49,9 @@ CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection*
m_languagesPage = new CLanguageSettingsPage(this);
addPage(m_languagesPage);
-// // Add "Keyboard" (accelerators) page
-// m_acceleratorsPage = new CAcceleratorSettingsPage(this);
-// KPageWidgetItem* accelPage = new KPageWidgetItem(m_acceleratorsPage);
-// accelPage->setHeader( tr( "HotKeys" ) );
-// accelPage->setName( tr( "HotKeys" ) );
-// accelPage->setIcon( KIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::settings::keys::icon)) );
-// addPage(accelPage);
+ // Add "Keyboard" (accelerators) page
+ m_acceleratorsPage = new CAcceleratorSettingsPage(this);
+ addPage(m_acceleratorsPage);
// Dialog buttons
m_bbox = new QDialogButtonBox(this);
@@ -67,10 +63,25 @@ CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection*
bool ok = connect(m_bbox, SIGNAL(clicked(QAbstractButton *)), SLOT(slotButtonClicked(QAbstractButton *)));
Q_ASSERT(ok);
+ loadDialogSettings();
+
slotChangePage(0);
}
-CConfigurationDialog::~CConfigurationDialog() {}
+CConfigurationDialog::~CConfigurationDialog()
+{
+ saveDialogSettings();
+}
+
+/** Save the dialog settings **/
+void CConfigurationDialog::save()
+{
+ m_acceleratorsPage->save();
+ m_languagesPage->save();
+ m_swordPage->save();
+ m_displayPage->save();
+ emit signalSettingsChanged( );
+}
/** Called if any button was clicked*/
void CConfigurationDialog::slotButtonClicked(QAbstractButton* button)
@@ -81,13 +92,22 @@ void CConfigurationDialog::slotButtonClicked(QAbstractButton* button)
return;
}
-// m_acceleratorsPage->save();
- m_languagesPage->save();
- m_swordPage->save();
- m_displayPage->save();
- emit signalSettingsChanged( );
+ save();
if (button == static_cast<QAbstractButton*>(m_bbox->button(QDialogButtonBox::Ok)))
close();
}
+void CConfigurationDialog::loadDialogSettings()
+{
+ resize(CBTConfig::get(CBTConfig::configDialogWidth), CBTConfig::get(CBTConfig::configDialogHeight));
+ move(CBTConfig::get(CBTConfig::configDialogPosX), CBTConfig::get(CBTConfig::configDialogPosY));
+}
+
+void CConfigurationDialog::saveDialogSettings()
+{
+ CBTConfig::set(CBTConfig::configDialogWidth, size().width());
+ CBTConfig::set(CBTConfig::configDialogHeight, size().height());
+ CBTConfig::set(CBTConfig::configDialogPosX, x());
+ CBTConfig::set(CBTConfig::configDialogPosY, y());
+}
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.h b/src/frontend/settingsdialogs/cconfigurationdialog.h
index f7a1718..0153a74 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.h
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.h
@@ -4,7 +4,7 @@
// Description: BibleTime Configuration dialog.
//
//
-// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2008
+// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2009
//
// Copyright: See COPYING file that comes with this distribution
//
@@ -31,8 +31,11 @@ class CConfigurationDialog : public BtConfigDialog {
public:
CConfigurationDialog(QWidget *parent, BtActionCollection* actionCollection);
virtual ~CConfigurationDialog();
+ void save();
+
protected slots:
void slotButtonClicked(QAbstractButton *);
+
private:
BtActionCollection* m_actionCollection;
CDisplaySettingsPage* m_displayPage;
@@ -41,6 +44,12 @@ private:
CLanguageSettingsPage* m_languagesPage;
QDialogButtonBox* m_bbox;
+ // Load the settings from the resource file
+ void loadDialogSettings();
+
+ // Save the settings to the resource file
+ void saveDialogSettings();
+
signals:
void signalSettingsChanged();
};
diff --git a/src/frontend/settingsdialogs/cfontchooser.cpp b/src/frontend/settingsdialogs/cfontchooser.cpp
index f755e57..4fa88c4 100644
--- a/src/frontend/settingsdialogs/cfontchooser.cpp
+++ b/src/frontend/settingsdialogs/cfontchooser.cpp
@@ -41,7 +41,7 @@ WebViewerWidget::~WebViewerWidget()
QSize WebViewerWidget::sizeHint () const
{
- return QSize(100,85);
+ return QSize(100,100);
}
// ************************
@@ -78,6 +78,7 @@ void CFontChooser::createFontAreaLayout()
m_fontListWidget = new CListWidget();
m_fontListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ m_fontListWidget->setMinimumHeight(50);
fontLayout->addWidget(m_fontListWidget);
// style column
@@ -89,6 +90,7 @@ void CFontChooser::createFontAreaLayout()
m_styleListWidget = new CListWidget();
m_styleListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ m_styleListWidget->setMinimumHeight(50);
m_styleListWidget->setCharWidth(12);
styleLayout->addWidget(m_styleListWidget);
@@ -101,6 +103,7 @@ void CFontChooser::createFontAreaLayout()
m_sizeListWidget = new CListWidget();
m_sizeListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ m_sizeListWidget->setMinimumHeight(50);
m_sizeListWidget->setCharWidth(5);
sizeLayout->addWidget(m_sizeListWidget);
@@ -120,6 +123,8 @@ void CFontChooser::createTextAreaLayout()
{
QWidget* webViewWidget = new WebViewerWidget(this);
QLayout* webViewLayout = new QVBoxLayout(webViewWidget);
+
+ webViewWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_webView = new QWebView(webViewWidget);
webViewLayout->addWidget(m_webView);
@@ -333,7 +338,7 @@ void CFontChooser::sizeChanged(QListWidgetItem* current, QListWidgetItem* /*prev
QSize CFontChooser::sizeHint() const
{
- return QSize(170,170);
+ return QSize(170,100);
}
void CFontChooser::styleChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/)
diff --git a/src/frontend/settingsdialogs/clanguagesettings.h b/src/frontend/settingsdialogs/clanguagesettings.h
index cf635d3..9dccc85 100644
--- a/src/frontend/settingsdialogs/clanguagesettings.h
+++ b/src/frontend/settingsdialogs/clanguagesettings.h
@@ -40,17 +40,14 @@ public:
QString header();
protected slots:
- /**
- * This slot is called when the "Use own font for language" button was clicked.
- */
+
+ // This slot is called when the "Use own font for language" button was clicked.
void useOwnFontClicked(bool);
- /**
- * Called when a new font in the fonts page was selected.
- */
+
+ // Called when a new font in the fonts page was selected.
void newDisplayWindowFontSelected(const QFont &);
- /**
- * Called when the combobox contents is changed
- */
+
+ // Called when the combobox contents is changed
void newDisplayWindowFontAreaSelected(const QString&);
private:
diff --git a/src/main.cpp b/src/main.cpp
index ee669d6..bf8aff7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -39,8 +39,7 @@
using namespace util::filesystem;
-bool showDebugMessages = false;
-BibleTime* bibletime_ptr = 0;
+bool showDebugMessages;
void myMessageOutput( QtMsgType type, const char *msg ) {
//we use this messagehandler to switch debugging off in final releases
@@ -168,46 +167,34 @@ int main(int argc, char* argv[]) {
// This is the QT4 version, will only work if main App is QApplication
// A binary option (on / off)
- if (app.QCoreApplication::arguments().contains("--debug"))
- {
- showDebugMessages = true;
- app.setProperty("--debug", true);
- }
- else
- {
- app.setProperty("--debug", false);
- }
+ showDebugMessages = QCoreApplication::arguments().contains("--debug");
+ app.setProperty("--debug", showDebugMessages);
//Migrate configuration data, if neccessary
util::MigrationUtil::checkMigration();
// setSignalHandler(signalHandler);
- bibletime_ptr = new BibleTime();
+ BibleTime bibleTime;
// a new BibleTime version was installed (maybe a completely new installation)
- if (CBTConfig::get(CBTConfig::bibletimeVersion) != BT_VERSION) {
-
+ if (CBTConfig::get(CBTConfig::bibletimeVersion) != BT_VERSION)
+ {
CBTConfig::set(CBTConfig::bibletimeVersion, BT_VERSION);
- //TODO: unabled temporarily
- //bibletime_ptr->slotSettingsOptions();
- bibletime_ptr->slotSettingsOptions();
+ bibleTime.saveConfigSettings();
}
// restore the workspace and process command line options
//app.setMainWidget(bibletime_ptr); //no longer used in qt4 (QApplication)
- bibletime_ptr->show();
- bibletime_ptr->processCommandline(); //must be done after the bibletime window is visible
+ bibleTime.show();
+ bibleTime.processCommandline(); //must be done after the bibletime window is visible
#ifndef NO_DBUS
- new BibleTimeDBusAdaptor(bibletime_ptr);
+ new BibleTimeDBusAdaptor(&bibleTime);
// connect to D-Bus and register as an object:
- QDBusConnection::sessionBus().registerObject("/BibleTime", bibletime_ptr);
+ QDBusConnection::sessionBus().registerObject("/BibleTime", &bibleTime);
#endif
- const int ret = app.exec();
-
- delete bibletime_ptr;
- return ret;
+ return app.exec();
}