mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00

1、删除已经移到插件中的文件 2、点击插件图标,弹出当前插件对应的列表 Log: Influence: 点击插件,观察是否弹出插件自己对应的列表,如果没有弹出列表,则触发这个插件的功能 Task: https://pms.uniontech.com/task-view-222353.html Change-Id: Ia8797ccbe630d56d79ab9138d5aa982b66f74c57
108 lines
3.0 KiB
C++
108 lines
3.0 KiB
C++
/*
|
|
* Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd.
|
|
*
|
|
* Author: donghualin <donghualin@uniontech.com>
|
|
*
|
|
* Maintainer: donghualin <donghualin@uniontech.com>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "quicksettingitem.h"
|
|
#include "pluginsiteminterface.h"
|
|
#include "imageutil.h"
|
|
#include "quicksettingcontroller.h"
|
|
|
|
#include <DGuiApplicationHelper>
|
|
#include <DFontSizeManager>
|
|
#include <DPaletteHelper>
|
|
|
|
#include <QIcon>
|
|
#include <QPainterPath>
|
|
#include <QPushButton>
|
|
#include <QFontMetrics>
|
|
#include <QPainterPath>
|
|
#include <QBitmap>
|
|
|
|
#define ICONWIDTH 24
|
|
#define ICONHEIGHT 24
|
|
#define ICONSPACE 10
|
|
#define RADIUS 8
|
|
#define FONTSIZE 10
|
|
|
|
#define BGWIDTH 128
|
|
#define BGSIZE 36
|
|
#define MARGINLEFTSPACE 10
|
|
#define OPENICONSIZE 12
|
|
#define MARGINRIGHTSPACE 9
|
|
|
|
QuickSettingItem::QuickSettingItem(PluginsItemInterface *const pluginInter, QWidget *parent)
|
|
: DockItem(parent)
|
|
, m_pluginInter(pluginInter)
|
|
, m_itemKey(QuickSettingController::instance()->itemKey(pluginInter))
|
|
{
|
|
setAcceptDrops(true);
|
|
this->installEventFilter(this);
|
|
}
|
|
|
|
QuickSettingItem::~QuickSettingItem()
|
|
{
|
|
}
|
|
|
|
PluginsItemInterface *QuickSettingItem::pluginItem() const
|
|
{
|
|
return m_pluginInter;
|
|
}
|
|
|
|
DockItem::ItemType QuickSettingItem::itemType() const
|
|
{
|
|
return DockItem::QuickSettingPlugin;
|
|
}
|
|
|
|
const QPixmap QuickSettingItem::dragPixmap()
|
|
{
|
|
return grab();
|
|
}
|
|
|
|
const QString QuickSettingItem::itemKey() const
|
|
{
|
|
return m_itemKey;
|
|
}
|
|
|
|
void QuickSettingItem::paintEvent(QPaintEvent *e)
|
|
{
|
|
QWidget::paintEvent(e);
|
|
QPainter painter(this);
|
|
painter.setRenderHint(QPainter::RenderHint::Antialiasing);
|
|
painter.setPen(foregroundColor());
|
|
QPainterPath path;
|
|
path.addRoundedRect(rect(), RADIUS, RADIUS);
|
|
painter.setClipPath(path);
|
|
// 绘制背景色
|
|
DPalette dpa = DPaletteHelper::instance()->palette(this);
|
|
painter.fillRect(rect(), Qt::white);
|
|
}
|
|
|
|
QColor QuickSettingItem::foregroundColor() const
|
|
{
|
|
DPalette dpa = DPaletteHelper::instance()->palette(this);
|
|
// 此处的颜色是临时获取的,后期需要和设计师确认,改成正规的颜色
|
|
if (m_pluginInter->status() == PluginsItemInterface::PluginMode::Active)
|
|
return dpa.color(DPalette::ColorGroup::Active, DPalette::ColorRole::Text);
|
|
|
|
if (m_pluginInter->status() == PluginsItemInterface::PluginMode::Deactive)
|
|
return dpa.color(DPalette::ColorGroup::Disabled, DPalette::ColorRole::Text);
|
|
|
|
return dpa.color(DPalette::ColorGroup::Normal, DPalette::ColorRole::Text);
|
|
}
|