mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix: 加载系统托盘插件
1、systemTray目录下的插件由QuickItemController类来统一加载,托盘区域增加系统插件的展示 2、蓝牙、飞行模式等插件修改为普通插件,用于在快捷面板显示 Log: 托盘区显示系统托盘插件 Influence: 插入U盘,查看托盘区域是否有U盘图标 Task: https://pms.uniontech.com/task-view-112073.html Change-Id: I57e1321fcc59dfc7cfad1c21aca343203e3fad00
This commit is contained in:
parent
ee248287d3
commit
b2633a5f50
3
debian/dde-dock.install
vendored
3
debian/dde-dock.install
vendored
@ -4,9 +4,8 @@ etc/dde-dock
|
|||||||
usr/lib/dde-dock/plugins/libshutdown.so
|
usr/lib/dde-dock/plugins/libshutdown.so
|
||||||
usr/lib/dde-dock/plugins/libtrash.so
|
usr/lib/dde-dock/plugins/libtrash.so
|
||||||
usr/lib/dde-dock/plugins/liboverlay-warning.so
|
usr/lib/dde-dock/plugins/liboverlay-warning.so
|
||||||
usr/lib/dde-dock/plugins/system-trays
|
|
||||||
usr/lib/dde-dock/plugins/quick-trays
|
usr/lib/dde-dock/plugins/quick-trays
|
||||||
usr/lib/dde-dock/plugins/libmultitasking.so
|
usr/lib/dde-dock/plugins/libmultitasking.so
|
||||||
usr/lib/dde-dock/plugins/libshow-desktop.so
|
usr/lib/dde-dock/plugins/libshow-desktop.so
|
||||||
usr/lib/dde-dock/plugins/system-trays/libkeyboard-layout.so
|
usr/lib/dde-dock/plugins/libkeyboard-layout.so
|
||||||
usr/share/dsg/apps/dde-dock/configs/
|
usr/share/dsg/apps/dde-dock/configs/
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "proxyplugincontroller.h"
|
#include "proxyplugincontroller.h"
|
||||||
#include "pluginsiteminterface.h"
|
#include "pluginsiteminterface.h"
|
||||||
|
#include "constants.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
@ -41,13 +42,15 @@ static QMap<PluginType, QStringList> getPluginPaths()
|
|||||||
{
|
{
|
||||||
QStringList pluginPaths;
|
QStringList pluginPaths;
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
pluginPaths << qApp->applicationDirPath() + "/../plugins/quick-trays"
|
pluginPaths << QString("%1/..%2").arg(qApp->applicationDirPath()).arg(QUICK_PATH)
|
||||||
<< qApp->applicationDirPath() + "/../plugins";
|
<< QString("%1/..%2").arg(qApp->applicationDirPath()).arg(PLUGIN_PATH)
|
||||||
|
<< QString("%1/..%2").arg(qApp->applicationDirPath()).arg(TRAY_PATH);
|
||||||
#else
|
#else
|
||||||
pluginPaths << "/usr/lib/dde-dock/plugins/quick-trays"
|
pluginPaths << QString("/usr/lib/dde-dock%1").arg(QUICK_PATH)
|
||||||
<< "/usr/lib/dde-dock/plugins";
|
<< QString("/usr/lib/dde-dock%1").arg(PLUGIN_PATH)
|
||||||
|
<< QString("/usr/lib/dde-dock%1").arg(TRAY_PATH);
|
||||||
|
|
||||||
const QStringList pluginsDirs = (getPathFromConf("QUICK_TRAY_PATH") << getPathFromConf("PATH"));
|
const QStringList pluginsDirs = (getPathFromConf("QUICK_TRAY_PATH") << getPathFromConf("PATH") << getPathFromConf("SYSTEM_TRAY_PATH"));
|
||||||
if (!pluginsDirs.isEmpty())
|
if (!pluginsDirs.isEmpty())
|
||||||
pluginPaths << pluginsDirs;
|
pluginPaths << pluginsDirs;
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,13 +41,17 @@ void QuickSettingController::pluginItemAdded(PluginsItemInterface * const itemIn
|
|||||||
// 根据读取到的metaData数据获取当前插件的类型,提供给外部
|
// 根据读取到的metaData数据获取当前插件的类型,提供给外部
|
||||||
PluginAttribute pluginClass = PluginAttribute::Quick;
|
PluginAttribute pluginClass = PluginAttribute::Quick;
|
||||||
QPluginLoader *pluginLoader = ProxyPluginController::instance(PluginType::QuickPlugin)->pluginLoader(itemInter);
|
QPluginLoader *pluginLoader = ProxyPluginController::instance(PluginType::QuickPlugin)->pluginLoader(itemInter);
|
||||||
QJsonObject meta;
|
|
||||||
if (pluginLoader) {
|
if (pluginLoader) {
|
||||||
meta = pluginLoader->metaData().value("MetaData").toObject();
|
if (pluginLoader->fileName().contains("/plugins/system-trays")) {
|
||||||
if (meta.contains("tool") && meta.value("tool").toBool())
|
// 如果是从系统托盘目录下加载的插件,则认为它是托盘插件,此时需要放入到托盘中
|
||||||
pluginClass = PluginAttribute::Tool;
|
pluginClass = PluginAttribute::System;
|
||||||
else if (meta.contains("fixed") && meta.value("fixed").toBool())
|
} else {
|
||||||
pluginClass = PluginAttribute::Fixed;
|
QJsonObject meta = pluginLoader->metaData().value("MetaData").toObject();
|
||||||
|
if (meta.contains("tool") && meta.value("tool").toBool())
|
||||||
|
pluginClass = PluginAttribute::Tool;
|
||||||
|
else if (meta.contains("fixed") && meta.value("fixed").toBool())
|
||||||
|
pluginClass = PluginAttribute::Fixed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_quickPlugins[pluginClass] << itemInter;
|
m_quickPlugins[pluginClass] << itemInter;
|
||||||
@ -64,8 +68,10 @@ void QuickSettingController::pluginItemRemoved(PluginsItemInterface * const item
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
plugins.removeOne(itemInter);
|
plugins.removeOne(itemInter);
|
||||||
if (plugins.isEmpty())
|
if (plugins.isEmpty()) {
|
||||||
m_quickPlugins.remove(it.key());
|
QuickSettingController::PluginAttribute pluginclass = it.key();
|
||||||
|
m_quickPlugins.remove(pluginclass);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@ public:
|
|||||||
enum class PluginAttribute {
|
enum class PluginAttribute {
|
||||||
Quick = 0,
|
Quick = 0,
|
||||||
Tool,
|
Tool,
|
||||||
Fixed
|
Fixed,
|
||||||
|
System
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -162,13 +162,21 @@ PluginsItemInterface::PluginSizePolicy PluginAdapter::pluginSizePolicy() const
|
|||||||
|
|
||||||
QIcon PluginAdapter::icon(const DockPart &dockPart)
|
QIcon PluginAdapter::icon(const DockPart &dockPart)
|
||||||
{
|
{
|
||||||
if (dockPart == DockPart::QuickPanel) {
|
QWidget *itemWidget = m_pluginInter->itemWidget(m_itemKey);
|
||||||
|
if (!itemWidget)
|
||||||
|
return QIcon();
|
||||||
|
|
||||||
|
switch (dockPart) {
|
||||||
|
case DockPart::QuickPanel: {
|
||||||
// 如果图标为空,就使用itemWidget的截图作为它的图标,这种一般是适用于老版本插件或者没有实现v23接口的插件
|
// 如果图标为空,就使用itemWidget的截图作为它的图标,这种一般是适用于老版本插件或者没有实现v23接口的插件
|
||||||
QWidget *itemWidget = m_pluginInter->itemWidget(m_itemKey);
|
itemWidget->setFixedSize(ICONWIDTH, ICONHEIGHT);
|
||||||
if (itemWidget) {
|
return itemWidget->grab();
|
||||||
itemWidget->setFixedSize(ICONWIDTH, ICONHEIGHT);
|
}
|
||||||
return itemWidget->grab();
|
case DockPart::SystemPanel: {
|
||||||
}
|
itemWidget->setFixedSize(16, 16);
|
||||||
|
return itemWidget->grab();
|
||||||
|
}
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QIcon();
|
return QIcon();
|
||||||
|
@ -261,7 +261,7 @@ void DockTrayWindow::initUi()
|
|||||||
m_mainBoxLayout->setAlignment(m_toolLineLabel, Qt::AlignCenter);
|
m_mainBoxLayout->setAlignment(m_toolLineLabel, Qt::AlignCenter);
|
||||||
|
|
||||||
WinInfo info;
|
WinInfo info;
|
||||||
info.type = TrayIconType::EXPANDICON;
|
info.type = TrayIconType::ExpandIcon;
|
||||||
m_model->addRow(info);
|
m_model->addRow(info);
|
||||||
m_trayView->openPersistentEditor(m_model->index(0, 0));
|
m_trayView->openPersistentEditor(m_model->index(0, 0));
|
||||||
|
|
||||||
@ -277,11 +277,15 @@ void DockTrayWindow::initConnection()
|
|||||||
connect(m_quickIconWidget, &QuickPluginWindow::itemCountChanged, this, &DockTrayWindow::onResetLayout);
|
connect(m_quickIconWidget, &QuickPluginWindow::itemCountChanged, this, &DockTrayWindow::onResetLayout);
|
||||||
connect(m_trayView, &TrayGridView::requestRemove, this, &DockTrayWindow::onResetLayout);
|
connect(m_trayView, &TrayGridView::requestRemove, this, &DockTrayWindow::onResetLayout);
|
||||||
|
|
||||||
connect(QuickSettingController::instance(), &QuickSettingController::pluginInserted, this, [ this ] (PluginsItemInterface *itemInter, const QuickSettingController::PluginAttribute &pluginClass) {
|
connect(QuickSettingController::instance(), &QuickSettingController::pluginInserted, this, [ this ] (PluginsItemInterface *itemInter, const QuickSettingController::PluginAttribute &pluginAttr) {
|
||||||
if (pluginClass != QuickSettingController::PluginAttribute::Tool)
|
switch (pluginAttr) {
|
||||||
return;
|
case QuickSettingController::PluginAttribute::Tool:
|
||||||
|
// 下方只处理回收站等插件
|
||||||
onItemAdded(itemInter);
|
onItemAdded(itemInter);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(QuickSettingController::instance(), &QuickSettingController::pluginRemoved, this, &DockTrayWindow::onItemRemove);
|
connect(QuickSettingController::instance(), &QuickSettingController::pluginRemoved, this, &DockTrayWindow::onItemRemove);
|
||||||
@ -336,6 +340,7 @@ void DockTrayWindow::onItemRemove(PluginsItemInterface *itemInter)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_toolLayout->removeWidget(pluginItem);
|
m_toolLayout->removeWidget(pluginItem);
|
||||||
|
|
||||||
Q_EMIT requestUpdate();
|
Q_EMIT requestUpdate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
#include "widgets/snitrayitemwidget.h"
|
#include "widgets/snitrayitemwidget.h"
|
||||||
#include "widgets/expandiconwidget.h"
|
#include "widgets/expandiconwidget.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "pluginsiteminterface.h"
|
||||||
|
#include "quicksettingcontroller.h"
|
||||||
|
#include "systempluginitem.h"
|
||||||
|
|
||||||
#include <DGuiApplicationHelper>
|
#include <DGuiApplicationHelper>
|
||||||
|
|
||||||
@ -62,7 +65,7 @@ QWidget *TrayDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem
|
|||||||
quint32 winId = index.data(TrayModel::WinIdRole).value<quint32>();
|
quint32 winId = index.data(TrayModel::WinIdRole).value<quint32>();
|
||||||
|
|
||||||
BaseTrayWidget *trayWidget = nullptr;
|
BaseTrayWidget *trayWidget = nullptr;
|
||||||
if(type == TrayIconType::XEMBED) {
|
if(type == TrayIconType::XEmbed) {
|
||||||
if (Utils::IS_WAYLAND_DISPLAY) {
|
if (Utils::IS_WAYLAND_DISPLAY) {
|
||||||
static Display *display = XOpenDisplay(nullptr);
|
static Display *display = XOpenDisplay(nullptr);
|
||||||
static int screenp = 0;
|
static int screenp = 0;
|
||||||
@ -74,9 +77,9 @@ QWidget *TrayDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem
|
|||||||
const TrayModel *model = qobject_cast<const TrayModel *>(index.model());
|
const TrayModel *model = qobject_cast<const TrayModel *>(index.model());
|
||||||
if (model)
|
if (model)
|
||||||
connect(model, &TrayModel::requestUpdateIcon, trayWidget, &BaseTrayWidget::updateIcon);
|
connect(model, &TrayModel::requestUpdateIcon, trayWidget, &BaseTrayWidget::updateIcon);
|
||||||
} else if (type == TrayIconType::SNI) {
|
} else if (type == TrayIconType::Sni) {
|
||||||
trayWidget = new SNITrayItemWidget(servicePath, parent);
|
trayWidget = new SNITrayItemWidget(servicePath, parent);
|
||||||
} else if (type == TrayIconType::EXPANDICON) {
|
} else if (type == TrayIconType::ExpandIcon) {
|
||||||
ExpandIconWidget *expandWidget = new ExpandIconWidget(parent);
|
ExpandIconWidget *expandWidget = new ExpandIconWidget(parent);
|
||||||
expandWidget->setPositonValue(m_position);
|
expandWidget->setPositonValue(m_position);
|
||||||
connect(expandWidget, &ExpandIconWidget::trayVisbleChanged, this, [ = ](bool visible) {
|
connect(expandWidget, &ExpandIconWidget::trayVisbleChanged, this, [ = ](bool visible) {
|
||||||
@ -84,7 +87,7 @@ QWidget *TrayDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem
|
|||||||
});
|
});
|
||||||
connect(this, &TrayDelegate::requestDrag, this, &TrayDelegate::onRequestDrag);
|
connect(this, &TrayDelegate::requestDrag, this, &TrayDelegate::onRequestDrag);
|
||||||
trayWidget = expandWidget;
|
trayWidget = expandWidget;
|
||||||
} else if (type == TrayIconType::INDICATOR) {
|
} else if (type == TrayIconType::Incicator) {
|
||||||
QString indicateName = key;
|
QString indicateName = key;
|
||||||
int flagIndex = indicateName.indexOf("indicator:");
|
int flagIndex = indicateName.indexOf("indicator:");
|
||||||
if (flagIndex >= 0)
|
if (flagIndex >= 0)
|
||||||
@ -100,6 +103,13 @@ QWidget *TrayDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem
|
|||||||
indicatorWidget->setText(text);
|
indicatorWidget->setText(text);
|
||||||
}
|
}
|
||||||
trayWidget = indicatorWidget;
|
trayWidget = indicatorWidget;
|
||||||
|
} else if (type == TrayIconType::SystemItem) {
|
||||||
|
PluginsItemInterface *pluginInter = (PluginsItemInterface *)(index.data(TrayModel::PluginInterfaceRole).toULongLong());
|
||||||
|
if (pluginInter) {
|
||||||
|
const QString itemKey = QuickSettingController::instance()->itemKey(pluginInter);
|
||||||
|
SystemPluginItem::setDockPostion(m_position);
|
||||||
|
trayWidget = new SystemPluginItem(pluginInter, itemKey, parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trayWidget)
|
if (trayWidget)
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
struct WinInfo;
|
struct WinInfo;
|
||||||
class ExpandIconWidget;
|
class ExpandIconWidget;
|
||||||
class QListView;
|
class QListView;
|
||||||
|
class PluginsItemInterface;
|
||||||
|
|
||||||
class TrayDelegate : public QStyledItemDelegate
|
class TrayDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
|
@ -289,7 +289,7 @@ void TrayGridView::mouseMoveEvent(QMouseEvent *e)
|
|||||||
|
|
||||||
// 如果当前拖动的位置是托盘展开按钮,则不让其拖动
|
// 如果当前拖动的位置是托盘展开按钮,则不让其拖动
|
||||||
TrayIconType iconType = index.data(TrayModel::Role::TypeRole).value<TrayIconType>();
|
TrayIconType iconType = index.data(TrayModel::Role::TypeRole).value<TrayIconType>();
|
||||||
if (iconType == TrayIconType::EXPANDICON)
|
if (iconType == TrayIconType::ExpandIcon)
|
||||||
return DListView::mouseMoveEvent(e);
|
return DListView::mouseMoveEvent(e);
|
||||||
|
|
||||||
if ((qAbs(e->pos().x() - m_dragPos.x()) > m_dragDistance ||
|
if ((qAbs(e->pos().x() - m_dragPos.x()) > m_dragDistance ||
|
||||||
@ -426,7 +426,7 @@ bool TrayGridView::beginDrag(Qt::DropActions supportedActions)
|
|||||||
QModelIndex modelIndex = indexAt(m_dragPos);
|
QModelIndex modelIndex = indexAt(m_dragPos);
|
||||||
TrayIconType trayType = modelIndex.data(TrayModel::Role::TypeRole).value<TrayIconType>();
|
TrayIconType trayType = modelIndex.data(TrayModel::Role::TypeRole).value<TrayIconType>();
|
||||||
// 展开图标不能移动
|
// 展开图标不能移动
|
||||||
if (trayType == TrayIconType::EXPANDICON)
|
if (trayType == TrayIconType::ExpandIcon)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_dropPos = indexRect(modelIndex).center();
|
m_dropPos = indexRect(modelIndex).center();
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include "indicatortrayitem.h"
|
#include "indicatortrayitem.h"
|
||||||
#include "indicatorplugin.h"
|
#include "indicatorplugin.h"
|
||||||
|
#include "quicksettingcontroller.h"
|
||||||
|
#include "pluginsiteminterface.h"
|
||||||
|
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
@ -46,6 +48,19 @@ TrayModel::TrayModel(QListView *view, bool isIconTray, bool hasInputMethod, QObj
|
|||||||
if (isIconTray) {
|
if (isIconTray) {
|
||||||
connect(m_monitor, &TrayMonitor::xEmbedTrayAdded, this, &TrayModel::onXEmbedTrayAdded);
|
connect(m_monitor, &TrayMonitor::xEmbedTrayAdded, this, &TrayModel::onXEmbedTrayAdded);
|
||||||
connect(m_monitor, &TrayMonitor::indicatorFounded, this, &TrayModel::onIndicatorFounded);
|
connect(m_monitor, &TrayMonitor::indicatorFounded, this, &TrayModel::onIndicatorFounded);
|
||||||
|
connect(QuickSettingController::instance(), &QuickSettingController::pluginInserted, this, [ = ](PluginsItemInterface *itemInter, const QuickSettingController::PluginAttribute &pluginAttr) {
|
||||||
|
if (pluginAttr != QuickSettingController::PluginAttribute::System)
|
||||||
|
return;
|
||||||
|
|
||||||
|
systemItemAdded(itemInter);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(QuickSettingController::instance(), &QuickSettingController::pluginRemoved, this, &TrayModel::onSystemItemRemoved);
|
||||||
|
QMetaObject::invokeMethod(this, [ = ] {
|
||||||
|
QList<PluginsItemInterface *> systemPlugins = QuickSettingController::instance()->pluginItems(QuickSettingController::PluginAttribute::System);
|
||||||
|
for (PluginsItemInterface *plugin : systemPlugins)
|
||||||
|
systemItemAdded(plugin);
|
||||||
|
}, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
connect(m_monitor, &TrayMonitor::xEmbedTrayRemoved, this, &TrayModel::onXEmbedTrayRemoved);
|
connect(m_monitor, &TrayMonitor::xEmbedTrayRemoved, this, &TrayModel::onXEmbedTrayRemoved);
|
||||||
connect(m_monitor, &TrayMonitor::requestUpdateIcon, this, &TrayModel::requestUpdateIcon);
|
connect(m_monitor, &TrayMonitor::requestUpdateIcon, this, &TrayModel::requestUpdateIcon);
|
||||||
@ -173,6 +188,8 @@ QVariant TrayModel::data(const QModelIndex &index, int role) const
|
|||||||
return info.winId;
|
return info.winId;
|
||||||
case Role::ServiceRole:
|
case Role::ServiceRole:
|
||||||
return info.servicePath;
|
return info.servicePath;
|
||||||
|
case Role::PluginInterfaceRole:
|
||||||
|
return (qulonglong)(info.pluginInter);
|
||||||
case Role::Blank:
|
case Role::Blank:
|
||||||
return indexDragging(index);
|
return indexDragging(index);
|
||||||
default:
|
default:
|
||||||
@ -202,7 +219,7 @@ bool TrayModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, in
|
|||||||
Q_UNUSED(column)
|
Q_UNUSED(column)
|
||||||
|
|
||||||
TrayIconType iconType = parent.data(TrayModel::Role::TypeRole).value<TrayIconType>();
|
TrayIconType iconType = parent.data(TrayModel::Role::TypeRole).value<TrayIconType>();
|
||||||
if (iconType == TrayIconType::EXPANDICON)
|
if (iconType == TrayIconType::ExpandIcon)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return data->formats().contains(TRAY_DRAG_FALG);
|
return data->formats().contains(TRAY_DRAG_FALG);
|
||||||
@ -243,7 +260,7 @@ void TrayModel::onXEmbedTrayAdded(quint32 winId)
|
|||||||
|
|
||||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
WinInfo info;
|
WinInfo info;
|
||||||
info.type = XEMBED;
|
info.type = XEmbed;
|
||||||
info.key = "wininfo:" + QString::number(winId);
|
info.key = "wininfo:" + QString::number(winId);
|
||||||
info.winId = winId;
|
info.winId = winId;
|
||||||
m_winInfos.append(info);
|
m_winInfos.append(info);
|
||||||
@ -295,6 +312,23 @@ bool TrayModel::isTypeWriting(const QString &servicePath)
|
|||||||
return (appFilePath.startsWith("/usr/bin/fcitx") || appFilePath.endsWith("chinime-qim"));
|
return (appFilePath.startsWith("/usr/bin/fcitx") || appFilePath.endsWith("chinime-qim"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrayModel::systemItemAdded(PluginsItemInterface *itemInter)
|
||||||
|
{
|
||||||
|
for (const WinInfo &info : m_winInfos) {
|
||||||
|
if (info.pluginInter == itemInter)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
|
|
||||||
|
WinInfo info;
|
||||||
|
info.type = SystemItem;
|
||||||
|
info.pluginInter = itemInter;
|
||||||
|
m_winInfos.append(info);
|
||||||
|
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
void TrayModel::onSniTrayAdded(const QString &servicePath)
|
void TrayModel::onSniTrayAdded(const QString &servicePath)
|
||||||
{
|
{
|
||||||
bool typeWriting = isTypeWriting(servicePath);
|
bool typeWriting = isTypeWriting(servicePath);
|
||||||
@ -313,7 +347,7 @@ void TrayModel::onSniTrayAdded(const QString &servicePath)
|
|||||||
|
|
||||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
WinInfo info;
|
WinInfo info;
|
||||||
info.type = SNI;
|
info.type = Sni;
|
||||||
info.key = "sni:" + servicePath;
|
info.key = "sni:" + servicePath;
|
||||||
info.servicePath = servicePath;
|
info.servicePath = servicePath;
|
||||||
info.isTypeWriting = typeWriting; // 是否为输入法
|
info.isTypeWriting = typeWriting; // 是否为输入法
|
||||||
@ -395,7 +429,7 @@ void TrayModel::onIndicatorAdded(const QString &indicatorName)
|
|||||||
|
|
||||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
WinInfo info;
|
WinInfo info;
|
||||||
info.type = INDICATOR;
|
info.type = Incicator;
|
||||||
info.key = itemKey;
|
info.key = itemKey;
|
||||||
m_winInfos.append(info);
|
m_winInfos.append(info);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
@ -407,6 +441,21 @@ void TrayModel::onIndicatorRemoved(const QString &indicatorName)
|
|||||||
removeRow(itemKey);
|
removeRow(itemKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrayModel::onSystemItemRemoved(PluginsItemInterface *itemInter)
|
||||||
|
{
|
||||||
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
|
|
||||||
|
for (const WinInfo &info : m_winInfos) {
|
||||||
|
if (info.pluginInter != itemInter)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
m_winInfos.removeOne(info);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
void TrayModel::removeRow(const QString &itemKey)
|
void TrayModel::removeRow(const QString &itemKey)
|
||||||
{
|
{
|
||||||
for (const WinInfo &info : m_winInfos) {
|
for (const WinInfo &info : m_winInfos) {
|
||||||
|
@ -28,13 +28,15 @@
|
|||||||
class TrayMonitor;
|
class TrayMonitor;
|
||||||
class IndicatorPlugin;
|
class IndicatorPlugin;
|
||||||
class IndicatorTrayItem;
|
class IndicatorTrayItem;
|
||||||
|
class PluginsItemInterface;
|
||||||
|
|
||||||
enum TrayIconType {
|
enum TrayIconType {
|
||||||
UNKNOW,
|
UnKnow,
|
||||||
XEMBED,
|
XEmbed,
|
||||||
SNI,
|
Sni,
|
||||||
INDICATOR,
|
Incicator,
|
||||||
EXPANDICON
|
ExpandIcon,
|
||||||
|
SystemItem
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WinInfo {
|
struct WinInfo {
|
||||||
@ -43,19 +45,22 @@ struct WinInfo {
|
|||||||
quint32 winId;
|
quint32 winId;
|
||||||
QString servicePath;
|
QString servicePath;
|
||||||
bool isTypeWriting;
|
bool isTypeWriting;
|
||||||
|
PluginsItemInterface *pluginInter;
|
||||||
|
|
||||||
WinInfo() : type(UNKNOW)
|
WinInfo() : type(UnKnow)
|
||||||
, key(QString())
|
, key(QString())
|
||||||
, winId(0)
|
, winId(0)
|
||||||
, servicePath(QString())
|
, servicePath(QString())
|
||||||
, isTypeWriting(false) {}
|
, isTypeWriting(false)
|
||||||
|
, pluginInter(nullptr) {}
|
||||||
|
|
||||||
bool operator==(const WinInfo &other) {
|
bool operator==(const WinInfo &other) {
|
||||||
return this->type == other.type
|
return this->type == other.type
|
||||||
&& this->key == other.key
|
&& this->key == other.key
|
||||||
&& this->winId == other.winId
|
&& this->winId == other.winId
|
||||||
&& this->servicePath == other.servicePath
|
&& this->servicePath == other.servicePath
|
||||||
&& this->isTypeWriting == other.isTypeWriting;
|
&& this->isTypeWriting == other.isTypeWriting
|
||||||
|
&& this->pluginInter == other.pluginInter;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,6 +74,7 @@ public:
|
|||||||
KeyRole,
|
KeyRole,
|
||||||
WinIdRole,
|
WinIdRole,
|
||||||
ServiceRole,
|
ServiceRole,
|
||||||
|
PluginInterfaceRole,
|
||||||
Blank
|
Blank
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -113,11 +119,15 @@ private Q_SLOTS:
|
|||||||
void onIndicatorAdded(const QString &indicatorName);
|
void onIndicatorAdded(const QString &indicatorName);
|
||||||
void onIndicatorRemoved(const QString &indicatorName);
|
void onIndicatorRemoved(const QString &indicatorName);
|
||||||
|
|
||||||
|
void onSystemItemRemoved(PluginsItemInterface *itemInter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool exist(const QString &itemKey);
|
bool exist(const QString &itemKey);
|
||||||
QString fileNameByServiceName(const QString &serviceName);
|
QString fileNameByServiceName(const QString &serviceName);
|
||||||
bool isTypeWriting(const QString &servicePath);
|
bool isTypeWriting(const QString &servicePath);
|
||||||
|
|
||||||
|
void systemItemAdded(PluginsItemInterface *itemInter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE;
|
QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE;
|
||||||
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
||||||
|
@ -231,7 +231,7 @@ void TrayManagerWindow::initUi()
|
|||||||
m_splitLine->setPalette(pal);
|
m_splitLine->setPalette(pal);
|
||||||
|
|
||||||
WinInfo info;
|
WinInfo info;
|
||||||
info.type = TrayIconType::EXPANDICON;
|
info.type = TrayIconType::ExpandIcon;
|
||||||
m_model->addRow(info);
|
m_model->addRow(info);
|
||||||
m_trayView->openPersistentEditor(m_model->index(0, 0));
|
m_trayView->openPersistentEditor(m_model->index(0, 0));
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@ namespace Dock {
|
|||||||
#define PLUGIN_ICON_MAX_SIZE 20
|
#define PLUGIN_ICON_MAX_SIZE 20
|
||||||
#define PLUGIN_ITEM_WIDTH 300
|
#define PLUGIN_ITEM_WIDTH 300
|
||||||
|
|
||||||
|
#define QUICK_PATH "/plugins/quick-trays"
|
||||||
|
#define PLUGIN_PATH "/plugins"
|
||||||
|
#define TRAY_PATH "/plugins/system-trays"
|
||||||
|
|
||||||
// 需求变更成插件图标始终保持20x20,但16x16的资源还在。所以暂时保留此宏
|
// 需求变更成插件图标始终保持20x20,但16x16的资源还在。所以暂时保留此宏
|
||||||
#define PLUGIN_ICON_MIN_SIZE 20
|
#define PLUGIN_ICON_MIN_SIZE 20
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
|||||||
|
|
||||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||||
add_library(${PLUGIN_NAME} SHARED ${SRCS} resources/airplane_mode.qrc)
|
add_library(${PLUGIN_NAME} SHARED ${SRCS} resources/airplane_mode.qrc)
|
||||||
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../system-trays)
|
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ..)
|
||||||
|
|
||||||
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
||||||
${QGSettings_INCLUDE_DIRS}
|
${QGSettings_INCLUDE_DIRS}
|
||||||
@ -45,4 +45,4 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE
|
|||||||
${Qt5Widgets_LIBRARIES}
|
${Qt5Widgets_LIBRARIES}
|
||||||
${Qt5Svg_LIBRARIES})
|
${Qt5Svg_LIBRARIES})
|
||||||
|
|
||||||
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/system-trays)
|
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins)
|
||||||
|
@ -37,5 +37,5 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE
|
|||||||
${Qt5DBus_LIBRARIES}
|
${Qt5DBus_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/system-trays/)
|
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/)
|
||||||
install(FILES ./keybord_layout.json DESTINATION /etc/dde-dock/indicator)
|
install(FILES ./keybord_layout.json DESTINATION /etc/dde-dock/indicator)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user