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

Commit

Permalink
Add Support for KF6
Browse files Browse the repository at this point in the history
  • Loading branch information
maltejur committed Feb 9, 2024
1 parent 3f3f179 commit 0bf538a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.vscode
/submodules/arrpc
/submodules/Vencord
.cache
24 changes: 19 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
string(TIMESTAMP TIMESTAMP %s)
# set(CMAKE_AUTOUIC ON)

option(PREFER_QT6 "Prefer Qt6 over Qt5" OFF)
option(PREFER_QT6 "Prefer Qt6 over Qt5" ON)
option(SKIP_KDE "Do not include features requiring KDE Frameworks (notifications, global shortcuts)" OFF)

if(NOT PREFER_QT6)
Expand Down Expand Up @@ -52,6 +53,7 @@ if (Qt5_FOUND)
else()
find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets WebEngineWidgets)
message(STATUS "Using Qt6")
add_definitions( -DQT6 )

if(NOT SKIP_KDE)
find_package(KF6Notifications QUIET)
Expand All @@ -62,7 +64,8 @@ else()
endif()

find_package(KF6XmlGui QUIET)
if(KF6XmlGui_FOUND)
find_package(KF6CoreAddons QUIET)
if(KF6XmlGui_FOUND AND KF6CoreAddons_FOUND)
add_definitions( -DKXMLGUI )
else()
message(WARNING "KF6XmlGui not found, some UI elements and global shortcuts will not work")
Expand Down Expand Up @@ -115,17 +118,28 @@ add_executable(discord-screenaudio ${discord-screenaudio_SRC})

target_link_libraries(discord-screenaudio Qt::Widgets Qt::WebEngineWidgets rohrkabel)

if(KF5Notifications_FOUND OR KF6Notifications_FOUND)
if(KF5Notifications_FOUND)
target_link_libraries(discord-screenaudio KF5::Notifications)
install(FILES assets/discord-screenaudio.notifyrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/knotifications5)
endif()
if(KF5XmlGui_FOUND OR KF6XmlGui_FOUND)
if(KF5XmlGui_FOUND)
target_link_libraries(discord-screenaudio KF5::XmlGui)
endif()
if(KF5GlobalAccel_FOUND OR KF6GlobalAccel_FOUND)
if(KF5GlobalAccel_FOUND)
target_link_libraries(discord-screenaudio KF5::GlobalAccel)
endif()

if(KF6Notifications_FOUND)
target_link_libraries(discord-screenaudio KF6::Notifications)
install(FILES assets/discord-screenaudio.notifyrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/knotifications6)
endif()
if(KF6XmlGui_FOUND)
target_link_libraries(discord-screenaudio KF6::XmlGui KF6::CoreAddons)
endif()
if(KF6GlobalAccel_FOUND)
target_link_libraries(discord-screenaudio KF6::GlobalAccel)
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)
Expand Down
11 changes: 11 additions & 0 deletions src/centralwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ void CentralWidget::setupWebView() {
notification->setText(notificationInfo->message());
notification->setPixmap(
QPixmap::fromImage(notificationInfo->icon()));
#ifdef QT6
auto action = notification->addDefaultAction("View");
connect(action, &KNotificationAction::activated,
[&, notificationInfo = std::move(notificationInfo)]() {
notificationInfo->click();
show();
activateWindow();
});
notification->sendEvent();
#else
notification->setDefaultAction("View");
connect(notification, &KNotification::defaultActivated,
[&, notificationInfo = std::move(notificationInfo)]() {
Expand All @@ -58,6 +68,7 @@ void CentralWidget::setupWebView() {
activateWindow();
});
notification->sendEvent();
#endif
#endif
}
});
Expand Down
4 changes: 0 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#include "mainwindow.h"
#include "virtmic.h"

#ifdef KXMLGUI
#include <KAboutData>
#endif

#include <QApplication>
#include <QCommandLineParser>
#include <QLocalServer>
Expand Down
1 change: 1 addition & 0 deletions src/userscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <QTimer>

#ifdef KXMLGUI
#include <KAboutData>
#include <KActionCollection>
#endif

Expand Down
1 change: 0 additions & 1 deletion src/userscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <QProcess>

#ifdef KXMLGUI
#include <KAboutData>
#include <KHelpMenu>
#include <KShortcutsDialog>
#include <KXmlGuiWindow>
Expand Down

0 comments on commit 0bf538a

Please sign in to comment.