Update UI.

This commit is contained in:
iaom 2021-07-26 15:08:46 +08:00
parent 323fc1bdab
commit 23fac0cc57
5 changed files with 25 additions and 11 deletions

View File

@ -68,6 +68,7 @@ SearchLineEdit::SearchLineEdit(QWidget *parent) : QLineEdit(parent) {
if(text == "") { if(text == "") {
m_isEmpty = true; m_isEmpty = true;
m_timer->stop(); m_timer->stop();
Q_EMIT this->requestSearchKeyword(text);
return; return;
} }
m_timer->start(0.1 * 1000); m_timer->start(0.1 * 1000);

View File

@ -99,8 +99,6 @@ void ResultArea::initUi()
void ResultArea::setupConnectionsForWidget(ResultWidget *widget) void ResultArea::setupConnectionsForWidget(ResultWidget *widget)
{ {
connect(this, &ResultArea::startSearch, widget, &ResultWidget::startSearch); connect(this, &ResultArea::startSearch, widget, &ResultWidget::startSearch);
connect(this, &ResultArea::startSearch, [=](){
});
connect(this, &ResultArea::stopSearch, widget, &ResultWidget::stopSearch); connect(this, &ResultArea::stopSearch, widget, &ResultWidget::stopSearch);
connect(widget, &ResultWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged); connect(widget, &ResultWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged);

View File

@ -89,7 +89,7 @@ MainWindow::~MainWindow() {
if(m_settingsWidget) { if(m_settingsWidget) {
delete m_settingsWidget; delete m_settingsWidget;
m_settingsWidget = NULL; m_settingsWidget = NULL;
}
#endif #endif
if(m_askDialog) { if(m_askDialog) {
delete m_askDialog; delete m_askDialog;
@ -109,22 +109,25 @@ MainWindow::~MainWindow() {
* @brief initUi ui控件 * @brief initUi ui控件
*/ */
void MainWindow::initUi() { void MainWindow::initUi() {
this->setFixedSize(WINDOW_WIDTH, WINDOW_HEIGHT); this->setFixedSize(WINDOW_WIDTH, 68);
// this->setStyleSheet("QMainWindow{border:2px solid red;}");
m_widget = new QWidget(this); // m_widget = new QWidget(this);
this->setCentralWidget(m_widget); // this->setCentralWidget(m_widget);
m_widget->setFixedSize(this->size()); // m_widget->setFixedSize(this->size());
// QVBoxLayout * mainlayout = new QVBoxLayout(m_frame); // QVBoxLayout * mainlayout = new QVBoxLayout(m_frame);
// mainlayout->setContentsMargins(MAIN_MARGINS); // mainlayout->setContentsMargins(MAIN_MARGINS);
// m_frame->setLayout(mainlayout); // m_frame->setLayout(mainlayout);
// m_stackedWidget = new StackedWidget(m_frame);//内容栏 // m_stackedWidget = new StackedWidget(m_frame);//内容栏
m_searchBarWidget = new SeachBarWidget(m_widget); m_searchBarWidget = new SeachBarWidget(this);
m_searchBarWidget->move(m_widget->rect().topLeft()); m_searchBarWidget->move(this->rect().topLeft());
m_searchBarWidget->show(); m_searchBarWidget->show();
m_searchResultPage = new SearchResultPage(m_widget); m_searchResultPage = new SearchResultPage(this);
m_searchResultPage->hide();
m_searchResultPage->move(0, 58); m_searchResultPage->move(0, 58);
// m_searchResultPage->show();
// m_searchWidget = new SeachBarWidget(this); // m_searchWidget = new SeachBarWidget(this);
// m_searchLayout = new SearchBarHLayout(this); // m_searchLayout = new SearchBarHLayout(this);
// m_searchWidget->setLayout(m_searchLayout); // m_searchWidget->setLayout(m_searchLayout);
@ -290,6 +293,9 @@ void MainWindow::searchKeywordSlot(const QString &keyword)
// m_stackedWidget->setPage(int(StackedPage::HomePage)); // m_stackedWidget->setPage(int(StackedPage::HomePage));
m_askTimer->stop(); m_askTimer->stop();
Q_EMIT m_searchResultPage->stopSearch(); Q_EMIT m_searchResultPage->stopSearch();
m_searchResultPage->hide();
this->resizeHeight(68);
} else { } else {
// m_stackedWidget->setPage(int(StackedPage::SearchPage)); // m_stackedWidget->setPage(int(StackedPage::SearchPage));
QTimer::singleShot(10, this, [ = ]() { QTimer::singleShot(10, this, [ = ]() {
@ -297,11 +303,20 @@ void MainWindow::searchKeywordSlot(const QString &keyword)
if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH) if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH)
m_askTimer->start(); m_askTimer->start();
Q_EMIT m_searchResultPage->startSearch(keyword); Q_EMIT m_searchResultPage->startSearch(keyword);
this->resizeHeight(610);
m_searchResultPage->move(0, 58);
m_searchResultPage->show();
}); });
} }
m_researchTimer->stop(); //如果搜索内容发生改变,则停止建索引后重新搜索的倒计时 m_researchTimer->stop(); //如果搜索内容发生改变,则停止建索引后重新搜索的倒计时
} }
void MainWindow::resizeHeight(int height)
{
this->setFixedHeight(height);
}
/** /**
* @brief monitorResolutionChange * @brief monitorResolutionChange
* @param rect * @param rect

View File

@ -105,6 +105,7 @@ public Q_SLOTS:
void trayIconActivatedSlot(QSystemTrayIcon::ActivationReason reason); void trayIconActivatedSlot(QSystemTrayIcon::ActivationReason reason);
void settingsBtnClickedSlot(); void settingsBtnClickedSlot();
void searchKeywordSlot(const QString&); void searchKeywordSlot(const QString&);
void resizeHeight(int height);
private: private:

View File

@ -80,7 +80,6 @@ void ResultWidget::initConnections()
{ {
connect(this, &ResultWidget::startSearch, m_resultView, &ResultView::startSearch); connect(this, &ResultWidget::startSearch, m_resultView, &ResultView::startSearch);
connect(this, &ResultWidget::startSearch, this, [ = ]() { connect(this, &ResultWidget::startSearch, this, [ = ]() {
qDebug() << "==========start search!";
m_showMoreLabel->resetLabel(); m_showMoreLabel->resetLabel();
}); });
connect(this, &ResultWidget::stopSearch, m_resultView, &ResultView::stopSearch); connect(this, &ResultWidget::stopSearch, m_resultView, &ResultView::stopSearch);