mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add VLineEdit which supports Ctrl+H/W/U shortcuts
This commit is contained in:
parent
b19b1d8079
commit
044b3d3c29
@ -5,7 +5,6 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
|
||||||
class QString;
|
class QString;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
|
@ -17,7 +17,7 @@ VDirInfoDialog::VDirInfoDialog(const QString &title,
|
|||||||
{
|
{
|
||||||
setupUI();
|
setupUI();
|
||||||
|
|
||||||
connect(m_nameEdit, &QLineEdit::textChanged, this, &VDirInfoDialog::handleInputChanged);
|
connect(m_nameEdit, &VMetaWordLineEdit::textChanged, this, &VDirInfoDialog::handleInputChanged);
|
||||||
|
|
||||||
handleInputChanged();
|
handleInputChanged();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "vmetawordlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "utils/vmetawordmanager.h"
|
#include "utils/vmetawordmanager.h"
|
||||||
|
#include "vlineedit.h"
|
||||||
|
|
||||||
extern VMetaWordManager *g_mwMgr;
|
extern VMetaWordManager *g_mwMgr;
|
||||||
|
|
||||||
@ -65,11 +66,11 @@ void VEditSnippetDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cursor mark.
|
// Cursor mark.
|
||||||
m_cursorMarkEdit = new QLineEdit(m_snippet.getCursorMark());
|
m_cursorMarkEdit = new VLineEdit(m_snippet.getCursorMark());
|
||||||
m_cursorMarkEdit->setToolTip(tr("String in the content to mark the cursor position"));
|
m_cursorMarkEdit->setToolTip(tr("String in the content to mark the cursor position"));
|
||||||
|
|
||||||
// Selection mark.
|
// Selection mark.
|
||||||
m_selectionMarkEdit = new QLineEdit(m_snippet.getSelectionMark());
|
m_selectionMarkEdit = new VLineEdit(m_snippet.getSelectionMark());
|
||||||
m_selectionMarkEdit->setToolTip(tr("String in the content to be replaced with selected text"));
|
m_selectionMarkEdit->setToolTip(tr("String in the content to be replaced with selected text"));
|
||||||
|
|
||||||
// Auto Indent.
|
// Auto Indent.
|
||||||
@ -117,16 +118,16 @@ void VEditSnippetDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
|
|
||||||
setWindowTitle(p_title);
|
setWindowTitle(p_title);
|
||||||
|
|
||||||
connect(m_nameEdit, &QLineEdit::textChanged,
|
connect(m_nameEdit, &VMetaWordLineEdit::textChanged,
|
||||||
this, &VEditSnippetDialog::handleInputChanged);
|
this, &VEditSnippetDialog::handleInputChanged);
|
||||||
|
|
||||||
connect(m_typeCB, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(m_typeCB, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
this, &VEditSnippetDialog::handleInputChanged);
|
this, &VEditSnippetDialog::handleInputChanged);
|
||||||
|
|
||||||
connect(m_cursorMarkEdit, &QLineEdit::textChanged,
|
connect(m_cursorMarkEdit, &VLineEdit::textChanged,
|
||||||
this, &VEditSnippetDialog::handleInputChanged);
|
this, &VEditSnippetDialog::handleInputChanged);
|
||||||
|
|
||||||
connect(m_selectionMarkEdit, &QLineEdit::textChanged,
|
connect(m_selectionMarkEdit, &VLineEdit::textChanged,
|
||||||
this, &VEditSnippetDialog::handleInputChanged);
|
this, &VEditSnippetDialog::handleInputChanged);
|
||||||
|
|
||||||
connect(m_contentEdit, &QTextEdit::textChanged,
|
connect(m_contentEdit, &QTextEdit::textChanged,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "vsnippet.h"
|
#include "vsnippet.h"
|
||||||
|
|
||||||
class VMetaWordLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QLineEdit;
|
class VLineEdit;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
@ -54,8 +54,8 @@ private:
|
|||||||
VMetaWordLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
QComboBox *m_typeCB;
|
QComboBox *m_typeCB;
|
||||||
QComboBox *m_shortcutCB;
|
QComboBox *m_shortcutCB;
|
||||||
QLineEdit *m_cursorMarkEdit;
|
VLineEdit *m_cursorMarkEdit;
|
||||||
QLineEdit *m_selectionMarkEdit;
|
VLineEdit *m_selectionMarkEdit;
|
||||||
QCheckBox *m_autoIndentCB;
|
QCheckBox *m_autoIndentCB;
|
||||||
QTextEdit *m_contentEdit;
|
QTextEdit *m_contentEdit;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ VFileInfoDialog::VFileInfoDialog(const QString &title,
|
|||||||
{
|
{
|
||||||
setupUI(title, info);
|
setupUI(title, info);
|
||||||
|
|
||||||
connect(m_nameEdit, &QLineEdit::textChanged, this, &VFileInfoDialog::handleInputChanged);
|
connect(m_nameEdit, &VMetaWordLineEdit::textChanged, this, &VFileInfoDialog::handleInputChanged);
|
||||||
|
|
||||||
handleInputChanged();
|
handleInputChanged();
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ void VFileInfoDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
m_nameEdit->setSelection(baseStart, baseLength);
|
m_nameEdit->setSelection(baseStart, baseLength);
|
||||||
|
|
||||||
// Attachment folder.
|
// Attachment folder.
|
||||||
QLineEdit *attachmentFolderEdit = new QLineEdit(m_file->getAttachmentFolder());
|
VLineEdit *attachmentFolderEdit = new VLineEdit(m_file->getAttachmentFolder());
|
||||||
attachmentFolderEdit->setPlaceholderText(tr("Will be assigned when adding attachments"));
|
attachmentFolderEdit->setPlaceholderText(tr("Will be assigned when adding attachments"));
|
||||||
attachmentFolderEdit->setToolTip(tr("The folder to hold attachments of this note"));
|
attachmentFolderEdit->setToolTip(tr("The folder to hold attachments of this note"));
|
||||||
attachmentFolderEdit->setReadOnly(true);
|
attachmentFolderEdit->setReadOnly(true);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "utils/viconutils.h"
|
#include "utils/viconutils.h"
|
||||||
|
#include "vlineedit.h"
|
||||||
|
|
||||||
VFindReplaceDialog::VFindReplaceDialog(QWidget *p_parent)
|
VFindReplaceDialog::VFindReplaceDialog(QWidget *p_parent)
|
||||||
: QWidget(p_parent), m_options(0), m_replaceAvailable(true)
|
: QWidget(p_parent), m_options(0), m_replaceAvailable(true)
|
||||||
@ -28,7 +29,7 @@ void VFindReplaceDialog::setupUI()
|
|||||||
|
|
||||||
// Find
|
// Find
|
||||||
QLabel *findLabel = new QLabel(tr("Find:"));
|
QLabel *findLabel = new QLabel(tr("Find:"));
|
||||||
m_findEdit = new QLineEdit();
|
m_findEdit = new VLineEdit();
|
||||||
m_findEdit->setPlaceholderText(tr("Enter text to search"));
|
m_findEdit->setPlaceholderText(tr("Enter text to search"));
|
||||||
findLabel->setBuddy(m_findEdit);
|
findLabel->setBuddy(m_findEdit);
|
||||||
m_findNextBtn = new QPushButton(tr("Find &Next"));
|
m_findNextBtn = new QPushButton(tr("Find &Next"));
|
||||||
@ -39,7 +40,7 @@ void VFindReplaceDialog::setupUI()
|
|||||||
|
|
||||||
// Replace
|
// Replace
|
||||||
QLabel *replaceLabel = new QLabel(tr("&Replace with:"));
|
QLabel *replaceLabel = new QLabel(tr("&Replace with:"));
|
||||||
m_replaceEdit = new QLineEdit();
|
m_replaceEdit = new VLineEdit();
|
||||||
m_replaceEdit->setPlaceholderText(tr("Enter text to replace with"));
|
m_replaceEdit->setPlaceholderText(tr("Enter text to replace with"));
|
||||||
replaceLabel->setBuddy(m_replaceEdit);
|
replaceLabel->setBuddy(m_replaceEdit);
|
||||||
m_replaceBtn = new QPushButton(tr("Replace"));
|
m_replaceBtn = new QPushButton(tr("Replace"));
|
||||||
@ -121,7 +122,7 @@ void VFindReplaceDialog::setupUI()
|
|||||||
// Signals
|
// Signals
|
||||||
connect(m_closeBtn, &QPushButton::clicked,
|
connect(m_closeBtn, &QPushButton::clicked,
|
||||||
this, &VFindReplaceDialog::closeDialog);
|
this, &VFindReplaceDialog::closeDialog);
|
||||||
connect(m_findEdit, &QLineEdit::textChanged,
|
connect(m_findEdit, &VLineEdit::textChanged,
|
||||||
this, &VFindReplaceDialog::handleFindTextChanged);
|
this, &VFindReplaceDialog::handleFindTextChanged);
|
||||||
connect(m_advancedBtn, &QPushButton::toggled,
|
connect(m_advancedBtn, &QPushButton::toggled,
|
||||||
this, &VFindReplaceDialog::advancedBtnToggled);
|
this, &VFindReplaceDialog::advancedBtnToggled);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include "vconstants.h"
|
#include "vconstants.h"
|
||||||
|
|
||||||
class QLineEdit;
|
class VLineEdit;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
|
||||||
@ -52,8 +52,8 @@ private:
|
|||||||
uint m_options;
|
uint m_options;
|
||||||
bool m_replaceAvailable;
|
bool m_replaceAvailable;
|
||||||
|
|
||||||
QLineEdit *m_findEdit;
|
VLineEdit *m_findEdit;
|
||||||
QLineEdit *m_replaceEdit;
|
VLineEdit *m_replaceEdit;
|
||||||
QPushButton *m_findNextBtn;
|
QPushButton *m_findNextBtn;
|
||||||
QPushButton *m_findPrevBtn;
|
QPushButton *m_findPrevBtn;
|
||||||
QPushButton *m_replaceBtn;
|
QPushButton *m_replaceBtn;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "vmetawordlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
#include "vdownloader.h"
|
#include "vdownloader.h"
|
||||||
|
#include "vlineedit.h"
|
||||||
|
|
||||||
VInsertImageDialog::VInsertImageDialog(const QString &p_title,
|
VInsertImageDialog::VInsertImageDialog(const QString &p_title,
|
||||||
const QString &p_imageTitle,
|
const QString &p_imageTitle,
|
||||||
@ -20,7 +21,7 @@ VInsertImageDialog::VInsertImageDialog(const QString &p_title,
|
|||||||
{
|
{
|
||||||
setupUI(p_title, p_imageTitle, p_imagePath);
|
setupUI(p_title, p_imageTitle, p_imagePath);
|
||||||
|
|
||||||
connect(m_imageTitleEdit, &QLineEdit::textChanged,
|
connect(m_imageTitleEdit, &VMetaWordLineEdit::textChanged,
|
||||||
this, &VInsertImageDialog::handleInputChanged);
|
this, &VInsertImageDialog::handleInputChanged);
|
||||||
|
|
||||||
if (m_browsable) {
|
if (m_browsable) {
|
||||||
@ -30,7 +31,7 @@ VInsertImageDialog::VInsertImageDialog(const QString &p_title,
|
|||||||
connect(m_timer, &QTimer::timeout,
|
connect(m_timer, &QTimer::timeout,
|
||||||
this, &VInsertImageDialog::handlePathEditChanged);
|
this, &VInsertImageDialog::handlePathEditChanged);
|
||||||
|
|
||||||
connect(m_pathEdit, &QLineEdit::textChanged,
|
connect(m_pathEdit, &VLineEdit::textChanged,
|
||||||
this, [this]() {
|
this, [this]() {
|
||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ void VInsertImageDialog::setupUI(const QString &p_title,
|
|||||||
const QString &p_imagePath)
|
const QString &p_imagePath)
|
||||||
{
|
{
|
||||||
QLabel *pathLabel = new QLabel(tr("&From:"));
|
QLabel *pathLabel = new QLabel(tr("&From:"));
|
||||||
m_pathEdit = new QLineEdit(p_imagePath);
|
m_pathEdit = new VLineEdit(p_imagePath);
|
||||||
pathLabel->setBuddy(m_pathEdit);
|
pathLabel->setBuddy(m_pathEdit);
|
||||||
browseBtn = new QPushButton(tr("&Browse"));
|
browseBtn = new QPushButton(tr("&Browse"));
|
||||||
m_pathEdit->setReadOnly(!m_browsable);
|
m_pathEdit->setReadOnly(!m_browsable);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class VLineEdit;
|
||||||
class VMetaWordLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
@ -59,7 +59,7 @@ private:
|
|||||||
void fetchImageFromClipboard();
|
void fetchImageFromClipboard();
|
||||||
|
|
||||||
VMetaWordLineEdit *m_imageTitleEdit;
|
VMetaWordLineEdit *m_imageTitleEdit;
|
||||||
QLineEdit *m_pathEdit;
|
VLineEdit *m_pathEdit;
|
||||||
QPushButton *browseBtn;
|
QPushButton *browseBtn;
|
||||||
QDialogButtonBox *m_btnBox;
|
QDialogButtonBox *m_btnBox;
|
||||||
QLabel *imagePreviewLabel;
|
QLabel *imagePreviewLabel;
|
||||||
|
@ -40,7 +40,7 @@ void VInsertLinkDialog::setupUI(const QString &p_title,
|
|||||||
m_linkTextEdit = new VMetaWordLineEdit(p_linkText);
|
m_linkTextEdit = new VMetaWordLineEdit(p_linkText);
|
||||||
m_linkTextEdit->selectAll();
|
m_linkTextEdit->selectAll();
|
||||||
|
|
||||||
m_linkUrlEdit = new QLineEdit(p_linkUrl);
|
m_linkUrlEdit = new VLineEdit(p_linkUrl);
|
||||||
m_linkUrlEdit->setToolTip(tr("Absolute or relative path of the link"));
|
m_linkUrlEdit->setToolTip(tr("Absolute or relative path of the link"));
|
||||||
|
|
||||||
QFormLayout *inputLayout = new QFormLayout();
|
QFormLayout *inputLayout = new QFormLayout();
|
||||||
@ -71,9 +71,9 @@ void VInsertLinkDialog::setupUI(const QString &p_title,
|
|||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
setWindowTitle(p_title);
|
setWindowTitle(p_title);
|
||||||
|
|
||||||
connect(m_linkTextEdit, &QLineEdit::textChanged,
|
connect(m_linkTextEdit, &VMetaWordLineEdit::textChanged,
|
||||||
this, &VInsertLinkDialog::handleInputChanged);
|
this, &VInsertLinkDialog::handleInputChanged);
|
||||||
connect(m_linkUrlEdit, &QLineEdit::textChanged,
|
connect(m_linkUrlEdit, &VLineEdit::textChanged,
|
||||||
this, &VInsertLinkDialog::handleInputChanged);
|
this, &VInsertLinkDialog::handleInputChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class VMetaWordLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QLineEdit;
|
class VLineEdit;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ private:
|
|||||||
|
|
||||||
VMetaWordLineEdit *m_linkTextEdit;
|
VMetaWordLineEdit *m_linkTextEdit;
|
||||||
|
|
||||||
QLineEdit *m_linkUrlEdit;
|
VLineEdit *m_linkUrlEdit;
|
||||||
|
|
||||||
QDialogButtonBox *m_btnBox;
|
QDialogButtonBox *m_btnBox;
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@ VNewDirDialog::VNewDirDialog(const QString &title,
|
|||||||
{
|
{
|
||||||
setupUI();
|
setupUI();
|
||||||
|
|
||||||
connect(m_nameEdit, &QLineEdit::textChanged, this, &VNewDirDialog::handleInputChanged);
|
connect(m_nameEdit, &VMetaWordLineEdit::textChanged, this, &VNewDirDialog::handleInputChanged);
|
||||||
|
|
||||||
handleInputChanged();
|
handleInputChanged();
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ VNewNotebookDialog::VNewNotebookDialog(const QString &title, const QString &info
|
|||||||
{
|
{
|
||||||
setupUI(title, info);
|
setupUI(title, info);
|
||||||
|
|
||||||
connect(m_nameEdit, &QLineEdit::textChanged, this, &VNewNotebookDialog::handleInputChanged);
|
connect(m_nameEdit, &VMetaWordLineEdit::textChanged, this, &VNewNotebookDialog::handleInputChanged);
|
||||||
connect(pathEdit, &QLineEdit::textChanged, this, &VNewNotebookDialog::handleInputChanged);
|
connect(pathEdit, &VLineEdit::textChanged, this, &VNewNotebookDialog::handleInputChanged);
|
||||||
connect(browseBtn, &QPushButton::clicked, this, &VNewNotebookDialog::handleBrowseBtnClicked);
|
connect(browseBtn, &QPushButton::clicked, this, &VNewNotebookDialog::handleBrowseBtnClicked);
|
||||||
|
|
||||||
handleInputChanged();
|
handleInputChanged();
|
||||||
@ -42,12 +42,12 @@ void VNewNotebookDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
nameLabel->setBuddy(m_nameEdit);
|
nameLabel->setBuddy(m_nameEdit);
|
||||||
|
|
||||||
QLabel *pathLabel = new QLabel(tr("Notebook &root folder:"));
|
QLabel *pathLabel = new QLabel(tr("Notebook &root folder:"));
|
||||||
pathEdit = new QLineEdit(defaultPath);
|
pathEdit = new VLineEdit(defaultPath);
|
||||||
pathLabel->setBuddy(pathEdit);
|
pathLabel->setBuddy(pathEdit);
|
||||||
browseBtn = new QPushButton(tr("&Browse"));
|
browseBtn = new QPushButton(tr("&Browse"));
|
||||||
|
|
||||||
QLabel *imageFolderLabel = new QLabel(tr("&Image folder:"));
|
QLabel *imageFolderLabel = new QLabel(tr("&Image folder:"));
|
||||||
m_imageFolderEdit = new QLineEdit();
|
m_imageFolderEdit = new VLineEdit();
|
||||||
imageFolderLabel->setBuddy(m_imageFolderEdit);
|
imageFolderLabel->setBuddy(m_imageFolderEdit);
|
||||||
m_imageFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
m_imageFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
||||||
.arg(g_config->getImageFolder()));
|
.arg(g_config->getImageFolder()));
|
||||||
@ -58,7 +58,7 @@ void VNewNotebookDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
m_imageFolderEdit->setValidator(validator);
|
m_imageFolderEdit->setValidator(validator);
|
||||||
|
|
||||||
QLabel *attachmentFolderLabel = new QLabel(tr("&Attachment folder:"));
|
QLabel *attachmentFolderLabel = new QLabel(tr("&Attachment folder:"));
|
||||||
m_attachmentFolderEdit = new QLineEdit();
|
m_attachmentFolderEdit = new VLineEdit();
|
||||||
attachmentFolderLabel->setBuddy(m_attachmentFolderEdit);
|
attachmentFolderLabel->setBuddy(m_attachmentFolderEdit);
|
||||||
m_attachmentFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
m_attachmentFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
||||||
.arg(g_config->getAttachmentFolder()));
|
.arg(g_config->getAttachmentFolder()));
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class VLineEdit;
|
||||||
class VMetaWordLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
@ -54,11 +54,11 @@ private:
|
|||||||
bool autoComplete();
|
bool autoComplete();
|
||||||
|
|
||||||
VMetaWordLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
QLineEdit *pathEdit;
|
VLineEdit *pathEdit;
|
||||||
QPushButton *browseBtn;
|
QPushButton *browseBtn;
|
||||||
QLabel *m_warnLabel;
|
QLabel *m_warnLabel;
|
||||||
QLineEdit *m_imageFolderEdit;
|
VLineEdit *m_imageFolderEdit;
|
||||||
QLineEdit *m_attachmentFolderEdit;
|
VLineEdit *m_attachmentFolderEdit;
|
||||||
QDialogButtonBox *m_btnBox;
|
QDialogButtonBox *m_btnBox;
|
||||||
|
|
||||||
QString defaultName;
|
QString defaultName;
|
||||||
|
@ -17,7 +17,7 @@ VNotebookInfoDialog::VNotebookInfoDialog(const QString &p_title,
|
|||||||
{
|
{
|
||||||
setupUI(p_title, p_info);
|
setupUI(p_title, p_info);
|
||||||
|
|
||||||
connect(m_nameEdit, &QLineEdit::textChanged,
|
connect(m_nameEdit, &VMetaWordLineEdit::textChanged,
|
||||||
this, &VNotebookInfoDialog::handleInputChanged);
|
this, &VNotebookInfoDialog::handleInputChanged);
|
||||||
|
|
||||||
handleInputChanged();
|
handleInputChanged();
|
||||||
@ -36,11 +36,11 @@ void VNotebookInfoDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
m_nameEdit->setValidator(validator);
|
m_nameEdit->setValidator(validator);
|
||||||
m_nameEdit->selectAll();
|
m_nameEdit->selectAll();
|
||||||
|
|
||||||
m_pathEdit = new QLineEdit(m_notebook->getPath());
|
m_pathEdit = new VLineEdit(m_notebook->getPath());
|
||||||
m_pathEdit->setReadOnly(true);
|
m_pathEdit->setReadOnly(true);
|
||||||
|
|
||||||
// Image folder.
|
// Image folder.
|
||||||
m_imageFolderEdit = new QLineEdit(m_notebook->getImageFolderConfig());
|
m_imageFolderEdit = new VLineEdit(m_notebook->getImageFolderConfig());
|
||||||
m_imageFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
m_imageFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
||||||
.arg(g_config->getImageFolder()));
|
.arg(g_config->getImageFolder()));
|
||||||
m_imageFolderEdit->setToolTip(tr("Set the name of the folder to hold images of all the notes in this notebook "
|
m_imageFolderEdit->setToolTip(tr("Set the name of the folder to hold images of all the notes in this notebook "
|
||||||
@ -50,14 +50,14 @@ void VNotebookInfoDialog::setupUI(const QString &p_title, const QString &p_info)
|
|||||||
|
|
||||||
// Attachment folder.
|
// Attachment folder.
|
||||||
Q_ASSERT(!m_notebook->getAttachmentFolder().isEmpty());
|
Q_ASSERT(!m_notebook->getAttachmentFolder().isEmpty());
|
||||||
m_attachmentFolderEdit = new QLineEdit(m_notebook->getAttachmentFolder());
|
m_attachmentFolderEdit = new VLineEdit(m_notebook->getAttachmentFolder());
|
||||||
m_attachmentFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
m_attachmentFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
||||||
.arg(g_config->getAttachmentFolder()));
|
.arg(g_config->getAttachmentFolder()));
|
||||||
m_attachmentFolderEdit->setToolTip(tr("The folder to hold attachments of all the notes in this notebook"));
|
m_attachmentFolderEdit->setToolTip(tr("The folder to hold attachments of all the notes in this notebook"));
|
||||||
m_attachmentFolderEdit->setReadOnly(true);
|
m_attachmentFolderEdit->setReadOnly(true);
|
||||||
|
|
||||||
// Recycle bin folder.
|
// Recycle bin folder.
|
||||||
QLineEdit *recycleBinFolderEdit = new QLineEdit(m_notebook->getRecycleBinFolder());
|
VLineEdit *recycleBinFolderEdit = new VLineEdit(m_notebook->getRecycleBinFolder());
|
||||||
recycleBinFolderEdit->setReadOnly(true);
|
recycleBinFolderEdit->setReadOnly(true);
|
||||||
recycleBinFolderEdit->setToolTip(tr("The folder to hold deleted files from within VNote of all the notes in this notebook"));
|
recycleBinFolderEdit->setToolTip(tr("The folder to hold deleted files from within VNote of all the notes in this notebook"));
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class VLineEdit;
|
||||||
class VMetaWordLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
@ -40,10 +40,10 @@ private:
|
|||||||
const VNotebook *m_notebook;
|
const VNotebook *m_notebook;
|
||||||
|
|
||||||
VMetaWordLineEdit *m_nameEdit;
|
VMetaWordLineEdit *m_nameEdit;
|
||||||
QLineEdit *m_pathEdit;
|
VLineEdit *m_pathEdit;
|
||||||
QLineEdit *m_imageFolderEdit;
|
VLineEdit *m_imageFolderEdit;
|
||||||
// Read-only.
|
// Read-only.
|
||||||
QLineEdit *m_attachmentFolderEdit;
|
VLineEdit *m_attachmentFolderEdit;
|
||||||
QLabel *m_warnLabel;
|
QLabel *m_warnLabel;
|
||||||
QDialogButtonBox *m_btnBox;
|
QDialogButtonBox *m_btnBox;
|
||||||
const QVector<VNotebook *> &m_notebooks;
|
const QVector<VNotebook *> &m_notebooks;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "vorphanfile.h"
|
#include "vorphanfile.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
|
#include "vlineedit.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ VOrphanFileInfoDialog::VOrphanFileInfoDialog(const VOrphanFile *p_file, QWidget
|
|||||||
{
|
{
|
||||||
setupUI();
|
setupUI();
|
||||||
|
|
||||||
connect(m_imageFolderEdit, &QLineEdit::textChanged,
|
connect(m_imageFolderEdit, &VLineEdit::textChanged,
|
||||||
this, &VOrphanFileInfoDialog::handleInputChanged);
|
this, &VOrphanFileInfoDialog::handleInputChanged);
|
||||||
|
|
||||||
handleInputChanged();
|
handleInputChanged();
|
||||||
@ -25,7 +26,7 @@ void VOrphanFileInfoDialog::setupUI()
|
|||||||
QLabel *fileLabel = new QLabel(m_file->fetchPath());
|
QLabel *fileLabel = new QLabel(m_file->fetchPath());
|
||||||
topLayout->addRow(tr("File:"), fileLabel);
|
topLayout->addRow(tr("File:"), fileLabel);
|
||||||
|
|
||||||
m_imageFolderEdit = new QLineEdit(m_file->getImageFolder());
|
m_imageFolderEdit = new VLineEdit(m_file->getImageFolder());
|
||||||
m_imageFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
m_imageFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
||||||
.arg(g_config->getImageFolderExt()));
|
.arg(g_config->getImageFolderExt()));
|
||||||
QString imgFolderTip = tr("Set the path of the image folder to store images "
|
QString imgFolderTip = tr("Set the path of the image folder to store images "
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class VOrphanFile;
|
class VOrphanFile;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QLineEdit;
|
class VLineEdit;
|
||||||
|
|
||||||
class VOrphanFileInfoDialog : public QDialog
|
class VOrphanFileInfoDialog : public QDialog
|
||||||
{
|
{
|
||||||
@ -28,7 +28,7 @@ private:
|
|||||||
const VOrphanFile *m_file;
|
const VOrphanFile *m_file;
|
||||||
|
|
||||||
QDialogButtonBox *m_btnBox;
|
QDialogButtonBox *m_btnBox;
|
||||||
QLineEdit *m_imageFolderEdit;
|
VLineEdit *m_imageFolderEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VORPHANFILEINFODIALOG_H
|
#endif // VORPHANFILEINFODIALOG_H
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "vconstants.h"
|
#include "vconstants.h"
|
||||||
|
#include "vlineedit.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
|
|
||||||
@ -440,7 +441,7 @@ VNoteManagementTab::VNoteManagementTab(QWidget *p_parent)
|
|||||||
connect(m_customImageFolder, &QCheckBox::stateChanged,
|
connect(m_customImageFolder, &QCheckBox::stateChanged,
|
||||||
this, &VNoteManagementTab::customImageFolderChanged);
|
this, &VNoteManagementTab::customImageFolderChanged);
|
||||||
|
|
||||||
m_imageFolderEdit = new QLineEdit(this);
|
m_imageFolderEdit = new VLineEdit(this);
|
||||||
m_imageFolderEdit->setPlaceholderText(tr("Name of the image folder"));
|
m_imageFolderEdit->setPlaceholderText(tr("Name of the image folder"));
|
||||||
m_imageFolderEdit->setToolTip(m_customImageFolder->toolTip());
|
m_imageFolderEdit->setToolTip(m_customImageFolder->toolTip());
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp), this);
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp), this);
|
||||||
@ -457,7 +458,7 @@ VNoteManagementTab::VNoteManagementTab(QWidget *p_parent)
|
|||||||
connect(m_customAttachmentFolder, &QCheckBox::stateChanged,
|
connect(m_customAttachmentFolder, &QCheckBox::stateChanged,
|
||||||
this, &VNoteManagementTab::customAttachmentFolderChanged);
|
this, &VNoteManagementTab::customAttachmentFolderChanged);
|
||||||
|
|
||||||
m_attachmentFolderEdit = new QLineEdit(this);
|
m_attachmentFolderEdit = new VLineEdit(this);
|
||||||
m_attachmentFolderEdit->setPlaceholderText(tr("Name of the attachment folder"));
|
m_attachmentFolderEdit->setPlaceholderText(tr("Name of the attachment folder"));
|
||||||
m_attachmentFolderEdit->setToolTip(m_customAttachmentFolder->toolTip());
|
m_attachmentFolderEdit->setToolTip(m_customAttachmentFolder->toolTip());
|
||||||
validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp), this);
|
validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp), this);
|
||||||
@ -483,7 +484,7 @@ VNoteManagementTab::VNoteManagementTab(QWidget *p_parent)
|
|||||||
connect(m_customImageFolderExt, &QCheckBox::stateChanged,
|
connect(m_customImageFolderExt, &QCheckBox::stateChanged,
|
||||||
this, &VNoteManagementTab::customImageFolderExtChanged);
|
this, &VNoteManagementTab::customImageFolderExtChanged);
|
||||||
|
|
||||||
m_imageFolderEditExt = new QLineEdit(this);
|
m_imageFolderEditExt = new VLineEdit(this);
|
||||||
m_imageFolderEditExt->setToolTip(m_customImageFolderExt->toolTip());
|
m_imageFolderEditExt->setToolTip(m_customImageFolderExt->toolTip());
|
||||||
m_imageFolderEditExt->setPlaceholderText(tr("Name of the image folder"));
|
m_imageFolderEditExt->setPlaceholderText(tr("Name of the image folder"));
|
||||||
|
|
||||||
@ -689,7 +690,7 @@ VMarkdownTab::VMarkdownTab(QWidget *p_parent)
|
|||||||
zoomFactorLayout->addWidget(m_webZoomFactorSpin);
|
zoomFactorLayout->addWidget(m_webZoomFactorSpin);
|
||||||
|
|
||||||
// Color column.
|
// Color column.
|
||||||
m_colorColumnEdit = new QLineEdit();
|
m_colorColumnEdit = new VLineEdit();
|
||||||
m_colorColumnEdit->setToolTip(tr("Specify the screen column in fenced code block "
|
m_colorColumnEdit->setToolTip(tr("Specify the screen column in fenced code block "
|
||||||
"which will be highlighted"));
|
"which will be highlighted"));
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp("\\d+"), this);
|
QValidator *validator = new QRegExpValidator(QRegExp("\\d+"), this);
|
||||||
|
@ -10,7 +10,7 @@ class QComboBox;
|
|||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
class QDoubleSpinBox;
|
class QDoubleSpinBox;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QLineEdit;
|
class VLineEdit;
|
||||||
class QStackedLayout;
|
class QStackedLayout;
|
||||||
class QListWidget;
|
class QListWidget;
|
||||||
class QPlainTextEdit;
|
class QPlainTextEdit;
|
||||||
@ -79,15 +79,15 @@ public:
|
|||||||
|
|
||||||
// Image folder.
|
// Image folder.
|
||||||
QCheckBox *m_customImageFolder;
|
QCheckBox *m_customImageFolder;
|
||||||
QLineEdit *m_imageFolderEdit;
|
VLineEdit *m_imageFolderEdit;
|
||||||
|
|
||||||
// Image folder of External File.
|
// Image folder of External File.
|
||||||
QCheckBox *m_customImageFolderExt;
|
QCheckBox *m_customImageFolderExt;
|
||||||
QLineEdit *m_imageFolderEditExt;
|
VLineEdit *m_imageFolderEditExt;
|
||||||
|
|
||||||
// Attachment folder.
|
// Attachment folder.
|
||||||
QCheckBox *m_customAttachmentFolder;
|
QCheckBox *m_customAttachmentFolder;
|
||||||
QLineEdit *m_attachmentFolderEdit;
|
VLineEdit *m_attachmentFolderEdit;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void customImageFolderChanged(int p_state);
|
void customImageFolderChanged(int p_state);
|
||||||
@ -125,7 +125,7 @@ public:
|
|||||||
QDoubleSpinBox *m_webZoomFactorSpin;
|
QDoubleSpinBox *m_webZoomFactorSpin;
|
||||||
|
|
||||||
// Color column in code block.
|
// Color column in code block.
|
||||||
QLineEdit *m_colorColumnEdit;
|
VLineEdit *m_colorColumnEdit;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool loadOpenMode();
|
bool loadOpenMode();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "lineeditdelegate.h"
|
#include "lineeditdelegate.h"
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include "vlineedit.h"
|
||||||
|
|
||||||
|
|
||||||
LineEditDelegate::LineEditDelegate(QObject *p_parent)
|
LineEditDelegate::LineEditDelegate(QObject *p_parent)
|
||||||
@ -15,7 +15,7 @@ QWidget *LineEditDelegate::createEditor(QWidget *p_parent,
|
|||||||
Q_UNUSED(p_option);
|
Q_UNUSED(p_option);
|
||||||
Q_UNUSED(p_index);
|
Q_UNUSED(p_index);
|
||||||
|
|
||||||
QLineEdit *edit = new QLineEdit(p_parent);
|
VLineEdit *edit = new VLineEdit(p_parent);
|
||||||
return edit;
|
return edit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ void LineEditDelegate::setEditorData(QWidget *p_editor, const QModelIndex &p_ind
|
|||||||
{
|
{
|
||||||
QString text = p_index.model()->data(p_index, Qt::EditRole).toString();
|
QString text = p_index.model()->data(p_index, Qt::EditRole).toString();
|
||||||
|
|
||||||
QLineEdit *edit = static_cast<QLineEdit *>(p_editor);
|
VLineEdit *edit = static_cast<VLineEdit *>(p_editor);
|
||||||
edit->setText(text);
|
edit->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ void LineEditDelegate::setModelData(QWidget *p_editor,
|
|||||||
QAbstractItemModel *p_model,
|
QAbstractItemModel *p_model,
|
||||||
const QModelIndex &p_index) const
|
const QModelIndex &p_index) const
|
||||||
{
|
{
|
||||||
QLineEdit *edit = static_cast<QLineEdit *>(p_editor);
|
VLineEdit *edit = static_cast<VLineEdit *>(p_editor);
|
||||||
|
|
||||||
p_model->setData(p_index, edit->text(), Qt::EditRole);
|
p_model->setData(p_index, edit->text(), Qt::EditRole);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,8 @@ SOURCES += main.cpp\
|
|||||||
dialog/vtipsdialog.cpp \
|
dialog/vtipsdialog.cpp \
|
||||||
dialog/vcopytextashtmldialog.cpp \
|
dialog/vcopytextashtmldialog.cpp \
|
||||||
vwaitingwidget.cpp \
|
vwaitingwidget.cpp \
|
||||||
utils/vwebutils.cpp
|
utils/vwebutils.cpp \
|
||||||
|
vlineedit.cpp
|
||||||
|
|
||||||
HEADERS += vmainwindow.h \
|
HEADERS += vmainwindow.h \
|
||||||
vdirectorytree.h \
|
vdirectorytree.h \
|
||||||
@ -197,7 +198,8 @@ HEADERS += vmainwindow.h \
|
|||||||
dialog/vtipsdialog.h \
|
dialog/vtipsdialog.h \
|
||||||
dialog/vcopytextashtmldialog.h \
|
dialog/vcopytextashtmldialog.h \
|
||||||
vwaitingwidget.h \
|
vwaitingwidget.h \
|
||||||
utils/vwebutils.h
|
utils/vwebutils.h \
|
||||||
|
vlineedit.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
vnote.qrc \
|
vnote.qrc \
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "dialog/vsortdialog.h"
|
#include "dialog/vsortdialog.h"
|
||||||
#include "utils/vimnavigationforwidget.h"
|
#include "utils/vimnavigationforwidget.h"
|
||||||
#include "utils/viconutils.h"
|
#include "utils/viconutils.h"
|
||||||
|
#include "vlineedit.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
extern VMainWindow *g_mainWin;
|
extern VMainWindow *g_mainWin;
|
||||||
@ -413,7 +414,7 @@ void VAttachmentList::sortItems()
|
|||||||
|
|
||||||
void VAttachmentList::handleListItemCommitData(QWidget *p_itemEdit)
|
void VAttachmentList::handleListItemCommitData(QWidget *p_itemEdit)
|
||||||
{
|
{
|
||||||
QString text = reinterpret_cast<QLineEdit *>(p_itemEdit)->text();
|
QString text = reinterpret_cast<VLineEdit *>(p_itemEdit)->text();
|
||||||
QListWidgetItem *item = m_attachmentList->currentItem();
|
QListWidgetItem *item = m_attachmentList->currentItem();
|
||||||
Q_ASSERT(item && item->text() == text);
|
Q_ASSERT(item && item->text() == text);
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "vnote.h"
|
#include "vnote.h"
|
||||||
#include "vmarkdownconverter.h"
|
#include "vmarkdownconverter.h"
|
||||||
#include "vdocument.h"
|
#include "vdocument.h"
|
||||||
|
#include "vlineedit.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ void VExporter::setupUI()
|
|||||||
|
|
||||||
// Target file path.
|
// Target file path.
|
||||||
QLabel *pathLabel = new QLabel(tr("Target &path:"));
|
QLabel *pathLabel = new QLabel(tr("Target &path:"));
|
||||||
m_pathEdit = new QLineEdit();
|
m_pathEdit = new VLineEdit();
|
||||||
pathLabel->setBuddy(m_pathEdit);
|
pathLabel->setBuddy(m_pathEdit);
|
||||||
m_browseBtn = new QPushButton(tr("&Browse"));
|
m_browseBtn = new QPushButton(tr("&Browse"));
|
||||||
connect(m_browseBtn, &QPushButton::clicked,
|
connect(m_browseBtn, &QPushButton::clicked,
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
class VWebView;
|
class VWebView;
|
||||||
class VFile;
|
class VFile;
|
||||||
class QLineEdit;
|
class VLineEdit;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
@ -99,7 +99,7 @@ private:
|
|||||||
ExportState m_state;
|
ExportState m_state;
|
||||||
|
|
||||||
QLabel *m_infoLabel;
|
QLabel *m_infoLabel;
|
||||||
QLineEdit *m_pathEdit;
|
VLineEdit *m_pathEdit;
|
||||||
QPushButton *m_browseBtn;
|
QPushButton *m_browseBtn;
|
||||||
QLabel *m_layoutLabel;
|
QLabel *m_layoutLabel;
|
||||||
QPushButton *m_layoutBtn;
|
QPushButton *m_layoutBtn;
|
||||||
|
74
src/vlineedit.cpp
Normal file
74
src/vlineedit.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#include "vlineedit.h"
|
||||||
|
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
#include "utils/vutils.h"
|
||||||
|
|
||||||
|
VLineEdit::VLineEdit(QWidget *p_parent)
|
||||||
|
: QLineEdit(p_parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VLineEdit::VLineEdit(const QString &p_contents, QWidget *p_parent)
|
||||||
|
: QLineEdit(p_contents, p_parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VLineEdit::keyPressEvent(QKeyEvent *p_event)
|
||||||
|
{
|
||||||
|
// Note that QKeyEvent starts with isAccepted() == true, so you do not
|
||||||
|
// need to call QKeyEvent::accept() - just do not call the base class
|
||||||
|
// implementation if you act upon the key.
|
||||||
|
|
||||||
|
bool accept = false;
|
||||||
|
int modifiers = p_event->modifiers();
|
||||||
|
switch (p_event->key()) {
|
||||||
|
case Qt::Key_H:
|
||||||
|
// Backspace.
|
||||||
|
if (VUtils::isControlModifierForVim(modifiers)) {
|
||||||
|
backspace();
|
||||||
|
accept = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::Key_W:
|
||||||
|
// Delete one word backward.
|
||||||
|
if (VUtils::isControlModifierForVim(modifiers)) {
|
||||||
|
if (!hasSelectedText()) {
|
||||||
|
cursorWordBackward(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
backspace();
|
||||||
|
accept = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::Key_U:
|
||||||
|
{
|
||||||
|
if (VUtils::isControlModifierForVim(modifiers)) {
|
||||||
|
if (hasSelectedText()) {
|
||||||
|
backspace();
|
||||||
|
} else {
|
||||||
|
int pos = cursorPosition();
|
||||||
|
if (pos > 0) {
|
||||||
|
cursorBackward(true, pos);
|
||||||
|
backspace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
accept = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!accept) {
|
||||||
|
QLineEdit::keyPressEvent(p_event);
|
||||||
|
}
|
||||||
|
}
|
19
src/vlineedit.h
Normal file
19
src/vlineedit.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef VLINEEDIT_H
|
||||||
|
#define VLINEEDIT_H
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
|
||||||
|
class VLineEdit : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit VLineEdit(QWidget *p_parent = nullptr);
|
||||||
|
|
||||||
|
VLineEdit(const QString &p_contents, QWidget *p_parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VLINEEDIT_H
|
@ -9,13 +9,13 @@ extern VMetaWordManager *g_mwMgr;
|
|||||||
|
|
||||||
|
|
||||||
VMetaWordLineEdit::VMetaWordLineEdit(QWidget *p_parent)
|
VMetaWordLineEdit::VMetaWordLineEdit(QWidget *p_parent)
|
||||||
: QLineEdit(p_parent)
|
: VLineEdit(p_parent)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
VMetaWordLineEdit::VMetaWordLineEdit(const QString &p_contents, QWidget *p_parent)
|
VMetaWordLineEdit::VMetaWordLineEdit(const QString &p_contents, QWidget *p_parent)
|
||||||
: QLineEdit(p_contents, p_parent)
|
: VLineEdit(p_contents, p_parent)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ void VMetaWordLineEdit::init()
|
|||||||
{
|
{
|
||||||
m_evaluatedText = g_mwMgr->evaluate(text());
|
m_evaluatedText = g_mwMgr->evaluate(text());
|
||||||
|
|
||||||
connect(this, &QLineEdit::textChanged,
|
connect(this, &VLineEdit::textChanged,
|
||||||
this, &VMetaWordLineEdit::handleTextChanged);
|
this, &VMetaWordLineEdit::handleTextChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef VMETAWORDLINEEDIT_H
|
#ifndef VMETAWORDLINEEDIT_H
|
||||||
#define VMETAWORDLINEEDIT_H
|
#define VMETAWORDLINEEDIT_H
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include "vlineedit.h"
|
||||||
|
|
||||||
|
|
||||||
// QLineEdit with meta word support.
|
// VLineEdit with meta word support.
|
||||||
class VMetaWordLineEdit : public QLineEdit
|
class VMetaWordLineEdit : public VLineEdit
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -341,7 +341,7 @@ void VVimIndicator::triggerCommandLine(VVim::CommandLineType p_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
VVimCmdLineEdit::VVimCmdLineEdit(QWidget *p_parent)
|
VVimCmdLineEdit::VVimCmdLineEdit(QWidget *p_parent)
|
||||||
: QLineEdit(p_parent), m_type(VVim::CommandLineType::Invalid),
|
: VLineEdit(p_parent), m_type(VVim::CommandLineType::Invalid),
|
||||||
m_registerPending(false), m_enableInputMethod(true)
|
m_registerPending(false), m_enableInputMethod(true)
|
||||||
{
|
{
|
||||||
// When user delete all the text, cancel command input.
|
// When user delete all the text, cancel command input.
|
||||||
@ -432,7 +432,7 @@ QVariant VVimCmdLineEdit::inputMethodQuery(Qt::InputMethodQuery p_query) const
|
|||||||
return m_enableInputMethod;
|
return m_enableInputMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QLineEdit::inputMethodQuery(p_query);
|
return VLineEdit::inputMethodQuery(p_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if @p_modifiers is Control which is different on macOs and Windows.
|
// See if @p_modifiers is Control which is different on macOs and Windows.
|
||||||
@ -531,7 +531,7 @@ void VVimCmdLineEdit::keyPressEvent(QKeyEvent *p_event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
QLineEdit::keyPressEvent(p_event);
|
VLineEdit::keyPressEvent(p_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VVimCmdLineEdit::focusOutEvent(QFocusEvent *p_event)
|
void VVimCmdLineEdit::focusOutEvent(QFocusEvent *p_event)
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#define VVIMINDICATOR_H
|
#define VVIMINDICATOR_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include "utils/vvim.h"
|
#include "utils/vvim.h"
|
||||||
|
#include "vlineedit.h"
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class VButtonWithWidget;
|
class VButtonWithWidget;
|
||||||
@ -12,7 +12,7 @@ class QKeyEvent;
|
|||||||
class QFocusEvent;
|
class QFocusEvent;
|
||||||
class VEditTab;
|
class VEditTab;
|
||||||
|
|
||||||
class VVimCmdLineEdit : public QLineEdit
|
class VVimCmdLineEdit : public VLineEdit
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user