mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
feat(plugin):different colors under different theme
This commit is contained in:
parent
e66bde21b7
commit
398b88afd3
@ -27,6 +27,7 @@
|
||||
#include <DDBusSender>
|
||||
|
||||
#include <QDir>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#include <unistd.h>
|
||||
#include "dbus/dbusdockadaptors.h"
|
||||
@ -60,6 +61,7 @@ void RegisterDdeSession()
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
DGuiApplicationHelper::setUseInactiveColorGroup(false);
|
||||
DApplication::loadDXcbPlugin();
|
||||
DApplication app(argc, argv);
|
||||
|
||||
@ -67,7 +69,6 @@ int main(int argc, char *argv[])
|
||||
app.setApplicationName("dde-dock");
|
||||
app.setApplicationDisplayName("DDE Dock");
|
||||
app.setApplicationVersion("2.0");
|
||||
app.setTheme("dark");
|
||||
app.loadTranslator();
|
||||
app.setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps, false);
|
||||
|
@ -830,10 +830,7 @@ void MainWindow::onDbusNameOwnerChanged(const QString &name, const QString &oldO
|
||||
|
||||
void MainWindow::setEffectEnabled(const bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
setMaskColor(LightColor);
|
||||
else
|
||||
setMaskColor(QColor(55, 63, 71));
|
||||
setMaskColor(AutoColor);
|
||||
|
||||
setMaskAlpha(DockSettings::Instance().Opacity());
|
||||
}
|
||||
|
@ -130,7 +130,6 @@ void DatetimeWidget::paintEvent(QPaintEvent *e)
|
||||
else
|
||||
format = "hh:mm AP";
|
||||
|
||||
painter.setPen(Qt::white);
|
||||
painter.setFont(m_timeFont);
|
||||
|
||||
if (rect().height() >= SHOW_DATE_MIN_HEIGHT) {
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QIcon>
|
||||
|
||||
#include <DStyle>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
DWIDGET_USE_NAMESPACE;
|
||||
|
||||
@ -61,18 +62,32 @@ void OnboardItem::paintEvent(QPaintEvent *e)
|
||||
QPainter painter(this);
|
||||
if (std::min(width(), height()) > PLUGIN_BACKGROUND_MIN_SIZE) {
|
||||
|
||||
QColor color = QColor::fromRgb(40, 40, 40);;
|
||||
QColor color;
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
|
||||
color = Qt::black;
|
||||
painter.setOpacity(0.5);
|
||||
|
||||
if (m_hover) {
|
||||
color = QColor::fromRgb(60, 60, 60);
|
||||
}
|
||||
if (m_hover) {
|
||||
painter.setOpacity(0.6);
|
||||
}
|
||||
|
||||
if (m_pressed) {
|
||||
color = QColor::fromRgb(20, 20, 20);
|
||||
if (m_pressed) {
|
||||
painter.setOpacity(0.3);
|
||||
}
|
||||
} else {
|
||||
color = Qt::white;
|
||||
painter.setOpacity(0.1);
|
||||
|
||||
if (m_hover) {
|
||||
painter.setOpacity(0.2);
|
||||
}
|
||||
|
||||
if (m_pressed) {
|
||||
painter.setOpacity(0.05);
|
||||
}
|
||||
}
|
||||
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.setOpacity(0.5);
|
||||
|
||||
DStyleHelper dstyle(style());
|
||||
const int radius = dstyle.pixelMetric(DStyle::PM_FrameRadius);
|
||||
@ -91,6 +106,7 @@ void OnboardItem::paintEvent(QPaintEvent *e)
|
||||
|
||||
pixmap = loadSvg(iconName, QSize(iconSize, iconSize));
|
||||
|
||||
painter.setOpacity(1);
|
||||
painter.drawPixmap(rect().center() - pixmap.rect().center() / devicePixelRatioF(), pixmap);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QIcon>
|
||||
|
||||
#include <DStyle>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
DWIDGET_USE_NAMESPACE;
|
||||
|
||||
@ -57,18 +58,32 @@ void PluginWidget::paintEvent(QPaintEvent *e)
|
||||
|
||||
if (rect().height() > PLUGIN_BACKGROUND_MIN_SIZE) {
|
||||
|
||||
QColor color = QColor::fromRgb(40, 40, 40);;
|
||||
QColor color;
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
|
||||
color = Qt::black;
|
||||
painter.setOpacity(0.5);
|
||||
|
||||
if (m_hover) {
|
||||
color = QColor::fromRgb(60, 60, 60);
|
||||
}
|
||||
if (m_hover) {
|
||||
painter.setOpacity(0.6);
|
||||
}
|
||||
|
||||
if (m_pressed) {
|
||||
color = QColor::fromRgb(20, 20, 20);
|
||||
if (m_pressed) {
|
||||
painter.setOpacity(0.3);
|
||||
}
|
||||
} else {
|
||||
color = Qt::white;
|
||||
painter.setOpacity(0.1);
|
||||
|
||||
if (m_hover) {
|
||||
painter.setOpacity(0.2);
|
||||
}
|
||||
|
||||
if (m_pressed) {
|
||||
painter.setOpacity(0.05);
|
||||
}
|
||||
}
|
||||
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.setOpacity(0.5);
|
||||
|
||||
DStyleHelper dstyle(style());
|
||||
const int radius = dstyle.pixelMetric(DStyle::PM_FrameRadius);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <DHiDPIHelper>
|
||||
|
||||
#include <DStyle>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
@ -76,25 +77,30 @@ void FashionTrayControlWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.setOpacity(0.5);
|
||||
|
||||
QColor color;
|
||||
if (m_expanded) {
|
||||
color = QColor::fromRgb(40, 40, 40);
|
||||
if (m_hover) {
|
||||
color = QColor::fromRgb(60, 60, 60);
|
||||
}
|
||||
if (m_pressed) {
|
||||
color = QColor::fromRgb(20, 20, 20);
|
||||
}
|
||||
} else {
|
||||
color = QColor::fromRgb(255, 255, 255);
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
|
||||
color = Qt::black;
|
||||
painter.setOpacity(0.5);
|
||||
|
||||
if (m_hover) {
|
||||
painter.setOpacity(0.6);
|
||||
}
|
||||
|
||||
if (m_pressed) {
|
||||
painter.setOpacity(0.3);
|
||||
}
|
||||
} else {
|
||||
color = Qt::white;
|
||||
painter.setOpacity(0.1);
|
||||
|
||||
if (m_hover) {
|
||||
painter.setOpacity(0.2);
|
||||
}
|
||||
|
||||
if (m_pressed) {
|
||||
painter.setOpacity(0.05);
|
||||
}
|
||||
}
|
||||
|
||||
// draw background
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QMimeData>
|
||||
|
||||
#include <DStyle>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#include "constants.h"
|
||||
|
||||
@ -86,14 +87,30 @@ void FashionTrayWidgetWrapper::paintEvent(QPaintEvent *event)
|
||||
if (rect().height() > PLUGIN_BACKGROUND_MIN_SIZE) {
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.setOpacity(0.5);
|
||||
|
||||
QColor color = QColor::fromRgb(40, 40, 40);;
|
||||
if (m_hover) {
|
||||
color = QColor::fromRgb(60, 60, 60);
|
||||
}
|
||||
if (m_pressed) {
|
||||
color = QColor::fromRgb(20, 20, 20);
|
||||
QColor color;
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
|
||||
color = Qt::black;
|
||||
painter.setOpacity(0.5);
|
||||
|
||||
if (m_hover) {
|
||||
painter.setOpacity(0.6);
|
||||
}
|
||||
|
||||
if (m_pressed) {
|
||||
painter.setOpacity(0.3);
|
||||
}
|
||||
} else {
|
||||
color = Qt::white;
|
||||
painter.setOpacity(0.1);
|
||||
|
||||
if (m_hover) {
|
||||
painter.setOpacity(0.2);
|
||||
}
|
||||
|
||||
if (m_pressed) {
|
||||
painter.setOpacity(0.05);
|
||||
}
|
||||
}
|
||||
|
||||
DStyleHelper dstyle(style());
|
||||
|
Loading…
x
Reference in New Issue
Block a user