Skip to content

Commit

Permalink
chore: merge branch 'origin/main' into Orochimarufan-qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
keshavbhatt committed Nov 1, 2024
2 parents a40d1b8 + dde6e02 commit 7b8bc22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,17 +931,16 @@ void MainWindow::createWebPage(bool offTheRecord) {
}

void MainWindow::setNotificationPresenter(QWebEngineProfile *profile) {
auto *op = m_webEngine->findChild<NotificationPopup *>("engineNotifier");
if (op != nullptr) {
op->close();
op->deleteLater();

if (m_webengine_notifier_popup != nullptr) {
m_webengine_notifier_popup->close();
m_webengine_notifier_popup->deleteLater();
}

auto popup = new NotificationPopup(m_webEngine);
popup->setObjectName("engineNotifier");
m_webengine_notifier_popup = new NotificationPopup(m_webEngine);

connect(popup, &NotificationPopup::notification_clicked, this,
[this]() { notificationClicked(); });
connect(m_webengine_notifier_popup, &NotificationPopup::notification_clicked,
this, [this]() { notificationClicked(); });

profile->setNotificationPresenter(
[&](std::unique_ptr<QWebEngineNotification> notification) {
Expand Down Expand Up @@ -987,7 +986,12 @@ void MainWindow::setNotificationPresenter(QWebEngineProfile *profile) {
return;
}

popup->setMinimumWidth(300);
if (!m_webengine_notifier_popup) {
qWarning() << "Popup is not available!";
return;
}

m_webengine_notifier_popup->setMinimumWidth(300);
QScreen *screen = QGuiApplication::primaryScreen();
if (!screen) {
const auto screens = QGuiApplication::screens();
Expand All @@ -998,7 +1002,7 @@ void MainWindow::setNotificationPresenter(QWebEngineProfile *profile) {
return;
}
}
popup->present(screen, notification);
m_webengine_notifier_popup->present(screen, notification);
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ protected slots:
AutoLockEventFilter *m_autoLockEventFilter = nullptr;
Qt::WindowStates windowStateBeforeFullScreen;

QString userDesktopEnvironment = Utils::detectDesktopEnvironment();
QString userDesktopEnvironment = Utils::detectDesktopEnvironment();

void notificationClicked();
NotificationPopup *m_webengine_notifier_popup = nullptr;
private slots:
void iconActivated(QSystemTrayIcon::ActivationReason reason);
void toggleMute(const bool &checked);
Expand Down

0 comments on commit 7b8bc22

Please sign in to comment.