This commit is contained in:
ts-korhonen
2021-12-29 20:45:44 +02:00
12 changed files with 73 additions and 36 deletions

View File

@@ -21,6 +21,12 @@ int qt_nvr_save(void) {
char icon_set[256] = ""; /* name of the iconset to be used */ char icon_set[256] = ""; /* name of the iconset to be used */
#ifdef _WIN32
#define LIB_NAME_FLUIDSYNTH "libfluidsynth.dll"
#else
#define LIB_NAME_FLUIDSYNTH "libfluidsynth"
#endif
wchar_t* plat_get_string(int i) wchar_t* plat_get_string(int i)
{ {
switch (i) switch (i)
@@ -55,6 +61,8 @@ wchar_t* plat_get_string(int i)
return L"libfreetype is required for ESC/P printer emulation."; return L"libfreetype is required for ESC/P printer emulation.";
case IDS_2132: case IDS_2132:
return L"libgs is required for automatic conversion of PostScript files to PDF.\n\nAny documents sent to the generic PostScript printer will be saved as PostScript (.ps) files."; return L"libgs is required for automatic conversion of PostScript files to PDF.\n\nAny documents sent to the generic PostScript printer will be saved as PostScript (.ps) files.";
case IDS_2133:
return L""LIB_NAME_FLUIDSYNTH" is required for FluidSynth MIDI output.";
case IDS_2129: case IDS_2129:
return L"Make sure libpcap is installed and that you are on a libpcap-compatible network connection."; return L"Make sure libpcap is installed and that you are on a libpcap-compatible network connection.";
case IDS_2114: case IDS_2114:

View File

@@ -183,19 +183,7 @@ void HardwareRenderer::resizeEvent(QResizeEvent *event) {
bool HardwareRenderer::event(QEvent *event) bool HardwareRenderer::event(QEvent *event)
{ {
switch (event->type()) bool res = false;
{ if (!eventDelegate(event, res)) return QOpenGLWindow::event(event);
default: return res;
return QOpenGLWindow::event(event);
case QEvent::MouseButtonPress:
case QEvent::MouseMove:
case QEvent::MouseButtonRelease:
case QEvent::KeyPress:
case QEvent::KeyRelease:
case QEvent::Wheel:
case QEvent::Enter:
case QEvent::Leave:
return QApplication::sendEvent(parentWidget, event);
}
return false;
} }

View File

@@ -29,7 +29,6 @@ class HardwareRenderer : public QOpenGLWindow, protected QOpenGLFunctions, publi
private: private:
bool wayland = false; bool wayland = false;
QWidget* parentWidget{nullptr};
QOpenGLContext* m_context; QOpenGLContext* m_context;
QOpenGLTexture* m_texture{nullptr}; QOpenGLTexture* m_texture{nullptr};
QOpenGLShaderProgram* m_prog{nullptr}; QOpenGLShaderProgram* m_prog{nullptr};

View File

@@ -120,7 +120,6 @@ int main(int argc, char* argv[]) {
main_window = new MainWindow(); main_window = new MainWindow();
main_window->show(); main_window->show();
main_window->setFocus();
app.installEventFilter(main_window); app.installEventFilter(main_window);
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
@@ -134,13 +133,6 @@ int main(int argc, char* argv[]) {
} }
#endif #endif
auto widgetList = app.allWidgets();
for (auto curWidget : widgetList)
{
curWidget->setFocusPolicy(Qt::NoFocus);
}
main_window->setFocusPolicy(Qt::StrongFocus);
pc_reset_hard_init(); pc_reset_hard_init();
/* Set the PAUSE mode depending on the renderer. */ /* Set the PAUSE mode depending on the renderer. */

View File

@@ -97,6 +97,7 @@ MainWindow::MainWindow(QWidget *parent) :
qt_mouse_capture(mouse_capture); qt_mouse_capture(mouse_capture);
if (mouse_capture) { if (mouse_capture) {
ui->stackedWidget->grabMouse(); ui->stackedWidget->grabMouse();
this->grabKeyboard();
#ifdef WAYLAND #ifdef WAYLAND
if (QGuiApplication::platformName().contains("wayland")) { if (QGuiApplication::platformName().contains("wayland")) {
wl_mouse_capture(this->windowHandle()); wl_mouse_capture(this->windowHandle());
@@ -104,6 +105,7 @@ MainWindow::MainWindow(QWidget *parent) :
#endif #endif
} else { } else {
ui->stackedWidget->releaseMouse(); ui->stackedWidget->releaseMouse();
this->releaseKeyboard();
#ifdef WAYLAND #ifdef WAYLAND
if (QGuiApplication::platformName().contains("wayland")) { if (QGuiApplication::platformName().contains("wayland")) {
wl_mouse_uncapture(); wl_mouse_uncapture();
@@ -125,8 +127,12 @@ MainWindow::MainWindow(QWidget *parent) :
} }
}); });
connect(ui->menubar, &QMenuBar::triggered, this, [] { connect(ui->menubar, &QMenuBar::triggered, this, [this] {
config_save(); config_save();
if (QApplication::activeWindow() == this)
{
ui->stackedWidget->current->setFocus();
}
}); });
connect(this, &MainWindow::updateStatusBarPanes, this, [this] { connect(this, &MainWindow::updateStatusBarPanes, this, [this] {
@@ -278,13 +284,6 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionChange_contrast_for_monochrome_display->setChecked(true); ui->actionChange_contrast_for_monochrome_display->setChecked(true);
} }
setFocusPolicy(Qt::StrongFocus);
ui->stackedWidget->setFocusPolicy(Qt::NoFocus);
ui->centralwidget->setFocusPolicy(Qt::NoFocus);
menuBar()->setFocusPolicy(Qt::NoFocus);
menuWidget()->setFocusPolicy(Qt::NoFocus);
statusBar()->setFocusPolicy(Qt::NoFocus);
video_setblit(qt_blit); video_setblit(qt_blit);
} }

View File

@@ -79,6 +79,10 @@ void ProgSettings::accept()
main_window->status.reset(new MachineStatus(main_window)); main_window->status.reset(new MachineStatus(main_window));
main_window->refreshMediaMenu(); main_window->refreshMediaMenu();
main_window->status->message(msg); main_window->status->message(msg);
connect(main_window, &MainWindow::updateStatusBarTip, main_window->status.get(), &MachineStatus::updateTip);
connect(main_window, &MainWindow::updateStatusBarActivity, main_window->status.get(), &MachineStatus::setActivity);
connect(main_window, &MainWindow::updateStatusBarEmpty, main_window->status.get(), &MachineStatus::setEmpty);
connect(main_window, &MainWindow::statusBarMessage, main_window->status.get(), &MachineStatus::message);
QDialog::accept(); QDialog::accept();
} }

View File

@@ -1,7 +1,10 @@
#include "qt_renderercomon.hpp" #include "qt_renderercomon.hpp"
#include "qt_mainwindow.hpp"
#include <QPainter> #include <QPainter>
#include <QWidget> #include <QWidget>
#include <QEvent>
#include <QApplication>
#include <cmath> #include <cmath>
@@ -12,6 +15,7 @@ extern "C" {
RendererCommon::RendererCommon() = default; RendererCommon::RendererCommon() = default;
extern MainWindow* main_window;
void RendererCommon::onPaint(QPaintDevice* device) { void RendererCommon::onPaint(QPaintDevice* device) {
QPainter painter(device); QPainter painter(device);
painter.setRenderHint(QPainter::SmoothPixmapTransform, video_filter_method > 0 ? true : false); painter.setRenderHint(QPainter::SmoothPixmapTransform, video_filter_method > 0 ? true : false);
@@ -86,3 +90,25 @@ void RendererCommon::onResize(int width, int height) {
break; break;
} }
} }
bool RendererCommon::eventDelegate(QEvent *event, bool& result)
{
switch (event->type())
{
default:
return false;
case QEvent::KeyPress:
case QEvent::KeyRelease:
result = QApplication::sendEvent(main_window, event);
return true;
case QEvent::MouseButtonPress:
case QEvent::MouseMove:
case QEvent::MouseButtonRelease:
case QEvent::Wheel:
case QEvent::Enter:
case QEvent::Leave:
result = QApplication::sendEvent(parentWidget, event);
return true;
}
return false;
}

View File

@@ -13,7 +13,9 @@ public:
void onResize(int width, int height); void onResize(int width, int height);
protected: protected:
void onPaint(QPaintDevice* device); void onPaint(QPaintDevice* device);
bool eventDelegate(QEvent* event, bool& result);
QImage image{QSize(2048, 2048), QImage::Format_RGB32}; QImage image{QSize(2048, 2048), QImage::Format_RGB32};
QRect source, destination; QRect source, destination;
QWidget* parentWidget{nullptr};
}; };

View File

@@ -4,6 +4,8 @@
#include "qt_softwarerenderer.hpp" #include "qt_softwarerenderer.hpp"
#include "qt_hardwarerenderer.hpp" #include "qt_hardwarerenderer.hpp"
#include "qt_mainwindow.hpp"
#include "evdev_mouse.hpp" #include "evdev_mouse.hpp"
#include <QScreen> #include <QScreen>
@@ -19,6 +21,7 @@ extern "C"
#include <86box/video.h> #include <86box/video.h>
} }
extern MainWindow* main_window;
RendererStack::RendererStack(QWidget *parent) : RendererStack::RendererStack(QWidget *parent) :
QStackedWidget(parent), QStackedWidget(parent),
ui(new Ui::RendererStack) ui(new Ui::RendererStack)
@@ -116,6 +119,10 @@ void RendererStack::mousePressEvent(QMouseEvent *event)
{ {
mousedata.mousebuttons |= event->button(); mousedata.mousebuttons |= event->button();
} }
if (main_window->frameGeometry().contains(event->pos()) && !geometry().contains(event->pos()))
{
main_window->windowHandle()->startSystemMove();
}
event->accept(); event->accept();
} }
void RendererStack::wheelEvent(QWheelEvent *event) void RendererStack::wheelEvent(QWheelEvent *event)
@@ -177,7 +184,7 @@ void RendererStack::switchRenderer(Renderer renderer) {
{ {
auto sw = new SoftwareRenderer(this); auto sw = new SoftwareRenderer(this);
connect(this, &RendererStack::blitToRenderer, sw, &SoftwareRenderer::onBlit, Qt::QueuedConnection); connect(this, &RendererStack::blitToRenderer, sw, &SoftwareRenderer::onBlit, Qt::QueuedConnection);
current.reset(sw); current.reset(this->createWindowContainer(sw, this));
} }
break; break;
case Renderer::OpenGL: case Renderer::OpenGL:

View File

@@ -68,6 +68,8 @@ private:
/* atomic flag for each buffer to not overload the renderer */ /* atomic flag for each buffer to not overload the renderer */
std::vector<std::atomic_flag> buffers_in_use; std::vector<std::atomic_flag> buffers_in_use;
friend class MainWindow;
}; };
#endif // QT_RENDERERCONTAINER_HPP #endif // QT_RENDERERCONTAINER_HPP

View File

@@ -1,6 +1,7 @@
#include "qt_softwarerenderer.hpp" #include "qt_softwarerenderer.hpp"
#include <QApplication>
SoftwareRenderer::SoftwareRenderer(QWidget *parent) : QWidget(parent) {} SoftwareRenderer::SoftwareRenderer(QWidget *parent) : QRasterWindow(parent->windowHandle()) { parentWidget = parent; }
void SoftwareRenderer::paintEvent(QPaintEvent *event) { void SoftwareRenderer::paintEvent(QPaintEvent *event) {
(void) event; (void) event;
@@ -19,5 +20,12 @@ void SoftwareRenderer::onBlit(const std::unique_ptr<uint8_t>* img, int x, int y,
void SoftwareRenderer::resizeEvent(QResizeEvent *event) { void SoftwareRenderer::resizeEvent(QResizeEvent *event) {
onResize(width(), height()); onResize(width(), height());
QWidget::resizeEvent(event); QRasterWindow::resizeEvent(event);
}
bool SoftwareRenderer::event(QEvent *event)
{
bool res = false;
if (!eventDelegate(event, res)) return QRasterWindow::event(event);
return res;
} }

View File

@@ -2,10 +2,11 @@
#define SOFTWARERENDERER_HPP #define SOFTWARERENDERER_HPP
#include <QWidget> #include <QWidget>
#include <QRasterWindow>
#include <atomic> #include <atomic>
#include "qt_renderercomon.hpp" #include "qt_renderercomon.hpp"
class SoftwareRenderer : public QWidget, public RendererCommon class SoftwareRenderer : public QRasterWindow, public RendererCommon
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -17,6 +18,7 @@ public slots:
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
bool event(QEvent *event) override;
}; };
#endif // SOFTWARERENDERER_HPP #endif // SOFTWARERENDERER_HPP