Keep notification independent of main window minimization
This commit is contained in:
1 parent
2caa653f02
commit
bc42df12f5
3 files changed
+26
-10
No files matched your search
@@ -13,8 +13,8 @@
|
||||
#include <QHideEvent>
|
||||
#include <QCloseEvent>
|
||||
|
||||
MessageNotification::MessageNotification(QWidget* parent)
|
||||
: QWidget(parent, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus)
|
||||
MessageNotification::MessageNotification()
|
||||
: QWidget(nullptr, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus)
|
||||
, m_activity(new UserActivityMonitor(this))
|
||||
{
|
||||
setObjectName("messageNotification");
|
||||
@@ -67,9 +67,10 @@ MessageNotification::~MessageNotification() {
|
||||
qPrintable(m_target), int(isVisible()), int(m_hideTimer.isActive()));
|
||||
}
|
||||
|
||||
void MessageNotification::showMessage(const QString& target, const QString& sender, const QString& channel, const QRect& trayGeometry) {
|
||||
void MessageNotification::showMessage(const QString& target, const QString& sender, const QString& channel,
|
||||
const QRect& trayGeometry, QScreen* preferredScreen) {
|
||||
QScreen* screen = trayGeometry.isEmpty() ? nullptr : QGuiApplication::screenAt(trayGeometry.center());
|
||||
if (!screen && parentWidget()) screen = parentWidget()->screen();
|
||||
if (!screen) screen = preferredScreen;
|
||||
if (!screen) screen = QGuiApplication::primaryScreen();
|
||||
if (!screen || screen->availableGeometry().isEmpty()) {
|
||||
GUI_ERROR("notification: no available screen target=%s", qPrintable(target));
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
#include <QTimer>
|
||||
|
||||
class QLabel;
|
||||
class QScreen;
|
||||
class UserActivityMonitor;
|
||||
|
||||
class MessageNotification : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MessageNotification(QWidget* parent = nullptr);
|
||||
MessageNotification();
|
||||
~MessageNotification() override;
|
||||
void showMessage(const QString& target, const QString& sender, const QString& channel, const QRect& trayGeometry);
|
||||
void showMessage(const QString& target, const QString& sender, const QString& channel,
|
||||
const QRect& trayGeometry, QScreen* preferredScreen = nullptr);
|
||||
void dismiss(const char* reason);
|
||||
|
||||
signals:
|
||||
|
||||
Reference in new issue
Block a user