fix(frontend): Fix ui bugs for detail widget.

Description: 修复详情页显示不全和不换行的Bug

Log: 修复详情页显示不全和不换行的Bug
Bug: http://172.17.66.192/biz/bug-view-33617.html
This commit is contained in:
zhangjiaping 2021-01-14 15:19:25 +08:00
parent c62fff805b
commit 22e1331c99
6 changed files with 59 additions and 17 deletions

View File

@ -111,11 +111,12 @@ QIcon FileUtils::getSettingIcon(const QString& setting, const bool& is_white) {
if (file.exists()) { if (file.exists()) {
return QIcon(path); return QIcon(path);
} else { } else {
if (is_white) { return QIcon::fromTheme("ukui-control-center"); //无插件图标时,返回控制面板应用图标
return QIcon(QString("/usr/share/ukui-control-center/shell/res/secondaryleftmenu/%1White.svg").arg("About")); // if (is_white) {
} else { // return QIcon(QString("/usr/share/ukui-control-center/shell/res/secondaryleftmenu/%1White.svg").arg("About"));
return QIcon(QString("/usr/share/ukui-control-center/shell/res/secondaryleftmenu/%1.svg").arg("About")); // } else {
} // return QIcon(QString("/usr/share/ukui-control-center/shell/res/secondaryleftmenu/%1.svg").arg("About"));
// }
} }
} }

View File

@ -364,8 +364,11 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, const
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;
for (auto s : contents){ for (int i = 0; i < contents.length(); i ++) {
temp.append(s); temp.append(contents.at(i));
if (i != contents.length() - 1) {
temp.append("\n");
}
} }
m_contentList.append(temp); m_contentList.append(temp);
return; return;

View File

@ -22,6 +22,7 @@ SearchDetailView::SearchDetailView(QWidget *parent) : QWidget(parent)
m_layout->setContentsMargins(16, 60, 16, 24); m_layout->setContentsMargins(16, 60, 16, 24);
this->setObjectName("detailView"); this->setObjectName("detailView");
this->setStyleSheet("QWidget#detailView{background:transparent;}"); this->setStyleSheet("QWidget#detailView{background:transparent;}");
this->setFixedWidth(360);
} }
SearchDetailView::~SearchDetailView() SearchDetailView::~SearchDetailView()
@ -136,8 +137,8 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
QLabel * pathLabel_1 = new QLabel(pathFrame); QLabel * pathLabel_1 = new QLabel(pathFrame);
QLabel * pathLabel_2 = new QLabel(pathFrame); QLabel * pathLabel_2 = new QLabel(pathFrame);
pathLabel_1->setText(tr("Path")); pathLabel_1->setText(tr("Path"));
pathLabel_2->setFixedWidth(240);
pathLabel_2->setText(path); pathLabel_2->setText(path);
pathLabel_2->setMaximumWidth(500);
pathLabel_2->setWordWrap(true); pathLabel_2->setWordWrap(true);
pathLyt->addWidget(pathLabel_1); pathLyt->addWidget(pathLabel_1);
pathLyt->addStretch(); pathLyt->addStretch();
@ -176,7 +177,9 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
case SearchListView::ResType::App : { case SearchListView::ResType::App : {
QIcon icon = FileUtils::getAppIcon(path); QIcon icon = FileUtils::getAppIcon(path);
iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96))));
nameLabel->setText(FileUtils::getAppName(path)); QFontMetrics fontMetrics = nameLabel->fontMetrics();
QString name = fontMetrics.elidedText(FileUtils::getAppName(path), Qt::ElideRight, 215); //当字体长度超过215时显示为省略号
nameLabel->setText(name);
typeLabel->setText(tr("Application")); typeLabel->setText(tr("Application"));
break; break;
} }
@ -185,7 +188,9 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
case SearchListView::ResType::File : { case SearchListView::ResType::File : {
QIcon icon = FileUtils::getFileIcon(QString("file://%1").arg(path)); QIcon icon = FileUtils::getFileIcon(QString("file://%1").arg(path));
iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96))));
nameLabel->setText(FileUtils::getFileName(path)); QFontMetrics fontMetrics = nameLabel->fontMetrics();
QString name = fontMetrics.elidedText(FileUtils::getFileName(path), Qt::ElideRight, 215);
nameLabel->setText(name);
typeLabel->setText(tr("Document")); typeLabel->setText(tr("Document"));
break; break;
} }

View File

@ -163,12 +163,7 @@ void MainWindow::initUi()
"QPushButton:hover:!pressed{background: transparent;}"); "QPushButton:hover:!pressed{background: transparent;}");
connect(m_menuBtn, &QPushButton::clicked, this, [ = ]() { connect(m_menuBtn, &QPushButton::clicked, this, [ = ]() {
if (m_settingsWidget) { //当此窗口已存在时,仅需置顶 if (m_settingsWidget) { //当此窗口已存在时,仅需置顶
Qt::WindowFlags flags = m_settingsWidget->windowFlags(); m_settingsWidget->showWidget();
flags |= Qt::WindowStaysOnTopHint;
m_settingsWidget->setWindowFlags(flags);
flags &= ~Qt::WindowStaysOnTopHint;
m_settingsWidget->setWindowFlags(flags);
m_settingsWidget->show();
return; return;
} }
m_settingsWidget = new SettingsWidget(); m_settingsWidget = new SettingsWidget();

View File

@ -6,6 +6,7 @@
#include <QDebug> #include <QDebug>
#include "folder-list-item.h" #include "folder-list-item.h"
#include "global-settings.h" #include "global-settings.h"
#include "file-utils.h"
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent) SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent)
@ -13,12 +14,12 @@ SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent)
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground); this->setAttribute(Qt::WA_TranslucentBackground);
initUi(); initUi();
refreshIndexState();
setupBlackList(GlobalSettings::getInstance()->getBlockDirs()); setupBlackList(GlobalSettings::getInstance()->getBlockDirs());
} }
SettingsWidget::~SettingsWidget() SettingsWidget::~SettingsWidget()
{ {
} }
/** /**
@ -50,6 +51,7 @@ void SettingsWidget::initUi() {
"QPushButton:hover:!pressed{background: transparent;}"); "QPushButton:hover:!pressed{background: transparent;}");
connect(m_closeBtn, &QPushButton::clicked, this, [ = ]() { connect(m_closeBtn, &QPushButton::clicked, this, [ = ]() {
Q_EMIT this->settingWidgetClosed(); Q_EMIT this->settingWidgetClosed();
m_timer->stop();
this->close(); this->close();
}); });
m_titleLyt->addWidget(m_titleIcon); m_titleLyt->addWidget(m_titleIcon);
@ -202,6 +204,21 @@ void SettingsWidget::clearLayout(QLayout * layout) {
child = NULL; child = NULL;
} }
/**
* @brief SettingsWidget::refreshIndexState
*/
void SettingsWidget::refreshIndexState()
{
m_indexStateLabel->setText(QString::number(FileUtils::_index_status));
m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileUtils::_current_index_count)).arg(QString::number(FileUtils::_max_index_count)));
m_timer = new QTimer;
connect(m_timer, &QTimer::timeout, this, [ = ]() {
m_indexStateLabel->setText(QString::number(FileUtils::_index_status));
m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileUtils::_current_index_count)).arg(QString::number(FileUtils::_max_index_count)));
});
m_timer->start(0.5 * 1000);
}
/** /**
* @brief SettingsWidget::onBtnDelClicked * @brief SettingsWidget::onBtnDelClicked
* @param path * @param path
@ -244,11 +261,26 @@ void SettingsWidget::setIndexNum(int num) {
m_indexNumLabel->setText(QString(tr("Index Entry: %1")).arg(QString::number(num))); m_indexNumLabel->setText(QString(tr("Index Entry: %1")).arg(QString::number(num)));
} }
/**
* @brief SettingsWidget::showWidget
*/
void SettingsWidget::showWidget()
{
Qt::WindowFlags flags = this->windowFlags();
flags |= Qt::WindowStaysOnTopHint;
this->setWindowFlags(flags);
flags &= ~Qt::WindowStaysOnTopHint;
this->setWindowFlags(flags);
m_timer->start();
this->show();
}
/** /**
* @brief SettingsWidget::onBtnConfirmClicked * @brief SettingsWidget::onBtnConfirmClicked
*/ */
void SettingsWidget::onBtnConfirmClicked() { void SettingsWidget::onBtnConfirmClicked() {
Q_EMIT this->settingWidgetClosed(); Q_EMIT this->settingWidgetClosed();
m_timer->stop();
this->close(); this->close();
} }
@ -257,6 +289,7 @@ void SettingsWidget::onBtnConfirmClicked() {
*/ */
void SettingsWidget::onBtnCancelClicked() { void SettingsWidget::onBtnCancelClicked() {
Q_EMIT this->settingWidgetClosed(); Q_EMIT this->settingWidgetClosed();
m_timer->stop();
this->close(); this->close();
} }

View File

@ -10,6 +10,7 @@
#include <QButtonGroup> #include <QButtonGroup>
#include <QPushButton> #include <QPushButton>
#include <QScrollArea> #include <QScrollArea>
#include <QTimer>
class SettingsWidget : public QWidget class SettingsWidget : public QWidget
{ {
@ -20,11 +21,13 @@ public:
void setIndexState(bool); void setIndexState(bool);
void setIndexNum(int); void setIndexNum(int);
void showWidget();
private: private:
void initUi(); void initUi();
void setupBlackList(const QStringList &); void setupBlackList(const QStringList &);
void clearLayout(QLayout *); void clearLayout(QLayout *);
void refreshIndexState();
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
//标题栏 //标题栏
QVBoxLayout * m_mainLyt = nullptr; QVBoxLayout * m_mainLyt = nullptr;
@ -69,6 +72,8 @@ private:
QPushButton * m_cancelBtn = nullptr; QPushButton * m_cancelBtn = nullptr;
QPushButton * m_confirmBtn = nullptr; QPushButton * m_confirmBtn = nullptr;
QTimer * m_timer;
Q_SIGNALS: Q_SIGNALS:
void settingWidgetClosed(); void settingWidgetClosed();