bug-fix: move cursor to the end after creating new note

focusWidget() is NULL in Linux.
This commit is contained in:
Le Tan 2017-09-12 21:16:47 +08:00
parent 7fd2273aad
commit 84d1648fe4
2 changed files with 16 additions and 6 deletions

View File

@ -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,8 +319,9 @@ void VFileList::newFile()
// Move cursor down if content has been inserted.
if (contentInserted) {
QWidget *wid = QApplication::focusWidget();
VMdEdit *edit = dynamic_cast<VMdEdit *>(wid);
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);
@ -327,6 +329,7 @@ void VFileList::newFile()
}
}
}
}
}
QVector<QListWidgetItem *> VFileList::updateFileListAdded()

View File

@ -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