mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
bugfix
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:
parent
30ee1e92d8
commit
882faeb5eb
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
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);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user