mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
Notification fix :
try fix for non showing notification on Windows add more debug for non showing notification and try hack fix mac notification #LINQT-2441
This commit is contained in:
parent
9aa5e1d8b3
commit
361a8f05bd
4 changed files with 20 additions and 20 deletions
|
|
@ -1596,10 +1596,6 @@ bool App::event(QEvent *event) {
|
|||
}
|
||||
receivedMessage(0, url.toLocal8Bit());
|
||||
} else if (event->type() == QEvent::ApplicationStateChange) {
|
||||
auto state = static_cast<QApplicationStateChangeEvent *>(event);
|
||||
if (state->applicationState() == Qt::ApplicationActive) {
|
||||
Utils::smartShowWindow(getLastActiveWindow());
|
||||
}
|
||||
if (getAccountList()) {
|
||||
for (int i = 0; i < getAccountList()->rowCount(); ++i) {
|
||||
auto accountCore = getAccountList()->getAt<AccountCore>(i);
|
||||
|
|
|
|||
|
|
@ -142,11 +142,10 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
|||
bool showAsTool = false;
|
||||
#ifdef Q_OS_MACOS
|
||||
for (auto w : QGuiApplication::topLevelWindows()) {
|
||||
if ((w->windowState() & Qt::WindowFullScreen) == Qt::WindowFullScreen) {
|
||||
if (w->visibility() == QWindow::FullScreen) {
|
||||
showAsTool = true;
|
||||
w->raise(); // Used to get focus on Mac (On Mac, A Tool is hidden if the app has not focus and the only
|
||||
// way to rid it is to use Widget Attributes(Qt::WA_MacAlwaysShowToolWindow) that is not
|
||||
// available)
|
||||
w->raise(); // Used to get focus on Mac (On Mac, A Tool is hidden if the app has not focus and the
|
||||
// only way to rid it is to use Widget Attributes(Qt::WA_MacAlwaysShowToolWindow) that is not available)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -160,7 +159,7 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
|||
const QUrl url(QString(NotificationsPath) + Notifier::Notifications[type].filename);
|
||||
QObject::connect(
|
||||
engine, &QQmlApplicationEngine::objectCreated, this,
|
||||
[this, url, screen, engine, type, data](QObject *obj, const QUrl &objUrl) {
|
||||
[this, url, screen, engine, type, data, showAsTool](QObject *obj, const QUrl &objUrl) {
|
||||
if (!obj && url == objUrl) {
|
||||
lCritical() << log().arg("%1 couldn't be load.").arg(url.toString());
|
||||
engine->deleteLater();
|
||||
|
|
@ -172,6 +171,13 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
|||
window->setParent(nullptr);
|
||||
window->setProperty(NotificationPropertyData, data);
|
||||
window->setScreen(screen);
|
||||
// Don't use Popup for flags : it could lead to error in geometry. On Mac, Using Tool ensure
|
||||
// to have the Window on Top and fullscreen independant
|
||||
window->setFlags((showAsTool ? Qt::Tool : Qt::WindowStaysOnTopHint) |
|
||||
Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
|
||||
#ifdef Q_OS_LINUX
|
||||
window->setFlag(Qt::WindowDoesNotAcceptFocus);
|
||||
#endif
|
||||
// for (auto it = data.begin(); it != data.end(); ++it)
|
||||
// window->setProperty(it.key().toLatin1(), it.value());
|
||||
const int timeout = Notifications[type].getTimeout() * 1000;
|
||||
|
|
@ -210,7 +216,7 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
|||
QObject::connect(window, &QQuickWindow::heightChanged, window, [this](int height) {
|
||||
lInfo() << log().arg("Notification height changed") << height;
|
||||
});
|
||||
lInfo() << QStringLiteral("Create notification:") << QVariant::fromValue(window);
|
||||
lInfo() << QStringLiteral("Create notification:") << window;
|
||||
showNotification(window, timeout);
|
||||
}
|
||||
}
|
||||
|
|
@ -236,6 +242,7 @@ void Notifier::showNotification(QQuickWindow *notification, int timeout) {
|
|||
notification->setProperty(NotificationPropertyTimer, QVariant::fromValue(timer));
|
||||
#ifdef Q_OS_WIN
|
||||
QObject::connect(App::getInstance(), &App::sessionUnlocked, notification, [this, notification] {
|
||||
if (!notification) return;
|
||||
lInfo() << log().arg("Windows : screen unlocked, force raising notification");
|
||||
notification->hide();
|
||||
notification->showNormal();
|
||||
|
|
@ -265,7 +272,7 @@ void Notifier::showNotification(QQuickWindow *notification, int timeout) {
|
|||
void Notifier::deleteNotificationOnTimeout(QVariant notification) {
|
||||
#ifdef Q_OS_MACOS
|
||||
for (auto w : QGuiApplication::topLevelWindows()) {
|
||||
if ((w->windowState() & Qt::WindowFullScreen) == Qt::WindowFullScreen) {
|
||||
if (w->visibility() == QWindow::FullScreen) {
|
||||
w->requestActivate(); // Used to get focus on fullscreens on Mac in order to avoid screen switching.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,9 +279,10 @@ VariantObject *Utils::haveAccount() {
|
|||
|
||||
void Utils::smartShowWindow(QQuickWindow *window) {
|
||||
if (!window) return;
|
||||
// if (window->visibility() == QWindow::Maximized) // Avoid to change visibility mode
|
||||
// window->showMaximized();
|
||||
lInfo() << "[Utils] : show window" << window;
|
||||
if (window->visibility() == QWindow::Maximized) // Avoid to change visibility mode
|
||||
window->showMaximized();
|
||||
else if (window->visibility() == QWindow::FullScreen) // Avoid to change visibility mode
|
||||
window->showFullScreen();
|
||||
window->show();
|
||||
App::getInstance()->setLastActiveWindow(window);
|
||||
lInfo() << "[Utils] : raise window" << window;
|
||||
|
|
@ -2224,4 +2225,4 @@ bool Utils::stringMatchFormat(QString toMatch, QRegularExpression regExp) {
|
|||
void Utils::forceCrash() {
|
||||
lInfo() << "throwing segmentation fault for debug";
|
||||
raise(SIGSEGV);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,14 +37,10 @@ Window {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
objectName: '__internalWindow'
|
||||
property bool showAsTool : false
|
||||
// Don't use Popup for flags : it could lead to error in geometry. On Mac, Using Tool ensure to have the Window on Top and fullscreen independant
|
||||
// flags: Qt.WindowDoesNotAcceptFocus | Qt.BypassWindowManagerHint | (showAsTool?Qt.Tool:Qt.WindowStaysOnTopHint) | Qt.Window | Qt.FramelessWindowHint;
|
||||
flags: Qt.SplashScreen | Qt.WindowDoesNotAcceptFocus | Qt.WindowStaysOnTopHint //| Qt.FramelessWindowHint
|
||||
opacity: 1.0
|
||||
transientParent: null
|
||||
height: _content[0] != null ? _content[0].height : 0
|
||||
width: _content[0] != null ? _content[0].width : 0
|
||||
|
||||
Item {
|
||||
id: content
|
||||
anchors.fill:parent
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue