refactor(system-tray): new fashion system tray

Change-Id: I7d359c1a33fbb32bc174026e7aee130d328313ef
This commit is contained in:
listenerri 2018-10-16 14:33:06 +08:00
parent 6ead8ff3fa
commit e9c48fb2f0
Notes: gerrit 2018-10-22 10:45:43 +08:00
Verified+1: <jenkins@deepin.com>
Code-Review+2: listenerri <listenerri@gmail.com>
Submitted-by: listenerri <listenerri@gmail.com>
Submitted-at: Mon, 22 Oct 2018 10:45:43 +0800
Reviewed-on: https://cr.deepin.io/39042
Project: dde/dde-dock
Branch: refs/heads/master
26 changed files with 768 additions and 202 deletions

View File

@ -86,7 +86,8 @@ void DockItemController::updatePluginsItemOrderKey()
int index = 0;
for (auto item : m_itemList)
{
if (item.isNull() || item->itemType() != DockItem::Plugins)
DockItem::ItemType tyep = item->itemType();
if (item.isNull() || (tyep != DockItem::Plugins && tyep != DockItem::SystemTrayPlugin))
continue;
static_cast<PluginsItem *>(item.data())->setItemSortKey(++index);
}
@ -105,8 +106,8 @@ void DockItemController::itemMove(DockItem * const moveItem, DockItem * const re
return;
// plugins move
if (moveType == DockItem::Plugins)
if (replaceType != DockItem::Plugins)
if (moveType == DockItem::Plugins || moveType == DockItem::SystemTrayPlugin)
if (replaceType != DockItem::Plugins && replaceType != DockItem::SystemTrayPlugin)
return;
const int moveIndex = m_itemList.indexOf(moveItem);
@ -120,7 +121,8 @@ void DockItemController::itemMove(DockItem * const moveItem, DockItem * const re
emit itemMoved(moveItem, replaceIndex);
// update plugins sort key if order changed
if (moveType == DockItem::Plugins || replaceType == DockItem::Plugins)
if (moveType == DockItem::Plugins || replaceType == DockItem::Plugins
|| moveType == DockItem::SystemTrayPlugin || replaceType == DockItem::SystemTrayPlugin)
m_updatePluginsOrderTimer->start();
// for app move, index 0 is launcher item, need to pass it.
@ -130,7 +132,7 @@ void DockItemController::itemMove(DockItem * const moveItem, DockItem * const re
void DockItemController::itemDroppedIntoContainer(DockItem * const item)
{
Q_ASSERT(item->itemType() == DockItem::Plugins);
Q_ASSERT(item->itemType() == DockItem::Plugins || item->itemType() == DockItem::SystemTrayPlugin);
PluginsItem *pi = static_cast<PluginsItem *>(item);
@ -161,6 +163,7 @@ void DockItemController::itemDragOutFromContainer(DockItem * const item)
switch (item->itemType())
{
case DockItem::Plugins:
case DockItem::SystemTrayPlugin:
static_cast<PluginsItem *>(item)->setInContainer(false);
pluginItemInserted(static_cast<PluginsItem *>(item));
break;
@ -227,6 +230,7 @@ DockItemController::DockItemController(QObject *parent)
connect(m_pluginsInter, &DockPluginsController::pluginItemInserted, this, &DockItemController::pluginItemInserted, Qt::QueuedConnection);
connect(m_pluginsInter, &DockPluginsController::pluginItemRemoved, this, &DockItemController::pluginItemRemoved, Qt::QueuedConnection);
connect(m_pluginsInter, &DockPluginsController::pluginItemUpdated, this, &DockItemController::itemUpdated, Qt::QueuedConnection);
connect(m_pluginsInter, &DockPluginsController::fashionSystemTraySizeChanged, this, &DockItemController::fashionSystemTraySizeChanged, Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "refershItemsIcon", Qt::QueuedConnection);
}
@ -293,7 +297,8 @@ void DockItemController::pluginItemInserted(PluginsItem *item)
int firstPluginPosition = -1;
for (int i(0); i != m_itemList.size(); ++i)
{
if (m_itemList[i]->itemType() != DockItem::Plugins)
DockItem::ItemType type = m_itemList[i]->itemType();
if (type != DockItem::Plugins && type != DockItem::SystemTrayPlugin)
continue;
firstPluginPosition = i;
@ -364,7 +369,8 @@ void DockItemController::sortPluginItems()
int firstPluginIndex = -1;
for (int i(0); i != m_itemList.size(); ++i)
{
if (m_itemList[i]->itemType() == DockItem::Plugins)
DockItem::ItemType type = m_itemList[i]->itemType();
if (type == DockItem::Plugins || type == DockItem::SystemTrayPlugin)
{
firstPluginIndex = i;
break;

View File

@ -53,6 +53,7 @@ signals:
void itemMoved(DockItem *item, const int index) const;
void itemManaged(DockItem *item) const;
void itemUpdated(DockItem *item) const;
void fashionSystemTraySizeChanged(const QSize &systemTraySize) const;
public slots:
void refershItemsIcon();

View File

@ -23,6 +23,7 @@
#include "pluginsiteminterface.h"
#include "dockitemcontroller.h"
#include "dockpluginloader.h"
#include "item/systemtraypluginitem.h"
#include <QDebug>
#include <QDir>
@ -44,7 +45,15 @@ void DockPluginsController::itemAdded(PluginsItemInterface * const itemInter, co
if (m_pluginList[itemInter].contains(itemKey))
return;
PluginsItem *item = new PluginsItem(itemInter, itemKey);
PluginsItem *item = nullptr;
if (itemInter->pluginName() == "system-tray") {
item = new SystemTrayPluginItem(itemInter, itemKey);
connect(static_cast<SystemTrayPluginItem *>(item), &SystemTrayPluginItem::fashionSystemTraySizeChanged,
this, &DockPluginsController::fashionSystemTraySizeChanged, Qt::UniqueConnection);
} else {
item = new PluginsItem(itemInter, itemKey);
}
item->setVisible(false);
m_pluginList[itemInter][itemKey] = item;

View File

@ -50,6 +50,7 @@ signals:
void pluginItemInserted(PluginsItem *pluginItem) const;
void pluginItemRemoved(PluginsItem *pluginItem) const;
void pluginItemUpdated(PluginsItem *pluginItem) const;
void fashionSystemTraySizeChanged(const QSize &systemTraySize) const;
private slots:
void startLoader();

View File

@ -46,6 +46,7 @@ public:
Plugins,
Container,
Placeholder,
SystemTrayPlugin,
};
public:

View File

@ -100,6 +100,11 @@ void PluginsItem::setInContainer(const bool container)
m_pluginInter->setItemIsInContainer(m_itemKey, container);
}
QString PluginsItem::pluginName() const
{
return m_pluginInter->pluginName();
}
QSize PluginsItem::sizeHint() const
{
return m_centralWidget->sizeHint();
@ -110,6 +115,11 @@ void PluginsItem::refershIcon()
m_pluginInter->refershIcon(m_itemKey);
}
QWidget *PluginsItem::centralWidget()
{
return m_centralWidget;
}
void PluginsItem::mousePressEvent(QMouseEvent *e)
{
if (!isInContainer() && PopupWindow->isVisible())

View File

@ -41,6 +41,8 @@ public:
bool isInContainer() const;
void setInContainer(const bool container);
QString pluginName() const;
using DockItem::showContextMenu;
using DockItem::hidePopup;
@ -50,11 +52,14 @@ public:
public slots:
void refershIcon() override;
protected:
QWidget *centralWidget();
bool eventFilter(QObject *o, QEvent *e) override;
private:
void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
bool eventFilter(QObject *o, QEvent *e) override;
void invokedMenuItem(const QString &itemId, const bool checked) override;
void showPopupWindow(QWidget * const content, const bool model = false) override;
@ -68,6 +73,7 @@ private:
private:
PluginsItemInterface * const m_pluginInter;
QWidget *m_centralWidget;
const QString m_itemKey;
bool m_dragging;

View File

@ -0,0 +1,22 @@
#include "systemtraypluginitem.h"
#include <QEvent>
SystemTrayPluginItem::SystemTrayPluginItem(PluginsItemInterface * const pluginInter, const QString &itemKey, QWidget *parent)
: PluginsItem(pluginInter, itemKey, parent)
{
}
bool SystemTrayPluginItem::eventFilter(QObject *watched, QEvent *e)
{
// 时尚模式下
// 监听插件Widget的"FashionSystemTraySize"属性
// 当接收到这个属性变化的事件后重新计算和设置dock的大小
if (watched == centralWidget() && e->type() == QEvent::DynamicPropertyChange
&& static_cast<QDynamicPropertyChangeEvent *>(e)->propertyName() == "FashionSystemTraySize") {
Q_EMIT fashionSystemTraySizeChanged(watched->property("FashionSystemTraySize").toSize());
}
return PluginsItem::eventFilter(watched, e);
}

View File

@ -0,0 +1,22 @@
#ifndef SYSTEMTRAYPLUGINITEM_H
#define SYSTEMTRAYPLUGINITEM_H
#include "pluginsitem.h"
class SystemTrayPluginItem : public PluginsItem
{
Q_OBJECT
public:
SystemTrayPluginItem(PluginsItemInterface* const pluginInter, const QString &itemKey, QWidget *parent = 0);
inline ItemType itemType() const Q_DECL_OVERRIDE {return ItemType::SystemTrayPlugin;}
Q_SIGNALS:
void fashionSystemTraySizeChanged(const QSize &systemTraySize) const;
private:
bool eventFilter(QObject *watched, QEvent *e) Q_DECL_OVERRIDE;
};
#endif // SYSTEMTRAYPLUGINITEM_H

View File

@ -264,7 +264,8 @@ void MainPanel::dragLeaveEvent(QDragLeaveEvent *e)
RequestDockItem = nullptr;
}
if (DraggingItem && DraggingItem->itemType() != DockItem::Plugins)
DockItem::ItemType type = DraggingItem->itemType();
if (DraggingItem && type != DockItem::Plugins && type != DockItem::SystemTrayPlugin)
DraggingItem->hide();
}
@ -360,6 +361,7 @@ void MainPanel::adjustItemSize()
int totalWidth = 0;
int totalHeight = 0;
const auto &itemList = m_itemController->itemList();
const QSize &fashionSystemTraySize = DockSettings::Instance().fashionSystemTraySize();
for (auto item : itemList)
{
const auto itemType = item->itemType();
@ -382,12 +384,27 @@ void MainPanel::adjustItemSize()
totalHeight += itemSize.height();
break;
case DockItem::Plugins:
if (m_displayMode == Fashion)
{
item->setFixedSize(itemSize);
++totalAppItemCount;
totalWidth += itemSize.width();
totalHeight += itemSize.height();
case DockItem::SystemTrayPlugin:
if (m_displayMode == Fashion) {
// 特殊处理时尚模式下的托盘插件
if (item->itemType() == DockItem::SystemTrayPlugin) {
if (m_position == Dock::Top || m_position == Dock::Bottom) {
item->setFixedWidth(fashionSystemTraySize.width());
item->setFixedHeight(itemSize.height());
totalWidth += fashionSystemTraySize.width();
totalHeight += itemSize.height();
} else {
item->setFixedWidth(itemSize.width());
item->setFixedHeight(fashionSystemTraySize.height());
totalWidth += itemSize.width();
totalHeight += fashionSystemTraySize.height();
}
} else {
item->setFixedSize(itemSize);
totalWidth += itemSize.width();
totalHeight += itemSize.height();
++totalAppItemCount;
}
}
else
{
@ -472,6 +489,9 @@ void MainPanel::adjustItemSize()
if (m_itemController->itemIsInContainer(item))
continue;
}
if (itemType == DockItem::SystemTrayPlugin) {
continue;
}
switch (m_position)
{
@ -546,7 +566,8 @@ void MainPanel::itemDragStarted()
{
DraggingItem = qobject_cast<DockItem *>(sender());
if (DraggingItem->itemType() == DockItem::App)
DockItem::ItemType draggingTyep = DraggingItem->itemType();
if (draggingTyep == DockItem::App)
{
AppItem *appItem = qobject_cast<AppItem *>(DraggingItem);
m_appDragWidget = appItem->appDragWidget();
@ -554,7 +575,7 @@ void MainPanel::itemDragStarted()
static_cast<QGraphicsView *>(m_appDragWidget)->viewport()->installEventFilter(this);
}
if (DraggingItem->itemType() == DockItem::Plugins)
if (draggingTyep == DockItem::Plugins || draggingTyep == DockItem::SystemTrayPlugin)
{
if (static_cast<PluginsItem *>(DraggingItem)->allowContainer())
{
@ -590,7 +611,9 @@ void MainPanel::itemDropped(QObject *destnation)
const bool itemIsInContainer = m_itemController->itemIsInContainer(src);
// drag from container
if (itemIsInContainer && src->itemType() == DockItem::Plugins && destnation == this)
if (itemIsInContainer
&& (src->itemType() == DockItem::Plugins || src->itemType() == DockItem::SystemTrayPlugin)
&& destnation == this)
m_itemController->itemDragOutFromContainer(src);
// drop to container

View File

@ -42,6 +42,7 @@ DockSettings::DockSettings(QWidget *parent)
: QObject(parent)
, m_autoHide(true)
, m_opacity(0.4)
, m_fashionSystemTraySize(QSize(0, 0))
, m_fashionModeAct(tr("Fashion Mode"), this)
, m_efficientModeAct(tr("Efficient Mode"), this)
, m_topPosAct(tr("Top"), this)
@ -147,6 +148,7 @@ DockSettings::DockSettings(QWidget *parent)
connect(m_itemController, &DockItemController::itemInserted, this, &DockSettings::dockItemCountChanged, Qt::QueuedConnection);
connect(m_itemController, &DockItemController::itemRemoved, this, &DockSettings::dockItemCountChanged, Qt::QueuedConnection);
connect(m_itemController, &DockItemController::fashionSystemTraySizeChanged, this, &DockSettings::onFashionSystemTraySizeChanged, Qt::QueuedConnection);
connect(m_displayInter, &DBusDisplay::PrimaryRectChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
connect(m_displayInter, &DBusDisplay::ScreenHeightChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
@ -523,6 +525,21 @@ void DockSettings::onOpacityChanged(const double value)
emit opacityChanged(value * 255);
}
void DockSettings::onFashionSystemTraySizeChanged(const QSize &systemTraySize)
{
if (m_displayMode == Dock::Efficient)
return;
if (m_fashionSystemTraySize == systemTraySize)
return;
m_fashionSystemTraySize = systemTraySize;
calculateWindowConfig();
emit windowGeometryChanged();
}
void DockSettings::calculateWindowConfig()
{
const auto ratio = qApp->devicePixelRatio();
@ -567,8 +584,8 @@ void DockSettings::calculateWindowConfig()
}
}
const int perfectWidth = visibleItemCount * defaultWidth + PANEL_BORDER * 2 + PANEL_PADDING * 2 + PANEL_MARGIN * 2;
const int perfectHeight = visibleItemCount * defaultHeight + PANEL_BORDER * 2 + PANEL_PADDING * 2 + PANEL_MARGIN * 2;
const int perfectWidth = visibleItemCount * defaultWidth + PANEL_BORDER * 2 + PANEL_PADDING * 2 + PANEL_MARGIN * 2 + m_fashionSystemTraySize.width();
const int perfectHeight = visibleItemCount * defaultHeight + PANEL_BORDER * 2 + PANEL_PADDING * 2 + PANEL_MARGIN * 2 + m_fashionSystemTraySize.height();
const int calcWidth = qMin(m_primaryRect.width() - FASHION_MODE_PADDING * 2, perfectWidth);
const int calcHeight = qMin(m_primaryRect.height() - FASHION_MODE_PADDING * 2, perfectHeight);
switch (m_position)

View File

@ -77,6 +77,7 @@ public:
inline const QRect frontendWindowRect() const { return m_frontendRect; }
inline const QSize windowSize() const { return m_mainWindowSize; }
inline const quint8 Opacity() const { return m_opacity * 255; }
inline const QSize fashionSystemTraySize() const { return m_fashionSystemTraySize; }
const QSize panelSize() const;
const QRect windowRect(const Position position, const bool hide = false) const;
@ -109,6 +110,7 @@ private slots:
void resetFrontendGeometry();
void updateForbidPostions();
void onOpacityChanged(const double value);
void onFashionSystemTraySizeChanged(const QSize &systemTraySize);
private:
DockSettings(QWidget *parent = 0);
@ -134,6 +136,7 @@ private:
QRect m_primaryRawRect;
QRect m_frontendRect;
QSize m_mainWindowSize;
QSize m_fashionSystemTraySize;
WhiteMenu m_settingsMenu;
WhiteMenu *m_hideSubMenu;

View File

@ -23,6 +23,7 @@
#include <xcb/xproto.h>
#include <QMouseEvent>
#include <QDebug>
AbstractTrayWidget::AbstractTrayWidget(QWidget *parent, Qt::WindowFlags f):
QWidget(parent, f)
@ -35,6 +36,11 @@ AbstractTrayWidget::~AbstractTrayWidget()
}
void AbstractTrayWidget::mousePressEvent(QMouseEvent *event)
{
event->accept();
}
void AbstractTrayWidget::mouseReleaseEvent(QMouseEvent *e)
{
const QPoint point(e->pos() - rect().center());
@ -58,4 +64,9 @@ void AbstractTrayWidget::mouseReleaseEvent(QMouseEvent *e)
}
sendClick(buttonIndex, globalPos.x(), globalPos.y());
// left mouse button clicked
if (buttonIndex == XCB_BUTTON_INDEX_1) {
Q_EMIT clicked();
}
}

View File

@ -38,8 +38,10 @@ public:
Q_SIGNALS:
void iconChanged();
void clicked();
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
};

View File

@ -0,0 +1,113 @@
#include "fashiontraycontrolwidget.h"
#include <QMouseEvent>
#include <QPainter>
#define ExpandedKey "fashion-tray-expanded"
FashionTrayControlWidget::FashionTrayControlWidget(Dock::Position position, QWidget *parent)
: QWidget(parent),
m_settings(new QSettings("deepin", "dde-dock-tray")),
m_dockPosition(position),
m_expanded(m_settings->value(ExpandedKey, true).toBool()),
m_hover(false),
m_pressed(false)
{
setDockPostion(m_dockPosition);
setExpanded(m_expanded);
}
void FashionTrayControlWidget::setDockPostion(Dock::Position pos)
{
m_dockPosition = pos;
update();
}
bool FashionTrayControlWidget::expanded() const
{
return m_expanded;
}
void FashionTrayControlWidget::setExpanded(const bool &expanded)
{
if (m_expanded == expanded) {
return;
}
m_expanded = expanded;
update();
m_settings->setValue(ExpandedKey, m_expanded);
Q_EMIT expandChanged(m_expanded);
}
void FashionTrayControlWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setOpacity(0.5);
if (m_expanded) {
painter.setPen(QColor::fromRgb(40, 40, 40));
painter.setBrush(QColor::fromRgb(40, 40, 40));
if (m_hover) {
painter.setPen(QColor::fromRgb(60, 60, 60));
painter.setBrush(QColor::fromRgb(60, 60, 60));
}
if (m_pressed) {
painter.setPen(QColor::fromRgb(20, 20, 20));
painter.setBrush(QColor::fromRgb(20, 20, 20));
}
} else {
painter.setPen(QColor::fromRgb(255, 255, 255));
painter.setBrush(QColor::fromRgb(255, 255, 255));
if (m_hover) {
painter.setOpacity(0.6);
}
if (m_pressed) {
painter.setOpacity(0.3);
}
}
painter.drawRoundRect(rect());
}
void FashionTrayControlWidget::mouseReleaseEvent(QMouseEvent *event)
{
m_pressed = false;
update();
if (event->button() == Qt::LeftButton) {
event->accept();
setExpanded(!m_expanded);
return;
}
QWidget::mouseReleaseEvent(event);
}
void FashionTrayControlWidget::mousePressEvent(QMouseEvent *event)
{
m_pressed = true;
update();
QWidget::mousePressEvent(event);
}
void FashionTrayControlWidget::enterEvent(QEvent *event)
{
m_hover = true;
update();
QWidget::enterEvent(event);
}
void FashionTrayControlWidget::leaveEvent(QEvent *event)
{
m_hover = false;
update();
QWidget::leaveEvent(event);
}

View File

@ -0,0 +1,40 @@
#ifndef FASHIONTRAYCONTROLWIDGET_H
#define FASHIONTRAYCONTROLWIDGET_H
#include "constants.h"
#include <QLabel>
#include <QSettings>
class FashionTrayControlWidget : public QWidget
{
Q_OBJECT
public:
explicit FashionTrayControlWidget(Dock::Position position, QWidget *parent = nullptr);
void setDockPostion(Dock::Position pos);
bool expanded() const;
void setExpanded(const bool &expanded);
Q_SIGNALS:
void expandChanged(const bool expanded);
protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
private:
QSettings *m_settings;
Dock::Position m_dockPosition;
bool m_expanded;
bool m_hover;
bool m_pressed;
};
#endif // FASHIONTRAYCONTROLWIDGET_H

View File

@ -21,142 +21,322 @@
#include "fashiontrayitem.h"
#include <QPainter>
#include <QDebug>
#include <QMouseEvent>
#include <QPixmap>
#include <QSvgRenderer>
#include <QApplication>
#include <cmath>
#define SpliterSize 2
#define TraySpace 10
#define TrayWidgetWidth 26
#define TrayWidgetHeight 26
#include <xcb/xproto.h>
#define DRAG_THRESHOLD 10
const double pi = std::acos(-1);
FashionTrayItem::FashionTrayItem(QWidget *parent)
FashionTrayItem::FashionTrayItem(Dock::Position pos, QWidget *parent)
: QWidget(parent),
m_enableMouseEvent(false),
m_activeTray(nullptr)
m_mainBoxLayout(new QBoxLayout(QBoxLayout::Direction::LeftToRight, this)),
m_trayBoxLayout(new QBoxLayout(QBoxLayout::Direction::LeftToRight, this)),
m_leftSpliter(new QLabel(this)),
m_rightSpliter(new QLabel(this)),
m_controlWidget(new FashionTrayControlWidget(m_dockPosistion, this)),
m_currentAttentionTray(nullptr)
{
m_leftSpliter->setStyleSheet("background-color: rgba(255, 255, 255, 0.1);");
m_rightSpliter->setStyleSheet("background-color: rgba(255, 255, 255, 0.1);");
m_controlWidget->setFixedSize(QSize(TrayWidgetWidth, TrayWidgetHeight));
m_mainBoxLayout->setMargin(0);
m_mainBoxLayout->setContentsMargins(0, 0, 0, 0);
m_mainBoxLayout->setSpacing(TraySpace);
m_trayBoxLayout->setMargin(0);
m_trayBoxLayout->setContentsMargins(0, 0, 0, 0);
m_trayBoxLayout->setSpacing(TraySpace);
m_mainBoxLayout->addWidget(m_leftSpliter);
m_mainBoxLayout->addLayout(m_trayBoxLayout);
m_mainBoxLayout->addWidget(m_controlWidget);
m_mainBoxLayout->addWidget(m_rightSpliter);
m_mainBoxLayout->setAlignment(Qt::AlignCenter);
m_trayBoxLayout->setAlignment(Qt::AlignCenter);
m_mainBoxLayout->setAlignment(m_leftSpliter, Qt::AlignCenter);
m_mainBoxLayout->setAlignment(m_controlWidget, Qt::AlignCenter);
m_mainBoxLayout->setAlignment(m_rightSpliter, Qt::AlignCenter);
setLayout(m_mainBoxLayout);
setDockPostion(pos);
onTrayListExpandChanged(m_controlWidget->expanded());
connect(m_controlWidget, &FashionTrayControlWidget::expandChanged, this, &FashionTrayItem::onTrayListExpandChanged);
}
AbstractTrayWidget *FashionTrayItem::activeTray() const
void FashionTrayItem::setTrayWidgets(const QList<AbstractTrayWidget *> &trayWidgetList)
{
return m_activeTray;
}
void FashionTrayItem::setMouseEnable(const bool enable)
{
m_enableMouseEvent = enable;
}
void FashionTrayItem::setActiveTray(AbstractTrayWidget *tray)
{
if (!m_activeTray.isNull())
{
m_activeTray->setActive(false);
disconnect(m_activeTray, &AbstractTrayWidget::iconChanged, this, static_cast<void (FashionTrayItem::*)()>(&FashionTrayItem::update));
}
if (tray)
{
tray->setActive(true);
connect(tray, &AbstractTrayWidget::iconChanged, this, static_cast<void (FashionTrayItem::*)()>(&FashionTrayItem::update));
}
m_activeTray = tray;
update();
}
void FashionTrayItem::resizeEvent(QResizeEvent *e)
{
// update icon size
const auto ratio = qApp->devicePixelRatio();
const QSize s = e->size() * ratio;
m_backgroundPixmap = loadSvg(":/icons/resources/trayicon.svg", 0.8 * std::min(s.width(), s.height()));
m_backgroundPixmap.setDevicePixelRatio(ratio);
QWidget::resizeEvent(e);
}
void FashionTrayItem::paintEvent(QPaintEvent *e)
{
Q_UNUSED(e);
const QRectF r = rect();
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
// draw blue circle
const auto ratio = qApp->devicePixelRatio();
const int x = r.center().x() - m_backgroundPixmap.rect().center().x() / ratio;
const int y = r.center().y() - m_backgroundPixmap.rect().center().y() / ratio;
painter.drawPixmap(x, y, m_backgroundPixmap);
// draw active icon
if (m_activeTray)
{
const QImage &image = m_activeTray->trayImage();
const auto ratio = image.devicePixelRatioF();
const double x = double(r.center().x()) - double(image.rect().width()) / ratio / 2.0;
const double y = double(r.center().y()) - double(image.rect().height()) / ratio / 2.0;
painter.drawImage(std::round(x), std::round(y), image);
for (auto widget : trayWidgetList) {
trayWidgetAdded(widget);
}
}
void FashionTrayItem::mousePressEvent(QMouseEvent *e)
void FashionTrayItem::trayWidgetAdded(AbstractTrayWidget *trayWidget)
{
QWidget::mousePressEvent(e);
m_pressPoint = e->pos();
}
void FashionTrayItem::mouseReleaseEvent(QMouseEvent *e)
{
const QPoint dis = e->pos() - rect().center();
if (!m_enableMouseEvent || dis.manhattanLength() > std::min(width(), height()) / 2 * 0.8)
return QWidget::mouseReleaseEvent(e);
const QPoint point = e->pos() - m_pressPoint;
if (point.manhattanLength() > DRAG_THRESHOLD)
if (m_trayWidgetWrapperMap.keys().contains(trayWidget)) {
return;
if (!m_activeTray)
return;
QPoint globalPos = QCursor::pos();
uint8_t buttonIndex = XCB_BUTTON_INDEX_1;
switch (e->button()) {
case Qt:: MiddleButton:
buttonIndex = XCB_BUTTON_INDEX_2;
break;
case Qt::RightButton:
buttonIndex = XCB_BUTTON_INDEX_3;
break;
default:
break;
}
m_activeTray->sendClick(buttonIndex, globalPos.x(), globalPos.y());
FashionTrayWidgetWrapper *wrapper = new FashionTrayWidgetWrapper(trayWidget);
wrapper->setFixedSize(QSize(TrayWidgetWidth, TrayWidgetHeight));
m_trayWidgetWrapperMap.insert(trayWidget, wrapper);
m_trayBoxLayout->addWidget(wrapper);
wrapper->setVisible(m_controlWidget->expanded());
if (wrapper->attention()) {
setCurrentAttentionTray(wrapper);
}
connect(wrapper, &FashionTrayWidgetWrapper::attentionChanged, this, &FashionTrayItem::onTrayAttentionChanged, Qt::UniqueConnection);
requestResize();
}
const QPixmap FashionTrayItem::loadSvg(const QString &fileName, const int size) const
void FashionTrayItem::trayWidgetRemoved(AbstractTrayWidget *trayWidget)
{
QPixmap pixmap(size, size);
QSvgRenderer renderer(fileName);
pixmap.fill(Qt::transparent);
auto it = m_trayWidgetWrapperMap.constBegin();
QPainter painter;
painter.begin(&pixmap);
renderer.render(&painter);
painter.end();
for (; it != m_trayWidgetWrapperMap.constEnd(); ++it) {
if (it.key() == trayWidget) {
// removing the attention tray
if (m_currentAttentionTray == it.value()) {
if (m_controlWidget->expanded()) {
m_trayBoxLayout->removeWidget(m_currentAttentionTray);
} else {
m_mainBoxLayout->removeWidget(m_currentAttentionTray);
}
m_currentAttentionTray = nullptr;
} else {
m_trayBoxLayout->removeWidget(it.value());
}
it.value()->deleteLater();
m_trayWidgetWrapperMap.remove(it.key());
break;
}
}
return pixmap;
if (it == m_trayWidgetWrapperMap.constEnd()) {
qDebug() << "can not find the tray widget in fashion tray list:" << trayWidget;
return;
}
requestResize();
}
void FashionTrayItem::clearTrayWidgets()
{
if (m_currentAttentionTray) {
m_mainBoxLayout->removeWidget(m_currentAttentionTray);
m_currentAttentionTray = nullptr;
}
for (auto wrapper : m_trayWidgetWrapperMap.values()) {
m_trayBoxLayout->removeWidget(wrapper);
wrapper->deleteLater();
}
m_trayWidgetWrapperMap.clear();
requestResize();
}
void FashionTrayItem::setDockPostion(Dock::Position pos)
{
m_dockPosistion = pos;
m_controlWidget->setDockPostion(m_dockPosistion);
if (pos == Dock::Position::Top || pos == Dock::Position::Bottom) {
m_leftSpliter->setFixedSize(SpliterSize, height());
m_rightSpliter->setFixedSize(SpliterSize, height());
m_mainBoxLayout->setDirection(QBoxLayout::Direction::LeftToRight);
m_trayBoxLayout->setDirection(QBoxLayout::Direction::LeftToRight);
} else{
m_leftSpliter->setFixedSize(width(), SpliterSize);
m_rightSpliter->setFixedSize(width(), SpliterSize);
m_mainBoxLayout->setDirection(QBoxLayout::Direction::TopToBottom);
m_trayBoxLayout->setDirection(QBoxLayout::Direction::TopToBottom);
}
requestResize();
}
void FashionTrayItem::onTrayListExpandChanged(const bool expand)
{
if (m_currentAttentionTray) {
if (expand) {
m_mainBoxLayout->removeWidget(m_currentAttentionTray);
m_trayBoxLayout->addWidget(m_currentAttentionTray);
} else {
m_trayBoxLayout->removeWidget(m_currentAttentionTray);
m_mainBoxLayout->insertWidget(m_mainBoxLayout->indexOf(m_controlWidget) + 1, m_currentAttentionTray);
}
}
m_mainBoxLayout->setAlignment(m_currentAttentionTray, Qt::AlignCenter);
for (auto i = m_trayWidgetWrapperMap.begin(); i != m_trayWidgetWrapperMap.end(); ++i) {
if (i.value() == m_currentAttentionTray) {
continue;
}
i.value()->setVisible(expand);
}
requestResize();
}
void FashionTrayItem::showEvent(QShowEvent *event)
{
requestResize();
QWidget::showEvent(event);
}
void FashionTrayItem::hideEvent(QHideEvent *event)
{
requestResize();
QWidget::hideEvent(event);
}
QSize FashionTrayItem::sizeHint() const
{
return wantedTotalSize();
}
QSize FashionTrayItem::wantedTotalSize() const
{
QSize size;
if (m_controlWidget->expanded()) {
if (m_dockPosistion == Dock::Position::Top || m_dockPosistion == Dock::Position::Bottom) {
size.setWidth(m_trayWidgetWrapperMap.size() * TrayWidgetWidth // 所有插件
+ TrayWidgetWidth // 控制按钮
+ SpliterSize * 2 // 两个分隔条
+ 3 * TraySpace // MainBoxLayout所有space
+ (m_trayWidgetWrapperMap.size() - 1) * TraySpace); // TrayBoxLayout所有space
size.setHeight(height());
} else {
size.setWidth(width());
size.setHeight(m_trayWidgetWrapperMap.size() * TrayWidgetHeight // 所有插件
+ TrayWidgetHeight // 控制按钮
+ SpliterSize * 2 // 两个分隔条
+ 3 * TraySpace // MainBoxLayout所有space
+ (m_trayWidgetWrapperMap.size() - 1) * TraySpace); // TrayBoxLayout所有space
}
} else {
if (m_dockPosistion == Dock::Position::Top || m_dockPosistion == Dock::Position::Bottom) {
size.setWidth(TrayWidgetWidth // 控制按钮
+ (m_currentAttentionTray ? TrayWidgetWidth : 0) // 活动状态的tray
+ SpliterSize * 2 // 两个分隔条
+ 3 * TraySpace); // MainBoxLayout所有space
size.setHeight(height());
} else {
size.setWidth(width());
size.setHeight(TrayWidgetHeight // 控制按钮
+ (m_currentAttentionTray ? TrayWidgetHeight : 0) // 活动状态的tray
+ SpliterSize * 2 // 两个分隔条
+ 3 * TraySpace); // MainBoxLayout所有space
}
}
return size;
}
void FashionTrayItem::onTrayAttentionChanged(const bool attention)
{
FashionTrayWidgetWrapper *wrapper = static_cast<FashionTrayWidgetWrapper *>(sender());
Q_ASSERT(wrapper);
if (attention) {
setCurrentAttentionTray(wrapper);
} else {
if (m_currentAttentionTray != wrapper) {
return;
}
if (m_controlWidget->expanded()) {
m_currentAttentionTray = nullptr;
} else {
moveInAttionTray();
m_currentAttentionTray = nullptr;
}
}
}
void FashionTrayItem::setCurrentAttentionTray(FashionTrayWidgetWrapper *attentionWrapper)
{
if (!attentionWrapper) {
return;
}
if (m_controlWidget->expanded()) {
m_currentAttentionTray = attentionWrapper;
} else {
if (m_currentAttentionTray == attentionWrapper) {
return;
}
moveInAttionTray();
bool sizeChanged = !m_currentAttentionTray;
m_currentAttentionTray = attentionWrapper;
moveOutAttionTray();
if (sizeChanged) {
requestResize();
}
}
m_mainBoxLayout->setAlignment(m_currentAttentionTray, Qt::AlignCenter);
}
void FashionTrayItem::requestResize()
{
// reset property "FashionSystemTraySize" to notify dock resize
// DockPluginsController will watch this property
setProperty("FashionSystemTraySize", isVisible() ? wantedTotalSize() : QSize(0, 0));
}
void FashionTrayItem::moveOutAttionTray()
{
if (!m_currentAttentionTray) {
return;
}
m_trayBoxLayout->removeWidget(m_currentAttentionTray);
m_mainBoxLayout->insertWidget(m_mainBoxLayout->indexOf(m_rightSpliter), m_currentAttentionTray);
m_currentAttentionTray->setVisible(true);
}
void FashionTrayItem::moveInAttionTray()
{
if (!m_currentAttentionTray) {
return;
}
m_mainBoxLayout->removeWidget(m_currentAttentionTray);
m_trayBoxLayout->addWidget(m_currentAttentionTray);
m_currentAttentionTray->setVisible(m_controlWidget->expanded());
}
void FashionTrayItem::switchAttionTray(FashionTrayWidgetWrapper *attentionWrapper)
{
if (!m_currentAttentionTray || !attentionWrapper) {
return;
}
m_mainBoxLayout->replaceWidget(m_currentAttentionTray, attentionWrapper);
m_trayBoxLayout->removeWidget(attentionWrapper);
m_trayBoxLayout->addWidget(m_currentAttentionTray);
attentionWrapper->setVisible(true);
m_currentAttentionTray->setVisible(m_controlWidget->expanded());
m_currentAttentionTray = attentionWrapper;
}

View File

@ -22,8 +22,14 @@
#ifndef FASHIONTRAYITEM_H
#define FASHIONTRAYITEM_H
#include "constants.h"
#include "fashiontraywidgetwrapper.h"
#include "fashiontraycontrolwidget.h"
#include <QWidget>
#include <QPointer>
#include <QBoxLayout>
#include <QLabel>
#include <abstracttraywidget.h>
@ -32,30 +38,44 @@ class FashionTrayItem : public QWidget
Q_OBJECT
public:
explicit FashionTrayItem(QWidget *parent = 0);
explicit FashionTrayItem(Dock::Position pos, QWidget *parent = 0);
AbstractTrayWidget *activeTray() const;
void setTrayWidgets(const QList<AbstractTrayWidget *> &trayWidgetList);
void trayWidgetAdded(AbstractTrayWidget *trayWidget);
void trayWidgetRemoved(AbstractTrayWidget *trayWidget);
void clearTrayWidgets();
void setMouseEnable(const bool enable);
void setDockPostion(Dock::Position pos);
public slots:
void setActiveTray(AbstractTrayWidget *tray);
void onTrayListExpandChanged(const bool expand);
protected:
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE;
private:
void resizeEvent(QResizeEvent *e);
void paintEvent(QPaintEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
QSize sizeHint() const Q_DECL_OVERRIDE;
QSize wantedTotalSize() const;
const QPixmap loadSvg(const QString &fileName, const int size) const;
private Q_SLOTS:
void onTrayAttentionChanged(const bool attention);
void setCurrentAttentionTray(FashionTrayWidgetWrapper *attentionWrapper);
void requestResize();
void moveOutAttionTray();
void moveInAttionTray();
void switchAttionTray(FashionTrayWidgetWrapper *attentionWrapper);
private:
bool m_enableMouseEvent;
QMap<AbstractTrayWidget *, FashionTrayWidgetWrapper *> m_trayWidgetWrapperMap;
QBoxLayout *m_mainBoxLayout;
QBoxLayout *m_trayBoxLayout;
QLabel *m_leftSpliter;
QLabel *m_rightSpliter;
FashionTrayControlWidget *m_controlWidget;
FashionTrayWidgetWrapper *m_currentAttentionTray;
QPointer<AbstractTrayWidget> m_activeTray;
QPixmap m_backgroundPixmap;
QPoint m_pressPoint;
Dock::Position m_dockPosistion;
};
#endif // FASHIONTRAYITEM_H

View File

@ -0,0 +1,61 @@
#include "fashiontraywidgetwrapper.h"
#include <QPainter>
#include <QDebug>
FashionTrayWidgetWrapper::FashionTrayWidgetWrapper(AbstractTrayWidget *absTrayWidget, QWidget *parent)
: QWidget(parent),
m_absTrayWidget(absTrayWidget),
m_layout(new QVBoxLayout(this)),
m_attention(false)
{
m_layout->setSpacing(0);
m_layout->setMargin(0);
m_layout->setContentsMargins(0, 0, 0, 0);
m_layout->addWidget(m_absTrayWidget);
setLayout(m_layout);
connect(m_absTrayWidget, &AbstractTrayWidget::iconChanged, this, &FashionTrayWidgetWrapper::onTrayWidgetIconChanged);
connect(m_absTrayWidget, &AbstractTrayWidget::clicked, this, &FashionTrayWidgetWrapper::onTrayWidgetClicked);
}
AbstractTrayWidget *FashionTrayWidgetWrapper::absTrayWidget() const
{
return m_absTrayWidget;
}
void FashionTrayWidgetWrapper::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QColor(QColor::fromRgb(40, 40, 40)));
painter.setBrush(QColor(QColor::fromRgb(40, 40, 40)));
painter.setOpacity(0.5);
painter.drawRoundRect(rect());
}
void FashionTrayWidgetWrapper::onTrayWidgetIconChanged()
{
setAttention(true);
}
void FashionTrayWidgetWrapper::onTrayWidgetClicked()
{
setAttention(false);
}
bool FashionTrayWidgetWrapper::attention() const
{
return m_attention;
}
void FashionTrayWidgetWrapper::setAttention(bool attention)
{
m_attention = attention;
Q_EMIT attentionChanged(m_attention);
}

View File

@ -0,0 +1,38 @@
#ifndef FASHIONTRAYWIDGETWRAPPER_H
#define FASHIONTRAYWIDGETWRAPPER_H
#include "abstracttraywidget.h"
#include <QWidget>
#include <QVBoxLayout>
#include <QTimer>
class FashionTrayWidgetWrapper : public QWidget
{
Q_OBJECT
public:
FashionTrayWidgetWrapper(AbstractTrayWidget *absTrayWidget, QWidget *parent = nullptr);
AbstractTrayWidget *absTrayWidget() const;
bool attention() const;
Q_SIGNALS:
void attentionChanged(const bool attention);
protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
private:
void setAttention(bool attention);
void onTrayWidgetIconChanged();
void onTrayWidgetClicked();
private:
AbstractTrayWidget *m_absTrayWidget;
QVBoxLayout *m_layout;
bool m_attention;
};
#endif //FASHIONTRAYWIDGETWRAPPER_H

View File

@ -35,7 +35,8 @@ const QStringList ItemStatusList {"ApplicationStatus" , "Communications" , "Syst
SNITrayWidget::SNITrayWidget(const QString &sniServicePath, QWidget *parent)
: AbstractTrayWidget(parent),
m_dbusMenuImporter(nullptr),
m_menu(nullptr)
m_menu(nullptr),
m_updateTimer(new QTimer(this))
{
if (sniServicePath.startsWith("/") || !sniServicePath.contains("/")) {
return;
@ -55,7 +56,11 @@ SNITrayWidget::SNITrayWidget(const QString &sniServicePath, QWidget *parent)
m_dbusMenuImporter = new DBusMenuImporter(service, menuPath, SYNCHRONOUS, this);
m_menu = m_dbusMenuImporter->menu();
connect(m_sniInter, &StatusNotifierItem::NewIcon, this, &SNITrayWidget::refreshIcon);
m_updateTimer->setInterval(100);
m_updateTimer->setSingleShot(true);
connect(m_updateTimer, &QTimer::timeout, this, &SNITrayWidget::refreshIcon);
connect(m_sniInter, &StatusNotifierItem::NewIcon, m_updateTimer, static_cast<void (QTimer::*) ()>(&QTimer::start));
connect(m_sniInter, &StatusNotifierItem::NewOverlayIcon, this, &SNITrayWidget::refreshOverlayIcon);
connect(m_sniInter, &StatusNotifierItem::NewAttentionIcon, this, &SNITrayWidget::refreshAttentionIcon);
@ -72,7 +77,7 @@ void SNITrayWidget::setActive(const bool active)
void SNITrayWidget::updateIcon()
{
update();
m_updateTimer->start();
}
void SNITrayWidget::sendClick(uint8_t mouseButton, int x, int y)

View File

@ -71,6 +71,7 @@ private:
DBusMenuImporter *m_dbusMenuImporter;
QMenu *m_menu;
QTimer *m_updateTimer;
QPixmap m_pixmap;
QPixmap m_overlayPixmap;

View File

@ -43,7 +43,7 @@ SystemTrayPlugin::SystemTrayPlugin(QObject *parent)
m_containerSettings(new QSettings("deepin", "dde-dock-tray"))
{
m_trayApplet->setObjectName("sys-tray");
m_fashionItem = new FashionTrayItem;
m_fashionItem = new FashionTrayItem(position());
m_tipsLabel->setObjectName("sys-tray");
m_tipsLabel->setText(tr("System Tray"));
@ -95,6 +95,11 @@ void SystemTrayPlugin::displayModeChanged(const Dock::DisplayMode mode)
switchToMode(mode);
}
void SystemTrayPlugin::positionChanged(const Dock::Position position)
{
m_fashionItem->setDockPostion(position);
}
QWidget *SystemTrayPlugin::itemWidget(const QString &itemKey)
{
if (itemKey == FASHION_MODE_ITEM) {
@ -117,6 +122,8 @@ QWidget *SystemTrayPlugin::itemTipsWidget(const QString &itemKey)
QWidget *SystemTrayPlugin::itemPopupApplet(const QString &itemKey)
{
return nullptr;
if (itemKey != FASHION_MODE_ITEM) {
return nullptr;
}
@ -125,11 +132,11 @@ QWidget *SystemTrayPlugin::itemPopupApplet(const QString &itemKey)
updateTipsContent();
if (m_trayList.size() > 1) {
return m_trayApplet;
} else {
return nullptr;
}
// if (m_trayList.size() > 1) {
// return m_trayApplet;
// } else {
// return nullptr;
// }
}
bool SystemTrayPlugin::itemAllowContainer(const QString &itemKey)
@ -178,7 +185,6 @@ void SystemTrayPlugin::setItemIsInContainer(const QString &itemKey, const bool c
void SystemTrayPlugin::updateTipsContent()
{
auto trayList = m_trayList.values();
// trayList.removeOne(m_fashionItem->activeTray());
m_trayApplet->clear();
m_trayApplet->addWidgets(trayList);
@ -252,15 +258,11 @@ void SystemTrayPlugin::addTrayWidget(const QString &itemKey, AbstractTrayWidget
m_trayList.insert(itemKey, trayWidget);
}
m_fashionItem->setMouseEnable(m_trayList.size() == 1);
if (!m_fashionItem->activeTray()) {
m_fashionItem->setActiveTray(trayWidget);
}
if (displayMode() == Dock::Efficient) {
m_proxyInter->itemAdded(this, itemKey);
} else {
m_proxyInter->itemAdded(this, FASHION_MODE_ITEM);
m_fashionItem->trayWidgetAdded(trayWidget);
}
}
@ -310,27 +312,14 @@ void SystemTrayPlugin::trayRemoved(const QString itemKey)
return;
}
QWidget *widget = m_trayList.take(itemKey);
AbstractTrayWidget *widget = m_trayList.take(itemKey);
m_fashionItem->trayWidgetRemoved(widget);
m_proxyInter->itemRemoved(this, itemKey);
widget->deleteLater();
m_fashionItem->setMouseEnable(m_trayList.size() == 1);
if (m_trayApplet->isVisible()) {
updateTipsContent();
}
if (m_fashionItem->activeTray() && m_fashionItem->activeTray() != widget) {
return;
}
// reset active tray
if (m_trayList.values().isEmpty()) {
m_fashionItem->setActiveTray(nullptr);
m_proxyInter->itemRemoved(this, FASHION_MODE_ITEM);
} else {
m_fashionItem->setActiveTray(m_trayList.values().last());
}
}
void SystemTrayPlugin::trayChanged(quint32 winId)
@ -341,7 +330,6 @@ void SystemTrayPlugin::trayChanged(quint32 winId)
}
m_trayList.value(itemKey)->updateIcon();
m_fashionItem->setActiveTray(m_trayList.value(itemKey));
if (m_trayApplet->isVisible()) {
updateTipsContent();
@ -354,12 +342,6 @@ void SystemTrayPlugin::sniItemIconChanged()
if (!m_trayList.values().contains(trayWidget)) {
return;
}
m_fashionItem->setActiveTray(trayWidget);
//if (m_trayApplet->isVisible()) {
// updateTipsContent();
//}
}
void SystemTrayPlugin::switchToMode(const Dock::DisplayMode mode)
@ -371,9 +353,11 @@ void SystemTrayPlugin::switchToMode(const Dock::DisplayMode mode)
if (m_trayList.isEmpty()) {
m_proxyInter->itemRemoved(this, FASHION_MODE_ITEM);
} else {
m_fashionItem->setTrayWidgets(m_trayList.values());
m_proxyInter->itemAdded(this, FASHION_MODE_ITEM);
}
} else {
m_fashionItem->clearTrayWidgets();
m_proxyInter->itemRemoved(this, FASHION_MODE_ITEM);
for (auto itemKey : m_trayList.keys()) {
m_proxyInter->itemAdded(this, itemKey);

View File

@ -49,6 +49,7 @@ public:
const QString pluginName() const Q_DECL_OVERRIDE;
void init(PluginProxyInterface *proxyInter) Q_DECL_OVERRIDE;
void displayModeChanged(const Dock::DisplayMode mode) Q_DECL_OVERRIDE;
void positionChanged(const Dock::Position position) Q_DECL_OVERRIDE;
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
QWidget *itemTipsWidget(const QString &itemKey) Q_DECL_OVERRIDE;

View File

@ -127,16 +127,6 @@ void XWindowTrayWidget::paintEvent(QPaintEvent *e)
painter.end();
}
void XWindowTrayWidget::mousePressEvent(QMouseEvent *e)
{
e->accept();
const QPoint point(e->pos() - rect().center());
if (point.manhattanLength() > 24)
e->ignore();
QWidget::mousePressEvent(e);
}
void XWindowTrayWidget::mouseMoveEvent(QMouseEvent *e)
{
QWidget::mouseMoveEvent(e);
@ -270,8 +260,8 @@ void XWindowTrayWidget::sendHoverEvent()
void XWindowTrayWidget::updateIcon()
{
if (!isVisible() && !m_active)
return;
// if (!isVisible() && !m_active)
// return;
m_updateTimer->start();
}

View File

@ -48,7 +48,6 @@ private:
QSize sizeHint() const Q_DECL_OVERRIDE;
void showEvent(QShowEvent *e) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
void configContainerPosition();