From d68797cebb2a2fdbc6df7722ac01ced0640043b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20J=C3=BCrgens?= Date: Fri, 29 Jul 2022 16:31:04 +0200 Subject: [PATCH] make KF5Notifications optional --- CMakeLists.txt | 14 +++++++++++--- src/mainwindow.cpp | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 441ae56..528dacb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,11 @@ find_package(Qt5 CONFIG REQUIRED COMPONENTS WebEngineWidgets ) -find_package(KF5Notifications) +option(KF5NOTIFICATIONS "Use KF5Notifications for enhanced system notifications" ON) +if(KF5NOTIFICATIONS) + add_definitions( -DKF5NOTIFICATIONS ) + find_package(KF5Notifications) +endif() set(discord-screenaudio_SRC src/main.cpp @@ -52,11 +56,15 @@ add_subdirectory(submodules/rohrkabel) add_executable(discord-screenaudio ${discord-screenaudio_SRC}) -target_link_libraries(discord-screenaudio Qt5::Widgets Qt5::WebEngineWidgets KF5::Notifications rohrkabel) +target_link_libraries(discord-screenaudio Qt5::Widgets Qt5::WebEngineWidgets rohrkabel) + +if(KF5NOTIFICATIONS) + target_link_libraries(discord-screenaudio KF5::Notifications) + install(FILES assets/discord-screenaudio.notifyrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/knotifications5) +endif() install(TARGETS discord-screenaudio DESTINATION bin) install(FILES assets/de.shorsh.discord-screenaudio.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/256x256/apps) install(PROGRAMS assets/de.shorsh.discord-screenaudio.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) configure_file(assets/de.shorsh.discord-screenaudio.metainfo.xml.in de.shorsh.discord-screenaudio.metainfo.xml) install(FILES ${CMAKE_BINARY_DIR}/de.shorsh.discord-screenaudio.metainfo.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo) -install(FILES assets/discord-screenaudio.notifyrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/knotifications5) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ec55e18..a7e5444 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,7 +1,10 @@ #include "mainwindow.h" #include "virtmic.h" +#ifdef KF5NOTIFICATIONS #include +#endif + #include #include #include @@ -33,6 +36,7 @@ void MainWindow::setupWebView() { m_webView = new QWebEngineView(this); m_webView->setPage(page); +#ifdef KF5NOTIFICATIONS QWebEngineProfile::defaultProfile()->setNotificationPresenter( [&](std::unique_ptr notificationInfo) { KNotification *notification = new KNotification("discordNotification"); @@ -47,6 +51,7 @@ void MainWindow::setupWebView() { }); notification->sendEvent(); }); +#endif setCentralWidget(m_webView); }