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 Mar 22, 2024
1 parent 3f3f179 commit 878918b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 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
3 changes: 2 additions & 1 deletion src/discordpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <QWebEngineScriptCollection>
#include <QWebEngineSettings>

DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) {
DiscordPage::DiscordPage(QWidget *parent)
: QWebEnginePage(new QWebEngineProfile("discord-screenaudio"), parent) {
setBackgroundColor(QColor("#313338"));

connect(this, &QWebEnginePage::featurePermissionRequested, this,
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 878918b

Please sign in to comment.