mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00

The tray in fashion mode is not the same object as the tray in efficient mode, and only one xembedtray is vaild, so there will be a contention between the two. The latter xembedtray who call reparent() will be the vaild one. So drag from expandiconwidget, the xembed tray click in the efficient mode get no response while the tray click get response when switching from the fashion mode. log: make tray(both fashion and efficient mode) to be one object
60 lines
1.8 KiB
C++
60 lines
1.8 KiB
C++
// Copyright (C) 2018 ~ 2025 Deepin Technology Co., Ltd.
|
|
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
|
//
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
#ifndef TRAYDELEGATE_H
|
|
#define TRAYDELEGATE_H
|
|
|
|
#include "constants.h"
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
#define ITEM_SIZE 30
|
|
// 托盘图标固定20个像素
|
|
// 16 x 16 will make the icon be cut, reserve 2 pixels for each side to prevent being cut
|
|
#define ICON_SIZE 20
|
|
#define ITEM_SPACING 5
|
|
|
|
class ExpandIconWidget;
|
|
class QListView;
|
|
class PluginsItemInterface;
|
|
|
|
class TrayDelegate : public QStyledItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
static TrayDelegate *getDockTrayDelegate(QListView *view, QObject *parent = nullptr);
|
|
static TrayDelegate *getIconTrayDelegate(QListView *view, QObject *parent = nullptr);
|
|
|
|
void setPositon(Dock::Position position);
|
|
|
|
Q_SIGNALS:
|
|
void removeRow(const QModelIndex &) const;
|
|
void requestDrag(bool) const;
|
|
void requestHide();
|
|
|
|
private Q_SLOTS:
|
|
void onUpdateExpand(bool on);
|
|
|
|
protected:
|
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
|
|
void setEditorData(QWidget *editor, const QModelIndex &index) const override ;
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
|
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
|
|
private:
|
|
explicit TrayDelegate(QListView *view, QObject *parent = nullptr);
|
|
|
|
ExpandIconWidget *expandWidget();
|
|
bool isPopupTray() const;
|
|
|
|
private:
|
|
Dock::Position m_position;
|
|
QListView *m_listView;
|
|
};
|
|
|
|
#endif // TRAYDELEGATE_H
|