Skip to content

Commit

Permalink
feat: Allow plugins sending close quick panel requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchieMeng committed Oct 15, 2024
1 parent 00e44d5 commit 3857259
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 25 deletions.
62 changes: 37 additions & 25 deletions src/loader/widgetplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,36 +218,48 @@ void WidgetPlugin::requestRefreshWindowVisible(PluginsItemInterface * const item

void WidgetPlugin::requestSetAppletVisible(PluginsItemInterface * const itemInter, const QString &itemKey, const bool visible)
{
if (!visible) return;

QWidget* appletWidget = itemInter->itemPopupApplet(itemKey);
if (!appletWidget) {
qWarning() << itemKey << " plugin applet popup is null";
return;
}
qDebug() << "requestSetAppletVisible was called";

if (!visible) {
if (appletWidget == nullptr || !appletWidget->isVisible()) {
qDebug() << "send hide quick panel message";
Plugin::EmbedPlugin *plugin = Plugin::EmbedPlugin::get(itemInter->itemWidget(itemKey)->window()->windowHandle());
if (plugin) {
emit plugin->closeQuickPanel();
} else {
qWarning() << "plugin is null";
}
}
} else {
if (!appletWidget) {
qWarning() << itemKey << " plugin applet popup is null";
return;
}

updateDockContainerState(itemInter, false);
if (Plugin::PluginPopup::contains(appletWidget->windowHandle())) {
Plugin::PluginPopup::remove(appletWidget->windowHandle());
}
updateDockContainerState(itemInter, false);
if (Plugin::PluginPopup::contains(appletWidget->windowHandle())) {
Plugin::PluginPopup::remove(appletWidget->windowHandle());
}

appletWidget->winId();
appletWidget->setParent(nullptr);
appletWidget->setAttribute(Qt::WA_TranslucentBackground);
appletWidget->winId();
appletWidget->setParent(nullptr);
appletWidget->setAttribute(Qt::WA_TranslucentBackground);

bool hasCreated = Plugin::PluginPopup::contains(appletWidget->windowHandle());
auto pluginPopup = Plugin::PluginPopup::get(appletWidget->windowHandle());
if (!hasCreated) {
connect(pluginPopup, &Plugin::PluginPopup::eventGeometry, appletWidget, [appletWidget](const QRect &geometry) {
appletWidget->setFixedSize(geometry.size());
appletWidget->update();
});
}

bool hasCreated = Plugin::PluginPopup::contains(appletWidget->windowHandle());
auto pluginPopup = Plugin::PluginPopup::get(appletWidget->windowHandle());
if (!hasCreated) {
connect(pluginPopup, &Plugin::PluginPopup::eventGeometry, appletWidget, [appletWidget](const QRect &geometry) {
appletWidget->setFixedSize(geometry.size());
appletWidget->update();
});
pluginPopup->setPluginId(m_pluginsItemInterface->pluginName());
pluginPopup->setItemKey(itemKey);
pluginPopup->setPopupType(Plugin::PluginPopup::PopupTypeEmbed);
appletWidget->show();
}

pluginPopup->setPluginId(m_pluginsItemInterface->pluginName());
pluginPopup->setItemKey(itemKey);
pluginPopup->setPopupType(Plugin::PluginPopup::PopupTypeEmbed);
appletWidget->show();
}

void WidgetPlugin::saveValue(PluginsItemInterface * const itemInter, const QString &key, const QVariant &value)
Expand Down
1 change: 1 addition & 0 deletions src/protocol/plugin-manager-v1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,6 @@
<request name="dcc_icon" >
<arg name="type" type="string"/>
</request>
<request name="close_quick_panel" />
</interface>
</protocol>
1 change: 1 addition & 0 deletions src/tray-wayland-integration/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class Q_DECL_EXPORT EmbedPlugin : public QObject
void requestMessage(const QString &msg);
void pluginRecvMouseEvent(int type);
void rawGlobalPosChanged();
void closeQuickPanel();

private:
explicit EmbedPlugin(QWindow* window);
Expand Down
5 changes: 5 additions & 0 deletions src/tray-wayland-integration/pluginsurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ PluginSurface::PluginSurface(PluginManager *manager, QtWaylandClient::QWaylandWi
connect(m_plugin, &EmbedPlugin::pluginRecvMouseEvent, this, [this] (int type){
mouse_event(type);
});

connect(m_plugin, &EmbedPlugin::closeQuickPanel, this, [this] {
qDebug() << "send close popup signal";
close_quick_panel();
});
}

PluginSurface::~PluginSurface()
Expand Down

0 comments on commit 3857259

Please sign in to comment.