Merge branch '0615-dev' into 'dev-unity'

Feat:#6732 #6733 #6734

See merge request kylin-desktop/ukui-search!32
This commit is contained in:
PengfeiZhang 2021-06-17 02:29:09 +00:00
commit 660e81ccc0
5 changed files with 36 additions and 26 deletions

View File

@ -60,8 +60,10 @@ ContentWidget::~ContentWidget() {
void ContentWidget::initUI() {
this->setFixedHeight(486);
QPalette pal = palette();
pal.setColor(QPalette::Base, QColor(0, 0, 0, 0));
QPalette scroll_bar_pal = palette();
// pal.setColor(QPalette::Base, QColor(0, 0, 0, 0));
pal.setColor(QPalette::Window, QColor(0, 0, 0, 0)); //使用此palette的窗口背景将为透明
scroll_bar_pal.setColor(QPalette::Base, QColor(0, 0, 0, 0));
m_homePage = new QWidget(this);
m_homePageLyt = new QVBoxLayout(m_homePage);
m_homePageLyt->setSpacing(0);
@ -106,6 +108,8 @@ void ContentWidget::initUI() {
m_resultDetailArea->setFrameShape(QFrame::NoFrame);
m_resultListArea->setPalette(pal);
m_resultDetailArea->setPalette(pal);
m_resultListArea->verticalScrollBar()->setPalette(scroll_bar_pal);
m_resultDetailArea->verticalScrollBar()->setPalette(scroll_bar_pal);
this->addWidget(m_homePage);
this->addWidget(m_resultPage);
@ -387,7 +391,7 @@ void ContentWidget::initHomePage() {
itemWidget->setLayout(layout);
for(int j = 0; j < lists.at(i).count(); j++) {
HomePageItem * item = new HomePageItem(itemWidget, i, lists.at(i).at(j));
item->setFixedSize(300, 48);
item->setFixedSize(312, 48);
layout->addWidget(item, j / 2, j % 2);
}
if(lists.at(i).length() == 1) {
@ -421,6 +425,7 @@ void ContentWidget::initHomePage() {
}
itemWidgetLyt->setSpacing(6);
titleLabel->setFixedHeight(24);
titleLabel->setContentsMargins(6,0,0,0);
itemWidgetLyt->addWidget(titleLabel);
itemWidgetLyt->addWidget(itemWidget);
m_homePageLyt->addWidget(listWidget);

View File

@ -25,6 +25,7 @@
#include <QStackedWidget>
#include <QScrollArea>
#include <QGridLayout>
#include <QScrollBar>
#include "control/search-detail-view.h"
#include "home-page-item.h"
#include "show-more-label.h"

View File

@ -313,25 +313,26 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
m_pathLabel_1->show();
m_pathLabel_2->show();
// m_pathLabel_2->setText(path);
QString showPath = path;
QFontMetrics fontMetrics = m_pathLabel_2->fontMetrics();
if(fontMetrics.width(path) > m_pathLabel_2->width() - 10) {
//路径长度超过230,手动添加换行符以实现折叠
int lastIndex = 0;
for(int i = lastIndex; i < path.length(); i++) {
if(fontMetrics.width(path.mid(lastIndex, i - lastIndex)) == m_pathLabel_2->width() - 10) {
lastIndex = i;
showPath.insert(i, '\n');
} else if(fontMetrics.width(path.mid(lastIndex, i - lastIndex)) > m_pathLabel_2->width() - 10) {
lastIndex = i;
showPath.insert(i - 1, '\n');
} else {
continue;
}
}
}
m_pathLabel_2->setText(showPath);
// QString showPath = path;
// QFontMetrics fontMetrics = m_pathLabel_2->fontMetrics();
// if(fontMetrics.width(path) > m_pathLabel_2->width() - 10) {
// //路径长度超过230,手动添加换行符以实现折叠
// int lastIndex = 0;
// for(int i = lastIndex; i < path.length(); i++) {
// if(fontMetrics.width(path.mid(lastIndex, i - lastIndex)) == m_pathLabel_2->width() - 10) {
// lastIndex = i;
// showPath.insert(i, '\n');
// } else if(fontMetrics.width(path.mid(lastIndex, i - lastIndex)) > m_pathLabel_2->width() - 10) {
// lastIndex = i;
// showPath.insert(i - 1, '\n');
// } else {
// continue;
// }
// }
// }
// m_pathLabel_2->setText(showPath);
m_pathLabel_2->setText(m_pathLabel_2->fontMetrics().elidedText(path, Qt::ElideRight, m_pathLabel_2->width()));
m_pathLabel_2->setToolTip(path);
m_timeLabel_1->show();
m_timeLabel_2->show();
QFileInfo fileInfo(path);
@ -465,7 +466,7 @@ void SearchDetailView::initUI() {
m_layout = new QVBoxLayout(this);
this->setLayout(m_layout);
m_layout->setContentsMargins(16, 60, 16, 24);
this->setFixedWidth(378);
this->setFixedWidth(368);
//没有网络的时候的提示信息
m_noNetFrame = new QFrame(this);
@ -526,12 +527,14 @@ void SearchDetailView::initUI() {
m_pathLabel_2 = new QLabel(m_pathFrame);
m_pathLabel_1->setText(tr("Path"));
m_pathLabel_2->setFixedWidth(240);
m_pathLabel_2->setAlignment(Qt::AlignRight);
// m_pathLabel_2->setWordWrap(true);
m_pathLyt->addWidget(m_pathLabel_1);
m_pathLyt->addStretch();
m_pathLyt->addWidget(m_pathLabel_2);
m_timeLabel_1 = new QLabel(m_timeFrame);
m_timeLabel_2 = new QLabel(m_timeFrame);
m_timeLabel_2->setAlignment(Qt::AlignRight);
m_timeLabel_1->setText(tr("Last time modified"));
m_timeLyt->addWidget(m_timeLabel_1);
m_timeLyt->addStretch();

View File

@ -89,7 +89,7 @@ SearchBarHLayout::~SearchBarHLayout() {
* @brief ui
*/
void SearchBarHLayout::initUI() {
m_queryLineEdit = new SearchLineEdit();
m_queryLineEdit = new SearchLineEdit(this->parentWidget());
m_queryLineEdit->installEventFilter(this);
m_queryLineEdit->setTextMargins(30, 1, 0, 1);
this->setContentsMargins(0, 0, 0, 0);
@ -150,7 +150,8 @@ void SearchBarHLayout::effectiveSearchRecord() {
}
void SearchBarHLayout::focusIn() {
m_queryLineEdit->setFocus();
if (!m_queryLineEdit->hasFocus())
m_queryLineEdit->setFocus(Qt::MouseFocusReason);
}
void SearchBarHLayout::focusOut() {
@ -203,7 +204,7 @@ bool SearchBarHLayout::eventFilter(QObject *watched, QEvent *event) {
/**
* @brief UKuiSearchLineEdit
*/
SearchLineEdit::SearchLineEdit() {
SearchLineEdit::SearchLineEdit(QWidget *parent) : QLineEdit(parent) {
this->setFocusPolicy(Qt::ClickFocus);
this->installEventFilter(this);
// this->setContextMenuPolicy(Qt::NoContextMenu);

View File

@ -100,7 +100,7 @@ class SearchLineEdit : public QLineEdit {
   */
Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox")
public:
SearchLineEdit();
SearchLineEdit(QWidget *parent = nullptr);
void record();
~SearchLineEdit();