Added clear text button, accurate down arrow behavior, and fixed sizing

This commit is contained in:
Jonathan White 2017-01-14 20:27:34 -05:00
parent fd3fefd6f1
commit 01464a7860
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
2 changed files with 41 additions and 27 deletions

View file

@ -66,18 +66,24 @@ bool SearchWidget::eventFilter(QObject *obj, QEvent *event)
return true; return true;
} }
else if (keyEvent->matches(QKeySequence::Copy)) { else if (keyEvent->matches(QKeySequence::Copy)) {
// If Control+C is pressed in the search edit when no // If Control+C is pressed in the search edit when no text
// text is selected, copy the password of the current // is selected, copy the password of the current entry
// entry.
if (!m_ui->searchEdit->hasSelectedText()) { if (!m_ui->searchEdit->hasSelectedText()) {
emit copyPressed(); emit copyPressed();
return true; return true;
} }
} }
else if (keyEvent->matches(QKeySequence::MoveToNextLine)) { else if (keyEvent->matches(QKeySequence::MoveToNextLine)) {
// If Down is pressed move the focus to the entry view. if (m_ui->searchEdit->cursorPosition() == m_ui->searchEdit->text().length()) {
emit downPressed(); // If down is pressed at EOL, move the focus to the entry view
return true; emit downPressed();
return true;
}
else {
// Otherwise move the cursor to EOL
m_ui->searchEdit->setCursorPosition(m_ui->searchEdit->text().length());
return true;
}
} }
} }

View file

@ -10,40 +10,48 @@
<height>34</height> <height>34</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>3</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>6</number> <number>7</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <widget class="QToolButton" name="searchIcon">
<item> <property name="focusPolicy">
<widget class="QToolButton" name="searchIcon"> <enum>Qt::ClickFocus</enum>
<property name="focusPolicy"> </property>
<enum>Qt::ClickFocus</enum> <property name="toolButtonStyle">
</property> <enum>Qt::ToolButtonIconOnly</enum>
<property name="toolButtonStyle"> </property>
<enum>Qt::ToolButtonIconOnly</enum> <property name="autoRaise">
</property> <bool>true</bool>
<property name="autoRaise"> </property>
<bool>true</bool> </widget>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="0" column="1"> <item>
<widget class="QLineEdit" name="searchEdit"> <widget class="QLineEdit" name="searchEdit">
<property name="styleSheet">
<string notr="true">padding:3px</string>
</property>
<property name="placeholderText"> <property name="placeholderText">
<string>Find:</string> <string>Find</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>