Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
make KF5Notifications optional
Browse files Browse the repository at this point in the history
  • Loading branch information
maltejur committed Jul 29, 2022
1 parent ef221d4 commit d68797c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
5 changes: 5 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "mainwindow.h"
#include "virtmic.h"

#ifdef KF5NOTIFICATIONS
#include <KNotification>
#endif

#include <QApplication>
#include <QColor>
#include <QComboBox>
Expand Down Expand Up @@ -33,6 +36,7 @@ void MainWindow::setupWebView() {
m_webView = new QWebEngineView(this);
m_webView->setPage(page);

#ifdef KF5NOTIFICATIONS
QWebEngineProfile::defaultProfile()->setNotificationPresenter(
[&](std::unique_ptr<QWebEngineNotification> notificationInfo) {
KNotification *notification = new KNotification("discordNotification");
Expand All @@ -47,6 +51,7 @@ void MainWindow::setupWebView() {
});
notification->sendEvent();
});
#endif

setCentralWidget(m_webView);
}
Expand Down

0 comments on commit d68797c

Please sign in to comment.