Port Win32 Discord integration to Linux and macOS
This commit is contained in:
@@ -26,6 +26,7 @@ Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin)
|
||||
#include <86box/plat.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/discord.h>
|
||||
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
@@ -127,6 +128,7 @@ int main(int argc, char* argv[]) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
discord_load();
|
||||
main_window = new MainWindow();
|
||||
main_window->show();
|
||||
app.installEventFilter(main_window);
|
||||
@@ -148,10 +150,24 @@ int main(int argc, char* argv[]) {
|
||||
// plat_pause(0);
|
||||
if (settings_only) dopause = 1;
|
||||
QTimer onesec;
|
||||
QTimer discordupdate;
|
||||
QObject::connect(&onesec, &QTimer::timeout, &app, [] {
|
||||
pc_onesec();
|
||||
});
|
||||
onesec.start(1000);
|
||||
if (discord_loaded) {
|
||||
QTimer::singleShot(1000, &app, [] {
|
||||
if (enable_discord) {
|
||||
discord_init();
|
||||
discord_update_activity(dopause);
|
||||
} else
|
||||
discord_close();
|
||||
});
|
||||
QObject::connect(&discordupdate, &QTimer::timeout, &app, [] {
|
||||
discord_run_callbacks();
|
||||
});
|
||||
discordupdate.start(0);
|
||||
}
|
||||
|
||||
/* Initialize the rendering window, or fullscreen. */
|
||||
auto main_thread = std::thread([] {
|
||||
|
||||
@@ -13,6 +13,7 @@ extern "C" {
|
||||
#include <86box/config.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/discord.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/vid_ega.h>
|
||||
#include <86box/version.h>
|
||||
@@ -152,6 +153,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
ui->actionHiDPI_scaling->setChecked(dpi_scale);
|
||||
ui->actionHide_status_bar->setChecked(hide_status_bar);
|
||||
ui->actionUpdate_status_bar_icons->setChecked(update_icons);
|
||||
ui->actionEnable_Discord_integration->setChecked(enable_discord);
|
||||
|
||||
#if defined Q_OS_WINDOWS || defined Q_OS_MACOS
|
||||
/* Make the option visible only if ANGLE is loaded. */
|
||||
@@ -420,7 +422,8 @@ void MainWindow::on_actionSettings_triggered() {
|
||||
plat_pause(currentPause);
|
||||
if (settings_only) {
|
||||
cpu_thread_run = 0;
|
||||
close();
|
||||
config_save();
|
||||
QApplication::quit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1392,3 +1395,14 @@ void MainWindow::on_actionPreferences_triggered()
|
||||
progsettings.exec();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionEnable_Discord_integration_triggered(bool checked)
|
||||
{
|
||||
enable_discord = checked;
|
||||
if(enable_discord) {
|
||||
discord_init();
|
||||
discord_update_activity(dopause);
|
||||
} else
|
||||
discord_close();
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,8 @@ private slots:
|
||||
|
||||
void on_actionPreferences_triggered();
|
||||
|
||||
void on_actionEnable_Discord_integration_triggered(bool checked);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
|
||||
@@ -73,6 +73,8 @@
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="actionUpdate_status_bar_icons"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionEnable_Discord_integration"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionTake_screenshot"/>
|
||||
<addaction name="actionSound_gain"/>
|
||||
<addaction name="separator"/>
|
||||
@@ -554,6 +556,14 @@
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEnable_Discord_integration">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable &Discord integration</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
@@ -67,6 +67,7 @@ extern "C" {
|
||||
#include <86box/plat_dynld.h>
|
||||
#include <86box/config.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/discord.h>
|
||||
|
||||
#include "../cpu/cpu.h"
|
||||
#include <86box/plat.h>
|
||||
@@ -339,7 +340,7 @@ plat_pause(int p)
|
||||
wchar_t title[512];
|
||||
|
||||
if ((p == 0) && (time_sync & TIME_SYNC_ENABLED))
|
||||
nvr_time_sync();
|
||||
nvr_time_sync();
|
||||
|
||||
dopause = p;
|
||||
if (p) {
|
||||
@@ -350,6 +351,7 @@ plat_pause(int p)
|
||||
} else {
|
||||
ui_window_title(oldtitle);
|
||||
}
|
||||
discord_update_activity(dopause);
|
||||
}
|
||||
|
||||
// because we can't include nvr.h because it's got fields named new
|
||||
|
||||
Reference in New Issue
Block a user