- Set proper defalut focus of VInsertLinkDialog;
- Fix bug in snippet when selection mark is empty;
- Focus editor after double-click applying a snippet;
This commit is contained in:
Le Tan 2017-11-20 19:29:14 +08:00
parent 4ffd6a5ef4
commit 8ab8b3d83a
4 changed files with 17 additions and 1 deletions

View File

@ -130,3 +130,12 @@ QString VInsertLinkDialog::getLinkUrl() const
{
return m_linkUrlEdit->text();
}
void VInsertLinkDialog::showEvent(QShowEvent *p_event)
{
QDialog::showEvent(p_event);
if (!m_linkTextEdit->text().isEmpty() && m_linkUrlEdit->text().isEmpty()) {
m_linkUrlEdit->setFocus();
}
}

View File

@ -7,6 +7,7 @@
class VLineEdit;
class QLineEdit;
class QDialogButtonBox;
class QShowEvent;
class VInsertLinkDialog : public QDialog
{
@ -23,6 +24,9 @@ public:
QString getLinkUrl() const;
protected:
void showEvent(QShowEvent *p_event) Q_DECL_OVERRIDE;
private slots:
void handleInputChanged();

View File

@ -782,6 +782,8 @@ void VMdTab::applySnippet(const VSnippet *p_snippet)
m_editor->setVimMode(VimMode::Insert);
g_mainWin->showStatusMessage(tr("Snippet applied"));
focusTab();
}
} else {
g_mainWin->showStatusMessage(tr("Snippet %1 is not applicable").arg(p_snippet->getName()));

View File

@ -189,9 +189,10 @@ bool VSnippet::apply(QTextCursor &p_cursor) const
if (!m_selectionMark.isEmpty() && !secondPart.isEmpty()) {
secondPart.replace(m_selectionMark, selection);
content += secondPart;
}
content += secondPart;
// Insert it.
switch (m_type) {
case Type::Html: