From 753da8b1d337ddedaeaf34c829ffa0157ef7cfe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20J=C3=BCrgens?= Date: Mon, 29 Aug 2022 14:23:00 +0200 Subject: [PATCH] automatically detect if kf5notifications is installed --- CMakeLists.txt | 9 ++++----- src/mainwindow.cpp | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e9fae2..41df0fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,10 +18,9 @@ find_package(Qt5 CONFIG REQUIRED COMPONENTS WebEngineWidgets ) -option(KF5NOTIFICATIONS "Use KF5Notifications for enhanced system notifications" ON) -if(KF5NOTIFICATIONS) - add_definitions( -DKF5NOTIFICATIONS ) - find_package(KF5Notifications) +find_package(KF5Notifications) +if(KF5Notifications_FOUND) + add_definitions( -DKNOTIFICATIONS ) endif() set(discord-screenaudio_SRC @@ -59,7 +58,7 @@ add_executable(discord-screenaudio ${discord-screenaudio_SRC}) target_link_libraries(discord-screenaudio Qt5::Widgets Qt5::WebEngineWidgets rohrkabel) -if(KF5NOTIFICATIONS) +if(KF5Notifications_FOUND) target_link_libraries(discord-screenaudio KF5::Notifications) install(FILES assets/discord-screenaudio.notifyrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/knotifications5) endif() diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a7e5444..c44e458 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,7 +1,7 @@ #include "mainwindow.h" #include "virtmic.h" -#ifdef KF5NOTIFICATIONS +#ifdef KNOTIFICATIONS #include #endif @@ -36,7 +36,7 @@ void MainWindow::setupWebView() { m_webView = new QWebEngineView(this); m_webView->setPage(page); -#ifdef KF5NOTIFICATIONS +#ifdef KNOTIFICATIONS QWebEngineProfile::defaultProfile()->setNotificationPresenter( [&](std::unique_ptr notificationInfo) { KNotification *notification = new KNotification("discordNotification");