Forráskód Böngészése

Insert footnote dialog

Kandrashin Denis 13 éve
szülő
commit
4e6e730609
10 módosított fájl, 218 hozzáadás és 3 törlés
  1. 1 1
      CMakeLists.txt
  2. 7 2
      fb2edit.pro
  3. 2 0
      source/fb2main.cpp
  4. 22 0
      source/fb2note.cpp
  5. 24 0
      source/fb2note.hpp
  6. 122 0
      source/fb2note.ui
  7. 12 0
      source/fb2view.cpp
  8. 2 0
      source/fb2view.hpp
  9. BIN
      source/ts/ru.qm
  10. 26 0
      source/ts/ru.ts

+ 1 - 1
CMakeLists.txt

@@ -41,7 +41,7 @@ qt4_wrap_cpp(MOC_SRCS ${FB2_HEAD})
 qt4_add_resources(RCC_SRCS ${FB2_RES})
 qt4_add_resources(RCC_SRCS ${FB2_RES})
 qt4_add_translation(QMS_FILES ${FB2_TSS})
 qt4_add_translation(QMS_FILES ${FB2_TSS})
 include_directories(${CMAKE_BINARY_DIR} ${QSCINTILLA_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIRS})
 include_directories(${CMAKE_BINARY_DIR} ${QSCINTILLA_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIRS})
-add_executable(fb2edit ${FB2_SRCS} ${FB2_HEAD} ${MOC_SRCS} ${RCC_SRCS} ${QMS_FILES})
+add_executable(fb2edit ${FB2_SRCS} ${FB2_HEAD} ${UI_HEADERS} ${MOC_SRCS} ${RCC_SRCS} ${QMS_FILES})
 target_link_libraries(fb2edit ${QT_LIBRARIES} ${QSCINTILLA_LIBRARIES} ${LIBXML2_LIBRARIES})
 target_link_libraries(fb2edit ${QT_LIBRARIES} ${QSCINTILLA_LIBRARIES} ${LIBXML2_LIBRARIES})
 
 
 set(LINUX_DESKTOP_FILE desktop/fb2edit.desktop)
 set(LINUX_DESKTOP_FILE desktop/fb2edit.desktop)

+ 7 - 2
fb2edit.pro

@@ -10,7 +10,8 @@ HEADERS = \
     source/fb2temp.hpp \
     source/fb2temp.hpp \
     source/fb2tree.hpp \
     source/fb2tree.hpp \
     source/fb2view.hpp \
     source/fb2view.hpp \
-    source/fb2tool.h
+    source/fb2tool.h \
+    source/fb2note.hpp
 
 
 SOURCES = \
 SOURCES = \
     source/fb2app.cpp \
     source/fb2app.cpp \
@@ -24,7 +25,8 @@ SOURCES = \
     source/fb2view.cpp \
     source/fb2view.cpp \
     source/fb2xml.cpp \
     source/fb2xml.cpp \
     source/fb2xml2.cpp \
     source/fb2xml2.cpp \
-    source/fb2tool.cpp
+    source/fb2tool.cpp \
+    source/fb2note.cpp
 
 
 RESOURCES = \
 RESOURCES = \
     3rdparty/gnome/gnome.qrc \
     3rdparty/gnome/gnome.qrc \
@@ -62,3 +64,6 @@ if (win32) {
     LIBS += -lxml2
     LIBS += -lxml2
 
 
 }
 }
+
+FORMS += \
+    source/fb2note.ui

+ 2 - 0
source/fb2main.cpp

@@ -681,6 +681,8 @@ void Fb2MainWindow::viewText()
     connect(actionTextSup, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleSuperscript), SIGNAL(triggered()));
     connect(actionTextSup, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleSuperscript), SIGNAL(triggered()));
 
 
     connect(actionImage, SIGNAL(triggered()), textEdit, SLOT(insertImage()));
     connect(actionImage, SIGNAL(triggered()), textEdit, SLOT(insertImage()));
+    connect(actionNote, SIGNAL(triggered()), textEdit, SLOT(insertNote()));
+    connect(actionLink, SIGNAL(triggered()), textEdit, SLOT(insertLink()));
 
 
     connect(actionZoomIn, SIGNAL(triggered()), textEdit, SLOT(zoomIn()));
     connect(actionZoomIn, SIGNAL(triggered()), textEdit, SLOT(zoomIn()));
     connect(actionZoomOut, SIGNAL(triggered()), textEdit, SLOT(zoomOut()));
     connect(actionZoomOut, SIGNAL(triggered()), textEdit, SLOT(zoomOut()));

+ 22 - 0
source/fb2note.cpp

@@ -0,0 +1,22 @@
+#include "fb2note.hpp"
+#include "fb2view.hpp"
+#include "ui_fb2note.h"
+
+Fb2NoteDlg::Fb2NoteDlg(Fb2WebView &view, QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::Fb2Note)
+{
+    ui->setupUi(this);
+    ui->m_key->addItem(tr("<create new>"));
+    ui->m_key->setCurrentIndex(0);
+    ui->m_title->setFocus();
+
+    Fb2WebPage *page = new Fb2WebPage(this);
+    page->setNetworkAccessManager(view.page()->networkAccessManager());
+    ui->m_text->setPage(page);
+}
+
+Fb2NoteDlg::~Fb2NoteDlg()
+{
+    delete ui;
+}

+ 24 - 0
source/fb2note.hpp

@@ -0,0 +1,24 @@
+#ifndef FB2NOTE_H
+#define FB2NOTE_H
+
+#include <QDialog>
+
+class Fb2WebView;
+
+namespace Ui {
+class Fb2Note;
+}
+
+class Fb2NoteDlg : public QDialog
+{
+    Q_OBJECT
+    
+public:
+    explicit Fb2NoteDlg(Fb2WebView &view, QWidget *parent = 0);
+    virtual ~Fb2NoteDlg();
+    
+private:
+    Ui::Fb2Note *ui;
+};
+
+#endif // FB2NOTE_H

+ 122 - 0
source/fb2note.ui

@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Fb2Note</class>
+ <widget class="QDialog" name="Fb2Note">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Insert footnote</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="1">
+    <widget class="QComboBox" name="m_key">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="editable">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0" colspan="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0" colspan="2">
+    <widget class="QWebView" name="m_text">
+     <property name="url">
+      <url>
+       <string>about:blank</string>
+      </url>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="text">
+      <string>Identifier:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QLineEdit" name="m_title"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>Title:</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>QWebView</class>
+   <extends>QWidget</extends>
+   <header>QtWebKit/QWebView</header>
+  </customwidget>
+ </customwidgets>
+ <tabstops>
+  <tabstop>m_title</tabstop>
+  <tabstop>m_text</tabstop>
+  <tabstop>buttonBox</tabstop>
+  <tabstop>m_key</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>Fb2Note</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>257</x>
+     <y>290</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>Fb2Note</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>325</x>
+     <y>290</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

+ 12 - 0
source/fb2view.cpp

@@ -1,4 +1,5 @@
 #include "fb2view.hpp"
 #include "fb2view.hpp"
+#include "fb2note.hpp"
 #include "fb2read.hpp"
 #include "fb2read.hpp"
 #include "fb2save.h"
 #include "fb2save.h"
 #include "fb2tool.h"
 #include "fb2tool.h"
@@ -246,6 +247,17 @@ void Fb2WebView::insertImage()
     execCommand("insertImage", url.toString());
     execCommand("insertImage", url.toString());
 }
 }
 
 
+void Fb2WebView::insertNote()
+{
+    Fb2NoteDlg * dlg = new Fb2NoteDlg(*this);
+    dlg->setModal(true);
+    dlg->show();
+}
+
+void Fb2WebView::insertLink()
+{
+}
+
 void Fb2WebView::execCommand(const QString &cmd, const QString &arg)
 void Fb2WebView::execCommand(const QString &cmd, const QString &arg)
 {
 {
     QString javascript = QString("document.execCommand(\"%1\",false,\"%2\")").arg(cmd).arg(arg);
     QString javascript = QString("document.execCommand(\"%1\",false,\"%2\")").arg(cmd).arg(arg);

+ 2 - 0
source/fb2view.hpp

@@ -84,6 +84,8 @@ public slots:
     void html(QString name, QString html);
     void html(QString name, QString html);
     void linkHovered(const QString &link, const QString &title, const QString &textContent);
     void linkHovered(const QString &link, const QString &title, const QString &textContent);
     void insertImage();
     void insertImage();
+    void insertNote();
+    void insertLink();
     void zoomIn();
     void zoomIn();
     void zoomOut();
     void zoomOut();
     void zoomOrig();
     void zoomOrig();

BIN
source/ts/ru.qm


+ 26 - 0
source/ts/ru.ts

@@ -359,6 +359,32 @@
         <translation type="unfinished"></translation>
         <translation type="unfinished"></translation>
     </message>
     </message>
 </context>
 </context>
+<context>
+    <name>Fb2Note</name>
+    <message>
+        <source>Insert footnote</source>
+        <translation>Вставить сноску</translation>
+    </message>
+    <message>
+        <source>about:blank</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Identifier:</source>
+        <translation>Идентификатор:</translation>
+    </message>
+    <message>
+        <source>Title:</source>
+        <translation>Заголовок:</translation>
+    </message>
+</context>
+<context>
+    <name>Fb2NoteDlg</name>
+    <message>
+        <source>&lt;create new&gt;</source>
+        <translation>&lt;создать новую&gt;</translation>
+    </message>
+</context>
 <context>
 <context>
     <name>Fb2WebView</name>
     <name>Fb2WebView</name>
     <message>
     <message>