Skip to content
Draft
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
35 changes: 21 additions & 14 deletions panels/dock/pluginmanagerextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,18 @@ void PluginPopup::plugin_popup_set_cursor(Resource *resource, int32_t cursor_sha
PluginManager::PluginManager(QWaylandCompositor *compositor)
: QWaylandCompositorExtensionTemplate(compositor)
{
m_themeNotifyTimer = new QTimer(this);
m_themeNotifyTimer->setSingleShot(true);
m_themeNotifyTimer->setInterval(0);
connect(m_themeNotifyTimer, &QTimer::timeout, this, [this]() {
auto theme = DGuiApplicationHelper::instance()->applicationTheme();
foreachPluginSurface([this, theme](Resource *source) {
send_color_theme_changed(source->handle, m_dockColorTheme);
send_theme_changed(source->handle, theme->themeName(), theme->iconThemeName());
send_active_color_changed(source->handle, theme->activeColor().name(), theme->darkActiveColor().name());
});
});

auto theme = DGuiApplicationHelper::instance()->applicationTheme();
QObject::connect(theme, &DPlatformTheme::fontNameChanged, this, &PluginManager::onFontChanged);
QObject::connect(theme, &DPlatformTheme::fontPointSizeChanged, this, &PluginManager::onFontChanged);
Expand Down Expand Up @@ -609,12 +621,7 @@ void PluginManager::setDockColorTheme(uint32_t type)
return;

m_dockColorTheme = type;
foreach (PluginSurface *plugin, m_pluginSurfaces) {
Resource *target = resourceMap().value(plugin->surface()->waylandClient());
if (target) {
send_color_theme_changed(target->handle, m_dockColorTheme);
}
}
scheduleThemeNotify();
}

void PluginManager::setEmbedPanelMinHeight(int height)
Expand Down Expand Up @@ -824,10 +831,7 @@ void PluginManager::onFontChanged()

void PluginManager::onActiveColorChanged()
{
foreachPluginSurface([this](Resource *source) {
auto theme = DGuiApplicationHelper::instance()->applicationTheme();
send_active_color_changed(source->handle, theme->activeColor().name(), theme->darkActiveColor().name());
});
scheduleThemeNotify();
}

PluginSurface* PluginManager::findPluginSurface(const QString &pluginId, const QString &itemKey) const
Expand All @@ -842,10 +846,7 @@ PluginSurface* PluginManager::findPluginSurface(const QString &pluginId, const Q

void PluginManager::onThemeChanged()
{
foreachPluginSurface([this](Resource *source) {
auto theme = DGuiApplicationHelper::instance()->applicationTheme();
send_theme_changed(source->handle, theme->themeName(), theme->iconThemeName());
});
scheduleThemeNotify();
}

void PluginManager::foreachPluginSurface(PluginSurfaceCallback callback)
Expand All @@ -858,6 +859,12 @@ void PluginManager::foreachPluginSurface(PluginSurfaceCallback callback)
}
}

void PluginManager::scheduleThemeNotify()
{
if (m_themeNotifyTimer)
m_themeNotifyTimer->start();
}

QString PluginManager::dockSizeMsg() const
{
if (m_dockSize.isEmpty())
Expand Down
3 changes: 3 additions & 0 deletions panels/dock/pluginmanagerextension_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#pragma once

#include <QMap>

Check warning on line 7 in panels/dock/pluginmanagerextension_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 8 in panels/dock/pluginmanagerextension_p.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 <QTimer>

Check warning on line 9 in panels/dock/pluginmanagerextension_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 10 in panels/dock/pluginmanagerextension_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQuickWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandCompositor/QWaylandCompositor>

Check warning on line 11 in panels/dock/pluginmanagerextension_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtWaylandCompositor/QWaylandCompositor> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandCompositor/QWaylandQuickExtension>

Check warning on line 12 in panels/dock/pluginmanagerextension_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtWaylandCompositor/QWaylandQuickExtension> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandCompositor/QWaylandResource>
#include <QtWaylandCompositor/QWaylandSeat>
#include <QtWaylandCompositor/QWaylandShellSurfaceTemplate>
Expand Down Expand Up @@ -128,6 +129,7 @@
QString popupMinHeightMsg() const;
using PluginSurfaceCallback = std::function<void(Resource *)>;
void foreachPluginSurface(PluginSurfaceCallback callback);
void scheduleThemeNotify();
PluginSurface* findPluginSurface(const QString &pluginId, const QString &itemKey) const;

private:
Expand All @@ -146,6 +148,7 @@
// Map of pending XEmbed callbacks: wid -> callback info
// Supports multiple concurrent requests from different clients
QMap<uint32_t, PendingXEmbedCallback> m_pendingXEmbedCallbacks;
QTimer *m_themeNotifyTimer = nullptr;
};

class PluginSurface : public QWaylandShellSurfaceTemplate<PluginSurface>, public QtWaylandServer::plugin
Expand Down
Loading