dde-dock/frame/window/quickpluginwindow.h
donghualin da1b436796 fix: 修复高缩放率下图标显示异常的问题
1、高缩放率下计算图标任务栏尺寸需要乘以缩放率的数值
2、加载声音图标带上具体的后缀名,否则会出现图标显示异常
3、自定义图标的尺寸的显示,需要重新计算图标的宽度

Log: 修复高分屏下图标显示异常
Influence: 高分屏,高缩放率,观察任务栏插件区域的图标
Bug: https://pms.uniontech.com/bug-view-183543.html
Bug: https://pms.uniontech.com/bug-view-184089.html
Change-Id: Iaa8833b20608129e5c10c8614702a9e5afeae2d9
2023-01-31 21:27:52 +08:00

158 lines
4.6 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/>.
*/
#ifndef QUICKPLUGINWINDOW_H
#define QUICKPLUGINWINDOW_H
#include "constants.h"
#include <QWidget>
class QuickSettingItem;
class PluginsItemInterface;
class QHBoxLayout;
class QStandardItemModel;
class QStandardItem;
class QMouseEvent;
class QBoxLayout;
class QuickDockItem;
class DockPopupWindow;
class QMenu;
class QuickPluginMimeData;
enum class DockPart;
namespace Dtk { namespace Widget { class DListView; class DStandardItem; } }
using namespace Dtk::Widget;
class QuickPluginWindow : public QWidget
{
Q_OBJECT
public:
explicit QuickPluginWindow(Dock::DisplayMode displayMode, QWidget *parent = nullptr);
~QuickPluginWindow() override;
void setPositon(Dock::Position position);
void dragPlugin(PluginsItemInterface *item);
QSize suitableSize() const;
QSize suitableSize(const Dock::Position &position) const;
bool isQuickWindow(QObject *object) const;
Q_SIGNALS:
void itemCountChanged();
protected:
bool eventFilter(QObject *watched, QEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private Q_SLOTS:
void onRequestUpdate();
void onUpdatePlugin(PluginsItemInterface *itemInter, const DockPart &dockPart);
void onRequestAppletVisible(PluginsItemInterface * itemInter, const QString &itemKey, bool visible);
private:
void initUi();
void initConnection();
void startDrag();
PluginsItemInterface *findQuickSettingItem(const QPoint &mousePoint, const QList<PluginsItemInterface *> &settingItems);
int getDropIndex(QPoint point);
QPoint popupPoint(QWidget *widget) const;
QuickDockItem *getDockItemByPlugin(PluginsItemInterface *item);
QuickDockItem *getActiveDockItem(QPoint point) const;
void showPopup(QuickDockItem *item, PluginsItemInterface *itemInter = nullptr, QWidget *childPage = nullptr, bool isClicked = true);
QList<QuickDockItem *> quickDockItems();
DockPopupWindow *getPopWindow() const;
void updateDockItemSize(QuickDockItem *dockItem);
void resizeDockItem();
private:
QBoxLayout *m_mainLayout;
Dock::Position m_position;
struct DragInfo *m_dragInfo;
QuickPluginMimeData *m_dragEnterMimeData;
Dock::DisplayMode m_displayMode;
};
// 用于在任务栏上显示的插件
class QuickDockItem : public QWidget
{
Q_OBJECT
public:
explicit QuickDockItem(PluginsItemInterface *pluginItem, const QString &itemKey, QWidget *parent = nullptr);
~QuickDockItem();
void setPosition(Dock::Position position);
PluginsItemInterface *pluginItem();
bool canInsert() const;
bool canMove() const;
void hideToolTip();
QSize suitableSize() const;
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
bool eventFilter(QObject *watched, QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private:
QPoint topleftPoint() const;
QPoint popupMarkPoint() const;
QPixmap iconPixmap() const;
void initUi();
void initAttribute();
void initConnection();
void updateWidgetSize();
int shadowRadius() const;
int iconSize() const;
private Q_SLOTS:
void onMenuActionClicked(QAction *action);
private:
PluginsItemInterface *m_pluginItem;
QString m_itemKey;
Dock::Position m_position;
DockPopupWindow *m_popupWindow;
QMenu *m_contextMenu;
QWidget *m_tipParent;
QHBoxLayout *m_topLayout;
QWidget *m_mainWidget;
QHBoxLayout *m_mainLayout;
QWidget *m_dockItemParent;
bool m_isEnter;
};
#endif // QUICKPLUGINWINDOW_H