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 0eeaf66
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 23 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
48 changes: 31 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ 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_QT5 "Prefer Qt5 over Qt5" OFF)
option(SKIP_KDE "Do not include features requiring KDE Frameworks (notifications, global shortcuts)" OFF)

if(NOT PREFER_QT6)
if(NOT PREFER_QT5)
find_package(Qt5 COMPONENTS Widgets QUIET)
endif()
if (Qt5_FOUND)
Expand Down Expand Up @@ -50,29 +51,31 @@ if (Qt5_FOUND)
endif()
endif()
else()
find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets WebEngineWidgets)
message(STATUS "Using Qt6")
find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets WebEngineWidgets)
message(STATUS "Using Qt5")
add_definitions( -DQT5 )

if(NOT SKIP_KDE)
find_package(KF6Notifications QUIET)
if(KF6Notifications_FOUND)
find_package(KF5Notifications QUIET)
if(KF5Notifications_FOUND)
add_definitions( -DKNOTIFICATIONS )
else()
message(WARNING "KF6Notifications not found, notifications will not work")
message(WARNING "KF5Notifications not found, notifications will not work")
endif()

find_package(KF6XmlGui QUIET)
if(KF6XmlGui_FOUND)
find_package(KF5XmlGui QUIET)
find_package(KF5CoreAddons QUIET)
if(KF5XmlGui_FOUND AND KF5CoreAddons_FOUND)
add_definitions( -DKXMLGUI )
else()
message(WARNING "KF6XmlGui not found, some UI elements and global shortcuts will not work")
message(WARNING "KF5XmlGui not found, some UI elements and global shortcuts will not work")
endif()

find_package(KF6GlobalAccel QUIET)
if(KF6GlobalAccel_FOUND)
find_package(KF5GlobalAccel QUIET)
if(KF5GlobalAccel_FOUND)
add_definitions( -DKGLOBALACCEL )
else()
message(WARNING "KF6GlobalAccel not found, global shortcuts will not work")
message(WARNING "KF5GlobalAccel not found, global shortcuts will not work")
endif()
endif()
endif()
Expand Down Expand Up @@ -115,19 +118,30 @@ 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(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)
target_link_libraries(discord-screenaudio KF5::XmlGui KF5::CoreAddons)
endif()
if(KF5GlobalAccel_FOUND)
target_link_libraries(discord-screenaudio KF5::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(FILES assets/de.shorsh.discord-screenaudio.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/255x255/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)
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 0eeaf66

Please sign in to comment.