2022-07-07 13:11:51 +02:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "virtmic.h"
|
|
|
|
|
|
2022-07-29 16:08:19 +02:00
|
|
|
#include <KNotification>
|
2022-07-09 22:07:14 +02:00
|
|
|
#include <QApplication>
|
2022-07-07 21:48:23 +02:00
|
|
|
#include <QColor>
|
2022-07-07 13:11:51 +02:00
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QSpacerItem>
|
|
|
|
|
#include <QThread>
|
|
|
|
|
#include <QUrl>
|
2022-07-29 16:08:19 +02:00
|
|
|
#include <QWebEngineNotification>
|
|
|
|
|
#include <QWebEngineProfile>
|
2022-07-07 13:11:51 +02:00
|
|
|
#include <QWebEngineScript>
|
|
|
|
|
#include <QWebEngineScriptCollection>
|
|
|
|
|
#include <QWebEngineSettings>
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
2022-07-09 22:07:14 +02:00
|
|
|
setupWebView();
|
2022-07-07 13:11:51 +02:00
|
|
|
resize(1000, 700);
|
|
|
|
|
showMaximized();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::setupWebView() {
|
2022-07-18 20:46:06 +02:00
|
|
|
auto page = new DiscordPage(this);
|
2022-07-27 14:13:59 +02:00
|
|
|
connect(page, &QWebEnginePage::fullScreenRequested, this,
|
|
|
|
|
&MainWindow::fullScreenRequested);
|
|
|
|
|
|
|
|
|
|
m_webView = new QWebEngineView(this);
|
2022-07-09 22:07:14 +02:00
|
|
|
m_webView->setPage(page);
|
2022-07-27 14:13:59 +02:00
|
|
|
|
2022-07-29 16:08:19 +02:00
|
|
|
QWebEngineProfile::defaultProfile()->setNotificationPresenter(
|
|
|
|
|
[&](std::unique_ptr<QWebEngineNotification> notificationInfo) {
|
|
|
|
|
KNotification *notification = new KNotification("discordNotification");
|
|
|
|
|
notification->setTitle(notificationInfo->title());
|
|
|
|
|
notification->setText(notificationInfo->message());
|
|
|
|
|
notification->setPixmap(QPixmap::fromImage(notificationInfo->icon()));
|
|
|
|
|
notification->setDefaultAction("View");
|
|
|
|
|
connect(notification, &KNotification::defaultActivated,
|
|
|
|
|
[&, notificationInfo = std::move(notificationInfo)]() {
|
|
|
|
|
notificationInfo->click();
|
|
|
|
|
activateWindow();
|
|
|
|
|
});
|
|
|
|
|
notification->sendEvent();
|
|
|
|
|
});
|
|
|
|
|
|
2022-07-07 13:11:51 +02:00
|
|
|
setCentralWidget(m_webView);
|
|
|
|
|
}
|
2022-07-27 14:13:59 +02:00
|
|
|
|
|
|
|
|
void MainWindow::fullScreenRequested(
|
|
|
|
|
QWebEngineFullScreenRequest fullScreenRequest) {
|
|
|
|
|
fullScreenRequest.accept();
|
2022-07-27 19:38:09 +02:00
|
|
|
if (fullScreenRequest.toggleOn()) {
|
|
|
|
|
m_wasMaximized = isMaximized();
|
|
|
|
|
showFullScreen();
|
|
|
|
|
} else {
|
|
|
|
|
m_wasMaximized ? showMaximized() : showNormal();
|
|
|
|
|
}
|
2022-07-27 14:13:59 +02:00
|
|
|
}
|
2022-07-27 15:11:53 +02:00
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event) { QApplication::quit(); }
|