Set associated window for tray icon
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include "trayicon_sni.h"
|
||||
#include <KWindowSystem>
|
||||
|
||||
#include "windowcontroller.h"
|
||||
|
||||
TrayIcon::TrayIcon(QObject *parent)
|
||||
: KStatusNotifierItem(parent)
|
||||
{
|
||||
@@ -13,6 +15,12 @@ TrayIcon::TrayIcon(QObject *parent)
|
||||
KWindowSystem::setCurrentXdgActivationToken(providedToken());
|
||||
Q_EMIT showWindow();
|
||||
});
|
||||
|
||||
connect(&WindowController::instance(), &WindowController::windowChanged, this, [this] {
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
setAssociatedWindow(WindowController::instance().window());
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
void TrayIcon::show()
|
||||
|
||||
@@ -24,6 +24,13 @@ WindowController &WindowController::instance()
|
||||
void WindowController::setWindow(QWindow *window)
|
||||
{
|
||||
m_window = window;
|
||||
|
||||
Q_EMIT windowChanged();
|
||||
}
|
||||
|
||||
QWindow *WindowController::window() const
|
||||
{
|
||||
return m_window;
|
||||
}
|
||||
|
||||
void WindowController::restoreGeometry()
|
||||
|
||||
@@ -14,11 +14,15 @@ public:
|
||||
static WindowController &instance();
|
||||
|
||||
void setWindow(QWindow *window);
|
||||
QWindow *window() const;
|
||||
|
||||
void restoreGeometry();
|
||||
void saveGeometry();
|
||||
void showAndRaiseWindow(const QString &startupId);
|
||||
|
||||
Q_SIGNALS:
|
||||
void windowChanged();
|
||||
|
||||
private:
|
||||
WindowController() = default;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user