Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/loader/pluginitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ QWidget *PluginItem::itemPopupApplet()
pluginPopup->setPluginId(m_pluginsItemInterface->pluginName());
pluginPopup->setItemKey(m_itemKey);
pluginPopup->setPopupType(Plugin::PluginPopup::PopupTypePanel);
Q_EMIT appletOpened(popup);
return popup;
}
return nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/loader/pluginitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class PluginItem : public QWidget
signals:
void recvMouseEvent(int type);
void sigRequestShutdown(const QString &type);
void appletOpened(QWidget *applet);

protected:
void mousePressEvent(QMouseEvent *e) override;
Expand Down
48 changes: 46 additions & 2 deletions src/loader/widgetplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ void WidgetPlugin::requestSetAppletVisible(PluginsItemInterface * const itemInte
return;
}

trackAppletWidget(appletWidget);

updateDockContainerState(itemInter, false);
if (Plugin::PluginPopup::contains(appletWidget->windowHandle())) {
Plugin::PluginPopup::remove(appletWidget->windowHandle());
Expand Down Expand Up @@ -377,9 +379,50 @@ void WidgetPlugin::onDockEventMessageArrived(const QString &message)
}

auto pluginsItemInterfaceV2 = dynamic_cast<PluginsItemInterfaceV2 *>(m_pluginsItemInterface);
if (pluginsItemInterfaceV2) {
pluginsItemInterfaceV2->message(message);
if (!pluginsItemInterfaceV2)
return;

if (getRootObj(message).value(Dock::MSG_TYPE).toString() == Dock::MSG_SET_APPLET_MIN_HEIGHT) {
if (m_appletWidget && m_appletWidget->isVisible()) {
m_pendingAppletMinHeightMsg = message;
return;
}
m_pendingAppletMinHeightMsg.clear();
}

pluginsItemInterfaceV2->message(message);
}

void WidgetPlugin::trackAppletWidget(QWidget *applet)
{
if (!applet || m_appletWidget == applet)
return;

if (m_appletWidget)
m_appletWidget->removeEventFilter(this);

m_appletWidget = applet;
m_appletWidget->installEventFilter(this);
}

void WidgetPlugin::flushPendingAppletMinHeight()
{
if (m_pendingAppletMinHeightMsg.isEmpty())
return;

const QString message = m_pendingAppletMinHeightMsg;
m_pendingAppletMinHeightMsg.clear();

if (auto pluginsItemInterfaceV2 = dynamic_cast<PluginsItemInterfaceV2 *>(m_pluginsItemInterface))
pluginsItemInterfaceV2->message(message);
}

bool WidgetPlugin::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_appletWidget && event->type() == QEvent::Show)
flushPendingAppletMinHeight();

return QObject::eventFilter(watched, event);
}

void WidgetPlugin::setFashionMode(bool fashionMode)
Expand Down Expand Up @@ -512,6 +555,7 @@ void WidgetPlugin::initConnections(Plugin::EmbedPlugin *plugin, PluginItem *plug
connect(plugin, &Plugin::EmbedPlugin::dockColorThemeChanged, this, &WidgetPlugin::onDockColorThemeChanged, Qt::UniqueConnection);
connect(plugin, &Plugin::EmbedPlugin::dockPositionChanged, this, &WidgetPlugin::onDockPositionChanged, Qt::UniqueConnection);
connect(plugin, &Plugin::EmbedPlugin::eventMessage, this, &WidgetPlugin::onDockEventMessageArrived, Qt::UniqueConnection);
connect(pluginItem, &PluginItem::appletOpened, this, &WidgetPlugin::trackAppletWidget, Qt::UniqueConnection);

connect(plugin, &Plugin::EmbedPlugin::eventGeometry, this, [this, plugin, pluginItem](const QRect &geometry) {
if (plugin->pluginType() == Plugin::EmbedPlugin::Quick) {
Expand Down
8 changes: 8 additions & 0 deletions src/loader/widgetplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
#include <QMenu>
#include <QLabel>
#include <QObject>
#include <QPointer>

Check warning on line 14 in src/loader/widgetplugin.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPointer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWindow>

Check warning on line 15 in src/loader/widgetplugin.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScopedPointer>

Check warning on line 16 in src/loader/widgetplugin.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QScopedPointer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPointer>

Check warning on line 17 in src/loader/widgetplugin.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPointer> not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace Plugin {
class EmbedPlugin;
Expand Down Expand Up @@ -47,6 +48,9 @@
void onDockDisplayModeChanged(uint32_t displayMode);
void onDockEventMessageArrived(const QString &message);

protected:
bool eventFilter(QObject *watched, QEvent *event) override;

private:
Plugin::EmbedPlugin* getPlugin(QWidget*);
void initConnections(Plugin::EmbedPlugin *plugin, PluginItem *pluginItem);
Expand All @@ -56,6 +60,8 @@
bool bindCardPluginSurface(PluginsItemInterface *itemInter);
int getPluginFlags();
void pluginUpdateDockSize(const QSize &size);
void trackAppletWidget(QWidget *applet);
void flushPendingAppletMinHeight();

static QString messageCallback(PluginsItemInterfaceV2 *, const QString &);
static bool supportFlag(PluginsItemInterfaceV2 *pluginV2);
Expand All @@ -68,6 +74,8 @@
QPointer<CardPluginItem> m_cardItem;
bool m_fashionMode = false;
bool m_itemAdded = false;
QPointer<QWidget> m_appletWidget;
QString m_pendingAppletMinHeightMsg;
};

}
Loading