Improved functions filter show/hide

This commit is contained in:
Hugo Teso 2017-05-18 14:17:51 +02:00
parent a3adfab8c3
commit 117d547570
3 changed files with 70 additions and 16 deletions

View File

@ -335,7 +335,7 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
// Ctrl-F to show/hide the filter entry
QShortcut *search_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this);
connect(search_shortcut, SIGNAL(activated()), this, SLOT(toggle_visibility()));
connect(search_shortcut, SIGNAL(activated()), this, SLOT(show_filter()));
search_shortcut->setContext(Qt::WidgetWithChildrenShortcut);
// Esc to clear the filter entry
@ -617,21 +617,25 @@ void FunctionsWidget::setScrollMode()
qhelpers::setVerticalScrollMode(ui->functionsTreeView);
}
void FunctionsWidget::toggle_visibility() {
if (ui->filterLineEdit->isVisible()) {
ui->filterLineEdit->setVisible(false);
ui->functionsTreeView->setFocus();
} else {
ui->filterLineEdit->setVisible(true);
ui->filterLineEdit->setFocus();
}
void FunctionsWidget::show_filter() {
ui->filterLineEdit->setVisible(true);
ui->closeFilterButton->setVisible(true);
ui->filterLineEdit->setFocus();
}
void FunctionsWidget::clear_filter() {
if (ui->filterLineEdit->text() == "") {
ui->filterLineEdit->setVisible(false);
ui->closeFilterButton->setVisible(false);
ui->functionsTreeView->setFocus();
} else {
ui->filterLineEdit->setText("");
}
}
void FunctionsWidget::on_closeFilterButton_clicked()
{
ui->filterLineEdit->setVisible(false);
ui->closeFilterButton->setVisible(false);
ui->functionsTreeView->setFocus();
}

View File

@ -103,10 +103,12 @@ private slots:
void on_actionVertical_triggered();
void toggle_visibility();
void show_filter();
void clear_filter();
void on_closeFilterButton_clicked();
protected:
void resizeEvent(QResizeEvent *event) override;

View File

@ -192,14 +192,62 @@ QToolTip {
</widget>
</item>
<item>
<widget class="QLineEdit" name="filterLineEdit">
<property name="placeholderText">
<string>Quick Filter</string>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
<property name="rightMargin">
<number>2</number>
</property>
</widget>
<item>
<widget class="QLineEdit" name="filterLineEdit">
<property name="placeholderText">
<string>Quick Filter</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="closeFilterButton">
<property name="font">
<font>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QToolButton { /* all types of tool button */
border: 2px solid #333;
border-left: 2px solid #333;
border-right: 2px solid #333;
background-color: #333;
color: rgb(255, 255, 255)
}
QToolButton:hover {
border: 2px solid rgb(128, 128, 128);
border-left: 2px solid rgb(128, 128, 128);
border-right: 2px solid rgb(128, 128, 128);
background-color: rgb(128, 128, 128);
color: rgb(255, 255, 255)
}
QToolButton:pressed {
border: 2px solid #2180a9;
border-left: 2px solid #2180a9;
border-right: 2px solid #2180a9;
background-color: #2180a9;
}</string>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>