mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-24 23:09:44 -05:00
TagsEdit code improvements and crash fix
Fix crash when pressing home on empty tag field Move completer to TagsEdit. Move cursor blink status to TagsEdit. Move paint implementation to impl. Simplify calcRect and drawTag. Hide editing_index and cursor position. Fix bug where an empty tag was shown if the tag edit was unfocused. Fix a bug where the scollbar was not updated when a tag was removed. Hide remaining TextEdit internal fields. Refactor to use QLinkedList. Remove obsolete EmptyTagIterator. Encapsulate tags and selected index in tags manager.
This commit is contained in:
parent
0cb0373f85
commit
571f7ba6e4
@ -402,7 +402,7 @@ void EntryPreviewWidget::updateEntryGeneralTab()
|
||||
const TimeInfo entryTime = m_currentEntry->timeInfo();
|
||||
const QString expires = entryTime.expires() ? Clock::toString(entryTime.expiryTime().toLocalTime()) : tr("Never");
|
||||
m_ui->entryExpirationLabel->setText(expires);
|
||||
m_ui->entryTagsList->tags(m_currentEntry->tagList());
|
||||
m_ui->entryTagsList->setTags(m_currentEntry->tagList());
|
||||
m_ui->entryTagsList->setReadOnly(true);
|
||||
}
|
||||
|
||||
|
@ -948,8 +948,8 @@ void EditEntryWidget::setForms(Entry* entry, bool restore)
|
||||
m_mainUi->usernameComboBox->lineEdit()->setReadOnly(m_history);
|
||||
m_mainUi->urlEdit->setReadOnly(m_history);
|
||||
m_mainUi->passwordEdit->setReadOnly(m_history);
|
||||
m_mainUi->tagsList->tags(entry->tagList());
|
||||
m_mainUi->tagsList->completion(m_db->tagList());
|
||||
m_mainUi->tagsList->setTags(entry->tagList());
|
||||
m_mainUi->tagsList->setCompletion(m_db->tagList());
|
||||
m_mainUi->expireCheck->setEnabled(!m_history);
|
||||
m_mainUi->expireDatePicker->setReadOnly(m_history);
|
||||
m_mainUi->revealNotesButton->setIcon(icons()->onOffIcon("password-show", false));
|
||||
|
@ -143,13 +143,25 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="TagsEdit" name="tagsList" native="true">
|
||||
<widget class="TagsEdit" name="tagsList">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Tags list</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
@ -345,7 +357,7 @@
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>TagsEdit</class>
|
||||
<extends>QWidget</extends>
|
||||
<extends>QScrollArea</extends>
|
||||
<header>gui/tag/TagsEdit.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,12 +25,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractScrollArea>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
class QCompleter;
|
||||
|
||||
/// Tag multi-line editor widget
|
||||
/// `Space` commits a tag and initiates a new tag edition
|
||||
class TagsEdit : public QAbstractScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -39,27 +37,20 @@ public:
|
||||
explicit TagsEdit(QWidget* parent = nullptr);
|
||||
~TagsEdit() override;
|
||||
|
||||
// QWidget
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
int heightForWidth(int w) const override;
|
||||
|
||||
/// Set completions
|
||||
void completion(QStringList const& completions);
|
||||
|
||||
/// Set tags
|
||||
void tags(QStringList const& tags);
|
||||
|
||||
/// Get tags
|
||||
QStringList tags() const;
|
||||
|
||||
void setReadOnly(bool readOnly);
|
||||
void setCompletion(const QStringList& completions);
|
||||
void setTags(const QStringList& tags);
|
||||
|
||||
QStringList tags() const;
|
||||
|
||||
signals:
|
||||
void tagsEdited();
|
||||
|
||||
protected:
|
||||
// QWidget
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void timerEvent(QTimerEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
@ -72,8 +63,16 @@ protected:
|
||||
|
||||
private:
|
||||
bool isAcceptableInput(QKeyEvent const* event) const;
|
||||
void setupCompleter();
|
||||
void setCursorVisible(bool visible);
|
||||
bool cursorVisible() const;
|
||||
void updateCursorBlinking();
|
||||
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
bool m_readOnly;
|
||||
QScopedPointer<Impl> impl;
|
||||
QScopedPointer<QCompleter> completer;
|
||||
|
||||
bool m_readOnly = false;
|
||||
int blink_timer = 0;
|
||||
bool blink_status = true;
|
||||
};
|
||||
|
@ -2421,7 +2421,7 @@ void TestGui::addCannedEntries()
|
||||
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
||||
QTest::keyClicks(titleEdit, "test");
|
||||
auto* editEntryWidgetTagsEdit = editEntryWidget->findChild<TagsEdit*>("tagsList");
|
||||
editEntryWidgetTagsEdit->tags(QStringList() << "testTag");
|
||||
editEntryWidgetTagsEdit->setTags({"testTag"});
|
||||
auto* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user