Browse Source

add menu item to enable the image preview

Not visible because we now could not handle the undo history very well.
Le Tan 8 years ago
parent
commit
8649f4f66f
2 changed files with 15 additions and 0 deletions
  1. 14 0
      src/vmainwindow.cpp
  2. 1 0
      src/vmainwindow.h

+ 14 - 0
src/vmainwindow.cpp

@@ -381,6 +381,15 @@ void VMainWindow::initMarkdownMenu()
             this, &VMainWindow::enableCodeBlockHighlight);
     markdownMenu->addAction(codeBlockAct);
     codeBlockAct->setChecked(vconfig.getEnableCodeBlockHighlight());
+
+    QAction *previewImageAct = new QAction(tr("Preview Images In Edit Mode"), this);
+    previewImageAct->setToolTip(tr("Enable image preview in edit mode"));
+    previewImageAct->setCheckable(true);
+    connect(previewImageAct, &QAction::triggered,
+            this, &VMainWindow::enableImagePreview);
+    // TODO: add the action to the menu after handling the UNDO history well.
+    // markdownMenu->addAction(previewImageAct);
+    previewImageAct->setChecked(vconfig.getEnablePreviewImages());
 }
 
 void VMainWindow::initViewMenu()
@@ -1274,6 +1283,11 @@ void VMainWindow::enableCodeBlockHighlight(bool p_checked)
     vconfig.setEnableCodeBlockHighlight(p_checked);
 }
 
+void VMainWindow::enableImagePreview(bool p_checked)
+{
+    vconfig.setEnablePreviewImages(p_checked);
+}
+
 void VMainWindow::shortcutHelp()
 {
     QString locale = VUtils::getLocale();

+ 1 - 0
src/vmainwindow.h

@@ -76,6 +76,7 @@ private slots:
     void changeAutoIndent(bool p_checked);
     void changeAutoList(bool p_checked);
     void enableCodeBlockHighlight(bool p_checked);
+    void enableImagePreview(bool p_checked);
 
 protected:
     void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;