Parcourir la source

Font format: subscript, superscript

Kandrashin Denis il y a 13 ans
Parent
commit
f422f39270
41 fichiers modifiés avec 75 ajouts et 26 suppressions
  1. 38 19
      source/fb2edit.qrc
  2. 35 7
      source/fb2main.cpp
  3. 2 0
      source/fb2main.h
  4. BIN
      source/images/16x16/application-exit.png
  5. BIN
      source/images/16x16/document-new.png
  6. BIN
      source/images/16x16/document-open.png
  7. BIN
      source/images/16x16/document-properties.png
  8. BIN
      source/images/16x16/document-save.png
  9. BIN
      source/images/16x16/edit-copy.png
  10. BIN
      source/images/16x16/edit-cut.png
  11. BIN
      source/images/16x16/edit-find-replace.png
  12. BIN
      source/images/16x16/edit-find.png
  13. BIN
      source/images/16x16/edit-paste.png
  14. BIN
      source/images/16x16/edit-redo.png
  15. BIN
      source/images/16x16/edit-undo.png
  16. BIN
      source/images/16x16/format-text-bold.png
  17. BIN
      source/images/16x16/format-text-italic.png
  18. BIN
      source/images/16x16/format-text-strikethrough.png
  19. BIN
      source/images/16x16/format-text-underline.png
  20. BIN
      source/images/16x16/window-close.png
  21. BIN
      source/images/16x16/zoom-in.png
  22. BIN
      source/images/16x16/zoom-out.png
  23. 0 0
      source/images/24x24/application-exit.png
  24. 0 0
      source/images/24x24/document-new.png
  25. 0 0
      source/images/24x24/document-open.png
  26. 0 0
      source/images/24x24/document-properties.png
  27. 0 0
      source/images/24x24/document-save.png
  28. 0 0
      source/images/24x24/edit-copy.png
  29. 0 0
      source/images/24x24/edit-cut.png
  30. 0 0
      source/images/24x24/edit-find-replace.png
  31. 0 0
      source/images/24x24/edit-find.png
  32. 0 0
      source/images/24x24/edit-paste.png
  33. 0 0
      source/images/24x24/edit-redo.png
  34. 0 0
      source/images/24x24/edit-undo.png
  35. 0 0
      source/images/24x24/format-text-bold.png
  36. 0 0
      source/images/24x24/format-text-italic.png
  37. 0 0
      source/images/24x24/format-text-strikethrough.png
  38. 0 0
      source/images/24x24/format-text-underline.png
  39. 0 0
      source/images/24x24/window-close.png
  40. 0 0
      source/images/24x24/zoom-in.png
  41. 0 0
      source/images/24x24/zoom-out.png

+ 38 - 19
source/fb2edit.qrc

@@ -1,23 +1,42 @@
 <RCC>
 <RCC>
     <qresource prefix="/">
     <qresource prefix="/">
-        <file>images/application-exit.png</file>
-        <file>images/document-new.png</file>
-        <file>images/document-open.png</file>
-        <file>images/document-properties.png</file>
-        <file>images/document-save.png</file>
-        <file>images/edit-copy.png</file>
-        <file>images/edit-cut.png</file>
-        <file>images/edit-find.png</file>
-        <file>images/edit-find-replace.png</file>
-        <file>images/edit-paste.png</file>
-        <file>images/edit-redo.png</file>
-        <file>images/edit-undo.png</file>
-        <file>images/format-text-bold.png</file>
-        <file>images/format-text-italic.png</file>
-        <file>images/format-text-strikethrough.png</file>
-        <file>images/format-text-underline.png</file>
-        <file>images/window-close.png</file>
-        <file>images/zoom-out.png</file>
-        <file>images/zoom-in.png</file>
+        <file>images/16x16/application-exit.png</file>
+        <file>images/16x16/document-new.png</file>
+        <file>images/16x16/document-open.png</file>
+        <file>images/16x16/document-properties.png</file>
+        <file>images/16x16/document-save.png</file>
+        <file>images/16x16/edit-copy.png</file>
+        <file>images/16x16/edit-cut.png</file>
+        <file>images/16x16/edit-find.png</file>
+        <file>images/16x16/edit-find-replace.png</file>
+        <file>images/16x16/edit-paste.png</file>
+        <file>images/16x16/edit-redo.png</file>
+        <file>images/16x16/edit-undo.png</file>
+        <file>images/16x16/format-text-bold.png</file>
+        <file>images/16x16/format-text-italic.png</file>
+        <file>images/16x16/format-text-strikethrough.png</file>
+        <file>images/16x16/format-text-underline.png</file>
+        <file>images/16x16/window-close.png</file>
+        <file>images/16x16/zoom-in.png</file>
+        <file>images/16x16/zoom-out.png</file>
+        <file>images/24x24/application-exit.png</file>
+        <file>images/24x24/document-new.png</file>
+        <file>images/24x24/document-open.png</file>
+        <file>images/24x24/document-properties.png</file>
+        <file>images/24x24/document-save.png</file>
+        <file>images/24x24/edit-copy.png</file>
+        <file>images/24x24/edit-cut.png</file>
+        <file>images/24x24/edit-find.png</file>
+        <file>images/24x24/edit-find-replace.png</file>
+        <file>images/24x24/edit-paste.png</file>
+        <file>images/24x24/edit-redo.png</file>
+        <file>images/24x24/edit-undo.png</file>
+        <file>images/24x24/format-text-bold.png</file>
+        <file>images/24x24/format-text-italic.png</file>
+        <file>images/24x24/format-text-strikethrough.png</file>
+        <file>images/24x24/format-text-underline.png</file>
+        <file>images/24x24/window-close.png</file>
+        <file>images/24x24/zoom-in.png</file>
+        <file>images/24x24/zoom-out.png</file>
     </qresource>
     </qresource>
 </RCC>
 </RCC>

+ 35 - 7
source/fb2main.cpp

@@ -183,8 +183,10 @@ void MainWindow::documentWasModified()
 
 
 QIcon MainWindow::icon(const QString &name)
 QIcon MainWindow::icon(const QString &name)
 {
 {
-    QString file = QString(":/images/%1.png").arg(name);
-    return QIcon::fromTheme(name, QIcon(file));
+    QIcon icon;
+    icon.addFile(QString(":/images/24x24/%1.png").arg(name), QSize(24,24));
+    icon.addFile(QString(":/images/16x16/%1.png").arg(name), QSize(16,16));
+    return QIcon::fromTheme(name, icon);
 }
 }
 
 
 void MainWindow::createActions()
 void MainWindow::createActions()
@@ -288,30 +290,40 @@ void MainWindow::createActions()
     actionTextBold = act = new QAction(icon("format-text-bold"), tr("Bold"), this);
     actionTextBold = act = new QAction(icon("format-text-bold"), tr("Bold"), this);
     act->setShortcuts(QKeySequence::Bold);
     act->setShortcuts(QKeySequence::Bold);
     act->setCheckable(true);
     act->setCheckable(true);
-    connect(act, SIGNAL(triggered()), this, SLOT(textBold()));
+    connect(act, SIGNAL(triggered()), SLOT(textBold()));
     menu->addAction(act);
     menu->addAction(act);
     tool->addAction(act);
     tool->addAction(act);
 
 
     actionTextItalic = act = new QAction(icon("format-text-italic"), tr("Italic"), this);
     actionTextItalic = act = new QAction(icon("format-text-italic"), tr("Italic"), this);
     act->setShortcuts(QKeySequence::Italic);
     act->setShortcuts(QKeySequence::Italic);
     act->setCheckable(true);
     act->setCheckable(true);
-    connect(act, SIGNAL(triggered()), this, SLOT(textItalic()));
+    connect(act, SIGNAL(triggered()), SLOT(textItalic()));
     menu->addAction(act);
     menu->addAction(act);
     tool->addAction(act);
     tool->addAction(act);
 
 
     actionTextUnder = act = new QAction(icon("format-text-underline"), tr("Underline"), this);
     actionTextUnder = act = new QAction(icon("format-text-underline"), tr("Underline"), this);
     act->setShortcuts(QKeySequence::Underline);
     act->setShortcuts(QKeySequence::Underline);
     act->setCheckable(true);
     act->setCheckable(true);
-    connect(act, SIGNAL(triggered()), this, SLOT(textUnder()));
+    connect(act, SIGNAL(triggered()), SLOT(textUnder()));
     menu->addAction(act);
     menu->addAction(act);
     tool->addAction(act);
     tool->addAction(act);
 
 
     actionTextStrike = act = new QAction(icon("format-text-strikethrough"), tr("Strikethrough"), this);
     actionTextStrike = act = new QAction(icon("format-text-strikethrough"), tr("Strikethrough"), this);
     act->setCheckable(true);
     act->setCheckable(true);
-    connect(act, SIGNAL(triggered()), this, SLOT(textStrike()));
+    connect(act, SIGNAL(triggered()), SLOT(textStrike()));
     menu->addAction(act);
     menu->addAction(act);
     tool->addAction(act);
     tool->addAction(act);
 
 
+    actionTextSup = act = new QAction(tr("Superscript"), this);
+    act->setCheckable(true);
+    connect(act, SIGNAL(triggered()), SLOT(textSup()));
+    menu->addAction(act);
+
+    actionTextSub = act = new QAction(tr("Subscript"), this);
+    act->setCheckable(true);
+    connect(act, SIGNAL(triggered()), SLOT(textSub()));
+    menu->addAction(act);
+
     // format-text-subscript
     // format-text-subscript
     // format-text-superscript
     // format-text-superscript
 
 
@@ -381,7 +393,7 @@ void MainWindow::createText()
     connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
     connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
     connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
     connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
 
 
-    connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &)));
+    connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), SLOT(currentCharFormatChanged(const QTextCharFormat &)));
 
 
     connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo()));
     connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo()));
     connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo()));
     connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo()));
@@ -568,6 +580,8 @@ void MainWindow::currentCharFormatChanged(const QTextCharFormat &format)
     actionTextItalic -> setChecked(font.italic());
     actionTextItalic -> setChecked(font.italic());
     actionTextUnder  -> setChecked(font.underline());
     actionTextUnder  -> setChecked(font.underline());
     actionTextStrike -> setChecked(font.strikeOut());
     actionTextStrike -> setChecked(font.strikeOut());
+    actionTextSub    -> setChecked(format.verticalAlignment() == QTextCharFormat::AlignSubScript);
+    actionTextSup    -> setChecked(format.verticalAlignment() == QTextCharFormat::AlignSuperScript);
 }
 }
 
 
 void MainWindow::cursorPositionChanged()
 void MainWindow::cursorPositionChanged()
@@ -610,6 +624,20 @@ void MainWindow::textStrike()
     mergeFormatOnWordOrSelection(fmt);
     mergeFormatOnWordOrSelection(fmt);
 }
 }
 
 
+void MainWindow::textSub()
+{
+    QTextCharFormat fmt;
+    fmt.setVerticalAlignment(actionTextSub->isChecked() ? QTextCharFormat::AlignSubScript : QTextCharFormat::AlignNormal);
+    mergeFormatOnWordOrSelection(fmt);
+}
+
+void MainWindow::textSup()
+{
+    QTextCharFormat fmt;
+    fmt.setVerticalAlignment(actionTextSup->isChecked() ? QTextCharFormat::AlignSuperScript : QTextCharFormat::AlignNormal);
+    mergeFormatOnWordOrSelection(fmt);
+}
+
 void MainWindow::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
 void MainWindow::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
 {
 {
     if (!textEdit) return;
     if (!textEdit) return;

+ 2 - 0
source/fb2main.h

@@ -50,6 +50,8 @@ private slots:
     void textUnder();
     void textUnder();
     void textItalic();
     void textItalic();
     void textStrike();
     void textStrike();
+    void textSub();
+    void textSup();
 
 
     void currentCharFormatChanged(const QTextCharFormat &format);
     void currentCharFormatChanged(const QTextCharFormat &format);
     void cursorPositionChanged();
     void cursorPositionChanged();

BIN
source/images/16x16/application-exit.png


BIN
source/images/16x16/document-new.png


BIN
source/images/16x16/document-open.png


BIN
source/images/16x16/document-properties.png


BIN
source/images/16x16/document-save.png


BIN
source/images/16x16/edit-copy.png


BIN
source/images/16x16/edit-cut.png


BIN
source/images/16x16/edit-find-replace.png


BIN
source/images/16x16/edit-find.png


BIN
source/images/16x16/edit-paste.png


BIN
source/images/16x16/edit-redo.png


BIN
source/images/16x16/edit-undo.png


BIN
source/images/16x16/format-text-bold.png


BIN
source/images/16x16/format-text-italic.png


BIN
source/images/16x16/format-text-strikethrough.png


BIN
source/images/16x16/format-text-underline.png


BIN
source/images/16x16/window-close.png


BIN
source/images/16x16/zoom-in.png


BIN
source/images/16x16/zoom-out.png


+ 0 - 0
source/images/application-exit.png → source/images/24x24/application-exit.png


+ 0 - 0
source/images/document-new.png → source/images/24x24/document-new.png


+ 0 - 0
source/images/document-open.png → source/images/24x24/document-open.png


+ 0 - 0
source/images/document-properties.png → source/images/24x24/document-properties.png


+ 0 - 0
source/images/document-save.png → source/images/24x24/document-save.png


+ 0 - 0
source/images/edit-copy.png → source/images/24x24/edit-copy.png


+ 0 - 0
source/images/edit-cut.png → source/images/24x24/edit-cut.png


+ 0 - 0
source/images/edit-find-replace.png → source/images/24x24/edit-find-replace.png


+ 0 - 0
source/images/edit-find.png → source/images/24x24/edit-find.png


+ 0 - 0
source/images/edit-paste.png → source/images/24x24/edit-paste.png


+ 0 - 0
source/images/edit-redo.png → source/images/24x24/edit-redo.png


+ 0 - 0
source/images/edit-undo.png → source/images/24x24/edit-undo.png


+ 0 - 0
source/images/format-text-bold.png → source/images/24x24/format-text-bold.png


+ 0 - 0
source/images/format-text-italic.png → source/images/24x24/format-text-italic.png


+ 0 - 0
source/images/format-text-strikethrough.png → source/images/24x24/format-text-strikethrough.png


+ 0 - 0
source/images/format-text-underline.png → source/images/24x24/format-text-underline.png


+ 0 - 0
source/images/window-close.png → source/images/24x24/window-close.png


+ 0 - 0
source/images/zoom-in.png → source/images/24x24/zoom-in.png


+ 0 - 0
source/images/zoom-out.png → source/images/24x24/zoom-out.png