Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [UI] Change the background color to active color #1034

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions src/plugins/core/gui/plugindetailsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@
#include <DFrame>
#include <DPalette>

#include <QGridLayout>

Check warning on line 18 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGridLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 18 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QGridLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDesktopServices>

Check warning on line 19 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDesktopServices> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 19 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDesktopServices> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#ifndef NOT_USE_WEBENGINE
#include <QWebEngineView>
#include <QWebEngineSettings>
# include <QWebEngineView>

Check warning on line 21 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWebEngineView> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 21 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QWebEngineView> not found. Please note: Cppcheck does not need standard library headers to get proper results.
# include <QWebEngineSettings>

Check warning on line 22 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWebEngineSettings> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 22 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QWebEngineSettings> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif
#include <QDir>

Check warning on line 24 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDir> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 24 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDir> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScreen>

Check warning on line 25 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QScreen> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 25 in src/plugins/core/gui/plugindetailsview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QScreen> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QGuiApplication>

DWIDGET_USE_NAMESPACE
using namespace dpfservice;

#ifndef NOT_USE_WEBENGINE
class AutoZoomWebEngineView : public QWebEngineView {
class AutoZoomWebEngineView : public QWebEngineView
{
public:
explicit AutoZoomWebEngineView(QWidget *parent = nullptr)
: QWebEngineView(parent)
Expand All @@ -38,7 +39,8 @@
}

protected:
void resizeEvent(QResizeEvent *event) override {
void resizeEvent(QResizeEvent *event) override
{
QWebEngineView::resizeEvent(event);

int pageWidth = static_cast<int>(QGuiApplication::primaryScreen()->size().width() * webPageWidthScale);
Expand Down Expand Up @@ -129,6 +131,23 @@
#endif
}

bool DetailsView::eventFilter(QObject *obj, QEvent *e)
{
if (obj == category && e->type() == QEvent::Paint) {
QPainter painter(category);
painter.setRenderHint(QPainter::Antialiasing);

auto pa = category->palette();
auto bkgColor = pa.color(QPalette::Highlight);
bkgColor.setAlpha(20);
painter.setBrush(bkgColor);
painter.setPen(Qt::NoPen);
painter.drawRoundedRect(category->rect(), 4, 4);
}

return DWidget::eventFilter(obj, e);
}

void DetailsView::changeLoadBtnState()
{
if (pluginMetaInfo.isNull())
Expand Down Expand Up @@ -186,11 +205,11 @@
operationLayout->setAlignment(Qt::AlignLeft);
tipLabel->hide();

connect(loadBtn, &DSuggestButton::clicked, this, [=](){
connect(loadBtn, &DSuggestButton::clicked, this, [=]() {
changeLoadBtnState();
tipLabel->show();
});

logoLabel = new QLabel(this);
auto logo = QIcon::fromTheme("default_plugin");
logoLabel->setPixmap(logo.pixmap(QSize(96, 96)));
Expand Down Expand Up @@ -251,24 +270,11 @@
versionLayout->setSpacing(0);
versionLayout->setContentsMargins(0, 0, 0, 0);

categoryFrame = new DFrame(this);
categoryFrame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
DPalette palette = categoryFrame->palette();
QColor color = palette.color(QPalette::Highlight);
color.setAlpha(20);
palette.setColor(QPalette::Base, color);
categoryFrame->setPalette(palette);
categoryFrame->setLineWidth(0);
DStyle::setFrameRadius(categoryFrame, 4);
QVBoxLayout *categoryLayout = new QVBoxLayout(categoryFrame);
category = new DLabel(categoryFrame);
category->setForegroundRole(DPalette::LightLively);
category->setContentsMargins(7, 0, 7, 0);
categoryLayout->addWidget(category);
categoryLayout->setAlignment(Qt::AlignCenter);
categoryLayout->setSpacing(0);
categoryLayout->setContentsMargins(0, 0, 0, 0);

category = new DLabel(this);
category->setForegroundRole(DPalette::Highlight);
category->setContentsMargins(7, 1, 7, 1);
category->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
category->installEventFilter(this);
description = new DLabel(this);
vendor = new DLabel(this);
dependency = new DLabel(this);
Expand All @@ -278,7 +284,7 @@
hbox->setSpacing(10);
hbox->addWidget(name);
hbox->addWidget(versionFrame);
hbox->addWidget(categoryFrame);
hbox->addWidget(category);

metaInfoLayout->addLayout(hbox);
metaInfoLayout->addWidget(vendor);
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/core/gui/plugindetailsview.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@

void update(const dpf::PluginMetaObjectPointer &metaInfo);

protected:
bool eventFilter(QObject *obj, QEvent *e) override;

private slots:

Check warning on line 47 in src/plugins/core/gui/plugindetailsview.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If slots is a macro then please configure it.

Check warning on line 47 in src/plugins/core/gui/plugindetailsview.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

There is an unknown macro here somewhere. Configuration is required. If slots is a macro then please configure it.
void changeLoadBtnState();
void showCfgWidget();

Expand All @@ -58,7 +61,6 @@
DTK_WIDGET_NAMESPACE::DLabel *vendor {nullptr};
DTK_WIDGET_NAMESPACE::DLabel *dependency {nullptr};
DTK_WIDGET_NAMESPACE::DFrame *versionFrame {nullptr};
DTK_WIDGET_NAMESPACE::DFrame *categoryFrame {nullptr};

DTK_WIDGET_NAMESPACE::DPushButton *loadBtn {nullptr};
dpf::PluginMetaObjectPointer pluginMetaInfo;
Expand Down
Loading