fix(ui): Fix some bugs for frontend.
Description: 修复设置界面和搜索结果列表的前端bug Log: 修复设置界面和搜索结果列表的前端bug
This commit is contained in:
parent
0f9e4d44a4
commit
c39ee571b0
|
@ -234,6 +234,7 @@ void ContentWidget::refreshSearchList(const QVector<int>& types, const QVector<Q
|
||||||
* @param contents 文件内容
|
* @param contents 文件内容
|
||||||
*/
|
*/
|
||||||
void ContentWidget::appendSearchItem(const int& type, const QString& path, const QString& keyword, QStringList contents) {
|
void ContentWidget::appendSearchItem(const int& type, const QString& path, const QString& keyword, QStringList contents) {
|
||||||
|
m_keyword = keyword;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SearchItem::SearchType::Files: {
|
case SearchItem::SearchType::Files: {
|
||||||
if (!m_fileListView) {
|
if (!m_fileListView) {
|
||||||
|
@ -269,6 +270,7 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, const
|
||||||
m_listLyt->addWidget(m_fileListView);
|
m_listLyt->addWidget(m_fileListView);
|
||||||
m_resultList->setFixedHeight(m_resultList->height() + m_fileListView->height() + titleLabel->height());
|
m_resultList->setFixedHeight(m_resultList->height() + m_fileListView->height() + titleLabel->height());
|
||||||
}
|
}
|
||||||
|
m_fileListView->setKeyword(keyword);
|
||||||
m_fileListView->appendItem(path);
|
m_fileListView->appendItem(path);
|
||||||
m_resultList->setFixedHeight(m_resultList->height() + m_fileListView->rowheight);
|
m_resultList->setFixedHeight(m_resultList->height() + m_fileListView->rowheight);
|
||||||
return;
|
return;
|
||||||
|
@ -308,6 +310,7 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, const
|
||||||
m_listLyt->addWidget(m_dirListView);
|
m_listLyt->addWidget(m_dirListView);
|
||||||
m_resultList->setFixedHeight(m_resultList->height() + m_dirListView->height() + titleLabel->height());
|
m_resultList->setFixedHeight(m_resultList->height() + m_dirListView->height() + titleLabel->height());
|
||||||
}
|
}
|
||||||
|
m_dirListView->setKeyword(keyword);
|
||||||
m_dirListView->appendItem(path);
|
m_dirListView->appendItem(path);
|
||||||
m_resultList->setFixedHeight(m_resultList->height() + m_dirListView->rowheight);
|
m_resultList->setFixedHeight(m_resultList->height() + m_dirListView->rowheight);
|
||||||
return;
|
return;
|
||||||
|
@ -323,7 +326,7 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, const
|
||||||
m_listLyt->addWidget(titleLabel);
|
m_listLyt->addWidget(titleLabel);
|
||||||
m_listLyt->addWidget(m_contentListView);
|
m_listLyt->addWidget(m_contentListView);
|
||||||
connect(m_contentListView, &SearchListView::currentRowChanged, this, [ = ](const int& type, const QString& path) {
|
connect(m_contentListView, &SearchListView::currentRowChanged, this, [ = ](const int& type, const QString& path) {
|
||||||
m_detailView->setContent(m_contentList.at(m_contentListView->currentIndex().row()), keyword);
|
m_detailView->setContent(m_contentList.at(m_contentListView->currentIndex().row()), m_keyword);
|
||||||
m_detailView->setupWidget(type, path);
|
m_detailView->setupWidget(type, path);
|
||||||
m_contentListView->is_current_list = true;
|
m_contentListView->is_current_list = true;
|
||||||
Q_EMIT this->currentItemChanged();
|
Q_EMIT this->currentItemChanged();
|
||||||
|
@ -348,6 +351,7 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, const
|
||||||
m_listLyt->addWidget(m_contentListView);
|
m_listLyt->addWidget(m_contentListView);
|
||||||
m_resultList->setFixedHeight(m_resultList->height() + m_contentListView->height() + titleLabel->height());
|
m_resultList->setFixedHeight(m_resultList->height() + m_contentListView->height() + titleLabel->height());
|
||||||
}
|
}
|
||||||
|
m_contentListView->setKeyword(keyword);
|
||||||
m_contentListView->appendItem(path);
|
m_contentListView->appendItem(path);
|
||||||
m_resultList->setFixedHeight(m_resultList->height() + m_contentListView->rowheight);
|
m_resultList->setFixedHeight(m_resultList->height() + m_contentListView->rowheight);
|
||||||
QString temp;
|
QString temp;
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void initUI();
|
void initUI();
|
||||||
void clearHomepage();
|
void clearHomepage();
|
||||||
|
QString m_keyword;
|
||||||
QStringList m_contentList;
|
QStringList m_contentList;
|
||||||
QWidget * m_homePage = nullptr;
|
QWidget * m_homePage = nullptr;
|
||||||
QVBoxLayout * m_homePageLyt = nullptr;
|
QVBoxLayout * m_homePageLyt = nullptr;
|
||||||
|
|
|
@ -35,7 +35,7 @@ void HighlightItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||||
ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText));
|
ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText));
|
||||||
|
|
||||||
QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4);
|
QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4);
|
||||||
textRect.adjust(0, 0, 0, 0);
|
textRect.adjust(0, -3, 0, 0);
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->translate(textRect.topLeft());
|
painter->translate(textRect.topLeft());
|
||||||
painter->setClipRect(textRect.translated(-textRect.topLeft()));
|
painter->setClipRect(textRect.translated(-textRect.topLeft()));
|
||||||
|
|
|
@ -20,7 +20,8 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const
|
||||||
this->setAutoFillBackground(false);
|
this->setAutoFillBackground(false);
|
||||||
this->setStyleSheet("QWidget{background:transparent;}");
|
this->setStyleSheet("QWidget{background:transparent;}");
|
||||||
m_styleDelegate = new HighlightItemDelegate();
|
m_styleDelegate = new HighlightItemDelegate();
|
||||||
m_styleDelegate->setSearchKeyword(keyword);
|
// m_styleDelegate->setSearchKeyword(keyword);
|
||||||
|
setKeyword(keyword);
|
||||||
this->setItemDelegate(m_styleDelegate);
|
this->setItemDelegate(m_styleDelegate);
|
||||||
|
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
@ -64,6 +65,15 @@ void SearchListView::clear()
|
||||||
this->isHidden = true;
|
this->isHidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SearchListView::setKeyword 设置关键词
|
||||||
|
* @param keyword 关键词
|
||||||
|
*/
|
||||||
|
void SearchListView::setKeyword(QString keyword)
|
||||||
|
{
|
||||||
|
m_styleDelegate->setSearchKeyword(keyword);
|
||||||
|
}
|
||||||
|
|
||||||
//获取当前选项所属搜索类型
|
//获取当前选项所属搜索类型
|
||||||
int SearchListView::getCurrentType() {
|
int SearchListView::getCurrentType() {
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
void appendItem(QString);
|
void appendItem(QString);
|
||||||
void removeItem(QString);
|
void removeItem(QString);
|
||||||
void clear();
|
void clear();
|
||||||
|
void setKeyword(QString);
|
||||||
bool isHidden = false;
|
bool isHidden = false;
|
||||||
private:
|
private:
|
||||||
SearchItemModel * m_model = nullptr;
|
SearchItemModel * m_model = nullptr;
|
||||||
|
|
|
@ -111,6 +111,10 @@ void UkuiSearchBarHLayout::clearText() {
|
||||||
m_queryLineEdit->setText("");
|
m_queryLineEdit->setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString UkuiSearchBarHLayout::text() {
|
||||||
|
return m_queryLineEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UKuiSearchLineEdit 全局搜索的输入框
|
* @brief UKuiSearchLineEdit 全局搜索的输入框
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
~UkuiSearchBarHLayout();
|
~UkuiSearchBarHLayout();
|
||||||
void searchContent(QString searchcontent);
|
void searchContent(QString searchcontent);
|
||||||
void clearText();
|
void clearText();
|
||||||
|
QString text();
|
||||||
private:
|
private:
|
||||||
void initUI();
|
void initUI();
|
||||||
bool m_isEmpty = true;
|
bool m_isEmpty = true;
|
||||||
|
|
|
@ -91,13 +91,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
m_search_result_thread = new SearchResult(this);
|
m_search_result_thread = new SearchResult(this);
|
||||||
// m_search_result_thread->start();
|
// m_search_result_thread->start();
|
||||||
connect(m_search_result_thread, &SearchResult::searchResultFile, this, [ = ](QString path) {
|
connect(m_search_result_thread, &SearchResult::searchResultFile, this, [ = ](QString path) {
|
||||||
m_contentFrame->appendSearchItem(SearchItem::SearchType::Files, path, m_keyword);
|
m_contentFrame->appendSearchItem(SearchItem::SearchType::Files, path, m_searchLayout->text());
|
||||||
});
|
});
|
||||||
connect(m_search_result_thread, &SearchResult::searchResultDir, this, [ = ](QString path) {
|
connect(m_search_result_thread, &SearchResult::searchResultDir, this, [ = ](QString path) {
|
||||||
m_contentFrame->appendSearchItem(SearchItem::SearchType::Dirs, path, m_keyword);
|
m_contentFrame->appendSearchItem(SearchItem::SearchType::Dirs, path, m_searchLayout->text());
|
||||||
});
|
});
|
||||||
connect(m_search_result_thread, &SearchResult::searchResultContent, this, [ = ](QPair<QString, QStringList> pair) {
|
connect(m_search_result_thread, &SearchResult::searchResultContent, this, [ = ](QPair<QString, QStringList> pair) {
|
||||||
m_contentFrame->appendSearchItem(SearchItem::SearchType::Contents, pair.first, m_keyword, pair.second);
|
m_contentFrame->appendSearchItem(SearchItem::SearchType::Contents, pair.first, m_searchLayout->text(), pair.second);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +161,8 @@ void MainWindow::initUi()
|
||||||
m_settingsWidget->show();
|
m_settingsWidget->show();
|
||||||
connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() {
|
connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() {
|
||||||
QTimer::singleShot(100, this, [ = ] {
|
QTimer::singleShot(100, this, [ = ] {
|
||||||
|
clearSearchResult();
|
||||||
|
m_search_result_thread->start();
|
||||||
this->setWindowState(this->windowState() & ~Qt::WindowMinimized);
|
this->setWindowState(this->windowState() & ~Qt::WindowMinimized);
|
||||||
this->raise();
|
this->raise();
|
||||||
this->showNormal();
|
this->showNormal();
|
||||||
|
@ -252,7 +254,6 @@ void MainWindow::primaryScreenChangedSlot(QScreen *screen)
|
||||||
* @param searchcontent
|
* @param searchcontent
|
||||||
*/
|
*/
|
||||||
void MainWindow::searchContent(QString searchcontent){
|
void MainWindow::searchContent(QString searchcontent){
|
||||||
m_keyword = searchcontent;
|
|
||||||
m_lists.clear();
|
m_lists.clear();
|
||||||
m_types.clear();
|
m_types.clear();
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,6 @@ private:
|
||||||
QQueue<QString> *m_search_result_dir = nullptr;
|
QQueue<QString> *m_search_result_dir = nullptr;
|
||||||
QQueue<QPair<QString,QStringList>> *m_search_result_content = nullptr;
|
QQueue<QPair<QString,QStringList>> *m_search_result_content = nullptr;
|
||||||
SearchResult * m_search_result_thread = nullptr;
|
SearchResult * m_search_result_thread = nullptr;
|
||||||
QString m_keyword = 0;
|
|
||||||
|
|
||||||
FileSearcher* m_searcher = nullptr;
|
FileSearcher* m_searcher = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,8 @@ void SettingsWidget::setIndexNum(int num) {
|
||||||
* @brief SettingsWidget::onBtnConfirmClicked 点击确认按钮的槽函数
|
* @brief SettingsWidget::onBtnConfirmClicked 点击确认按钮的槽函数
|
||||||
*/
|
*/
|
||||||
void SettingsWidget::onBtnConfirmClicked() {
|
void SettingsWidget::onBtnConfirmClicked() {
|
||||||
|
Q_EMIT this->settingWidgetClosed();
|
||||||
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue