mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
bug-fix: move cursor to the end after creating new note
focusWidget() is NULL in Linux.
This commit is contained in:
parent
7fd2273aad
commit
84d1648fe4
@ -11,6 +11,7 @@
|
||||
#include "vfile.h"
|
||||
#include "vconfigmanager.h"
|
||||
#include "vmdedit.h"
|
||||
#include "vmdtab.h"
|
||||
|
||||
extern VConfigManager *g_config;
|
||||
extern VNote *g_vnote;
|
||||
@ -318,12 +319,14 @@ void VFileList::newFile()
|
||||
|
||||
// Move cursor down if content has been inserted.
|
||||
if (contentInserted) {
|
||||
QWidget *wid = QApplication::focusWidget();
|
||||
VMdEdit *edit = dynamic_cast<VMdEdit *>(wid);
|
||||
if (edit && edit->getFile() == file) {
|
||||
QTextCursor cursor = edit->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
edit->setTextCursor(cursor);
|
||||
const VMdTab *tab = dynamic_cast<VMdTab *>(editArea->currentEditTab());
|
||||
if (tab) {
|
||||
VMdEdit *edit = dynamic_cast<VMdEdit *>(tab->getEditor());
|
||||
if (edit && edit->getFile() == file) {
|
||||
QTextCursor cursor = edit->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
edit->setTextCursor(cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
|
||||
VWebView *getWebViewer() const;
|
||||
|
||||
VEdit *getEditor() const;
|
||||
|
||||
MarkdownConverterType getMarkdownConverterType() const;
|
||||
|
||||
void requestUpdateVimStatus() Q_DECL_OVERRIDE;
|
||||
@ -150,4 +152,9 @@ inline VEdit *VMdTab::getEditor()
|
||||
return m_editor;
|
||||
}
|
||||
|
||||
inline VEdit *VMdTab::getEditor() const
|
||||
{
|
||||
return m_editor;
|
||||
}
|
||||
|
||||
#endif // VMDTAB_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user