Jelajahi Sumber

Align center for title

Kandrashin Denis 13 tahun lalu
induk
melakukan
e8580187f0
3 mengubah file dengan 30 tambahan dan 12 penghapusan
  1. 13 1
      source/fb2main.cpp
  2. 2 0
      source/fb2main.h
  3. 15 11
      source/fb2read.cpp

+ 13 - 1
source/fb2main.cpp

@@ -59,15 +59,27 @@ void MainWindow::logMessage(const QString &message)
 {
     if (!messageEdit) {
         messageEdit = new QTextEdit(this);
+        connect(messageEdit, SIGNAL(destroyed()), SLOT(logDestroyed()));
         QDockWidget * dock = new QDockWidget(tr("Message log"), this);
         dock->setAttribute(Qt::WA_DeleteOnClose);
         dock->setFeatures(QDockWidget::AllDockWidgetFeatures);
         dock->setWidget(messageEdit);
         addDockWidget(Qt::BottomDockWidgetArea, dock);
+        messageEdit->setMaximumHeight(80);
     }
     messageEdit->append(message);
 }
 
+void MainWindow::logShowed()
+{
+    messageEdit->setMaximumHeight(QWIDGETSIZE_MAX);
+}
+
+void MainWindow::logDestroyed()
+{
+    messageEdit = NULL;
+}
+
 bool MainWindow::loadXML(const QString &filename)
 {
     if (!filename.isEmpty()) {
@@ -392,7 +404,7 @@ void MainWindow::createQsci()
     qsciEdit->setMarginsBackgroundColor(QColor("gainsboro"));
     qsciEdit->setMarginWidth(0, 0);
     qsciEdit->setMarginLineNumbers(1, true);
-    qsciEdit->setMarginWidth(1, QString("1000"));
+    qsciEdit->setMarginWidth(1, QString("10000"));
     qsciEdit->setFolding(QsciScintilla::BoxedFoldStyle, 2);
 
     qsciEdit->setBraceMatching(QsciScintilla::SloppyBraceMatch);

+ 2 - 0
source/fb2main.h

@@ -41,6 +41,8 @@ private slots:
 
     void about();
     void documentWasModified();
+    void logDestroyed();
+    void logShowed();
     void viewQsci();
     void viewText();
 

+ 15 - 11
source/fb2read.cpp

@@ -328,17 +328,21 @@ Fb2Handler::TitleHandler::TitleHandler(TextHandler &parent, const QString &name,
 {
     Q_UNUSED(attributes);
 
-    QTextTableFormat format1;
-    format1.setBorder(0);
-    format1.setCellPadding(4);
-    format1.setCellSpacing(4);
-    format1.setWidth(QTextLength(QTextLength::PercentageLength, 100));
-    m_table = cursor().insertTable(1, 1, format1);
+    QTextTableFormat tableFormat;
+    tableFormat.setBorder(0);
+    tableFormat.setCellPadding(4);
+    tableFormat.setCellSpacing(4);
+    tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
+    m_table = cursor().insertTable(1, 1, tableFormat);
+
+    QTextTableCellFormat cellFormat;
+    cellFormat.setBackground(Qt::darkGreen);
+    cellFormat.setForeground(Qt::white);
+    m_table->cellAt(cursor()).setFormat(cellFormat);
 
-    QTextTableCellFormat format2;
-    format2.setBackground(Qt::darkGreen);
-    format2.setForeground(Qt::white);
-    m_table->cellAt(cursor()).setFormat(format2);
+    QTextBlockFormat blockFormat;
+    blockFormat.setAlignment(Qt::AlignHCenter);
+    cursor().mergeBlockFormat(blockFormat);
 }
 
 Fb2Handler::BaseHandler * Fb2Handler::TitleHandler::NewTag(const QString &name, const QXmlAttributes &attributes)
@@ -467,7 +471,7 @@ Fb2Handler::BlockHandler::BlockHandler(TextHandler &parent, const QString &name,
     QTextBlockFormat blockFormat;
     blockFormat.setTopMargin(4);
     blockFormat.setBottomMargin(4);
-    cursor().setBlockFormat(blockFormat);
+    cursor().mergeBlockFormat(blockFormat);
 }
 
 Fb2Handler::BaseHandler * Fb2Handler::BlockHandler::NewTag(const QString &name, const QXmlAttributes &attributes)