diff --git a/src/vconfigmanager.cpp b/src/vconfigmanager.cpp index 7e6a5130..f7912f0f 100644 --- a/src/vconfigmanager.cpp +++ b/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(); diff --git a/src/vdirectorytree.h b/src/vdirectorytree.h index 2a54130e..6d93fe51 100644 --- a/src/vdirectorytree.h +++ b/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); diff --git a/src/vedit.cpp b/src/vedit.cpp index 87313e5c..13cc6442 100644 --- a/src/vedit.cpp +++ b/src/vedit.cpp @@ -509,37 +509,39 @@ void VEdit::contextMenuEvent(QContextMenuEvent *p_event) const QList actions = menu->actions(); - VEditTab *editTab = dynamic_cast(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); + if (!textCursor().hasSelection()) { + VEditTab *editTab = dynamic_cast(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); + 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]); + 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]); + } } } diff --git a/src/veditarea.h b/src/veditarea.h index f4b8a892..8a171f76 100644 --- a/src/veditarea.h +++ b/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); diff --git a/src/vfilelist.h b/src/vfilelist.h index 1fd57cdf..e4f40989 100644 --- a/src/vfilelist.h +++ b/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); diff --git a/src/vnotebookselector.h b/src/vnotebookselector.h index b942b53d..3128e890 100644 --- a/src/vnotebookselector.h +++ b/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); diff --git a/src/voutline.h b/src/voutline.h index 24012089..04c4f5dc 100644 --- a/src/voutline.h +++ b/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);