summaryrefslogtreecommitdiff
path: root/src/frontend/display
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/display')
-rw-r--r--src/frontend/display/btcolorwidget.cpp2
-rw-r--r--src/frontend/display/btcolorwidget.h4
-rw-r--r--src/frontend/display/btfindwidget.cpp118
-rw-r--r--src/frontend/display/btfindwidget.h56
-rw-r--r--src/frontend/display/btfontsizewidget.cpp2
-rw-r--r--src/frontend/display/btfontsizewidget.h4
-rw-r--r--src/frontend/display/bthtml.js156
-rw-r--r--src/frontend/display/bthtmlfindtext.cpp95
-rw-r--r--src/frontend/display/bthtmlfindtext.h36
-rw-r--r--src/frontend/display/bthtmlfindtext.ui145
-rw-r--r--src/frontend/display/bthtmljsobject.cpp42
-rw-r--r--src/frontend/display/bthtmljsobject.h4
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp10
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h17
-rw-r--r--src/frontend/display/cdisplay.cpp16
-rw-r--r--src/frontend/display/cdisplay.h17
-rw-r--r--src/frontend/display/chtmlwritedisplay.cpp183
-rw-r--r--src/frontend/display/chtmlwritedisplay.h52
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp9
-rw-r--r--src/frontend/display/cplainwritedisplay.h31
-rw-r--r--src/frontend/display/creaddisplay.cpp2
-rw-r--r--src/frontend/display/creaddisplay.h6
-rw-r--r--src/frontend/display/cwritedisplay.cpp21
-rw-r--r--src/frontend/display/cwritedisplay.h47
24 files changed, 443 insertions, 632 deletions
diff --git a/src/frontend/display/btcolorwidget.cpp b/src/frontend/display/btcolorwidget.cpp
index 0d09259..579e461 100644
--- a/src/frontend/display/btcolorwidget.cpp
+++ b/src/frontend/display/btcolorwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btcolorwidget.h b/src/frontend/display/btcolorwidget.h
index 5cc0f56..9dd2e97 100644
--- a/src/frontend/display/btcolorwidget.h
+++ b/src/frontend/display/btcolorwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btfindwidget.cpp b/src/frontend/display/btfindwidget.cpp
new file mode 100644
index 0000000..1ada629
--- /dev/null
+++ b/src/frontend/display/btfindwidget.cpp
@@ -0,0 +1,118 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/display/btfindwidget.h"
+
+#include "QApplication"
+#include "QCheckBox"
+#include "QHBoxLayout"
+#include "QLineEdit"
+#include "QSpacerItem"
+#include "QToolButton"
+#include "bibletimeapp.h"
+#include "util/cresmgr.h"
+#include "util/geticon.h"
+
+
+BtFindWidget::BtFindWidget(QWidget* parent)
+ : QWidget(parent) {
+ createLayout();
+ createToolButton(CResMgr::findWidget::close_icon, "", SLOT(hide()));
+ createTextEditor();
+ createToolButton(CResMgr::findWidget::previous_icon, tr("Previous"), SLOT(findPrevious()));
+ createToolButton(CResMgr::findWidget::next_icon, tr("Next"), SLOT(findNext()));
+ createCaseCheckBox();
+ createSpacer();
+ setFocusProxy(m_textEditor);
+}
+
+BtFindWidget::~BtFindWidget() {
+}
+
+void BtFindWidget::createLayout() {
+ m_layout = new QHBoxLayout(this);
+ m_layout->setMargin(0);
+ m_layout->setSpacing(8);
+}
+
+void BtFindWidget::createToolButton(const QString& iconName, const QString& text, const char* slot) {
+ QToolButton* button = new QToolButton(this);
+ button->setIcon(util::getIcon(iconName));
+ button->setIconSize(QSize(16,16));
+ button->setText(text);
+ button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ button->setAutoRaise(true);
+ m_layout->addWidget(button);
+ bool ok = connect(button, SIGNAL(released()), this, slot);
+ Q_ASSERT(ok);
+}
+
+void BtFindWidget::createTextEditor() {
+ m_textEditor = new QLineEdit(this);
+#if QT_VERSION < 0x050000
+ m_textEditor->setToolTip(QApplication::translate("findWidget",
+ "The text you want to search for", 0, QApplication::UnicodeUTF8));
+#else
+ m_textEditor->setToolTip(QApplication::translate("findWidget",
+ "The text you want to search for", 0));
+#endif
+ m_layout->addWidget(m_textEditor);
+ bool ok = connect(m_textEditor, SIGNAL(textChanged(const QString&)),
+ this, SLOT(textChanged(const QString&)));
+ Q_ASSERT(ok);
+ ok = connect(m_textEditor,SIGNAL(returnPressed()), this, SLOT(returnPressed()));
+ Q_ASSERT(ok);
+}
+
+void BtFindWidget::createCaseCheckBox() {
+ m_caseCheckBox = new QCheckBox(tr("Match case"), this);
+ m_layout->addWidget(m_caseCheckBox);
+}
+
+void BtFindWidget::createSpacer() {
+ QSpacerItem* spacer = new QSpacerItem(0,0,QSizePolicy::Expanding, QSizePolicy::Minimum);
+ m_layout->addItem(spacer);
+}
+
+void BtFindWidget::highlightText(const QString& text) {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ emit highlightText(text, caseSensitive);
+}
+
+void BtFindWidget::returnPressed() {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ QString text = m_textEditor->text();
+ emit highlightText(text, caseSensitive);
+ emit findNext(text, caseSensitive);
+}
+
+void BtFindWidget::textChanged(const QString& text) {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ emit highlightText(text, caseSensitive);
+ emit findNext(text, caseSensitive);
+}
+
+void BtFindWidget::findNext() {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ QString text = m_textEditor->text();
+ emit findNext(text, caseSensitive);
+}
+
+void BtFindWidget::findPrevious() {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ QString text = m_textEditor->text();
+ emit findPrevious(text, caseSensitive);
+}
+
+void BtFindWidget::showAndSelect(){
+ setVisible(true);
+ QWidget::show();
+ m_textEditor->selectAll();
+ m_textEditor->setFocus(Qt::ShortcutFocusReason);
+}
diff --git a/src/frontend/display/btfindwidget.h b/src/frontend/display/btfindwidget.h
new file mode 100644
index 0000000..52a879a
--- /dev/null
+++ b/src/frontend/display/btfindwidget.h
@@ -0,0 +1,56 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTFINDIDGET_H
+#define BTFINDIDGET_H
+
+#include <QWidget>
+#include <QWebPage>
+class QCheckBox;
+class QLineEdit;
+class QHBoxLayout;
+class QString;
+
+class BtFindWidget : public QWidget {
+ Q_OBJECT
+
+ public:
+ BtFindWidget(QWidget* parent = 0);
+ ~BtFindWidget();
+ void showAndSelect();
+
+ private slots:
+ void findNext();
+ void findPrevious();
+ void returnPressed();
+ void textChanged(const QString& text);
+
+ private:
+ void createCaseCheckBox();
+ void createLayout();
+ void createSpacer();
+ void createTextEditor();
+ void createToolButton(const QString& iconName, const QString& text, const char* slot);
+ void highlightText(const QString& searchText);
+
+ QHBoxLayout* m_layout;
+ QLineEdit* m_textEditor;
+ QCheckBox* m_caseCheckBox;
+
+ signals:
+ void findPrevious(const QString & text, bool caseSensitive);
+ void findNext(const QString & text, bool caseSensitive);
+ void highlightText(const QString & text, bool caseSensitive);
+};
+
+#endif
+
+
diff --git a/src/frontend/display/btfontsizewidget.cpp b/src/frontend/display/btfontsizewidget.cpp
index b302fed..82fdd08 100644
--- a/src/frontend/display/btfontsizewidget.cpp
+++ b/src/frontend/display/btfontsizewidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btfontsizewidget.h b/src/frontend/display/btfontsizewidget.h
index c2d7198..40b94a1 100644
--- a/src/frontend/display/btfontsizewidget.h
+++ b/src/frontend/display/btfontsizewidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/bthtml.js b/src/frontend/display/bthtml.js
index 689ba55..d56318f 100644
--- a/src/frontend/display/bthtml.js
+++ b/src/frontend/display/bthtml.js
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,119 +18,105 @@ var timeOutId = -1;
// Scroll window to html anchor
function gotoAnchor(anchor)
{
- document.location=document.location + "#" + anchor;
-}
-
-// Set body editable
-function setEditable()
-{
- var theBody = document.getElementsByTagName('body')[0];
- theBody.setAttribute('contenteditable','true');
-}
-
-// Set body not editable
-function setNotEditable()
-{
- var theBody = document.getElementsByTagName('body')[0];
- theBody.setAttribute('contenteditable','false');
+ document.location=document.location + "#" + anchor;
}
// Mouse button clicked handler
function mouseClickHandler (mEvent)
{
- var mTarget = mEvent.target;
- if (mTarget)
- {
- var url = "";
- var tmpUrl = mEvent.target.getAttribute("href");
- if (tmpUrl)
- url = tmpUrl;
- btHtmlJsObject.mouseClick(url);
- }
+ var mTarget = mEvent.target;
+ if (mTarget)
+ {
+ var url = "";
+ var tmpUrl = mEvent.target.getAttribute("href");
+ if (tmpUrl)
+ url = tmpUrl;
+ btHtmlJsObject.mouseClick(url);
+ }
}
// Mouse button pressed down handler
function mouseDownHandler (mEvent)
{
- var node;
- var url = "";
- var lemma = "";
- var mTarget = mEvent.target;
- if (mTarget)
- {
- var tmpUrl = mEvent.target.getAttribute("href");
- if (tmpUrl)
- url = tmpUrl;
- var tmpLemma = mEvent.target.getAttribute("lemma");
- if (tmpLemma)
- lemma = tmpLemma;
- }
-
- if (mEvent.button === 2) // Right mouse button
- {
- btHtmlJsObject.mouseDownRight(url, lemma);
- }
- if (mEvent.button === 0) // Left mouse button
- {
- if (!(mEvent.target === undefined))
- {
- var X = mEvent.clientX;
- var Y = mEvent.clientY;
- btHtmlJsObject.mouseDownLeft(url, X, Y);
- }
- }
+ var node;
+ var url = "";
+ var lemma = "";
+ var mTarget = mEvent.target;
+ if (mTarget)
+ {
+ var tmpUrl = mEvent.target.getAttribute("href");
+ if (tmpUrl)
+ url = tmpUrl;
+ var tmpLemma = mEvent.target.getAttribute("lemma");
+ if (tmpLemma)
+ lemma = tmpLemma;
+ }
+
+ if (mEvent.button === 2) // Right mouse button
+ {
+ btHtmlJsObject.mouseDownRight(url, lemma);
+ }
+ if (mEvent.button === 0) // Left mouse button
+ {
+ if (!(mEvent.target === undefined))
+ {
+ var X = mEvent.clientX;
+ var Y = mEvent.clientY;
+ btHtmlJsObject.mouseDownLeft(url, X, Y);
+ }
+ }
}
// Mouse moved event handler
function mouseMoveHandler (mEvent)
{
- currentNode = mEvent.target;
- var shiftKey = mEvent.shiftKey;
- var x = mEvent.clientX;
- var y = mEvent.clientY;
- var node = mEvent.target;
- if ( node != undefined && node != prevNode )
- {
- prevNode = node;
-
- if (node.attributes.length > 0)
- {
- attribList = getNodeAttributes(node);
- btHtmlJsObject.mouseMoveEvent(attribList, x, y, shiftKey);
- }
- }
+ currentNode = mEvent.target;
+ var shiftKey = mEvent.shiftKey;
+ var x = mEvent.clientX;
+ var y = mEvent.clientY;
+ var node = mEvent.target;
+ if ( node != undefined && node != prevNode )
+ {
+ prevNode = node;
+
+ if (node.attributes.length > 0)
+ {
+ attribList = getNodeAttributes(node);
+ btHtmlJsObject.mouseMoveEvent(attribList, x, y, shiftKey);
+ }
+ }
}
// Get attributes of a DOM node and put into a single string
function getNodeAttributes(node)
{
- var attribList = '';
- if (node.attributes.length > 0)
- {
- for (i = 0; i < node.attributes.length; i++)
- {
- attribList = attribList + node.attributes[i].nodeName + '=' + node.attributes[i].nodeValue + '||';
- }
- }
- return attribList;
+ var attribList = '';
+ if (node.attributes.length > 0)
+ {
+ for (i = 0; i < node.attributes.length; i++)
+ {
+ attribList = attribList + node.attributes[i].nodeName + '=' + node.attributes[i].nodeValue + '||';
+ }
+ }
+ return attribList;
}
// Start a timer event
function startTimer(time)
{
- clearTimeout(timeOutId);
- timeOutId = setTimeout("timerEvent()",time);
+ clearTimeout(timeOutId);
+ timeOutId = setTimeout("timerEvent()",time);
}
// Handles a timer event
function timerEvent()
{
- timeOutId = -1;
- if (currentNode != 0 && currentNode == prevNode)
- {
- var attributes = getNodeAttributes(currentNode);
- btHtmlJsObject.timeOutEvent(attributes);
- }
+ timeOutId = -1;
+ if (currentNode != 0 && currentNode == prevNode)
+ {
+ var attributes = getNodeAttributes(currentNode);
+ btHtmlJsObject.timeOutEvent(attributes);
+ }
}
document.getElementsByTagName("body")[0].addEventListener ('mousedown', function (eve) { mouseDownHandler (eve); }, true);
@@ -139,8 +125,6 @@ document.getElementsByTagName("body")[0].addEventListener ('click', function
btHtmlJsObject.startTimer.connect(this, this.startTimer);
btHtmlJsObject.gotoAnchor.connect(this, this.gotoAnchor);
-btHtmlJsObject.setDocumentEditable.connect(this, this.setEditable);
-btHtmlJsObject.setDocumentNotEditable.connect(this, this.setNotEditable);
;
diff --git a/src/frontend/display/bthtmlfindtext.cpp b/src/frontend/display/bthtmlfindtext.cpp
deleted file mode 100644
index 1b15b11..0000000
--- a/src/frontend/display/bthtmlfindtext.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/display/bthtmlfindtext.h"
-
-#include <QMdiSubWindow>
-#include "frontend/cmdiarea.h"
-#include "frontend/display/bthtmlreaddisplay.h"
-#include "frontend/display/creaddisplay.h"
-#include "frontend/displaywindow/cdisplaywindow.h"
-
-
-static BtHtmlFindText* dialog = 0;
-
-void showBtHtmlFindText(CMDIArea* mdiArea) {
- if (dialog == 0)
- dialog = new BtHtmlFindText(mdiArea, mdiArea);
- dialog->show();
-}
-
-BtHtmlFindText::BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent, Qt::WindowFlags f)
- : QDialog(parent, f), m_mdiArea(mdiArea) {
- ui.setupUi(this);
- bool ok;
- ok = connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(findNext()));
- Q_ASSERT(ok);
- ok = connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(findPrevious()));
- Q_ASSERT(ok);
-}
-
-BtHtmlFindText::~BtHtmlFindText() {
-}
-
-void BtHtmlFindText::findNext() {
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0) {
- QWebPage::FindFlags options = 0;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText, options);
- }
-}
-
-void BtHtmlFindText::findPrevious() {
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0) {
- QWebPage::FindFlags options = QWebPage::FindBackward;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText, options);
- }
-}
-
-
-QWebView* BtHtmlFindText::getActiveWindowWebView() {
- QMdiSubWindow* activeSubWindow = m_mdiArea->activeSubWindow();
- if (activeSubWindow == 0)
- return 0;
-
- QWidget* activeWindowWidget = activeSubWindow->widget();
- if (activeWindowWidget == 0)
- return 0;
-
- CDisplayWindow* cDisplayWindow = qobject_cast<CDisplayWindow*>(activeWindowWidget);
- if (cDisplayWindow == 0)
- return 0;
-
- CDisplay* cDisplay = cDisplayWindow->displayWidget();
- if (cDisplay == 0)
- return 0;
-
- QWidget* textView = cDisplay->view();
- if (textView == 0)
- return 0;
-
- QWebView* webView = qobject_cast<QWebView*>(textView);
- return webView;
-}
-
-
-
-
-
-
-
diff --git a/src/frontend/display/bthtmlfindtext.h b/src/frontend/display/bthtmlfindtext.h
deleted file mode 100644
index 1d941c1..0000000
--- a/src/frontend/display/bthtmlfindtext.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTHTMLFINDTEXT_H
-#define BTHTMLFINDTEXT_H
-
-/// \todo Qt Designer UI file!?
-#include "ui_bthtmlfindtext.h"
-
-
-class CMDIArea;
-class QWebView;
-
-class BtHtmlFindText : public QDialog {
- Q_OBJECT
-
- public:
- BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent = 0, Qt::WindowFlags f = 0);
- ~BtHtmlFindText();
- public slots:
- void findNext();
- void findPrevious();
- private:
- QWebView* getActiveWindowWebView();
- Ui_findTextDialog ui;
- CMDIArea* m_mdiArea;
-};
-
-
-#endif
diff --git a/src/frontend/display/bthtmlfindtext.ui b/src/frontend/display/bthtmlfindtext.ui
deleted file mode 100644
index c04de0c..0000000
--- a/src/frontend/display/bthtmlfindtext.ui
+++ /dev/null
@@ -1,145 +0,0 @@
-<ui version="4.0" >
- <class>findTextDialog</class>
- <widget class="QDialog" name="findTextDialog" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>227</width>
- <height>115</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Find Text</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout" >
- <item>
- <widget class="QFrame" name="findFrame" >
- <property name="frameShape" >
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow" >
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2" >
- <item>
- <spacer name="verticalSpacer" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QComboBox" name="findTextComboBox" >
- <property name="toolTip" >
- <string>The text you want to search for</string>
- </property>
- <property name="editable" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="caseBox" >
- <property name="toolTip" >
- <string>Search with case sensitivity</string>
- </property>
- <property name="text" >
- <string>Case &amp;sensitive</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_2" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_6" >
- <item>
- <spacer name="horizontalSpacer_6" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="previousButton" >
- <property name="toolTip" >
- <string>Find the previous location of the text</string>
- </property>
- <property name="text" >
- <string>&amp;Previous</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="nextButton" >
- <property name="toolTip" >
- <string>Find the next location of the text</string>
- </property>
- <property name="text" >
- <string>&amp;Next</string>
- </property>
- <property name="default" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="closeButton" >
- <property name="toolTip" >
- <string>Close the dialog</string>
- </property>
- <property name="text" >
- <string>&amp;Close</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>closeButton</sender>
- <signal>clicked()</signal>
- <receiver>findTextDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>200</x>
- <y>124</y>
- </hint>
- <hint type="destinationlabel" >
- <x>224</x>
- <y>106</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/src/frontend/display/bthtmljsobject.cpp b/src/frontend/display/bthtmljsobject.cpp
index aa44865..cb395cc 100644
--- a/src/frontend/display/bthtmljsobject.cpp
+++ b/src/frontend/display/bthtmljsobject.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,7 +11,7 @@
#include <QDrag>
#include <QSharedPointer>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/keys/cswordkey.h"
#include "backend/managers/referencemanager.h"
#include "backend/managers/cswordbackend.h"
@@ -105,7 +105,7 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, con
// no mouse button pressed and tracking enabled
// start timer that updates the mag window
// Sets timer in javascript. See bthtml.js startTimer()
- emit startTimer(CBTConfig::get(CBTConfig::magDelay));
+ emit startTimer(btConfig().value<int>("GUI/magDelay", 400));
m_prev_attributes = attributes;
// When the javascript timer interupts, the see timerEvent() in bthtml.js
// will call the timeOutEvent in this class
@@ -113,40 +113,32 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, con
}
// called from javascript timerEvent() in bthtml.js
-void BtHtmlJsObject::timeOutEvent(const QString& attributes) {
+void BtHtmlJsObject::timeOutEvent(const QString & attributes) {
if (m_prev_attributes != attributes)
return;
m_prev_attributes = "";
CInfoDisplay::ListInfoData infoList;
- QStringList attrList = attributes.split("||");
+ const QStringList attrList = attributes.split("||");
for (int i = 0; i < attrList.count(); i++) {
- QString attrPair = attrList[i];
- QStringList attr = attrPair.split("=");
+ const QStringList attr(attrList[i].split('='));
if (attr.count() == 2) {
- QString attrName = attr[0];
- QString attrValue = attr[1];
- if (attrName == "note") {
- infoList.append( qMakePair(CInfoDisplay::Footnote, attrValue));
- }
- if (attrName == "lemma") {
- infoList.append( qMakePair(CInfoDisplay::Lemma, attrValue));
- }
- if (attrName == "morph") {
- infoList.append( qMakePair(CInfoDisplay::Morph, attrValue));
- }
- if (attrName == "expansion") {
- infoList.append( qMakePair(CInfoDisplay::Abbreviation, attrValue));
- }
- if (attrName == "crossrefs") {
- infoList.append( qMakePair(CInfoDisplay::CrossReference, attrValue));
+ if (attr[0] == "note") {
+ infoList.append(qMakePair(CInfoDisplay::Footnote, attr[1]));
+ } else if (attr[0] == "lemma") {
+ infoList.append(qMakePair(CInfoDisplay::Lemma, attr[1]));
+ } else if (attr[0] == "morph") {
+ infoList.append(qMakePair(CInfoDisplay::Morph, attr[1]));
+ } else if (attr[0] == "expansion") {
+ infoList.append(qMakePair(CInfoDisplay::Abbreviation, attr[1]));
+ } else if (attr[0] == "crossrefs") {
+ infoList.append(qMakePair(CInfoDisplay::CrossReference, attr[1]));
}
}
}
// Update the mag if valid attributes were found
- if (!(infoList.isEmpty())) {
+ if (!(infoList.isEmpty()))
BibleTime::instance()->infoDisplay()->setInfo(infoList);
- }
}
// clearing the previous attribute effectively stops any time out event
diff --git a/src/frontend/display/bthtmljsobject.h b/src/frontend/display/bthtmljsobject.h
index 109de5a..3bf37f5 100644
--- a/src/frontend/display/bthtmljsobject.h
+++ b/src/frontend/display/bthtmljsobject.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp
index 1842178..7b303e7 100644
--- a/src/frontend/display/bthtmlreaddisplay.cpp
+++ b/src/frontend/display/bthtmlreaddisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,8 +14,10 @@
#include <QString>
#include "backend/keys/cswordkey.h"
#include "backend/managers/referencemanager.h"
+#include "bibletime.h"
#include "frontend/cdragdrop.h"
#include "frontend/cinfodisplay.h"
+#include "frontend/cmdiarea.h"
#include "frontend/display/bthtmljsobject.h"
#include "frontend/displaywindow/cdisplaywindow.h"
#include "frontend/displaywindow/cdisplaywindowfactory.h"
@@ -25,8 +27,6 @@
using namespace InfoDisplay;
-void showBtHtmlFindText(CMDIArea*);
-
static QString javascript; // Initialized from file bthtml.js
BtHtmlReadDisplay::BtHtmlReadDisplay(CReadWindow* readWindow, QWidget* parentWidget)
@@ -266,8 +266,8 @@ void BtHtmlReadDisplay::setLemma(const QString& lemma) {
// Open the Find text dialog
void BtHtmlReadDisplay::openFindTextDialog() {
- CMDIArea* mdiArea = parentWindow()->mdi();
- showBtHtmlFindText(mdiArea);
+ BibleTime* bibleTime = parentWindow()->mdi()->bibleTimeWindow();
+ bibleTime->openFindWidget();
}
// Send "completed" signal when the text is finished loading into the viewer
diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h
index f1e1f5c..0a703d3 100644
--- a/src/frontend/display/bthtmlreaddisplay.h
+++ b/src/frontend/display/bthtmlreaddisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,11 +25,6 @@
class BtHtmlReadDisplayView;
-class QScrollArea;
-class QWidget;
-class QString;
-class BtHtmlReadDisplay;
-class QEvent;
/** The implementation for the HTML read display.
* @author The BibleTime team
@@ -38,6 +35,10 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
friend class BtHtmlReadDisplayView;
public:
+
+ BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
+ virtual ~BtHtmlReadDisplay();
+
//reimplemented functions from CDisplay
// Returns the right text part in the specified format.
virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText,
@@ -68,9 +69,7 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
void completed();
protected:
- friend class CDisplay;
- BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
- virtual ~BtHtmlReadDisplay();
+
void slotGoToAnchor(const QString& anchor);
struct DNDData {
bool mousePressed;
diff --git a/src/frontend/display/cdisplay.cpp b/src/frontend/display/cdisplay.cpp
index 4def9f5..a5c5bc8 100644
--- a/src/frontend/display/cdisplay.cpp
+++ b/src/frontend/display/cdisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -98,20 +98,6 @@ void CDisplayConnections::openFindTextDialog() {
/*----------------------*/
-CReadDisplay* CDisplay::createReadInstance( CReadWindow* readWindow, QWidget* parent ) {
- return new BtHtmlReadDisplay(readWindow, parent);
-}
-
-CWriteDisplay* CDisplay::createWriteInstance( CWriteWindow* writeWindow, const CWriteDisplay::WriteDisplayType& type, QWidget* parent ) {
- // qWarning("CDisplay::createWriteInstance");
- if (type == PlainTextDisplay) {
- return new CPlainWriteDisplay(writeWindow, parent);
- }
- else {
- return new CHTMLWriteDisplay(writeWindow, parent);
- };
-}
-
CDisplay::CDisplay(CDisplayWindow* parent) :
m_parentWindow(parent),
diff --git a/src/frontend/display/cdisplay.h b/src/frontend/display/cdisplay.h
index a0a0020..de971d5 100644
--- a/src/frontend/display/cdisplay.h
+++ b/src/frontend/display/cdisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,10 +18,6 @@
class CDisplayConnections;
class CDisplayWindow;
-class CReadDisplay;
-class CReadWindow;
-class CWriteDisplay;
-class CWriteWindow;
class QMenu;
/** The base class for all display widgets.
@@ -27,15 +25,6 @@ class QMenu;
*/
class CDisplay {
public:
- enum WriteDisplayType {
- HTMLDisplay = 0,
- PlainTextDisplay
- };
-
- static CReadDisplay* createReadInstance(CReadWindow* readWindow, QWidget* parent = 0);
- static CWriteDisplay* createWriteInstance( CWriteWindow* writeWindow,
- const WriteDisplayType& type = PlainTextDisplay,
- QWidget* parent = 0 );
enum TextType {
HTMLText, /* Used for HTML markup */
diff --git a/src/frontend/display/chtmlwritedisplay.cpp b/src/frontend/display/chtmlwritedisplay.cpp
index ce7b94c..829f607 100644
--- a/src/frontend/display/chtmlwritedisplay.cpp
+++ b/src/frontend/display/chtmlwritedisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,90 +14,109 @@
#include <QTextEdit>
#include <QToolBar>
#include <QToolTip>
+#include "backend/config/btconfig.h"
+#include "bibletimeapp.h"
#include "frontend/display/btcolorwidget.h"
#include "frontend/display/btfontsizewidget.h"
#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/chtmlwritewindow.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
class BtActionCollection;
-CHTMLWriteDisplay::CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent)
-: CPlainWriteDisplay(parentWindow, parent) {
- m_actions.bold = 0;
- m_actions.italic = 0;
- m_actions.underline = 0;
- m_actions.selectAll = 0;
+namespace {
+const QString CHTMLWriteDisplayFontKey = "HtmlWriteDisplay/font";
+const QString CHTMLWriteDisplayFontColorKey = "HtmlWriteDisplay/fontColor";
+}
+
+CHTMLWriteDisplay::CHTMLWriteDisplay(CHTMLWriteWindow * parentWindow, QWidget* parent)
+ : CPlainWriteDisplay(parentWindow, parent)
+ , m_handingFormatChangeFromEditor(false)
+{
+
+ BtConfig & conf = btConfig();
+ setTextColor(conf.sessionValue(CHTMLWriteDisplayFontColorKey, textColor()));
+ QFont f = conf.sessionValue(CHTMLWriteDisplayFontKey, currentFont());
+ setCurrentFont(f);
+
//--------------------bold toggle-------------------------
- namespace DU = util::directory;
m_actions.bold = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
tr("Bold"),
this);
m_actions.bold->setCheckable(true);
+ m_actions.bold->setChecked(f.bold());
m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::boldText::accel);
m_actions.bold->setToolTip( tr("Bold") );
- connect(m_actions.bold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool)));
+ connect(m_actions.bold, SIGNAL(toggled(bool)),
+ this, SLOT(toggleBold(bool)), Qt::DirectConnection);
//--------------------italic toggle-------------------------
m_actions.italic = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
tr("Italic"),
this );
m_actions.italic->setCheckable(true);
+ m_actions.italic->setChecked(f.italic());
m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel);
- connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));
+ connect(m_actions.italic, SIGNAL(toggled(bool)),
+ this, SLOT(toggleItalic(bool)), Qt::DirectConnection);
m_actions.italic->setToolTip( tr("Italic") );
//--------------------underline toggle-------------------------
m_actions.underline = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
tr("Underline"),
this );
m_actions.underline->setCheckable(true);
+ m_actions.underline->setChecked(f.underline());
m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel);
- connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));
+ connect(m_actions.underline, SIGNAL(toggled(bool)),
+ this, SLOT(toggleUnderline(bool)), Qt::DirectConnection);
m_actions.underline->setToolTip( tr("Underline") );
//--------------------align left toggle-------------------------
m_actions.alignLeft = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
tr("Left"), this);
m_actions.alignLeft->setCheckable(true);
m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel);
- connect(m_actions.alignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool)));
+ connect(m_actions.alignLeft, SIGNAL(toggled(bool)),
+ this, SLOT(alignLeft(bool)), Qt::DirectConnection);
m_actions.alignLeft->setToolTip( tr("Align left") );
//--------------------align center toggle-------------------------
m_actions.alignCenter = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
tr("Center"), this);
m_actions.alignCenter->setCheckable(true);
m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel);
- connect(m_actions.alignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter(bool)));
+ connect(m_actions.alignCenter, SIGNAL(toggled(bool)),
+ this, SLOT(alignCenter(bool)), Qt::DirectConnection);
m_actions.alignCenter->setToolTip( tr("Center") );
//--------------------align right toggle-------------------------
m_actions.alignRight = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
tr("Right"), this);
m_actions.alignRight->setCheckable(true);
m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel);
- connect(m_actions.alignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool)));
+ connect(m_actions.alignRight, SIGNAL(toggled(bool)),
+ this, SLOT(alignRight(bool)), Qt::DirectConnection);
m_actions.alignRight->setToolTip( tr("Align right") );
setAcceptRichText(true);
setAcceptDrops(true);
viewport()->setAcceptDrops(true);
-}
-CHTMLWriteDisplay::~CHTMLWriteDisplay() {
+ connect(this, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
+ this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat)), Qt::DirectConnection);
}
-void CHTMLWriteDisplay::setText( const QString& newText ) {
+void CHTMLWriteDisplay::setText(const QString & newText) {
QTextEdit::setHtml(newText);
}
@@ -105,42 +124,45 @@ const QString CHTMLWriteDisplay::plainText() {
return QTextEdit::toPlainText();
}
-void CHTMLWriteDisplay::toggleBold(bool) {
- setFontWeight( m_actions.bold->isChecked() ? QFont::Bold : QFont::Normal );
+void CHTMLWriteDisplay::toggleBold(bool checked) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontWeight(checked ? QFont::Bold : QFont::Normal);
}
-void CHTMLWriteDisplay::toggleItalic(bool) {
- setFontItalic( m_actions.italic->isChecked() );
+void CHTMLWriteDisplay::toggleItalic(bool checked) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontItalic(checked);
}
-void CHTMLWriteDisplay::toggleUnderline(bool) {
- setFontUnderline( m_actions.underline->isChecked() );
+void CHTMLWriteDisplay::toggleUnderline(bool checked) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontUnderline(checked);
}
-
void CHTMLWriteDisplay::alignLeft(bool set) {
- if (set && (alignment() != Qt::AlignLeft)) {
+ if (!m_handingFormatChangeFromEditor && set && (alignment() != Qt::AlignLeft)) {
setAlignment(Qt::AlignLeft);
- slotAlignmentChanged(Qt::AlignLeft);
+ alignmentChanged(Qt::AlignLeft);
}
}
void CHTMLWriteDisplay::alignCenter(bool set) {
- if (set && (alignment() != Qt::AlignHCenter)) {
+ if (!m_handingFormatChangeFromEditor && set && (alignment() != Qt::AlignHCenter)) {
setAlignment(Qt::AlignHCenter);
- slotAlignmentChanged(Qt::AlignHCenter);
+ alignmentChanged(Qt::AlignHCenter);
}
}
void CHTMLWriteDisplay::alignRight(bool set) {
- if (set && (alignment() != Qt::AlignRight)) {
+ if (!m_handingFormatChangeFromEditor && set && (alignment() != Qt::AlignRight)) {
setAlignment(Qt::AlignRight);
- slotAlignmentChanged(Qt::AlignRight);
+ alignmentChanged(Qt::AlignRight);
}
}
/** The text's alignment changed. Enable the right buttons. */
-void CHTMLWriteDisplay::slotAlignmentChanged( int a ) {
+void CHTMLWriteDisplay::alignmentChanged( int a ) {
+ Q_ASSERT(!m_handingFormatChangeFromEditor);
bool alignLeft = false;
bool alignCenter = false;
bool alignRight = false;
@@ -164,61 +186,79 @@ void CHTMLWriteDisplay::slotAlignmentChanged( int a ) {
m_actions.alignRight->setChecked( alignRight );
}
-void CHTMLWriteDisplay::changeFontSize(int newSize) {
- setFontPointSize((qreal)newSize);
-}
-
-/** Is called when a new color was selected. */
-void CHTMLWriteDisplay::slotColorSelected( const QColor& c) {
- setTextColor( c );
+void CHTMLWriteDisplay::slotCurrentCharFormatChanged(const QTextCharFormat &) {
+ Q_ASSERT(!m_handingFormatChangeFromEditor);
+ m_handingFormatChangeFromEditor = true;
+ QFont f = currentFont();
+ emit signalFontChanged(f);
+ emit signalFontSizeChanged(f.pointSize());
+ emit signalFontColorChanged(textColor());
+
+ m_actions.bold->setChecked(f.bold());
+ m_actions.italic->setChecked(f.italic());
+ m_actions.underline->setChecked(f.underline());
+ m_handingFormatChangeFromEditor = false;
+
+ BtConfig & conf = btConfig();
+ conf.setSessionValue(CHTMLWriteDisplayFontKey, currentFont());
+ conf.setSessionValue(CHTMLWriteDisplayFontColorKey, textColor());
}
-/** Is called when a text with another color was selected. */
-void CHTMLWriteDisplay::slotColorChanged(const QColor& c) {
- emit setColor(c);
+void CHTMLWriteDisplay::slotFontSizeChosen(int newSize) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontPointSize((qreal)newSize);
}
-void CHTMLWriteDisplay::slotFontChanged( const QFont& font ) {
- emit fontChanged(font);
- emit fontSizeChanged(font.pointSize());
-
- m_actions.bold->setChecked( font.bold() );
- m_actions.italic->setChecked( font.italic() );
- m_actions.underline->setChecked( font.underline() );
+/** Is called when a new color was selected. */
+void CHTMLWriteDisplay::slotFontColorChosen( const QColor& c) {
+ if (!m_handingFormatChangeFromEditor)
+ setTextColor( c );
}
-void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font) {
- setFontFamily(font.family());
+void CHTMLWriteDisplay::slotFontFamilyChosen(const QFont& font) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontFamily(font.family());
}
void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions) {
+ Q_UNUSED(actions);
+
+ QFont f = currentFont();
//--------------------font chooser-------------------------
QFontComboBox* fontFamilyCombo = new QFontComboBox(this);
+ fontFamilyCombo->setCurrentFont(f);
fontFamilyCombo->setToolTip( tr("Font") );
bar->addWidget(fontFamilyCombo);
bool ok = connect(fontFamilyCombo, SIGNAL(currentFontChanged(const QFont&)),
- this, SLOT(slotFontFamilyChoosen(const QFont&)));
+ this, SLOT(slotFontFamilyChosen(const QFont&)), Qt::DirectConnection);
Q_ASSERT(ok);
- ok = connect(this, SIGNAL(fontChanged(const QFont&)), fontFamilyCombo, SLOT(setCurrentFont(const QFont&)));
+ ok = connect(this, SIGNAL(signalFontChanged(const QFont&)),
+ fontFamilyCombo, SLOT(setCurrentFont(const QFont&)), Qt::DirectConnection);
Q_ASSERT(ok);
//--------------------font size chooser-------------------------
BtFontSizeWidget* fontSizeChooser = new BtFontSizeWidget(this);
+ fontSizeChooser->setFontSize(f.pointSize());
fontSizeChooser->setToolTip( tr("Font size") );
bar->addWidget(fontSizeChooser);
- ok = connect(fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int)));
+ ok = connect(fontSizeChooser, SIGNAL(fontSizeChanged(int)),
+ this, SLOT(slotFontSizeChosen(int)), Qt::DirectConnection);
Q_ASSERT(ok);
- ok = connect(this, SIGNAL(fontSizeChanged(int)), fontSizeChooser, SLOT(setFontSize(int)));
+ ok = connect(this, SIGNAL(signalFontSizeChanged(int)),
+ fontSizeChooser, SLOT(setFontSize(int)), Qt::DirectConnection);
Q_ASSERT(ok);
//--------------------color button-------------------------
- BtColorWidget* colorChooser = new BtColorWidget();
- colorChooser->setToolTip(tr("Font color"));
- bar->addWidget(colorChooser);
- ok = connect(colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&)));
+ BtColorWidget* fontColorChooser = new BtColorWidget();
+ fontColorChooser->setColor(textColor());
+ fontColorChooser->setToolTip(tr("Font color"));
+ bar->addWidget(fontColorChooser);
+ ok = connect(fontColorChooser, SIGNAL(changed(const QColor&)),
+ this, SLOT(slotFontColorChosen(const QColor&)), Qt::DirectConnection);
Q_ASSERT(ok);
- ok = connect(this, SIGNAL(setColor(const QColor&)), colorChooser, SLOT(setColor(const QColor&)));
+ ok = connect(this, SIGNAL(signalFontColorChanged(const QColor&)),
+ fontColorChooser, SLOT(setColor(QColor)), Qt::DirectConnection);
Q_ASSERT(ok);
bar->addSeparator();
@@ -233,13 +273,4 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
bar->addAction(m_actions.alignLeft);
bar->addAction(m_actions.alignCenter);
bar->addAction(m_actions.alignRight);
-
- connect(this, SIGNAL(currentFontChanged(const QFont&)), SLOT(slotFontChanged(const QFont&)));
- connect(this, SIGNAL(currentAlignmentChanged(int)), SLOT(slotAlignmentChanged(int)));
- connect(this, SIGNAL(currentColorChanged(const QColor&)), SLOT(slotColorChanged(const QColor&)));
-
- //set initial values for toolbar items
- slotFontChanged( font() );
- slotAlignmentChanged( alignment() );
- slotColorChanged( textColor() );
}
diff --git a/src/frontend/display/chtmlwritedisplay.h b/src/frontend/display/chtmlwritedisplay.h
index e8e4e7c..1bc9dd0 100644
--- a/src/frontend/display/chtmlwritedisplay.h
+++ b/src/frontend/display/chtmlwritedisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,7 +18,7 @@
class BtActionCollection;
class BtColorWidget;
class BtFontSizeWidget;
-class CWriteWindow;
+class CHTMLWriteWindow;
class QAction;
class QFontComboBox;
class QMenu;
@@ -29,6 +31,9 @@ class QWidget;
class CHTMLWriteDisplay : public CPlainWriteDisplay {
Q_OBJECT
public:
+
+ CHTMLWriteDisplay(CHTMLWriteWindow * parentWindow, QWidget * parent = 0);
+
/**
* Sets the new text for this display widget. (CPlainWriteDisplay).
*/
@@ -45,41 +50,29 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay {
virtual void setupToolbar(QToolBar * bar, BtActionCollection * actionCollection);
protected:
- friend class CDisplay;
- CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
- ~CHTMLWriteDisplay();
+
+ void alignmentChanged(int);
protected slots:
- void toggleBold(bool);
- void toggleItalic(bool);
- void toggleUnderline(bool);
+ void toggleBold(bool checked);
+ void toggleItalic(bool checked);
+ void toggleUnderline(bool checked);
void alignLeft(bool);
void alignCenter(bool);
void alignRight(bool);
- void changeFontSize(int);
+ void slotFontFamilyChosen(const QFont&);
+ void slotFontSizeChosen(int);
+ void slotFontColorChosen( const QColor& );
- void slotFontChanged( const QFont& );
- void slotFontFamilyChoosen(const QFont&);
-
- /**
- * The text's alignment changed. Enable the right buttons.
- */
- void slotAlignmentChanged( int );
- /**
- * Is called when a new color was selected.
- */
- void slotColorSelected( const QColor& );
- /**
- * Is called when a text with another color was selected.
- */
- void slotColorChanged( const QColor& );
+ void slotCurrentCharFormatChanged(const QTextCharFormat &);
signals:
- void fontChanged(const QFont& font);
- void fontSizeChanged(int);
- void setColor(const QColor&);
+
+ void signalFontChanged(const QFont &);
+ void signalFontSizeChanged(int);
+ void signalFontColorChanged(const QColor &);
private:
struct {
@@ -90,11 +83,10 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay {
QAction* alignLeft;
QAction* alignCenter;
QAction* alignRight;
-
- //popup menu
- QAction* selectAll;
}
m_actions;
+
+ bool m_handingFormatChangeFromEditor;
};
#endif
diff --git a/src/frontend/display/cplainwritedisplay.cpp b/src/frontend/display/cplainwritedisplay.cpp
index 07cecf3..e4b22d5 100644
--- a/src/frontend/display/cplainwritedisplay.cpp
+++ b/src/frontend/display/cplainwritedisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,10 +19,13 @@
#include "frontend/cdragdrop.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/cplainwritewindow.h"
-CPlainWriteDisplay::CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent) : QTextEdit(parentWindow ? parentWindow : parent), CWriteDisplay(parentWindow) {
+CPlainWriteDisplay::CPlainWriteDisplay(CPlainWriteWindow * parentWindow, QWidget * parent)
+ : QTextEdit(parentWindow ? parentWindow : parent)
+ , CDisplay(parentWindow)
+{
setAcceptRichText(false);
setAcceptDrops(true);
viewport()->setAcceptDrops(true);
diff --git a/src/frontend/display/cplainwritedisplay.h b/src/frontend/display/cplainwritedisplay.h
index 575789e..dad57a1 100644
--- a/src/frontend/display/cplainwritedisplay.h
+++ b/src/frontend/display/cplainwritedisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,22 +13,21 @@
#define CPLAINWRITEDISPLAY_H
#include <QTextEdit>
-#include "frontend/display/cwritedisplay.h"
+#include "frontend/display/cdisplay.h"
class BtActionCollection;
-class CHTMLWriteDisplay;
-class QDragEnterEvent;
-class QDragMoveEvent;
-class QDropEvent;
-class QMenu;
-class QWidget;
+class CPlainWriteWindow;
+class QToolBar;
/** The write display implementation for plain source code editing.
* @author The BibleTime team
*/
-class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
+class CPlainWriteDisplay : public QTextEdit, public CDisplay {
public:
+
+ CPlainWriteDisplay(CPlainWriteWindow * parentWindow, QWidget * parent = 0);
+
/**
* Reimplementation.
*/
@@ -52,27 +53,21 @@ class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
const DisplayOptions &,
const FilterOptions &) {}
- /**
- * Reimplementation (CWriteDisplay).
- */
virtual bool isModified() const;
/**
- * Sets the current status of the edit widget (CWriteDisplay).
+ * Sets the current status of the edit widget.
*/
virtual void setModified( const bool modified );
/**
- * Returns the text of this edit widget (CWriteDisplay).
+ * Returns the text of this edit widget.
*/
virtual const QString plainText();
/**
- * Creates the necessary action objects and puts them on the toolbar (CWriteDisplay).
+ * Creates the necessary action objects and puts them on the toolbar.
*/
virtual void setupToolbar(QToolBar*, BtActionCollection*);
protected:
- friend class CDisplay;
-
- CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
/**
* Reimplementation from QTextEdit to manage drops of our drag and drop objects.
diff --git a/src/frontend/display/creaddisplay.cpp b/src/frontend/display/creaddisplay.cpp
index f1b2f65..f5c3459 100644
--- a/src/frontend/display/creaddisplay.cpp
+++ b/src/frontend/display/creaddisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/creaddisplay.h b/src/frontend/display/creaddisplay.h
index 4b6dbeb..dd25a76 100644
--- a/src/frontend/display/creaddisplay.h
+++ b/src/frontend/display/creaddisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,6 +18,8 @@
#include "backend/managers/cswordbackend.h"
+class CReadWindow;
+
/** The base class for all read-only widgets like KHTMLView.
*@author The BibleTime team
*/
diff --git a/src/frontend/display/cwritedisplay.cpp b/src/frontend/display/cwritedisplay.cpp
deleted file mode 100644
index 47a3302..0000000
--- a/src/frontend/display/cwritedisplay.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/display/cwritedisplay.h"
-
-#include "frontend/displaywindow/cwritewindow.h"
-
-
-CWriteDisplay::CWriteDisplay( CWriteWindow* writeWindow ) : CDisplay(writeWindow) {
- // Intentionally empty
-}
-
-CWriteDisplay::~CWriteDisplay() {
- // Intentionally empty
-}
diff --git a/src/frontend/display/cwritedisplay.h b/src/frontend/display/cwritedisplay.h
deleted file mode 100644
index 0010749..0000000
--- a/src/frontend/display/cwritedisplay.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CWRITEDISPLAY_H
-#define CWRITEDISPLAY_H
-
-#include "frontend/display/cdisplay.h"
-
-
-class BtActionCollection;
-class QToolBar;
-
-/** The base class for all read/write-display classes.
- *@author The BibleTime team
- */
-class CWriteDisplay : public CDisplay {
- protected:
-
- CWriteDisplay( CWriteWindow* writeWindow );
- ~CWriteDisplay();
-
- public: // Public methods
- /**
- * Sets the current modified status of the widget.
- */
- virtual void setModified( const bool modified ) = 0;
- /**
- * Returns true if the current text was modified.
- */
- virtual bool isModified() const = 0;
- /**
- * Returns the text of this edit widget.
- */
- virtual const QString plainText() = 0;
- /**
- * Creates the necessary action objects and puts them on the toolbar.
- */
- virtual void setupToolbar( QToolBar* bar, BtActionCollection* actionCollection ) = 0;
-};
-
-#endif