mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
minor-fix
- Support repeat in title jump in read mode; - Trim input in VInsertLinkDialog; - Rename VLineEdit to VMetaWordLineEdit;
This commit is contained in:
parent
7e1a254073
commit
b19b1d8079
@ -2,7 +2,7 @@
|
|||||||
#include "vdirinfodialog.h"
|
#include "vdirinfodialog.h"
|
||||||
#include "vdirectory.h"
|
#include "vdirectory.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
@ -29,7 +29,7 @@ void VDirInfoDialog::setupUI()
|
|||||||
infoLabel = new QLabel(info);
|
infoLabel = new QLabel(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_nameEdit = new VLineEdit(m_directory->getName());
|
m_nameEdit = new VMetaWordLineEdit(m_directory->getName());
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
||||||
m_nameEdit);
|
m_nameEdit);
|
||||||
m_nameEdit->setValidator(validator);
|
m_nameEdit->setValidator(validator);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class VLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
class VDirectory;
|
class VDirectory;
|
||||||
@ -27,7 +27,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void setupUI();
|
void setupUI();
|
||||||
|
|
||||||
VLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
QLabel *m_warnLabel;
|
QLabel *m_warnLabel;
|
||||||
QDialogButtonBox *m_btnBox;
|
QDialogButtonBox *m_btnBox;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "utils/vmetawordmanager.h"
|
#include "utils/vmetawordmanager.h"
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ void VEditSnippetDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Name.
|
// Name.
|
||||||
m_nameEdit = new VLineEdit(m_snippet.getName());
|
m_nameEdit = new VMetaWordLineEdit(m_snippet.getName());
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
||||||
m_nameEdit);
|
m_nameEdit);
|
||||||
m_nameEdit->setValidator(validator);
|
m_nameEdit->setValidator(validator);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "vsnippet.h"
|
#include "vsnippet.h"
|
||||||
|
|
||||||
class VLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
@ -51,7 +51,7 @@ private:
|
|||||||
|
|
||||||
QVector<QChar> getAvailableShortcuts() const;
|
QVector<QChar> getAvailableShortcuts() const;
|
||||||
|
|
||||||
VLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
QComboBox *m_typeCB;
|
QComboBox *m_typeCB;
|
||||||
QComboBox *m_shortcutCB;
|
QComboBox *m_shortcutCB;
|
||||||
QLineEdit *m_cursorMarkEdit;
|
QLineEdit *m_cursorMarkEdit;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "vnotefile.h"
|
#include "vnotefile.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ void VFileInfoDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
|
|
||||||
// File name.
|
// File name.
|
||||||
QString name = m_file->getName();
|
QString name = m_file->getName();
|
||||||
m_nameEdit = new VLineEdit(name);
|
m_nameEdit = new VMetaWordLineEdit(name);
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
||||||
m_nameEdit);
|
m_nameEdit);
|
||||||
m_nameEdit->setValidator(validator);
|
m_nameEdit->setValidator(validator);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class VLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
class VDirectory;
|
class VDirectory;
|
||||||
@ -29,7 +29,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void setupUI(const QString &p_title, const QString &p_info);
|
void setupUI(const QString &p_title, const QString &p_info);
|
||||||
|
|
||||||
VLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
QLabel *m_warnLabel;
|
QLabel *m_warnLabel;
|
||||||
QDialogButtonBox *m_btnBox;
|
QDialogButtonBox *m_btnBox;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "vinsertimagedialog.h"
|
#include "vinsertimagedialog.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
#include "vdownloader.h"
|
#include "vdownloader.h"
|
||||||
|
|
||||||
VInsertImageDialog::VInsertImageDialog(const QString &p_title,
|
VInsertImageDialog::VInsertImageDialog(const QString &p_title,
|
||||||
@ -71,7 +71,7 @@ void VInsertImageDialog::setupUI(const QString &p_title,
|
|||||||
browseBtn->setEnabled(m_browsable);
|
browseBtn->setEnabled(m_browsable);
|
||||||
|
|
||||||
QLabel *imageTitleLabel = new QLabel(tr("&Image title:"));
|
QLabel *imageTitleLabel = new QLabel(tr("&Image title:"));
|
||||||
m_imageTitleEdit = new VLineEdit(p_imageTitle);
|
m_imageTitleEdit = new VMetaWordLineEdit(p_imageTitle);
|
||||||
m_imageTitleEdit->selectAll();
|
m_imageTitleEdit->selectAll();
|
||||||
imageTitleLabel->setBuddy(m_imageTitleEdit);
|
imageTitleLabel->setBuddy(m_imageTitleEdit);
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_imageTitleRegExp),
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_imageTitleRegExp),
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class VLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
@ -58,7 +58,7 @@ private:
|
|||||||
|
|
||||||
void fetchImageFromClipboard();
|
void fetchImageFromClipboard();
|
||||||
|
|
||||||
VLineEdit *m_imageTitleEdit;
|
VMetaWordLineEdit *m_imageTitleEdit;
|
||||||
QLineEdit *m_pathEdit;
|
QLineEdit *m_pathEdit;
|
||||||
QPushButton *browseBtn;
|
QPushButton *browseBtn;
|
||||||
QDialogButtonBox *m_btnBox;
|
QDialogButtonBox *m_btnBox;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
|
|
||||||
VInsertLinkDialog::VInsertLinkDialog(const QString &p_title,
|
VInsertLinkDialog::VInsertLinkDialog(const QString &p_title,
|
||||||
const QString &p_text,
|
const QString &p_text,
|
||||||
@ -37,7 +37,7 @@ void VInsertLinkDialog::setupUI(const QString &p_title,
|
|||||||
infoLabel->setWordWrap(true);
|
infoLabel->setWordWrap(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_linkTextEdit = new VLineEdit(p_linkText);
|
m_linkTextEdit = new VMetaWordLineEdit(p_linkText);
|
||||||
m_linkTextEdit->selectAll();
|
m_linkTextEdit->selectAll();
|
||||||
|
|
||||||
m_linkUrlEdit = new QLineEdit(p_linkUrl);
|
m_linkUrlEdit = new QLineEdit(p_linkUrl);
|
||||||
@ -108,6 +108,7 @@ void VInsertLinkDialog::fetchLinkFromClipboard()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString text = mimeData->text();
|
QString text = mimeData->text();
|
||||||
|
text = text.trimmed();
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class VLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
@ -40,7 +40,7 @@ private:
|
|||||||
// Infer link text/url from clipboard only when text and url are both empty.
|
// Infer link text/url from clipboard only when text and url are both empty.
|
||||||
void fetchLinkFromClipboard();
|
void fetchLinkFromClipboard();
|
||||||
|
|
||||||
VLineEdit *m_linkTextEdit;
|
VMetaWordLineEdit *m_linkTextEdit;
|
||||||
|
|
||||||
QLineEdit *m_linkUrlEdit;
|
QLineEdit *m_linkUrlEdit;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "vnewdirdialog.h"
|
#include "vnewdirdialog.h"
|
||||||
#include "vdirectory.h"
|
#include "vdirectory.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
@ -31,7 +31,7 @@ void VNewDirDialog::setupUI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QLabel *nameLabel = new QLabel(tr("Folder &name:"));
|
QLabel *nameLabel = new QLabel(tr("Folder &name:"));
|
||||||
m_nameEdit = new VLineEdit(defaultName);
|
m_nameEdit = new VMetaWordLineEdit(defaultName);
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
||||||
m_nameEdit);
|
m_nameEdit);
|
||||||
m_nameEdit->setValidator(validator);
|
m_nameEdit->setValidator(validator);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class VLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
class VDirectory;
|
class VDirectory;
|
||||||
@ -27,7 +27,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void setupUI();
|
void setupUI();
|
||||||
|
|
||||||
VLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
QDialogButtonBox *m_btnBox;
|
QDialogButtonBox *m_btnBox;
|
||||||
|
|
||||||
QLabel *m_warnLabel;
|
QLabel *m_warnLabel;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "vnewfiledialog.h"
|
#include "vnewfiledialog.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "vdirectory.h"
|
#include "vdirectory.h"
|
||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "utils/vmetawordmanager.h"
|
#include "utils/vmetawordmanager.h"
|
||||||
#include "utils/viconutils.h"
|
#include "utils/viconutils.h"
|
||||||
@ -25,7 +25,7 @@ VNewFileDialog::VNewFileDialog(const QString &p_title,
|
|||||||
{
|
{
|
||||||
setupUI(p_title, p_info, p_defaultName);
|
setupUI(p_title, p_info, p_defaultName);
|
||||||
|
|
||||||
connect(m_nameEdit, &VLineEdit::textChanged, this, &VNewFileDialog::handleInputChanged);
|
connect(m_nameEdit, &VMetaWordLineEdit::textChanged, this, &VNewFileDialog::handleInputChanged);
|
||||||
|
|
||||||
connect(m_templateCB, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(m_templateCB, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
this, &VNewFileDialog::handleCurrentTemplateChanged);
|
this, &VNewFileDialog::handleCurrentTemplateChanged);
|
||||||
@ -45,7 +45,7 @@ void VNewFileDialog::setupUI(const QString &p_title,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Name.
|
// Name.
|
||||||
m_nameEdit = new VLineEdit(p_defaultName);
|
m_nameEdit = new VMetaWordLineEdit(p_defaultName);
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
||||||
m_nameEdit);
|
m_nameEdit);
|
||||||
m_nameEdit->setValidator(validator);
|
m_nameEdit->setValidator(validator);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "vconstants.h"
|
#include "vconstants.h"
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class VLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class VDirectory;
|
class VDirectory;
|
||||||
@ -50,7 +50,7 @@ private:
|
|||||||
|
|
||||||
void tryToSelectLastTemplate();
|
void tryToSelectLastTemplate();
|
||||||
|
|
||||||
VLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
|
|
||||||
QComboBox *m_templateCB;
|
QComboBox *m_templateCB;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "vnotebook.h"
|
#include "vnotebook.h"
|
||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ void VNewNotebookDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QLabel *nameLabel = new QLabel(tr("Notebook &name:"));
|
QLabel *nameLabel = new QLabel(tr("Notebook &name:"));
|
||||||
m_nameEdit = new VLineEdit(defaultName);
|
m_nameEdit = new VMetaWordLineEdit(defaultName);
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
||||||
m_nameEdit);
|
m_nameEdit);
|
||||||
m_nameEdit->setValidator(validator);
|
m_nameEdit->setValidator(validator);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class VLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class VNotebook;
|
class VNotebook;
|
||||||
@ -53,7 +53,7 @@ private:
|
|||||||
// Returns true if name or path is modified.
|
// Returns true if name or path is modified.
|
||||||
bool autoComplete();
|
bool autoComplete();
|
||||||
|
|
||||||
VLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
QLineEdit *pathEdit;
|
QLineEdit *pathEdit;
|
||||||
QPushButton *browseBtn;
|
QPushButton *browseBtn;
|
||||||
QLabel *m_warnLabel;
|
QLabel *m_warnLabel;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "vnotebook.h"
|
#include "vnotebook.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ void VNotebookInfoDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
infoLabel = new QLabel(p_info);
|
infoLabel = new QLabel(p_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_nameEdit = new VLineEdit(m_notebook->getName());
|
m_nameEdit = new VMetaWordLineEdit(m_notebook->getName());
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
|
||||||
m_nameEdit);
|
m_nameEdit);
|
||||||
m_nameEdit->setValidator(validator);
|
m_nameEdit->setValidator(validator);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class VLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
class VNotebook;
|
class VNotebook;
|
||||||
@ -39,7 +39,7 @@ private:
|
|||||||
|
|
||||||
const VNotebook *m_notebook;
|
const VNotebook *m_notebook;
|
||||||
|
|
||||||
VLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
QLineEdit *m_pathEdit;
|
QLineEdit *m_pathEdit;
|
||||||
QLineEdit *m_imageFolderEdit;
|
QLineEdit *m_imageFolderEdit;
|
||||||
// Read-only.
|
// Read-only.
|
||||||
|
@ -146,6 +146,9 @@ window.onscroll = function() {
|
|||||||
content.setHeader(curHeader ? curHeader : "");
|
content.setHeader(curHeader ? curHeader : "");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Used to record the repeat token of user input.
|
||||||
|
var repeatToken = 0;
|
||||||
|
|
||||||
document.onkeydown = function(e) {
|
document.onkeydown = function(e) {
|
||||||
// Need to clear pending kyes.
|
// Need to clear pending kyes.
|
||||||
var clear = true;
|
var clear = true;
|
||||||
@ -174,20 +177,73 @@ document.onkeydown = function(e) {
|
|||||||
clear = false;
|
clear = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// 0 - 9.
|
||||||
|
case 48:
|
||||||
|
case 49:
|
||||||
|
case 50:
|
||||||
|
case 51:
|
||||||
|
case 52:
|
||||||
|
case 53:
|
||||||
|
case 54:
|
||||||
|
case 55:
|
||||||
|
case 56:
|
||||||
|
case 57:
|
||||||
|
case 96:
|
||||||
|
case 97:
|
||||||
|
case 98:
|
||||||
|
case 99:
|
||||||
|
case 100:
|
||||||
|
case 101:
|
||||||
|
case 102:
|
||||||
|
case 103:
|
||||||
|
case 104:
|
||||||
|
case 105:
|
||||||
|
{
|
||||||
|
if (pendingKeys.length != 0) {
|
||||||
|
accept = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var num = key >= 96 ? key - 96 : key - 48;
|
||||||
|
repeatToken = repeatToken * 10 + num;
|
||||||
|
clear = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 74: // J
|
case 74: // J
|
||||||
window.scrollBy(0, 100);
|
if (!ctrl && !shift) {
|
||||||
|
window.scrollBy(0, 100);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
accept = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 75: // K
|
case 75: // K
|
||||||
window.scrollBy(0, -100);
|
if (!ctrl && !shift) {
|
||||||
|
window.scrollBy(0, -100);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
accept = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 72: // H
|
case 72: // H
|
||||||
window.scrollBy(-100, 0);
|
if (!ctrl && !shift) {
|
||||||
|
window.scrollBy(-100, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
accept = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 76: // L
|
case 76: // L
|
||||||
window.scrollBy(100, 0);
|
if (!ctrl && !shift) {
|
||||||
|
window.scrollBy(100, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
accept = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 71: // G
|
case 71: // G
|
||||||
@ -198,7 +254,7 @@ document.onkeydown = function(e) {
|
|||||||
window.scrollTo(scrollLeft, scrollHeight);
|
window.scrollTo(scrollLeft, scrollHeight);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!ctrl) {
|
||||||
if (pendingKeys.length == 0) {
|
if (pendingKeys.length == 0) {
|
||||||
// First g, pend it.
|
// First g, pend it.
|
||||||
pendingKeys.push({
|
pendingKeys.push({
|
||||||
@ -245,17 +301,19 @@ document.onkeydown = function(e) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 219: // [ or {
|
case 219: // [ or {
|
||||||
|
{
|
||||||
|
var repeat = repeatToken < 1 ? 1 : repeatToken;
|
||||||
if (shift) {
|
if (shift) {
|
||||||
// {
|
// {
|
||||||
if (pendingKeys.length == 1) {
|
if (pendingKeys.length == 1) {
|
||||||
var pendKey = pendingKeys[0];
|
var pendKey = pendingKeys[0];
|
||||||
if (pendKey.key == key && !pendKey.shift && !pendKey.ctrl) {
|
if (pendKey.key == key && !pendKey.shift && !pendKey.ctrl) {
|
||||||
// [{, jump to previous title at a higher level.
|
// [{, jump to previous title at a higher level.
|
||||||
jumpTitle(false, -1, 1);
|
jumpTitle(false, -1, repeat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!ctrl) {
|
||||||
// [
|
// [
|
||||||
if (pendingKeys.length == 0) {
|
if (pendingKeys.length == 0) {
|
||||||
// First [, pend it.
|
// First [, pend it.
|
||||||
@ -271,11 +329,11 @@ document.onkeydown = function(e) {
|
|||||||
var pendKey = pendingKeys[0];
|
var pendKey = pendingKeys[0];
|
||||||
if (pendKey.key == key && !pendKey.shift && !pendKey.ctrl) {
|
if (pendKey.key == key && !pendKey.shift && !pendKey.ctrl) {
|
||||||
// [[, jump to previous title.
|
// [[, jump to previous title.
|
||||||
jumpTitle(false, 1, 1);
|
jumpTitle(false, 1, repeat);
|
||||||
break;
|
break;
|
||||||
} else if (pendKey.key == 221 && !pendKey.shift && !pendKey.ctrl) {
|
} else if (pendKey.key == 221 && !pendKey.shift && !pendKey.ctrl) {
|
||||||
// ][, jump to next title at the same level.
|
// ][, jump to next title at the same level.
|
||||||
jumpTitle(true, 0, 1);
|
jumpTitle(true, 0, repeat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,19 +341,22 @@ document.onkeydown = function(e) {
|
|||||||
|
|
||||||
accept = false;
|
accept = false;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 221: // ] or }
|
case 221: // ] or }
|
||||||
|
{
|
||||||
|
var repeat = repeatToken < 1 ? 1 : repeatToken;
|
||||||
if (shift) {
|
if (shift) {
|
||||||
// }
|
// }
|
||||||
if (pendingKeys.length == 1) {
|
if (pendingKeys.length == 1) {
|
||||||
var pendKey = pendingKeys[0];
|
var pendKey = pendingKeys[0];
|
||||||
if (pendKey.key == key && !pendKey.shift && !pendKey.ctrl) {
|
if (pendKey.key == key && !pendKey.shift && !pendKey.ctrl) {
|
||||||
// ]}, jump to next title at a higher level.
|
// ]}, jump to next title at a higher level.
|
||||||
jumpTitle(true, -1, 1);
|
jumpTitle(true, -1, repeat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!ctrl) {
|
||||||
// ]
|
// ]
|
||||||
if (pendingKeys.length == 0) {
|
if (pendingKeys.length == 0) {
|
||||||
// First ], pend it.
|
// First ], pend it.
|
||||||
@ -311,11 +372,11 @@ document.onkeydown = function(e) {
|
|||||||
var pendKey = pendingKeys[0];
|
var pendKey = pendingKeys[0];
|
||||||
if (pendKey.key == key && !pendKey.shift && !pendKey.ctrl) {
|
if (pendKey.key == key && !pendKey.shift && !pendKey.ctrl) {
|
||||||
// ]], jump to next title.
|
// ]], jump to next title.
|
||||||
jumpTitle(true, 1, 1);
|
jumpTitle(true, 1, repeat);
|
||||||
break;
|
break;
|
||||||
} else if (pendKey.key == 219 && !pendKey.shift && !pendKey.ctrl) {
|
} else if (pendKey.key == 219 && !pendKey.shift && !pendKey.ctrl) {
|
||||||
// [], jump to previous title at the same level.
|
// [], jump to previous title at the same level.
|
||||||
jumpTitle(false, 0, 1);
|
jumpTitle(false, 0, repeat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,6 +384,7 @@ document.onkeydown = function(e) {
|
|||||||
|
|
||||||
accept = false;
|
accept = false;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
accept = false;
|
accept = false;
|
||||||
@ -330,6 +392,7 @@ document.onkeydown = function(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (clear) {
|
if (clear) {
|
||||||
|
repeatToken = 0;
|
||||||
pendingKeys = [];
|
pendingKeys = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ SOURCES += main.cpp\
|
|||||||
vfilesessioninfo.cpp \
|
vfilesessioninfo.cpp \
|
||||||
vtableofcontent.cpp \
|
vtableofcontent.cpp \
|
||||||
utils/vmetawordmanager.cpp \
|
utils/vmetawordmanager.cpp \
|
||||||
vlineedit.cpp \
|
vmetawordlineedit.cpp \
|
||||||
dialog/vinsertlinkdialog.cpp \
|
dialog/vinsertlinkdialog.cpp \
|
||||||
vplaintextedit.cpp \
|
vplaintextedit.cpp \
|
||||||
vimageresourcemanager.cpp \
|
vimageresourcemanager.cpp \
|
||||||
@ -171,7 +171,7 @@ HEADERS += vmainwindow.h \
|
|||||||
vfilesessioninfo.h \
|
vfilesessioninfo.h \
|
||||||
vtableofcontent.h \
|
vtableofcontent.h \
|
||||||
utils/vmetawordmanager.h \
|
utils/vmetawordmanager.h \
|
||||||
vlineedit.h \
|
vmetawordlineedit.h \
|
||||||
dialog/vinsertlinkdialog.h \
|
dialog/vinsertlinkdialog.h \
|
||||||
vplaintextedit.h \
|
vplaintextedit.h \
|
||||||
vimageresourcemanager.h \
|
vimageresourcemanager.h \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "vlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
@ -8,22 +8,21 @@
|
|||||||
extern VMetaWordManager *g_mwMgr;
|
extern VMetaWordManager *g_mwMgr;
|
||||||
|
|
||||||
|
|
||||||
VLineEdit::VLineEdit(QWidget *p_parent)
|
VMetaWordLineEdit::VMetaWordLineEdit(QWidget *p_parent)
|
||||||
: QLineEdit(p_parent)
|
: QLineEdit(p_parent)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
VLineEdit::VLineEdit(const QString &p_contents, QWidget *p_parent)
|
VMetaWordLineEdit::VMetaWordLineEdit(const QString &p_contents, QWidget *p_parent)
|
||||||
: QLineEdit(p_contents, p_parent)
|
: QLineEdit(p_contents, p_parent)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VLineEdit::handleTextChanged(const QString &p_text)
|
void VMetaWordLineEdit::handleTextChanged(const QString &p_text)
|
||||||
{
|
{
|
||||||
m_evaluatedText = g_mwMgr->evaluate(p_text);
|
m_evaluatedText = g_mwMgr->evaluate(p_text);
|
||||||
qDebug() << "evaluate text:" << m_evaluatedText;
|
|
||||||
|
|
||||||
if (m_evaluatedText == p_text) {
|
if (m_evaluatedText == p_text) {
|
||||||
return;
|
return;
|
||||||
@ -34,15 +33,15 @@ void VLineEdit::handleTextChanged(const QString &p_text)
|
|||||||
QToolTip::showText(pos, m_evaluatedText, this);
|
QToolTip::showText(pos, m_evaluatedText, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VLineEdit::init()
|
void VMetaWordLineEdit::init()
|
||||||
{
|
{
|
||||||
m_evaluatedText = g_mwMgr->evaluate(text());
|
m_evaluatedText = g_mwMgr->evaluate(text());
|
||||||
|
|
||||||
connect(this, &QLineEdit::textChanged,
|
connect(this, &QLineEdit::textChanged,
|
||||||
this, &VLineEdit::handleTextChanged);
|
this, &VMetaWordLineEdit::handleTextChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &VLineEdit::getEvaluatedText() const
|
const QString &VMetaWordLineEdit::getEvaluatedText() const
|
||||||
{
|
{
|
||||||
return m_evaluatedText;
|
return m_evaluatedText;
|
||||||
}
|
}
|
@ -1,17 +1,17 @@
|
|||||||
#ifndef VLINEEDIT_H
|
#ifndef VMETAWORDLINEEDIT_H
|
||||||
#define VLINEEDIT_H
|
#define VMETAWORDLINEEDIT_H
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
|
||||||
// QLineEdit with meta word support.
|
// QLineEdit with meta word support.
|
||||||
class VLineEdit : public QLineEdit
|
class VMetaWordLineEdit : public QLineEdit
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit VLineEdit(QWidget *p_parent = nullptr);
|
explicit VMetaWordLineEdit(QWidget *p_parent = nullptr);
|
||||||
|
|
||||||
VLineEdit(const QString &p_contents, QWidget *p_parent = Q_NULLPTR);
|
VMetaWordLineEdit(const QString &p_contents, QWidget *p_parent = Q_NULLPTR);
|
||||||
|
|
||||||
// Return the evaluated text.
|
// Return the evaluated text.
|
||||||
const QString &getEvaluatedText() const;
|
const QString &getEvaluatedText() const;
|
||||||
@ -26,4 +26,4 @@ private:
|
|||||||
QString m_evaluatedText;
|
QString m_evaluatedText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VLINEEDIT_H
|
#endif // VMETAWORDLINEEDIT_H
|
Loading…
x
Reference in New Issue
Block a user