Merge pull request #261 from iaom/0531-dev-main

Make a slight adjustment to the UI.
This commit is contained in:
张佳萍 2021-06-05 14:11:06 +08:00 committed by GitHub
commit 5cbb5008c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 8 deletions

View File

@ -52,6 +52,7 @@ ContentWidget::~ContentWidget() {
* @brief initUI homepage和resultpage * @brief initUI homepage和resultpage
*/ */
void ContentWidget::initUI() { void ContentWidget::initUI() {
this->setFixedHeight(486);
QPalette pal = palette(); QPalette pal = palette();
pal.setColor(QPalette::Base, QColor(0, 0, 0, 0)); pal.setColor(QPalette::Base, QColor(0, 0, 0, 0));
pal.setColor(QPalette::Window, QColor(0, 0, 0, 0)); //使用此palette的窗口背景将为透明 pal.setColor(QPalette::Window, QColor(0, 0, 0, 0)); //使用此palette的窗口背景将为透明
@ -71,7 +72,7 @@ void ContentWidget::initUI() {
m_resultDetailArea = new QScrollArea(m_resultPage); m_resultDetailArea = new QScrollArea(m_resultPage);
m_resultDetailArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_resultDetailArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_resultDetailArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); m_resultDetailArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_resultListArea->setFixedWidth(244); m_resultListArea->setFixedWidth(280);
m_resultPageLyt->addWidget(m_resultListArea); m_resultPageLyt->addWidget(m_resultListArea);
m_resultPageLyt->addWidget(m_resultDetailArea); m_resultPageLyt->addWidget(m_resultDetailArea);
m_resultPage->setLayout(m_resultPageLyt); m_resultPage->setLayout(m_resultPageLyt);
@ -80,7 +81,7 @@ void ContentWidget::initUI() {
m_resultDetail = new QWidget(m_resultDetailArea); m_resultDetail = new QWidget(m_resultDetailArea);
m_listLyt = new QVBoxLayout(m_resultList); m_listLyt = new QVBoxLayout(m_resultList);
m_detailLyt = new QVBoxLayout(m_resultDetail); m_detailLyt = new QVBoxLayout(m_resultDetail);
m_resultList->setFixedWidth(236); m_resultList->setFixedWidth(280);
m_resultList->setFixedHeight(0); m_resultList->setFixedHeight(0);
m_listLyt->setContentsMargins(0, 0, 12, 0); m_listLyt->setContentsMargins(0, 0, 12, 0);
m_listLyt->setSpacing(0); m_listLyt->setSpacing(0);

View File

@ -53,7 +53,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, -5, 0, 0); // textRect.adjust(0, 0, 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()));
@ -174,3 +174,10 @@ void HighlightItemDelegate::setSearchKeyword(const QString &regFindKeyWords) {
m_regFindKeyWords.clear(); m_regFindKeyWords.clear();
m_regFindKeyWords = regFindKeyWords; m_regFindKeyWords = regFindKeyWords;
} }
QSize HighlightItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QSize size = QStyledItemDelegate::sizeHint(option,index);
size.setHeight(size.height() + 10);
return size;
}

View File

@ -30,6 +30,8 @@ class HighlightItemDelegate : public QStyledItemDelegate {
public: public:
explicit HighlightItemDelegate(QObject *parent = nullptr); explicit HighlightItemDelegate(QObject *parent = nullptr);
void setSearchKeyword(const QString &); void setSearchKeyword(const QString &);
protected:
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
private: private:
QString m_regFindKeyWords = 0; QString m_regFindKeyWords = 0;
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override; void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;

View File

@ -487,7 +487,7 @@ void SearchDetailView::initUI() {
//图标和名称、分割线区域 //图标和名称、分割线区域
m_iconLabel = new QLabel(this); m_iconLabel = new QLabel(this);
m_iconLabel->setAlignment(Qt::AlignCenter); m_iconLabel->setAlignment(Qt::AlignCenter);
m_iconLabel->setFixedHeight(120); m_iconLabel->setFixedHeight(128);
m_nameFrame = new QFrame(this); m_nameFrame = new QFrame(this);
m_nameLayout = new QHBoxLayout(m_nameFrame); m_nameLayout = new QHBoxLayout(m_nameFrame);
m_nameLabel = new QLabel(m_nameFrame); m_nameLabel = new QLabel(m_nameFrame);
@ -596,13 +596,13 @@ void SearchDetailView::setIcon(const QString &path, const bool &installed)
icon = QIcon::fromTheme(path); icon = QIcon::fromTheme(path);
} }
} }
m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(128, 128))));
} else if (m_type == SearchListView::ResType::Setting) { } else if (m_type == SearchListView::ResType::Setting) {
QIcon icon = FileUtils::getSettingIcon(path, true); QIcon icon = FileUtils::getSettingIcon(path, true);
m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(128, 128))));
} else { } else {
QIcon icon = FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString()); QIcon icon = FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString());
m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(128, 128))));
} }
} }

View File

@ -174,7 +174,7 @@ MainWindow::~MainWindow() {
* this->setFixedSize(640, 640); * this->setFixedSize(640, 640);
*/ */
void MainWindow::initUi() { void MainWindow::initUi() {
this->setFixedSize(640, 590); this->setFixedSize(680, 590);
m_frame = new QFrame(this); m_frame = new QFrame(this);