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