2018-10-25 19:56:21 +08:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
|
|
|
*
|
|
|
|
|
* Author: listenerri <listenerri@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* Maintainer: listenerri <listenerri@gmail.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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-11-20 14:04:16 +08:00
|
|
|
|
#include "traypluginitem.h"
|
2018-10-16 14:33:06 +08:00
|
|
|
|
|
|
|
|
|
#include <QEvent>
|
2019-08-01 15:59:25 +08:00
|
|
|
|
#include <QGSettings>
|
2018-10-16 14:33:06 +08:00
|
|
|
|
|
2020-11-06 17:52:08 +08:00
|
|
|
|
TrayPluginItem::TrayPluginItem(PluginsItemInterface * const pluginInter, const QString &itemKey, const QString &pluginApi, QWidget *parent)
|
|
|
|
|
: PluginsItem(pluginInter, itemKey, pluginApi, parent)
|
2018-10-16 14:33:06 +08:00
|
|
|
|
{
|
2018-11-22 10:25:38 +08:00
|
|
|
|
centralWidget()->installEventFilter(this);
|
2018-10-16 14:33:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-20 14:04:16 +08:00
|
|
|
|
void TrayPluginItem::setSuggestIconSize(QSize size)
|
2018-11-07 16:19:57 +08:00
|
|
|
|
{
|
|
|
|
|
// invoke the method "setSuggestIconSize" of FashionTrayItem class
|
|
|
|
|
QMetaObject::invokeMethod(centralWidget(), "setSuggestIconSize", Qt::QueuedConnection, Q_ARG(QSize, size));
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-20 14:04:16 +08:00
|
|
|
|
void TrayPluginItem::setRightSplitVisible(const bool visible)
|
2018-11-08 18:24:41 +08:00
|
|
|
|
{
|
|
|
|
|
// invoke the method "setRightSplitVisible" of FashionTrayItem class
|
|
|
|
|
QMetaObject::invokeMethod(centralWidget(), "setRightSplitVisible", Qt::QueuedConnection, Q_ARG(bool, visible));
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-29 14:53:35 +08:00
|
|
|
|
int TrayPluginItem::trayVisableItemCount()
|
|
|
|
|
{
|
|
|
|
|
return m_trayVisableItemCount;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-20 14:04:16 +08:00
|
|
|
|
bool TrayPluginItem::eventFilter(QObject *watched, QEvent *e)
|
2018-10-16 14:33:06 +08:00
|
|
|
|
{
|
|
|
|
|
// 时尚模式下
|
2018-11-20 14:04:16 +08:00
|
|
|
|
// 监听插件Widget的"FashionTraySize"属性
|
2018-10-16 14:33:06 +08:00
|
|
|
|
// 当接收到这个属性变化的事件后,重新计算和设置dock的大小
|
|
|
|
|
|
2019-08-01 15:59:25 +08:00
|
|
|
|
if (watched == centralWidget()) {
|
|
|
|
|
if (e->type() == QEvent::MouseButtonPress ||
|
|
|
|
|
e->type() == QEvent::MouseButtonRelease) {
|
|
|
|
|
QGSettings settings("com.deepin.dde.dock.module.systemtray");
|
|
|
|
|
if (settings.keys().contains("control")
|
|
|
|
|
&& settings.get("control").toBool()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-29 18:07:15 +08:00
|
|
|
|
if (watched == centralWidget() && e->type() == QEvent::DynamicPropertyChange) {
|
|
|
|
|
const QString &propertyName = static_cast<QDynamicPropertyChangeEvent *>(e)->propertyName();
|
2019-10-29 14:53:35 +08:00
|
|
|
|
if (propertyName == "TrayVisableItemCount") {
|
|
|
|
|
m_trayVisableItemCount = watched->property("TrayVisableItemCount").toInt();
|
|
|
|
|
Q_EMIT trayVisableCountChanged(m_trayVisableItemCount);
|
2018-10-29 18:07:15 +08:00
|
|
|
|
}
|
2018-10-16 14:33:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PluginsItem::eventFilter(watched, e);
|
|
|
|
|
}
|