2021-11-25 10:20:56 +01:00
|
|
|
#include <cstdint>
|
|
|
|
|
|
2021-11-28 20:49:05 +01:00
|
|
|
#include <QDebug>
|
2021-11-25 10:20:56 +01:00
|
|
|
#include <QThread>
|
2021-12-08 14:47:09 +01:00
|
|
|
#include <QMessageBox>
|
2021-11-25 10:20:56 +01:00
|
|
|
|
|
|
|
|
#include <QStatusBar>
|
|
|
|
|
|
|
|
|
|
#include "qt_mainwindow.hpp"
|
|
|
|
|
|
|
|
|
|
MainWindow* main_window = nullptr;
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
#include <86box/plat.h>
|
2022-02-02 22:08:19 +06:00
|
|
|
#include <86box/ui.h>
|
2021-11-25 10:20:56 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
plat_delay_ms(uint32_t count)
|
|
|
|
|
{
|
|
|
|
|
QThread::msleep(count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wchar_t* ui_window_title(wchar_t* str)
|
|
|
|
|
{
|
|
|
|
|
if (str == nullptr) {
|
|
|
|
|
static wchar_t title[512];
|
2021-12-01 15:55:41 +06:00
|
|
|
memset(title, 0, sizeof(title));
|
|
|
|
|
main_window->getTitle(title);
|
2021-11-25 10:20:56 +01:00
|
|
|
str = title;
|
|
|
|
|
} else {
|
2021-12-14 20:30:09 +01:00
|
|
|
emit main_window->setTitle(QString::fromWCharArray(str));
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-30 16:26:49 +06:00
|
|
|
extern "C" void qt_blit(int x, int y, int w, int h)
|
|
|
|
|
{
|
|
|
|
|
main_window->blitToWidget(x, y, w, h);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-25 10:20:56 +01:00
|
|
|
void mouse_poll() {
|
|
|
|
|
main_window->pollMouse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void plat_resize(int w, int h) {
|
|
|
|
|
main_window->resizeContents(w, h);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void plat_setfullscreen(int on) {
|
|
|
|
|
main_window->setFullscreen(on > 0 ? true : false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void plat_mouse_capture(int on) {
|
|
|
|
|
main_window->setMouseCapture(on > 0 ? true : false);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-29 12:25:27 +01:00
|
|
|
int ui_msgbox_header(int flags, void *header, void* message) {
|
2021-12-02 19:35:08 +02:00
|
|
|
if (header <= (void*)7168) header = plat_get_string((uintptr_t)header);
|
|
|
|
|
if (message <= (void*)7168) message = plat_get_string((uintptr_t)message);
|
2021-11-25 10:20:56 +01:00
|
|
|
|
2022-02-02 22:08:19 +06:00
|
|
|
auto hdr = (flags & MBX_ANSI) ? QString((char*)header) : QString::fromWCharArray(reinterpret_cast<const wchar_t*>(header));
|
|
|
|
|
auto msg = (flags & MBX_ANSI) ? QString((char*)message) : QString::fromWCharArray(reinterpret_cast<const wchar_t*>(message));
|
2021-11-25 10:20:56 +01:00
|
|
|
|
2021-12-08 14:47:09 +01:00
|
|
|
// any error in early init
|
|
|
|
|
if (main_window == nullptr) {
|
2021-12-10 15:36:55 +06:00
|
|
|
QMessageBox msgBox(QMessageBox::Icon::Critical, hdr, msg);
|
|
|
|
|
msgBox.setTextFormat(Qt::TextFormat::RichText);
|
|
|
|
|
msgBox.exec();
|
2021-12-08 14:47:09 +01:00
|
|
|
} else {
|
|
|
|
|
// else scope it to main_window
|
|
|
|
|
main_window->showMessage(hdr, msg);
|
|
|
|
|
}
|
2021-11-25 10:20:56 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ui_msgbox(int flags, void *message) {
|
|
|
|
|
return ui_msgbox_header(flags, nullptr, message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ui_sb_set_text_w(wchar_t *wstr) {
|
|
|
|
|
main_window->statusBar()->showMessage(QString::fromWCharArray(wstr));
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-28 20:49:05 +01:00
|
|
|
void
|
|
|
|
|
ui_sb_update_tip(int arg) {
|
2021-12-14 00:31:55 +06:00
|
|
|
main_window->updateStatusBarTip(arg);
|
2021-11-28 20:49:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ui_sb_update_panes() {
|
|
|
|
|
main_window->updateStatusBarPanes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ui_sb_bugui(char *str) {
|
2021-12-03 11:38:00 +01:00
|
|
|
main_window->statusBarMessage(str);
|
2021-11-28 20:49:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ui_sb_set_ready(int ready) {
|
|
|
|
|
qDebug() << Q_FUNC_INFO << ready;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ui_sb_update_icon_state(int tag, int state) {
|
|
|
|
|
if (main_window == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
main_window->updateStatusBarEmpty(tag, state > 0 ? true : false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ui_sb_update_icon(int tag, int active) {
|
2021-12-12 01:16:27 +06:00
|
|
|
if (!update_icons) return;
|
2021-11-28 20:49:05 +01:00
|
|
|
main_window->updateStatusBarActivity(tag, active > 0 ? true : false);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|