Add button to clear search field.

This commit is contained in:
Florian Geyer 2012-05-16 09:56:18 +02:00
parent 00ae8aabf1
commit ea6f2477ef
2 changed files with 26 additions and 7 deletions

View File

@ -54,22 +54,31 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
policy.setHorizontalStretch(30);
m_groupView->setSizePolicy(policy);
QWidget* widget = new QWidget();
policy = widget->sizePolicy();
QWidget* rightHandSideWidget = new QWidget();
policy = rightHandSideWidget->sizePolicy();
policy.setHorizontalStretch(70);
widget->setSizePolicy(policy);
splitter->addWidget(m_groupView);
rightHandSideWidget->setSizePolicy(policy);
QVBoxLayout* vLayout = new QVBoxLayout();
QHBoxLayout* hLayout = new QHBoxLayout();
hLayout->addWidget(new QLabel("Find:"));
m_searchEdit = new QLineEdit();
m_searchEdit->setObjectName("searchEdit");
hLayout->addWidget(m_searchEdit);
m_clearSearchButton = new QPushButton("Clear");
m_clearSearchButton->setObjectName("clearSearchButton");
hLayout->addWidget(m_clearSearchButton);
vLayout->addLayout(hLayout);
vLayout->addWidget(m_entryView);
widget->setLayout(vLayout);
splitter->addWidget(widget);
rightHandSideWidget->setLayout(vLayout);
splitter->addWidget(m_groupView);
splitter->addWidget(rightHandSideWidget);
layout->addWidget(splitter);
m_mainWidget->setLayout(layout);
@ -100,6 +109,7 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
connect(m_databaseSettingsWidget, SIGNAL(editFinished(bool)), SLOT(updateSettings(bool)));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(emitCurrentModeChanged()));
connect(m_searchEdit, SIGNAL(returnPressed()), this, SLOT(search()));
connect(m_clearSearchButton, SIGNAL(clicked()), this, SLOT(clearSearchEdit()));
setCurrentIndex(0);
}
@ -374,3 +384,9 @@ void DatabaseWidget::clearLastGroup(Group* group)
m_lastGroup = 0;
}
}
void DatabaseWidget::clearSearchEdit()
{
m_searchEdit->clear();
m_searchEdit->setFocus();
}

View File

@ -18,6 +18,7 @@
#ifndef KEEPASSX_DATABASEWIDGET_H
#define KEEPASSX_DATABASEWIDGET_H
#include <QtGui/QPushButton>
#include <QtGui/QStackedWidget>
class QLineEdit;
@ -78,6 +79,7 @@ private Q_SLOTS:
void updateSettings(bool accepted);
void emitCurrentModeChanged();
void clearLastGroup(Group* group);
void clearSearchEdit();
private:
void truncateHistories();
@ -94,6 +96,7 @@ private:
Entry* m_newEntry;
Group* m_newParent;
QLineEdit* m_searchEdit;
QPushButton* m_clearSearchButton;
Group* m_lastGroup;
};