1. Do not add additional actions if QTextEdit has selection;
2. Add Q_DECL_OVERRIDE to supress the warnings.
3. Fix getTemplateCssUrl().
This commit is contained in:
Le Tan 2017-04-24 20:05:24 +08:00
parent 30ee1e92d8
commit 882faeb5eb
7 changed files with 58 additions and 51 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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