瀏覽代碼

Small changes

Kandrashin Denis 13 年之前
父節點
當前提交
b491b020c2
共有 8 個文件被更改,包括 88 次插入90 次删除
  1. 2 2
      source/fb2dlgs.cpp
  2. 2 1
      source/fb2dlgs.hpp
  3. 1 1
      source/fb2html.cpp
  4. 2 2
      source/fb2main.cpp
  5. 77 0
      source/fb2text.cpp
  6. 4 1
      source/fb2text.hpp
  7. 0 75
      source/fb2utils.cpp
  8. 0 8
      source/fb2utils.h

+ 2 - 2
source/fb2dlgs.cpp

@@ -114,7 +114,7 @@ Fb2NoteDlg::Fb2NoteDlg(Fb2TextEdit &view)
     frameLayout->setSpacing(0);
     frameLayout->setMargin(0);
 
-    m_text = new QWebView(frame);
+    m_text = new Fb2TextBase(frame);
     m_text->setObjectName(QString::fromUtf8("m_text"));
     m_text->setUrl(QUrl(QString::fromUtf8("about:blank")));
     frameLayout->addWidget(m_text);
@@ -139,7 +139,7 @@ Fb2NoteDlg::Fb2NoteDlg(Fb2TextEdit &view)
     m_text->setPage(page);
     m_text->setHtml("<body><p><br></p></body>");
 
-    FB2::addTools(m_toolbar, m_text);
+    m_text->addTools(m_toolbar);
 }
 
 void Fb2NoteDlg::loadFinished()

+ 2 - 1
source/fb2dlgs.hpp

@@ -4,6 +4,7 @@
 #include <QDialog>
 
 class Fb2CodeEdit;
+class Fb2TextBase;
 class Fb2TextEdit;
 
 QT_BEGIN_NAMESPACE
@@ -61,7 +62,7 @@ private slots:
 
 private:
     QComboBox *m_key;
-    QWebView *m_text;
+    Fb2TextBase *m_text;
     QLineEdit *m_title;
     QToolBar *m_toolbar;
 };

+ 1 - 1
source/fb2html.cpp

@@ -152,9 +152,9 @@ void Fb2TitleCmd::undo()
 
 void Fb2SubtitleCmd::redo()
 {
-    QString html = "<div class=subtitle><p><br/></p></div>";
     Fb2TextElement element = m_page.element(m_location);
     if (m_element.isNull()) {
+        QString html = div("subtitle", p());
         element.appendOutside(html);
     } else {
         element.appendOutside(m_element);

+ 2 - 2
source/fb2main.cpp

@@ -689,7 +689,7 @@ void Fb2MainWindow::viewText()
     connect(actionTextSub, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::ToggleSubscript), SIGNAL(triggered()));
     connect(actionTextSup, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::ToggleSuperscript), SIGNAL(triggered()));
 
-    QWebView * textEdit = &(textFrame->view);
+    Fb2TextEdit * textEdit = &(textFrame->view);
 
     connect(actionFind, SIGNAL(triggered()), textEdit, SLOT(find()));
     connect(actionImage, SIGNAL(triggered()), textEdit, SLOT(insertImage()));
@@ -711,7 +711,7 @@ void Fb2MainWindow::viewText()
     tool->setMovable(false);
     tool->addSeparator();
 
-    FB2::addTools(tool, textEdit);
+    textEdit->addTools(tool);
 
     tool->addSeparator();
 

+ 77 - 0
source/fb2text.cpp

@@ -14,6 +14,7 @@
 #include <QNetworkRequest>
 #include <QStyle>
 #include <QStyleOptionFrame>
+#include <QToolBar>
 #include <QToolTip>
 #include <QUndoCommand>
 #include <QUndoStack>
@@ -183,6 +184,82 @@ QString Fb2TextPage::status()
     return mainFrame()->evaluateJavaScript(javascript).toString();
 }
 
+//---------------------------------------------------------------------------
+//  Fb2TextBase
+//---------------------------------------------------------------------------
+
+void Fb2TextBase::addTools(QToolBar *tool)
+{
+    QAction *act;
+
+    act = pageAction(QWebPage::Undo);
+    act->setIcon(FB2::icon("edit-undo"));
+    act->setText(QObject::tr("&Undo"));
+    act->setPriority(QAction::LowPriority);
+    act->setShortcut(QKeySequence::Undo);
+    tool->addAction(act);
+
+    act = pageAction(QWebPage::Redo);
+    act->setIcon(FB2::icon("edit-redo"));
+    act->setText(QObject::tr("&Redo"));
+    act->setPriority(QAction::LowPriority);
+    act->setShortcut(QKeySequence::Redo);
+    tool->addAction(act);
+
+    tool->addSeparator();
+
+    act = pageAction(QWebPage::Cut);
+    act->setIcon(FB2::icon("edit-cut"));
+    act->setText(QObject::tr("Cu&t"));
+    act->setPriority(QAction::LowPriority);
+    act->setShortcuts(QKeySequence::Cut);
+    act->setStatusTip(QObject::tr("Cut the current selection's contents to the clipboard"));
+    tool->addAction(act);
+
+    act = pageAction(QWebPage::Copy);
+    act->setIcon(FB2::icon("edit-copy"));
+    act->setText(QObject::tr("&Copy"));
+    act->setPriority(QAction::LowPriority);
+    act->setShortcuts(QKeySequence::Copy);
+    act->setStatusTip(QObject::tr("Copy the current selection's contents to the clipboard"));
+    tool->addAction(act);
+
+    act = pageAction(QWebPage::Paste);
+    act->setIcon(FB2::icon("edit-paste"));
+    act->setText(QObject::tr("&Paste"));
+    act->setPriority(QAction::LowPriority);
+    act->setShortcuts(QKeySequence::Paste);
+    act->setStatusTip(QObject::tr("Paste the clipboard's contents into the current selection"));
+    tool->addAction(act);
+
+    tool->addSeparator();
+
+    act = pageAction(QWebPage::ToggleBold);
+    act->setIcon(FB2::icon("format-text-bold"));
+    act->setText(QObject::tr("&Bold"));
+    tool->addAction(act);
+
+    act = pageAction(QWebPage::ToggleItalic);
+    act->setIcon(FB2::icon("format-text-italic"));
+    act->setText(QObject::tr("&Italic"));
+    tool->addAction(act);
+
+    act = pageAction(QWebPage::ToggleStrikethrough);
+    act->setIcon(FB2::icon("format-text-strikethrough"));
+    act->setText(QObject::tr("&Strikethrough"));
+    tool->addAction(act);
+
+    act = pageAction(QWebPage::ToggleSuperscript);
+    act->setIcon(FB2::icon("format-text-superscript"));
+    act->setText(QObject::tr("Su&perscript"));
+    tool->addAction(act);
+
+    act = pageAction(QWebPage::ToggleSubscript);
+    act->setIcon(FB2::icon("format-text-subscript"));
+    act->setText(QObject::tr("Su&bscript"));
+    tool->addAction(act);
+}
+
 //---------------------------------------------------------------------------
 //  Fb2TextEdit
 //---------------------------------------------------------------------------

+ 4 - 1
source/fb2text.hpp

@@ -11,8 +11,9 @@
 #include "fb2temp.hpp"
 
 QT_BEGIN_NAMESPACE
-class QWebInspector;
 class QDockWidget;
+class QToolBar;
+class QWebInspector;
 QT_END_NAMESPACE
 
 class Fb2NoteView;
@@ -31,6 +32,8 @@ public:
           connect(&m_timer, SIGNAL(timeout()), SLOT(doResize()));
     }
 
+    void addTools(QToolBar *tool);
+
 protected slots:
     void doResize() {
         QResizeEvent event(size(), m_size);

+ 0 - 75
source/fb2utils.cpp

@@ -1,10 +1,7 @@
 #include "fb2utils.h"
 
-#include <QAction>
 #include <QFile>
 #include <QTextStream>
-#include <QToolBar>
-#include <QWebView>
 
 namespace FB2 {
 
@@ -35,76 +32,4 @@ QString read(const QString &filename)
     return in.readAll();
 }
 
-void addTools(QToolBar *tool, QWebView *view)
-{
-    QAction *act;
-
-    act = view->pageAction(QWebPage::Undo);
-    act->setIcon(FB2::icon("edit-undo"));
-    act->setText(QObject::tr("&Undo"));
-    act->setPriority(QAction::LowPriority);
-    act->setShortcut(QKeySequence::Undo);
-    tool->addAction(act);
-
-    act = view->pageAction(QWebPage::Redo);
-    act->setIcon(FB2::icon("edit-redo"));
-    act->setText(QObject::tr("&Redo"));
-    act->setPriority(QAction::LowPriority);
-    act->setShortcut(QKeySequence::Redo);
-    tool->addAction(act);
-
-    tool->addSeparator();
-
-    act = view->pageAction(QWebPage::Cut);
-    act->setIcon(FB2::icon("edit-cut"));
-    act->setText(QObject::tr("Cu&t"));
-    act->setPriority(QAction::LowPriority);
-    act->setShortcuts(QKeySequence::Cut);
-    act->setStatusTip(QObject::tr("Cut the current selection's contents to the clipboard"));
-    tool->addAction(act);
-
-    act = view->pageAction(QWebPage::Copy);
-    act->setIcon(FB2::icon("edit-copy"));
-    act->setText(QObject::tr("&Copy"));
-    act->setPriority(QAction::LowPriority);
-    act->setShortcuts(QKeySequence::Copy);
-    act->setStatusTip(QObject::tr("Copy the current selection's contents to the clipboard"));
-    tool->addAction(act);
-
-    act = view->pageAction(QWebPage::Paste);
-    act->setIcon(FB2::icon("edit-paste"));
-    act->setText(QObject::tr("&Paste"));
-    act->setPriority(QAction::LowPriority);
-    act->setShortcuts(QKeySequence::Paste);
-    act->setStatusTip(QObject::tr("Paste the clipboard's contents into the current selection"));
-    tool->addAction(act);
-
-    tool->addSeparator();
-
-    act = view->pageAction(QWebPage::ToggleBold);
-    act->setIcon(FB2::icon("format-text-bold"));
-    act->setText(QObject::tr("&Bold"));
-    tool->addAction(act);
-
-    act = view->pageAction(QWebPage::ToggleItalic);
-    act->setIcon(FB2::icon("format-text-italic"));
-    act->setText(QObject::tr("&Italic"));
-    tool->addAction(act);
-
-    act = view->pageAction(QWebPage::ToggleStrikethrough);
-    act->setIcon(FB2::icon("format-text-strikethrough"));
-    act->setText(QObject::tr("&Strikethrough"));
-    tool->addAction(act);
-
-    act = view->pageAction(QWebPage::ToggleSuperscript);
-    act->setIcon(FB2::icon("format-text-superscript"));
-    act->setText(QObject::tr("Su&perscript"));
-    tool->addAction(act);
-
-    act = view->pageAction(QWebPage::ToggleSubscript);
-    act->setIcon(FB2::icon("format-text-subscript"));
-    act->setText(QObject::tr("Su&bscript"));
-    tool->addAction(act);
-}
-
 }

+ 0 - 8
source/fb2utils.h

@@ -4,12 +4,6 @@
 #include <QIcon>
 #include <QString>
 
-QT_BEGIN_NAMESPACE
-class QToolBar;
-class QWebView;
-QT_END_NAMESPACE
-
-
 #define FB2DELETE(p) { if ((p) != NULL) { delete (p); (p) = NULL; } }
 
 namespace FB2 {
@@ -18,8 +12,6 @@ QIcon icon(const QString &name);
 
 QString read(const QString &filename);
 
-void addTools(QToolBar *tool, QWebView *view);
-
 }
 
 #endif // FB2UTILS_H