summaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend')
-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
45 files changed, 2107 insertions, 1102 deletions
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: