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

Commit 0eeaf66

Browse files
committed
Add Support for KF6
1 parent 3f3f179 commit 0eeaf66

File tree

7 files changed

+46
-23
lines changed

7 files changed

+46
-23
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
.vscode
77
/submodules/arrpc
88
/submodules/Vencord
9+
.cache

CMakeLists.txt

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
1414
set(CMAKE_AUTOMOC ON)
1515
set(CMAKE_AUTORCC ON)
1616
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
17+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1718
string(TIMESTAMP TIMESTAMP %s)
1819
# set(CMAKE_AUTOUIC ON)
1920

20-
option(PREFER_QT6 "Prefer Qt6 over Qt5" OFF)
21+
option(PREFER_QT5 "Prefer Qt5 over Qt5" OFF)
2122
option(SKIP_KDE "Do not include features requiring KDE Frameworks (notifications, global shortcuts)" OFF)
2223

23-
if(NOT PREFER_QT6)
24+
if(NOT PREFER_QT5)
2425
find_package(Qt5 COMPONENTS Widgets QUIET)
2526
endif()
2627
if (Qt5_FOUND)
@@ -50,29 +51,31 @@ if (Qt5_FOUND)
5051
endif()
5152
endif()
5253
else()
53-
find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets WebEngineWidgets)
54-
message(STATUS "Using Qt6")
54+
find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets WebEngineWidgets)
55+
message(STATUS "Using Qt5")
56+
add_definitions( -DQT5 )
5557

5658
if(NOT SKIP_KDE)
57-
find_package(KF6Notifications QUIET)
58-
if(KF6Notifications_FOUND)
59+
find_package(KF5Notifications QUIET)
60+
if(KF5Notifications_FOUND)
5961
add_definitions( -DKNOTIFICATIONS )
6062
else()
61-
message(WARNING "KF6Notifications not found, notifications will not work")
63+
message(WARNING "KF5Notifications not found, notifications will not work")
6264
endif()
6365

64-
find_package(KF6XmlGui QUIET)
65-
if(KF6XmlGui_FOUND)
66+
find_package(KF5XmlGui QUIET)
67+
find_package(KF5CoreAddons QUIET)
68+
if(KF5XmlGui_FOUND AND KF5CoreAddons_FOUND)
6669
add_definitions( -DKXMLGUI )
6770
else()
68-
message(WARNING "KF6XmlGui not found, some UI elements and global shortcuts will not work")
71+
message(WARNING "KF5XmlGui not found, some UI elements and global shortcuts will not work")
6972
endif()
7073

71-
find_package(KF6GlobalAccel QUIET)
72-
if(KF6GlobalAccel_FOUND)
74+
find_package(KF5GlobalAccel QUIET)
75+
if(KF5GlobalAccel_FOUND)
7376
add_definitions( -DKGLOBALACCEL )
7477
else()
75-
message(WARNING "KF6GlobalAccel not found, global shortcuts will not work")
78+
message(WARNING "KF5GlobalAccel not found, global shortcuts will not work")
7679
endif()
7780
endif()
7881
endif()
@@ -115,19 +118,30 @@ add_executable(discord-screenaudio ${discord-screenaudio_SRC})
115118

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

118-
if(KF5Notifications_FOUND OR KF6Notifications_FOUND)
121+
if(KF5Notifications_FOUND)
119122
target_link_libraries(discord-screenaudio KF5::Notifications)
120123
install(FILES assets/discord-screenaudio.notifyrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/knotifications5)
121124
endif()
122-
if(KF5XmlGui_FOUND OR KF6XmlGui_FOUND)
125+
if(KF5XmlGui_FOUND)
123126
target_link_libraries(discord-screenaudio KF5::XmlGui)
124127
endif()
125-
if(KF5GlobalAccel_FOUND OR KF6GlobalAccel_FOUND)
128+
if(KF5GlobalAccel_FOUND)
129+
target_link_libraries(discord-screenaudio KF5::GlobalAccel)
130+
endif()
131+
132+
if(KF5Notifications_FOUND)
133+
target_link_libraries(discord-screenaudio KF5::Notifications)
134+
install(FILES assets/discord-screenaudio.notifyrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/knotifications5)
135+
endif()
136+
if(KF5XmlGui_FOUND)
137+
target_link_libraries(discord-screenaudio KF5::XmlGui KF5::CoreAddons)
138+
endif()
139+
if(KF5GlobalAccel_FOUND)
126140
target_link_libraries(discord-screenaudio KF5::GlobalAccel)
127141
endif()
128142

129143
install(TARGETS discord-screenaudio DESTINATION bin)
130-
install(FILES assets/de.shorsh.discord-screenaudio.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/256x256/apps)
144+
install(FILES assets/de.shorsh.discord-screenaudio.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/255x255/apps)
131145
install(PROGRAMS assets/de.shorsh.discord-screenaudio.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
132146
configure_file(assets/de.shorsh.discord-screenaudio.metainfo.xml.in de.shorsh.discord-screenaudio.metainfo.xml)
133147
install(FILES ${CMAKE_BINARY_DIR}/de.shorsh.discord-screenaudio.metainfo.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo)

src/centralwidget.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ void CentralWidget::setupWebView() {
5050
notification->setText(notificationInfo->message());
5151
notification->setPixmap(
5252
QPixmap::fromImage(notificationInfo->icon()));
53+
#ifdef QT6
54+
auto action = notification->addDefaultAction("View");
55+
connect(action, &KNotificationAction::activated,
56+
[&, notificationInfo = std::move(notificationInfo)]() {
57+
notificationInfo->click();
58+
show();
59+
activateWindow();
60+
});
61+
notification->sendEvent();
62+
#else
5363
notification->setDefaultAction("View");
5464
connect(notification, &KNotification::defaultActivated,
5565
[&, notificationInfo = std::move(notificationInfo)]() {
@@ -58,6 +68,7 @@ void CentralWidget::setupWebView() {
5868
activateWindow();
5969
});
6070
notification->sendEvent();
71+
#endif
6172
#endif
6273
}
6374
});

src/discordpage.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#include <QWebEngineScriptCollection>
2121
#include <QWebEngineSettings>
2222

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

2627
connect(this, &QWebEnginePage::featurePermissionRequested, this,

src/main.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
#include "mainwindow.h"
77
#include "virtmic.h"
88

9-
#ifdef KXMLGUI
10-
#include <KAboutData>
11-
#endif
12-
139
#include <QApplication>
1410
#include <QCommandLineParser>
1511
#include <QLocalServer>

src/userscript.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <QTimer>
1818

1919
#ifdef KXMLGUI
20+
#include <KAboutData>
2021
#include <KActionCollection>
2122
#endif
2223

src/userscript.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <QProcess>
1111

1212
#ifdef KXMLGUI
13-
#include <KAboutData>
1413
#include <KHelpMenu>
1514
#include <KShortcutsDialog>
1615
#include <KXmlGuiWindow>

0 commit comments

Comments
 (0)