Sfoglia il codice sorgente

Optimize dialog Fb2NoteDlg

Kandrashin Denis 13 anni fa
parent
commit
5b5e0c15b5
6 ha cambiato i file con 73 aggiunte e 155 eliminazioni
  1. 0 1
      fb2edit.pro
  2. 50 16
      source/fb2dlgs.cpp
  3. 11 3
      source/fb2dlgs.hpp
  4. 0 135
      source/fb2note.ui
  5. BIN
      source/ts/ru.qm
  6. 12 0
      source/ts/ru.ts

+ 0 - 1
fb2edit.pro

@@ -65,5 +65,4 @@ if (unix) {
 }
 
 FORMS += \
-    source/fb2note.ui \
     source/fb2find.ui

+ 50 - 16
source/fb2dlgs.cpp

@@ -4,8 +4,11 @@
 #include "fb2view.hpp"
 #include "fb2utils.h"
 #include "ui_fb2find.h"
-#include "ui_fb2note.h"
 
+#include <QComboBox>
+#include <QDialogButtonBox>
+#include <QLineEdit>
+#include <QToolBar>
 #include <QWebFrame>
 #include <QWebPage>
 
@@ -77,30 +80,61 @@ void Fb2TextFindDlg::find()
 
 Fb2NoteDlg::Fb2NoteDlg(Fb2WebView &view)
     : QDialog(&view)
-    , ui(new Ui::Fb2Note)
 {
-    ui->setupUi(this);
-    ui->m_key->addItem(tr("<create new>"));
-    ui->m_key->setCurrentIndex(0);
-    ui->m_title->setFocus();
+    setWindowTitle(tr("Insert footnote"));
+    resize(460, 300);
+
+    QGridLayout * gridLayout = new QGridLayout(this);
+
+    QLabel * label1 = new QLabel(this);
+    label1->setText(tr("Identifier:"));
+    gridLayout->addWidget(label1, 0, 0, 1, 1);
+
+    m_key = new QComboBox(this);
+    QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+    gridLayout->addWidget(m_key, 0, 1, 1, 1);
+
+    QLabel * label2 = new QLabel(this);
+    label2->setText(tr("Title:"));
+    gridLayout->addWidget(label2, 1, 0, 1, 1);
+
+    m_title = new QLineEdit(this);
+    m_title->setObjectName(QString::fromUtf8("m_title"));
+    gridLayout->addWidget(m_title, 1, 1, 1, 1);
+
+    m_toolbar = new QToolBar(this);
+    gridLayout->addWidget(m_toolbar, 2, 0, 1, 2);
+
+    m_text = new Fb2BaseWebView(this);
+    m_text->setObjectName(QString::fromUtf8("m_text"));
+    m_text->setUrl(QUrl(QString::fromUtf8("about:blank")));
+    gridLayout->addWidget(m_text, 3, 0, 1, 2);
+
+    QDialogButtonBox * buttonBox = new QDialogButtonBox(this);
+    buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
+    buttonBox->setOrientation(Qt::Horizontal);
+    buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
+    gridLayout->addWidget(buttonBox, 4, 0, 1, 2);
+
+    QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+    QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+
+    m_key->addItem(tr("<create new>"));
+    m_key->setCurrentIndex(0);
+    m_title->setFocus();
 
     Fb2WebPage *page = new Fb2WebPage(this);
-    connect(ui->m_text, SIGNAL(loadFinished(bool)), SLOT(loadFinished()));
+    connect(m_text, SIGNAL(loadFinished(bool)), SLOT(loadFinished()));
     page->setNetworkAccessManager(view.page()->networkAccessManager());
     page->setContentEditable(true);
-    ui->m_text->setPage(page);
-    ui->m_text->setHtml("<body><p></p></body>");
+    m_text->setPage(page);
+    m_text->setHtml("<body><p><br></p></body>");
 
-    FB2::addTools(ui->m_toolbar, ui->m_text);
-}
-
-Fb2NoteDlg::~Fb2NoteDlg()
-{
-    delete ui;
+    FB2::addTools(m_toolbar, m_text);
 }
 
 void Fb2NoteDlg::loadFinished()
 {
-    Fb2WebElement body = ui->m_text->page()->mainFrame()->documentElement().findFirst("body");
+    Fb2WebElement body = m_text->page()->mainFrame()->documentElement().findFirst("body");
     body.select();
 }

+ 11 - 3
source/fb2dlgs.hpp

@@ -6,9 +6,15 @@
 class Fb2CodeEdit;
 class Fb2WebView;
 
+QT_BEGIN_NAMESPACE
+class QComboBox;
+class QLineEdit;
+class QToolBar;
+class QWebView;
+QT_END_NAMESPACE
+
 namespace Ui {
 class Fb2Find;
-class Fb2Note;
 }
 
 class Fb2CodeFindDlg : public QDialog
@@ -49,13 +55,15 @@ class Fb2NoteDlg : public QDialog
     
 public:
     explicit Fb2NoteDlg(Fb2WebView &view);
-    virtual ~Fb2NoteDlg();
 
 private slots:
     void loadFinished();
 
 private:
-    Ui::Fb2Note * ui;
+    QComboBox *m_key;
+    QWebView *m_text;
+    QLineEdit *m_title;
+    QToolBar *m_toolbar;
 };
 
 #endif // FB2DLGS_H

+ 0 - 135
source/fb2note.ui

@@ -1,135 +0,0 @@
-<?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>460</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>
-    </widget>
-   </item>
-   <item row="4" 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="3" 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="label1">
-     <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="label2">
-     <property name="text">
-      <string>Title:</string>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="0" colspan="2">
-    <widget class="QToolBar" name="m_toolbar">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="floatable">
-      <bool>true</bool>
-     </property>
-     <property name="text" stdset="0">
-      <string>TextLabel</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>

BIN
source/ts/ru.qm


+ 12 - 0
source/ts/ru.ts

@@ -496,6 +496,18 @@
         <source>&lt;create new&gt;</source>
         <translation>&lt;создать новый&gt;</translation>
     </message>
+    <message>
+        <source>Insert footnote</source>
+        <translation>Вставить сноску</translation>
+    </message>
+    <message>
+        <source>Identifier:</source>
+        <translation>Идентификатор:</translation>
+    </message>
+    <message>
+        <source>Title:</source>
+        <translation>Заголовок:</translation>
+    </message>
 </context>
 <context>
     <name>Fb2SaveDialog</name>