Skip to content

Commit

Permalink
Several improvements to tags editing
Browse files Browse the repository at this point in the history
* Fix #7602 - Allow spaces in tag names
* Fix #7528 - Allow pasting text into the tags field. Text is split by comma creating tags for each section of text. If there are no commas then the pasted text becomes a tag.
* Fix tags editing not causing the entry to be marked as modified.
  • Loading branch information
droidmonkey committed Mar 29, 2022
1 parent ad61d71 commit 355cad4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ QString Entry::tags() const

QStringList Entry::tagList() const
{
static QRegExp rx("(\\ |\\,|\\t|\\;)");
static QRegExp rx("(\\,|\\t|\\;)");
auto taglist = tags().split(rx, QString::SkipEmptyParts);
std::sort(taglist.begin(), taglist.end());
return taglist;
Expand Down
1 change: 1 addition & 0 deletions src/gui/entry/EditEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ void EditEntryWidget::setupEntryUpdate()
#ifdef WITH_XC_NETWORKING
connect(m_mainUi->urlEdit, SIGNAL(textChanged(QString)), this, SLOT(updateFaviconButtonEnable(QString)));
#endif
connect(m_mainUi->tagsList, SIGNAL(tagsEdited()), this, SLOT(setModified()));
connect(m_mainUi->expireCheck, SIGNAL(stateChanged(int)), this, SLOT(setModified()));
connect(m_mainUi->expireDatePicker, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(setModified()));
connect(m_mainUi->notesEdit, SIGNAL(textChanged()), this, SLOT(setModified()));
Expand Down
15 changes: 14 additions & 1 deletion src/gui/tag/TagsEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "TagsEdit.h"
#include "gui/MainWindow.h"
#include <QApplication>
#include <QClipboard>
#include <QCompleter>
#include <QDebug>
#include <QPainter>
Expand Down Expand Up @@ -701,6 +702,7 @@ void TagsEdit::mousePressEvent(QMouseEvent* event)
if (i <= impl->editing_index) {
--impl->editing_index;
}
emit tagsEdited();
found = true;
break;
}
Expand Down Expand Up @@ -797,6 +799,15 @@ void TagsEdit::keyPressEvent(QKeyEvent* event)
} else if (event == QKeySequence::SelectNextChar) {
impl->moveCursor(impl->text_layout.nextCursorPosition(impl->cursor), true);
event->accept();
} else if (event == QKeySequence::Paste) {
auto clipboard = QApplication::clipboard();
if (clipboard) {
for (auto tagtext : clipboard->text().split(",")) {
impl->currentText().insert(impl->cursor, tagtext);
impl->editNewTag(impl->editing_index + 1);
}
}
event->accept();
} else {
switch (event->key()) {
case Qt::Key_Left:
Expand Down Expand Up @@ -839,7 +850,9 @@ void TagsEdit::keyPressEvent(QKeyEvent* event)
}
event->accept();
break;
case Qt::Key_Space:
case Qt::Key_Return:
case Qt::Key_Enter:
case Qt::Key_Comma:
if (!impl->currentText().isEmpty()) {
impl->editNewTag(impl->editing_index + 1);
}
Expand Down

0 comments on commit 355cad4

Please sign in to comment.