discord-awesomeaudio/src/discordpage.h

71 lines
2.2 KiB
C
Raw Normal View History

2022-07-09 16:07:14 -04:00
#pragma once
#include "streamdialog.h"
#include "virtmic.h"
2022-10-14 17:16:34 -04:00
#include "webclass.h"
2022-07-09 16:07:14 -04:00
2022-10-10 15:50:26 -04:00
#ifdef KXMLGUI
#include <KActionCollection>
#include <KHelpMenu>
#include <KShortcutsDialog>
#endif
2022-07-09 16:07:14 -04:00
#include <QProcess>
2022-07-27 08:13:59 -04:00
#include <QWebEngineFullScreenRequest>
2022-07-09 16:07:14 -04:00
#include <QWebEnginePage>
2022-10-14 17:16:34 -04:00
#include <QWebEngineScript>
2022-07-09 16:07:14 -04:00
class DiscordPage : public QWebEnginePage {
Q_OBJECT
public:
explicit DiscordPage(QWidget *parent = nullptr);
private:
StreamDialog m_streamDialog;
QProcess m_virtmicProcess;
2022-10-14 17:16:34 -04:00
WebClass m_webClass;
2022-10-10 15:50:26 -04:00
#ifdef KXMLGUI
KHelpMenu *m_helpMenu;
#ifdef KGLOBALACCEL
KActionCollection *m_actionCollection;
KShortcutsDialog *m_shortcutsDialog;
#endif
#endif
2022-07-09 16:07:14 -04:00
bool acceptNavigationRequest(const QUrl &url,
QWebEnginePage::NavigationType type,
bool isMainFrame) override;
2022-07-27 08:53:16 -04:00
QWebEnginePage *createWindow(QWebEnginePage::WebWindowType type) override;
2022-07-09 16:07:14 -04:00
void
javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level,
const QString &message, int lineNumber,
const QString &sourceID) override;
2022-10-14 17:16:34 -04:00
void injectScriptText(QString name, QString content,
QWebEngineScript::InjectionPoint injectionPoint =
QWebEngineScript::DocumentCreation);
void injectScriptFile(QString name, QString source,
QWebEngineScript::InjectionPoint injectionPoint =
QWebEngineScript::DocumentCreation);
2022-07-09 16:07:14 -04:00
void stopVirtmic();
void startVirtmic(QString target);
2022-10-10 15:50:26 -04:00
void toggleMute();
void toggleDeafen();
2022-07-09 16:07:14 -04:00
private Q_SLOTS:
void featurePermissionRequested(const QUrl &securityOrigin,
QWebEnginePage::Feature feature);
void startStream(QString target, uint width, uint height, uint frameRate);
};
2022-07-27 08:53:16 -04:00
// Will immediately get destroyed again but is needed for navigation to
// target="_blank" links, since QWebEnginePage::newWindowRequested is
// only available sinec Qt 6.3.
class ExternalPage : public QWebEnginePage {
Q_OBJECT
private:
bool acceptNavigationRequest(const QUrl &url,
QWebEnginePage::NavigationType type,
bool isMainFrame) override;
};