mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat(plugin):plugin icon always 20x20,change dark icon while dock mini size
This commit is contained in:
parent
6b4e5a5512
commit
4b65d62fb5
@ -35,13 +35,17 @@ namespace Dock {
|
||||
#define PLUGIN_BACKGROUND_MIN_SIZE 20
|
||||
|
||||
#define PLUGIN_ICON_MAX_SIZE 20
|
||||
#define PLUGIN_ICON_MIN_SIZE 16
|
||||
|
||||
// 需求变更成插件图标始终保持20x20,但16x16的资源还在。所以暂时保留此宏
|
||||
#define PLUGIN_ICON_MIN_SIZE 20
|
||||
|
||||
// 插件最小尺寸,图标采用深色
|
||||
#define PLUGIN_MIN_ICON_NAME "-dark"
|
||||
///
|
||||
/// \brief The DisplayMode enum
|
||||
/// spec dock display mode
|
||||
///
|
||||
enum DisplayMode
|
||||
{
|
||||
enum DisplayMode {
|
||||
Fashion = 0,
|
||||
Efficient = 1,
|
||||
// deprecreated
|
||||
@ -53,8 +57,7 @@ enum DisplayMode
|
||||
/// \brief The HideMode enum
|
||||
/// spec dock hide behavior
|
||||
///
|
||||
enum HideMode
|
||||
{
|
||||
enum HideMode {
|
||||
KeepShowing = 0,
|
||||
KeepHidden = 1,
|
||||
SmartHide = 3,
|
||||
@ -66,8 +69,7 @@ enum HideMode
|
||||
/// spec dock position, dock always placed at primary screen,
|
||||
/// so all position is the primary screen edge.
|
||||
///
|
||||
enum Position
|
||||
{
|
||||
enum Position {
|
||||
Top = 0,
|
||||
Right = 1,
|
||||
Bottom = 2,
|
||||
@ -80,8 +82,7 @@ enum Position
|
||||
/// spec current dock should hide or shown.
|
||||
/// this argument works only HideMode is SmartHide
|
||||
///
|
||||
enum HideState
|
||||
{
|
||||
enum HideState {
|
||||
Unknown = 0,
|
||||
Show = 1,
|
||||
Hide = 2,
|
||||
|
@ -73,7 +73,7 @@ void WiredItem::paintEvent(QPaintEvent *e)
|
||||
|
||||
QPainter painter(this);
|
||||
const auto ratio = devicePixelRatioF();
|
||||
const QRectF &rf = QRectF(rect());
|
||||
const QRectF &rf = QRectF(pos(), QSize(std::min(width(), height()), std::min(width(), height())));
|
||||
const QRectF &rfp = QRectF(m_icon.rect());
|
||||
const int x = rf.center().x() - rfp.center().x() / ratio;
|
||||
const int y = rf.center().y() - rfp.center().y() / ratio;
|
||||
@ -105,7 +105,8 @@ void WiredItem::reloadIcon()
|
||||
// const Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
|
||||
const Dock::DisplayMode displayMode = Dock::DisplayMode::Efficient;
|
||||
const auto ratio = devicePixelRatioF();
|
||||
const int iconSize = displayMode == Dock::Efficient ? 16 : std::min(width(), height()) * 0.8;
|
||||
// const int iconSize = displayMode == Dock::Efficient ? 16 : std::min(width(), height()) * 0.8;
|
||||
const int iconSize = PLUGIN_ICON_MAX_SIZE;
|
||||
|
||||
QString iconName = "network-";
|
||||
NetworkDevice::DeviceStatus devState = m_device->status();
|
||||
@ -165,6 +166,10 @@ void WiredItem::reloadIcon()
|
||||
if (displayMode == Dock::Efficient)
|
||||
iconName.append("-symbolic");
|
||||
|
||||
// 最小尺寸时采用深色图标
|
||||
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE)
|
||||
iconName.append(PLUGIN_MIN_ICON_NAME);
|
||||
|
||||
m_icon = QIcon::fromTheme(iconName).pixmap(iconSize * ratio, iconSize * ratio);
|
||||
m_icon.setDevicePixelRatio(ratio);
|
||||
update();
|
||||
|
@ -99,7 +99,7 @@ void WirelessItem::paintEvent(QPaintEvent *e)
|
||||
const Dock::DisplayMode displayMode = Dock::DisplayMode::Efficient;
|
||||
|
||||
const auto ratio = devicePixelRatioF();
|
||||
const int iconSize = displayMode == Dock::Fashion ? std::min(width(), height()) * 0.8 : 16;
|
||||
const int iconSize = PLUGIN_ICON_MAX_SIZE;
|
||||
QPixmap pixmap = iconPix(displayMode, iconSize * ratio);
|
||||
pixmap.setDevicePixelRatio(ratio);
|
||||
|
||||
@ -199,6 +199,9 @@ const QPixmap WirelessItem::iconPix(const Dock::DisplayMode displayMode, const i
|
||||
key = "network-wireless-warning-symbolic";
|
||||
}
|
||||
|
||||
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE)
|
||||
key.append(PLUGIN_MIN_ICON_NAME);
|
||||
|
||||
return cachedPix(key, size);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ void PluginWidget::paintEvent(QPaintEvent *e)
|
||||
|
||||
QPixmap pixmap;
|
||||
QString iconName = "system-shutdown";
|
||||
int iconSize;
|
||||
int iconSize = PLUGIN_ICON_MAX_SIZE;
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
@ -76,11 +76,9 @@ void PluginWidget::paintEvent(QPaintEvent *e)
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(rect(), radius, radius);
|
||||
painter.fillPath(path, color);
|
||||
|
||||
iconSize = PLUGIN_ICON_MAX_SIZE;
|
||||
} else {
|
||||
iconSize = PLUGIN_ICON_MIN_SIZE;
|
||||
iconName = iconName + "-symbolic";
|
||||
// 最小尺寸时,不画背景,采用深色图标
|
||||
iconName.append(PLUGIN_MIN_ICON_NAME);
|
||||
}
|
||||
|
||||
painter.setOpacity(1);
|
||||
|
@ -179,7 +179,10 @@ void SoundItem::refreshIcon()
|
||||
}
|
||||
|
||||
const auto ratio = devicePixelRatioF();
|
||||
const int iconSize = displayMode == Dock::Fashion ? std::min(width(), height()) * 0.8 : 16;
|
||||
int iconSize = PLUGIN_ICON_MAX_SIZE;
|
||||
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE)
|
||||
iconString.append(PLUGIN_MIN_ICON_NAME);
|
||||
|
||||
const QIcon icon = QIcon::fromTheme(iconString);
|
||||
m_iconPixmap = icon.pixmap(iconSize * ratio, iconSize * ratio);
|
||||
m_iconPixmap.setDevicePixelRatio(ratio);
|
||||
|
@ -180,7 +180,7 @@ void TrashWidget::resizeEvent(QResizeEvent *e)
|
||||
void TrashWidget::updateIcon()
|
||||
{
|
||||
// Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
|
||||
Dock::DisplayMode displayMode = displayMode = Dock::Fashion;
|
||||
Dock::DisplayMode displayMode = Dock::Fashion;
|
||||
|
||||
QString iconString = "user-trash";
|
||||
if (!m_popupApplet->empty())
|
||||
|
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "constants.h"
|
||||
#include "xembedtraywidget.h"
|
||||
|
||||
#include <QWindow>
|
||||
@ -43,7 +44,7 @@
|
||||
#define WINE_WINDOW_PROP_NAME "__wine_prefix"
|
||||
#define IS_WINE_WINDOW_BY_WM_CLASS "explorer.exe"
|
||||
|
||||
static const qreal iconSize = 16;
|
||||
static const qreal iconSize = PLUGIN_ICON_MAX_SIZE;
|
||||
|
||||
// this static var hold all suffix of tray widget keys.
|
||||
// that is in order to fix can not show multiple trays provide by one application,
|
||||
@ -114,7 +115,7 @@ const QImage XEmbedTrayWidget::trayImage()
|
||||
|
||||
QSize XEmbedTrayWidget::sizeHint() const
|
||||
{
|
||||
return QSize(26, 26);
|
||||
return QSize(PLUGIN_BACKGROUND_MAX_SIZE, PLUGIN_BACKGROUND_MAX_SIZE);
|
||||
}
|
||||
|
||||
void XEmbedTrayWidget::showEvent(QShowEvent *e)
|
||||
@ -411,7 +412,7 @@ void XEmbedTrayWidget::refershIconImage()
|
||||
if (qimage.isNull())
|
||||
return;
|
||||
|
||||
m_image = qimage.scaled(16 * ratio, 16 * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
m_image = qimage.scaled(iconSize * ratio, iconSize * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
m_image.setDevicePixelRatio(ratio);
|
||||
|
||||
update();
|
||||
|
Loading…
x
Reference in New Issue
Block a user