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

Commit 64bacdb

Browse files
committed
Add Support for KF6
1 parent 3f3f179 commit 64bacdb

File tree

8 files changed

+61
-37
lines changed

8 files changed

+61
-37
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: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,65 +14,69 @@ 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 Qt6" OFF)
2122
option(SKIP_KDE "Do not include features requiring KDE Frameworks (notifications, global shortcuts)" OFF)
2223

23-
if(NOT PREFER_QT6)
24-
find_package(Qt5 COMPONENTS Widgets QUIET)
24+
if(NOT PREFER_QT5)
25+
find_package(Qt6 COMPONENTS Widgets QUIET)
2526
endif()
26-
if (Qt5_FOUND)
27-
find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets WebEngineWidgets)
28-
message(STATUS "Using Qt5")
27+
if (Qt6_FOUND)
28+
find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets WebEngineWidgets)
29+
message(STATUS "Using Qt6")
2930

3031
if(NOT SKIP_KDE)
31-
find_package(KF5Notifications QUIET)
32-
if(KF5Notifications_FOUND)
32+
find_package(KF6Notifications QUIET)
33+
if(KF6Notifications_FOUND)
3334
add_definitions( -DKNOTIFICATIONS )
3435
else()
35-
message(WARNING "KF5Notifications not found, notifications will not work")
36+
message(WARNING "KF6Notifications not found, notifications will not work")
3637
endif()
3738

38-
find_package(KF5XmlGui QUIET)
39-
if(KF5XmlGui_FOUND)
39+
find_package(KF6XmlGui QUIET)
40+
if(KF6XmlGui_FOUND)
41+
find_package(KF6CoreAddons QUIET REQUIRED)
4042
add_definitions( -DKXMLGUI )
4143
else()
42-
message(WARNING "KF5XmlGui not found, some UI elements and global shortcuts will not work")
44+
message(WARNING "KF6XmlGui not found, some UI elements and global shortcuts will not work")
4345
endif()
4446

45-
find_package(KF5GlobalAccel QUIET)
46-
if(KF5GlobalAccel_FOUND)
47+
find_package(KF6GlobalAccel QUIET)
48+
if(KF6GlobalAccel_FOUND)
4749
add_definitions( -DKGLOBALACCEL )
4850
else()
49-
message(WARNING "KF5GlobalAccel not found, global shortcuts will not work")
51+
message(WARNING "KF6GlobalAccel not found, global shortcuts will not work")
5052
endif()
5153
endif()
5254
else()
53-
find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets WebEngineWidgets)
54-
message(STATUS "Using Qt6")
55+
find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets WebEngineWidgets)
56+
message(STATUS "Using Qt5")
57+
add_definitions( -DQT5 )
5558

5659
if(NOT SKIP_KDE)
57-
find_package(KF6Notifications QUIET)
58-
if(KF6Notifications_FOUND)
60+
find_package(KF5Notifications QUIET)
61+
if(KF5Notifications_FOUND)
5962
add_definitions( -DKNOTIFICATIONS )
6063
else()
61-
message(WARNING "KF6Notifications not found, notifications will not work")
64+
message(WARNING "KF5Notifications not found, notifications will not work")
6265
endif()
6366

64-
find_package(KF6XmlGui QUIET)
65-
if(KF6XmlGui_FOUND)
67+
find_package(KF5XmlGui QUIET)
68+
find_package(KF5CoreAddons QUIET)
69+
if(KF5XmlGui_FOUND AND KF5CoreAddons_FOUND)
6670
add_definitions( -DKXMLGUI )
6771
else()
68-
message(WARNING "KF6XmlGui not found, some UI elements and global shortcuts will not work")
72+
message(WARNING "KF5XmlGui not found, some UI elements and global shortcuts will not work")
6973
endif()
7074

71-
find_package(KF6GlobalAccel QUIET)
72-
if(KF6GlobalAccel_FOUND)
75+
find_package(KF5GlobalAccel QUIET)
76+
if(KF5GlobalAccel_FOUND)
7377
add_definitions( -DKGLOBALACCEL )
7478
else()
75-
message(WARNING "KF6GlobalAccel not found, global shortcuts will not work")
79+
message(WARNING "KF5GlobalAccel not found, global shortcuts will not work")
7680
endif()
7781
endif()
7882
endif()
@@ -115,19 +119,30 @@ add_executable(discord-screenaudio ${discord-screenaudio_SRC})
115119

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

118-
if(KF5Notifications_FOUND OR KF6Notifications_FOUND)
122+
if(KF5Notifications_FOUND)
119123
target_link_libraries(discord-screenaudio KF5::Notifications)
120124
install(FILES assets/discord-screenaudio.notifyrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/knotifications5)
121125
endif()
122-
if(KF5XmlGui_FOUND OR KF6XmlGui_FOUND)
126+
if(KF5XmlGui_FOUND)
123127
target_link_libraries(discord-screenaudio KF5::XmlGui)
124128
endif()
125-
if(KF5GlobalAccel_FOUND OR KF6GlobalAccel_FOUND)
129+
if(KF5GlobalAccel_FOUND)
126130
target_link_libraries(discord-screenaudio KF5::GlobalAccel)
127131
endif()
128132

133+
if(KF6Notifications_FOUND)
134+
target_link_libraries(discord-screenaudio KF6::Notifications)
135+
install(FILES assets/discord-screenaudio.notifyrc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/knotifications6)
136+
endif()
137+
if(KF6XmlGui_FOUND)
138+
target_link_libraries(discord-screenaudio KF6::XmlGui KF6::CoreAddons)
139+
endif()
140+
if(KF6GlobalAccel_FOUND)
141+
target_link_libraries(discord-screenaudio KF6::GlobalAccel)
142+
endif()
143+
129144
install(TARGETS discord-screenaudio DESTINATION bin)
130-
install(FILES assets/de.shorsh.discord-screenaudio.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/256x256/apps)
145+
install(FILES assets/de.shorsh.discord-screenaudio.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/255x255/apps)
131146
install(PROGRAMS assets/de.shorsh.discord-screenaudio.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
132147
configure_file(assets/de.shorsh.discord-screenaudio.metainfo.xml.in de.shorsh.discord-screenaudio.metainfo.xml)
133148
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,7 @@ void CentralWidget::setupWebView() {
5050
notification->setText(notificationInfo->message());
5151
notification->setPixmap(
5252
QPixmap::fromImage(notificationInfo->icon()));
53+
#ifdef QT5
5354
notification->setDefaultAction("View");
5455
connect(notification, &KNotification::defaultActivated,
5556
[&, notificationInfo = std::move(notificationInfo)]() {
@@ -58,6 +59,16 @@ void CentralWidget::setupWebView() {
5859
activateWindow();
5960
});
6061
notification->sendEvent();
62+
#else
63+
auto action = notification->addDefaultAction("View");
64+
connect(action, &KNotificationAction::activated,
65+
[&, notificationInfo = std::move(notificationInfo)]() {
66+
notificationInfo->click();
67+
show();
68+
activateWindow();
69+
});
70+
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/mainwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ MainWindow::MainWindow(bool useNotifySend, QWidget *parent)
3636
setCentralWidget(m_centralWidget);
3737
setupTrayIcon();
3838
setMinimumSize(800, 300);
39-
connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this),
39+
connect(new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q), this),
4040
&QShortcut::activated, this, &MainWindow::toggleOrCloseWindow);
4141
if (m_settings->contains("geometry")) {
4242
restoreGeometry(m_settings->value("geometry").toByteArray());

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)