Browse Source

bugfix

1. Do not add additional actions if QTextEdit has selection;
2. Add Q_DECL_OVERRIDE to supress the warnings.
3. Fix getTemplateCssUrl().
Le Tan 8 years ago
parent
commit
882faeb5eb
7 changed files with 60 additions and 53 deletions
  1. 7 2
      src/vconfigmanager.cpp
  2. 4 4
      src/vdirectorytree.h
  3. 33 31
      src/vedit.cpp
  4. 4 4
      src/veditarea.h
  5. 4 4
      src/vfilelist.h
  6. 4 4
      src/vnotebookselector.h
  7. 4 4
      src/voutline.h

+ 7 - 2
src/vconfigmanager.cpp

@@ -436,10 +436,15 @@ bool VConfigManager::outputDefaultEditorStyle() const
     return true;
 }
 
+// The URL will be used in the Web page.
 QString VConfigManager::getTemplateCssUrl()
 {
-    QString cssPath = getStyleConfigFolder() + QDir::separator() + m_templateCss + ".css";
-    if (!QFile::exists(cssPath)) {
+    QString cssPath = getStyleConfigFolder() +
+                      QDir::separator() +
+                      m_templateCss + ".css";
+    QUrl cssUrl = QUrl::fromLocalFile(cssPath);
+    cssPath = cssUrl.toString();
+    if (!QFile::exists(cssUrl.toLocalFile())) {
         // Specified css not exists.
         if (m_templateCss == "default") {
             bool ret = outputDefaultCssStyle();

+ 4 - 4
src/vdirectorytree.h

@@ -25,10 +25,10 @@ public:
     inline const VNotebook *currentNotebook() const;
 
     // Implementations for VNavigationMode.
-    void registerNavigation(QChar p_majorKey);
-    void showNavigation();
-    void hideNavigation();
-    bool handleKeyNavigation(int p_key, bool &p_succeed);
+    void registerNavigation(QChar p_majorKey) Q_DECL_OVERRIDE;
+    void showNavigation() Q_DECL_OVERRIDE;
+    void hideNavigation() Q_DECL_OVERRIDE;
+    bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
 
 signals:
     void currentDirectoryChanged(VDirectory *p_directory);

+ 33 - 31
src/vedit.cpp

@@ -509,37 +509,39 @@ void VEdit::contextMenuEvent(QContextMenuEvent *p_event)
 
     const QList<QAction *> actions = menu->actions();
 
-    VEditTab *editTab = dynamic_cast<VEditTab *>(parent());
-    V_ASSERT(editTab);
-    if (editTab->getIsEditMode()) {
-        QAction *saveExitAct = new QAction(QIcon(":/resources/icons/save_exit.svg"),
-                                           tr("&Save Changes And Read"), this);
-        saveExitAct->setToolTip(tr("Save changes and exit edit mode"));
-        connect(saveExitAct, &QAction::triggered,
-                this, &VEdit::handleSaveExitAct);
-
-        QAction *discardExitAct = new QAction(QIcon(":/resources/icons/discard_exit.svg"),
-                                              tr("&Discard Changes And Read"), this);
-        discardExitAct->setToolTip(tr("Discard changes and exit edit mode"));
-        connect(discardExitAct, &QAction::triggered,
-                this, &VEdit::handleDiscardExitAct);
-
-        menu->insertAction(actions.isEmpty() ? NULL : actions[0], discardExitAct);
-        menu->insertAction(discardExitAct, saveExitAct);
-        if (!actions.isEmpty()) {
-            menu->insertSeparator(actions[0]);
-        }
-    } else if (m_file->isModifiable()) {
-        // HTML.
-        QAction *editAct= new QAction(QIcon(":/resources/icons/edit_note.svg"),
-                                      tr("&Edit"), this);
-        editAct->setToolTip(tr("Edit current note"));
-        connect(editAct, &QAction::triggered,
-                this, &VEdit::handleEditAct);
-        menu->insertAction(actions.isEmpty() ? NULL : actions[0], editAct);
-        // actions does not contain editAction.
-        if (!actions.isEmpty()) {
-            menu->insertSeparator(actions[0]);
+    if (!textCursor().hasSelection()) {
+        VEditTab *editTab = dynamic_cast<VEditTab *>(parent());
+        V_ASSERT(editTab);
+        if (editTab->getIsEditMode()) {
+            QAction *saveExitAct = new QAction(QIcon(":/resources/icons/save_exit.svg"),
+                                               tr("&Save Changes And Read"), this);
+            saveExitAct->setToolTip(tr("Save changes and exit edit mode"));
+            connect(saveExitAct, &QAction::triggered,
+                    this, &VEdit::handleSaveExitAct);
+
+            QAction *discardExitAct = new QAction(QIcon(":/resources/icons/discard_exit.svg"),
+                                                  tr("&Discard Changes And Read"), this);
+            discardExitAct->setToolTip(tr("Discard changes and exit edit mode"));
+            connect(discardExitAct, &QAction::triggered,
+                    this, &VEdit::handleDiscardExitAct);
+
+            menu->insertAction(actions.isEmpty() ? NULL : actions[0], discardExitAct);
+            menu->insertAction(discardExitAct, saveExitAct);
+            if (!actions.isEmpty()) {
+                menu->insertSeparator(actions[0]);
+            }
+        } else if (m_file->isModifiable()) {
+            // HTML.
+            QAction *editAct= new QAction(QIcon(":/resources/icons/edit_note.svg"),
+                                          tr("&Edit"), this);
+            editAct->setToolTip(tr("Edit current note"));
+            connect(editAct, &QAction::triggered,
+                    this, &VEdit::handleEditAct);
+            menu->insertAction(actions.isEmpty() ? NULL : actions[0], editAct);
+            // actions does not contain editAction.
+            if (!actions.isEmpty()) {
+                menu->insertSeparator(actions[0]);
+            }
         }
     }
 

+ 4 - 4
src/veditarea.h

@@ -52,10 +52,10 @@ public:
     VEditWindow *getCurrentWindow() const;
 
     // Implementations for VNavigationMode.
-    void registerNavigation(QChar p_majorKey);
-    void showNavigation();
-    void hideNavigation();
-    bool handleKeyNavigation(int p_key, bool &p_succeed);
+    void registerNavigation(QChar p_majorKey) Q_DECL_OVERRIDE;
+    void showNavigation() Q_DECL_OVERRIDE;
+    void hideNavigation() Q_DECL_OVERRIDE;
+    bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
 
 signals:
     void curTabStatusChanged(const VFile *p_file, const VEditTab *p_editTab, bool p_editMode);

+ 4 - 4
src/vfilelist.h

@@ -35,10 +35,10 @@ public:
     inline const VDirectory *currentDirectory() const;
 
     // Implementations for VNavigationMode.
-    void registerNavigation(QChar p_majorKey);
-    void showNavigation();
-    void hideNavigation();
-    bool handleKeyNavigation(int p_key, bool &p_succeed);
+    void registerNavigation(QChar p_majorKey) Q_DECL_OVERRIDE;
+    void showNavigation() Q_DECL_OVERRIDE;
+    void hideNavigation() Q_DECL_OVERRIDE;
+    bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
 
 signals:
     void fileClicked(VFile *p_file, OpenFileMode mode = OpenFileMode::Read);

+ 4 - 4
src/vnotebookselector.h

@@ -26,10 +26,10 @@ public:
     void showPopup() Q_DECL_OVERRIDE;
 
     // Implementations for VNavigationMode.
-    void registerNavigation(QChar p_majorKey);
-    void showNavigation();
-    void hideNavigation();
-    bool handleKeyNavigation(int p_key, bool &p_succeed);
+    void registerNavigation(QChar p_majorKey) Q_DECL_OVERRIDE;
+    void showNavigation() Q_DECL_OVERRIDE;
+    void hideNavigation() Q_DECL_OVERRIDE;
+    bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
 
 signals:
     void curNotebookChanged(VNotebook *p_notebook);

+ 4 - 4
src/voutline.h

@@ -17,10 +17,10 @@ public:
     VOutline(QWidget *parent = 0);
 
     // Implementations for VNavigationMode.
-    void registerNavigation(QChar p_majorKey);
-    void showNavigation();
-    void hideNavigation();
-    bool handleKeyNavigation(int p_key, bool &p_succeed);
+    void registerNavigation(QChar p_majorKey) Q_DECL_OVERRIDE;
+    void showNavigation() Q_DECL_OVERRIDE;
+    void hideNavigation() Q_DECL_OVERRIDE;
+    bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
 
 signals:
     void outlineItemActivated(const VAnchor &anchor);