diff --git a/include/ui/mainwindow.h b/include/ui/mainwindow.h index a180043..9e6b281 100644 --- a/include/ui/mainwindow.h +++ b/include/ui/mainwindow.h @@ -213,8 +213,11 @@ private: QMutex mu_remoteRouteProfiles; // search + bool searchEnabled = false; QString searchString; + void setSearchState(bool enable); + QList> filterProfilesList(const QList& profiles); QList> get_now_selected_list(); diff --git a/include/ui/mainwindow.ui b/include/ui/mainwindow.ui index d08b87f..b64930a 100644 --- a/include/ui/mainwindow.ui +++ b/include/ui/mainwindow.ui @@ -20,7 +20,7 @@ nya - + @@ -204,18 +204,11 @@ + + + - - - - Search Filter... - - - true - - - diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 3475d62..0717fb0 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -326,8 +326,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi ui->proxyListTable->setTabKeyNavigation(false); // search box + setSearchState(false); connect(shortcut_ctrl_f, &QShortcut::activated, this, [=, this] { + setSearchState(true); ui->search_input->setFocus(); }); connect(ui->search_input, &QLineEdit::textChanged, this, [=,this](const QString& currentText) @@ -341,7 +343,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi select_mode = false; refresh_status(); } - if (ui->search_input->hasFocus()) ui->search_input->clear(); + if (searchEnabled) setSearchState(false); }); // refresh @@ -1314,6 +1316,31 @@ void MainWindow::UpdateConnectionListWithRecreate(const QListconnections->setUpdatesEnabled(true); } +void MainWindow::setSearchState(bool enable) +{ + searchEnabled = enable; + if (enable) + { + ui->data_view->hide(); + ui->search_input->show(); + adjustSize(); + } else + { + ui->search_input->blockSignals(true); + ui->search_input->clear(); + ui->search_input->blockSignals(false); + + ui->search_input->hide(); + ui->data_view->show(); + adjustSize(); + if (!searchString.isEmpty()) + { + searchString.clear(); + refresh_proxy_list(-1); + } + } +} + QList> MainWindow::filterProfilesList(const QList& profiles) { QList> res;