feat(frontend):适配主题的控件圆角配置
This commit is contained in:
parent
4a3b58abe9
commit
760ddecec1
|
@ -21,6 +21,7 @@
|
|||
#include "title-label.h"
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
#include <QApplication>
|
||||
#define UNFOLD_LABEL_HEIGHT 30
|
||||
#define NUM_LIMIT_SHOWN_DEFAULT 5
|
||||
using namespace UkuiSearch;
|
||||
|
@ -35,7 +36,12 @@ void TitleLabel::setShowMoreLableVisible()
|
|||
m_showMoreLabel->setLabel();
|
||||
}
|
||||
|
||||
void TitleLabel::initUi() {
|
||||
void TitleLabel::initUi()
|
||||
{
|
||||
m_radius = qApp->style()->property("normalRadius").toInt();
|
||||
connect(qApp, &QApplication::paletteChanged, this, [&]() {
|
||||
m_radius = qApp->style()->property("normalRadius").toInt();
|
||||
});
|
||||
this->setContentsMargins(8, 0, 0, 0);
|
||||
this->setFixedHeight(24);
|
||||
m_titleLyt = new QHBoxLayout(this);
|
||||
|
@ -48,13 +54,15 @@ void TitleLabel::initUi() {
|
|||
m_titleLyt->addWidget(m_showMoreLabel);
|
||||
}
|
||||
|
||||
void TitleLabel::initConnections() {
|
||||
void TitleLabel::initConnections()
|
||||
{
|
||||
connect(m_showMoreLabel, &ShowMoreLabel::showMoreClicked, this, &TitleLabel::showMoreClicked);
|
||||
connect(m_showMoreLabel, &ShowMoreLabel::retractClicked, this, &TitleLabel::retractClicked);
|
||||
|
||||
}
|
||||
|
||||
void TitleLabel::paintEvent(QPaintEvent * event) {
|
||||
void TitleLabel::paintEvent(QPaintEvent * event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
QStyleOption opt;
|
||||
|
@ -67,7 +75,7 @@ void TitleLabel::paintEvent(QPaintEvent * event) {
|
|||
p.setBrush(opt.palette.color(QPalette::Text));
|
||||
p.setOpacity(0.04);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(rect, 6, 6);
|
||||
p.drawRoundedRect(rect, m_radius, m_radius);
|
||||
return QLabel::paintEvent(event);
|
||||
}
|
||||
|
||||
|
@ -76,7 +84,7 @@ void TitleLabel::onListLengthChanged(const int &length)
|
|||
m_showMoreLabel->setVisible(length > NUM_LIMIT_SHOWN_DEFAULT);
|
||||
}
|
||||
|
||||
void TitleLabel::lableReset()
|
||||
void TitleLabel::labelReset()
|
||||
{
|
||||
m_showMoreLabel->resetLabel();
|
||||
}
|
||||
|
|
|
@ -43,10 +43,11 @@ private:
|
|||
|
||||
QHBoxLayout * m_titleLyt = nullptr;
|
||||
ShowMoreLabel * m_showMoreLabel = nullptr;
|
||||
int m_radius = 6;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onListLengthChanged(const int &);
|
||||
void lableReset();
|
||||
void labelReset();
|
||||
|
||||
Q_SIGNALS:
|
||||
void startSearch(const QString &);
|
||||
|
|
|
@ -27,7 +27,6 @@ using namespace UkuiSearch;
|
|||
#define RESULT_BACKGROUND_COLOR QColor(0, 0, 0, 0)
|
||||
#define DETAIL_BACKGROUND_COLOR QColor(0, 0, 0, 0)
|
||||
#define DETAIL_WIDGET_TRANSPARENT 0.04
|
||||
#define DETAIL_WIDGET_BORDER_RADIUS 4
|
||||
#define DETAIL_WIDGET_MARGINS 8,0,8,0
|
||||
#define DETAIL_FRAME_MARGINS 8,0,0,0
|
||||
#define DETAIL_ICON_HEIGHT 120
|
||||
|
@ -613,14 +612,15 @@ void DetailArea::initUi()
|
|||
|
||||
DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
// initUi();
|
||||
// clear();
|
||||
m_radius = qApp->style()->property("maxRadius").toInt();
|
||||
connect(qApp, &QApplication::paletteChanged, this, [&]() {
|
||||
m_radius = qApp->style()->property("maxRadius").toInt();
|
||||
});
|
||||
this->setFixedWidth(368);
|
||||
m_mainLyt = new QVBoxLayout(this);
|
||||
this->setLayout(m_mainLyt);
|
||||
m_mainLyt->setContentsMargins(DETAIL_WIDGET_MARGINS);
|
||||
m_mainLyt->setAlignment(Qt::AlignHCenter);
|
||||
// m_mainLyt->addStretch();
|
||||
}
|
||||
|
||||
QString escapeHtml(const QString & str) {
|
||||
|
@ -666,7 +666,7 @@ void DetailWidget::paintEvent(QPaintEvent *event)
|
|||
p.setBrush(opt.palette.color(QPalette::Text));
|
||||
p.setOpacity(DETAIL_WIDGET_TRANSPARENT);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(rect, DETAIL_WIDGET_BORDER_RADIUS, DETAIL_WIDGET_BORDER_RADIUS);
|
||||
p.drawRoundedRect(rect, m_radius, m_radius);
|
||||
return QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -118,12 +118,13 @@ public:
|
|||
public Q_SLOTS:
|
||||
void updateDetailPage(const QString &plugin_name, const SearchPluginIface::ResultInfo &info);
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
private:
|
||||
void clearLayout(QLayout *);
|
||||
QVBoxLayout * m_mainLyt = nullptr;
|
||||
QString m_currentPluginId;
|
||||
QWidget *m_detailPage = nullptr;
|
||||
int m_radius = 8;
|
||||
};
|
||||
|
||||
class DetailArea : public QScrollArea
|
||||
|
|
|
@ -99,7 +99,7 @@ SearchPluginIface::ResultInfo ResultWidget::getIndexResultInfo(QModelIndex &inde
|
|||
|
||||
void ResultWidget::resetTitleLabel()
|
||||
{
|
||||
Q_EMIT this->m_titleLabel->lableReset();
|
||||
Q_EMIT this->m_titleLabel->labelReset();
|
||||
}
|
||||
|
||||
void ResultWidget::setTitileLableHide(bool state)
|
||||
|
@ -177,7 +177,7 @@ void ResultWidget::initConnections()
|
|||
Q_EMIT this->sizeChanged();
|
||||
});
|
||||
connect(m_resultView, &ResultView::sendBestListData, this, &ResultWidget::sendBestListData);
|
||||
connect(m_resultView, &ResultView::lableReset, m_titleLabel, &TitleLabel::lableReset);
|
||||
connect(m_resultView, &ResultView::lableReset, m_titleLabel, &TitleLabel::labelReset);
|
||||
connect(this, &ResultWidget::resizeWidth, this, [=] (const int &size) {
|
||||
this->setFixedWidth(size);
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ class GlobalSettingsPrivate : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit GlobalSettingsPrivate(QObject *parent = nullptr);
|
||||
const QVariant getValue(const QString&);
|
||||
QVariant getValue(const QString&);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QString& key, QVariant value);
|
||||
|
|
|
@ -87,7 +87,7 @@ GlobalSettingsPrivate::GlobalSettingsPrivate(QObject *parent) : QObject(parent)
|
|||
}
|
||||
}
|
||||
|
||||
const QVariant GlobalSettingsPrivate::getValue(const QString &key) {
|
||||
QVariant GlobalSettingsPrivate::getValue(const QString &key) {
|
||||
|
||||
m_mutex.lock();
|
||||
QVariant value = m_cache.value(key);
|
||||
|
|
Loading…
Reference in New Issue