qt: Add fullscreen status icons support and option
This commit is contained in:
@@ -521,6 +521,7 @@ load_general(void)
|
|||||||
|
|
||||||
rctrl_is_lalt = config_get_int(cat, "rctrl_is_lalt", 0);
|
rctrl_is_lalt = config_get_int(cat, "rctrl_is_lalt", 0);
|
||||||
update_icons = config_get_int(cat, "update_icons", 1);
|
update_icons = config_get_int(cat, "update_icons", 1);
|
||||||
|
status_icons_fullscreen = !!config_get_int(cat, "status_icons_fullscreen", 0);
|
||||||
|
|
||||||
window_remember = config_get_int(cat, "window_remember", 0);
|
window_remember = config_get_int(cat, "window_remember", 0);
|
||||||
if (window_remember || (vid_resize & 2)) {
|
if (window_remember || (vid_resize & 2)) {
|
||||||
@@ -2294,6 +2295,11 @@ save_general(void)
|
|||||||
else
|
else
|
||||||
config_delete_var(cat, "enable_discord");
|
config_delete_var(cat, "enable_discord");
|
||||||
|
|
||||||
|
if (status_icons_fullscreen)
|
||||||
|
config_set_int(cat, "status_icons_fullscreen", status_icons_fullscreen);
|
||||||
|
else
|
||||||
|
config_delete_var(cat, "status_icons_fullscreen");
|
||||||
|
|
||||||
if (video_framerate != -1)
|
if (video_framerate != -1)
|
||||||
config_set_int(cat, "video_gl_framerate", video_framerate);
|
config_set_int(cat, "video_gl_framerate", video_framerate);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* Global variables residing in the platform module. */
|
/* Global variables residing in the platform module. */
|
||||||
extern int dopause, /* system is paused */
|
extern int dopause, /* system is paused */
|
||||||
mouse_capture; /* mouse is captured in app */
|
mouse_capture; /* mouse is captured in app */
|
||||||
extern atomic_flag_t doresize; /* screen resize requested */
|
extern atomic_flag_t doresize; /* screen resize requested */
|
||||||
extern volatile int is_quit; /* system exit requested */
|
extern volatile int is_quit; /* system exit requested */
|
||||||
|
|
||||||
@@ -88,9 +88,10 @@ extern int infocus;
|
|||||||
extern char emu_version[200]; /* version ID string */
|
extern char emu_version[200]; /* version ID string */
|
||||||
extern int rctrl_is_lalt;
|
extern int rctrl_is_lalt;
|
||||||
extern int update_icons;
|
extern int update_icons;
|
||||||
|
extern int status_icons_fullscreen;
|
||||||
|
|
||||||
extern int unscaled_size_x, /* current unscaled size X */
|
extern int unscaled_size_x, /* current unscaled size X */
|
||||||
unscaled_size_y; /* current unscaled size Y */
|
unscaled_size_y; /* current unscaled size Y */
|
||||||
|
|
||||||
extern int kbd_req_capture, hide_status_bar, hide_tool_bar;
|
extern int kbd_req_capture, hide_status_bar, hide_tool_bar;
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ void HardwareRenderer::initializeGL()
|
|||||||
"void main(void)\n"
|
"void main(void)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_FragColor = texture2D(texture, texc.st).bgra;\n"
|
" gl_FragColor = texture2D(texture, texc.st).bgra;\n"
|
||||||
|
" gl_FragColor.a = 1.0;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
QString fsrccore =
|
QString fsrccore =
|
||||||
"uniform sampler2D texture;\n"
|
"uniform sampler2D texture;\n"
|
||||||
@@ -94,6 +95,7 @@ void HardwareRenderer::initializeGL()
|
|||||||
"void main(void)\n"
|
"void main(void)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" FragColor = texture2D(texture, texc.st).bgra;\n"
|
" FragColor = texture2D(texture, texc.st).bgra;\n"
|
||||||
|
" FragColor.a = 1.0;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
if (m_context->isOpenGLES() && m_context->format().version() >= qMakePair(3, 0))
|
if (m_context->isOpenGLES() && m_context->format().version() >= qMakePair(3, 0))
|
||||||
{
|
{
|
||||||
@@ -135,6 +137,22 @@ void HardwareRenderer::initializeGL()
|
|||||||
glClearColor(0, 0, 0, 1);
|
glClearColor(0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HardwareRenderer::paintOverGL()
|
||||||
|
{
|
||||||
|
// Context switching is needed to make use of QPainter to draw status bar icons in fullscreen.
|
||||||
|
// Especially since it seems to be impossible to use QPainter on externally-created OpenGL contexts.
|
||||||
|
if (video_fullscreen && status_icons_fullscreen)
|
||||||
|
{
|
||||||
|
m_context->makeCurrent(nullptr);
|
||||||
|
makeCurrent();
|
||||||
|
QPainter painter(this);
|
||||||
|
drawStatusBarIcons(&painter);
|
||||||
|
painter.end();
|
||||||
|
doneCurrent();
|
||||||
|
m_context->makeCurrent(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void HardwareRenderer::paintGL() {
|
void HardwareRenderer::paintGL() {
|
||||||
m_context->makeCurrent(this);
|
m_context->makeCurrent(this);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
void resizeGL(int w, int h) override;
|
void resizeGL(int w, int h) override;
|
||||||
void initializeGL() override;
|
void initializeGL() override;
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
|
void paintOverGL() override;
|
||||||
std::vector<std::tuple<uint8_t*, std::atomic_flag*>> getBuffers() override;
|
std::vector<std::tuple<uint8_t*, std::atomic_flag*>> getBuffers() override;
|
||||||
HardwareRenderer(QWidget* parent = nullptr, RenderType rtype = RenderType::OpenGL)
|
HardwareRenderer(QWidget* parent = nullptr, RenderType rtype = RenderType::OpenGL)
|
||||||
: QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent->windowHandle()), QOpenGLFunctions()
|
: QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent->windowHandle()), QOpenGLFunctions()
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
ui->actionHide_tool_bar->setChecked(hide_tool_bar);
|
ui->actionHide_tool_bar->setChecked(hide_tool_bar);
|
||||||
ui->actionUpdate_status_bar_icons->setChecked(update_icons);
|
ui->actionUpdate_status_bar_icons->setChecked(update_icons);
|
||||||
ui->actionEnable_Discord_integration->setChecked(enable_discord);
|
ui->actionEnable_Discord_integration->setChecked(enable_discord);
|
||||||
|
ui->actionShow_status_icons_in_fullscreen->setChecked(status_icons_fullscreen);
|
||||||
|
|
||||||
#if defined Q_OS_WINDOWS || defined Q_OS_MACOS
|
#if defined Q_OS_WINDOWS || defined Q_OS_MACOS
|
||||||
/* Make the option visible only if ANGLE is loaded. */
|
/* Make the option visible only if ANGLE is loaded. */
|
||||||
@@ -1614,3 +1615,10 @@ void MainWindow::changeEvent(QEvent* event)
|
|||||||
#endif
|
#endif
|
||||||
QWidget::changeEvent(event);
|
QWidget::changeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionShow_status_icons_in_fullscreen_triggered()
|
||||||
|
{
|
||||||
|
status_icons_fullscreen = !status_icons_fullscreen;
|
||||||
|
ui->actionShow_status_icons_in_fullscreen->setChecked(status_icons_fullscreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ private slots:
|
|||||||
|
|
||||||
void on_actionEnable_Discord_integration_triggered(bool checked);
|
void on_actionEnable_Discord_integration_triggered(bool checked);
|
||||||
|
|
||||||
|
void on_actionShow_status_icons_in_fullscreen_triggered();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
void keyReleaseEvent(QKeyEvent* event) override;
|
void keyReleaseEvent(QKeyEvent* event) override;
|
||||||
|
|||||||
@@ -149,6 +149,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<addaction name="actionHide_tool_bar"/>
|
<addaction name="actionHide_tool_bar"/>
|
||||||
<addaction name="actionHide_status_bar"/>
|
<addaction name="actionHide_status_bar"/>
|
||||||
|
<addaction name="actionShow_status_icons_in_fullscreen"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionResizable_window"/>
|
<addaction name="actionResizable_window"/>
|
||||||
<addaction name="actionRemember_size_and_position"/>
|
<addaction name="actionRemember_size_and_position"/>
|
||||||
@@ -697,6 +698,14 @@
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionShow_status_icons_in_fullscreen">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Show status icons in fullscreen</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|||||||
@@ -17,17 +17,25 @@
|
|||||||
|
|
||||||
#include "qt_renderercommon.hpp"
|
#include "qt_renderercommon.hpp"
|
||||||
#include "qt_mainwindow.hpp"
|
#include "qt_mainwindow.hpp"
|
||||||
|
#include "qt_machinestatus.hpp"
|
||||||
|
#include "ui_qt_mainwindow.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QFontMetrics>
|
||||||
|
#include <QStatusBar>
|
||||||
|
#include <QLayout>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <86box/86box.h>
|
#include <86box/86box.h>
|
||||||
|
#include <86box/plat.h>
|
||||||
#include <86box/video.h>
|
#include <86box/video.h>
|
||||||
|
|
||||||
|
int status_icons_fullscreen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererCommon::RendererCommon() = default;
|
RendererCommon::RendererCommon() = default;
|
||||||
@@ -101,6 +109,44 @@ void RendererCommon::onResize(int width, int height) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RendererCommon::drawStatusBarIcons(QPainter* painter)
|
||||||
|
{
|
||||||
|
uint32_t x = 0;
|
||||||
|
auto prevcompositionMode = painter->compositionMode();
|
||||||
|
painter->setCompositionMode(QPainter::CompositionMode::CompositionMode_SourceOver);
|
||||||
|
for (int i = 0; i < main_window->ui->statusbar->children().count(); i++)
|
||||||
|
{
|
||||||
|
QLabel* label = qobject_cast<QLabel*>(main_window->ui->statusbar->children()[i]);
|
||||||
|
if (label)
|
||||||
|
{
|
||||||
|
auto pixmap = label->pixmap(Qt::ReturnByValue);
|
||||||
|
if (!pixmap.isNull())
|
||||||
|
{
|
||||||
|
painter->setBrush(QColor(0, 0, 0, 255));
|
||||||
|
painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, pixmap.width(), pixmap.height() + 4, QColor(0, 0, 0, 127));
|
||||||
|
painter->drawPixmap(x, painter->device()->height() - pixmap.height(), pixmap);
|
||||||
|
x += pixmap.width();
|
||||||
|
if (i <= main_window->ui->statusbar->children().count() - 3)
|
||||||
|
{
|
||||||
|
painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, main_window->ui->statusbar->layout()->spacing(), pixmap.height() + 4, QColor(0, 0, 0, 127));
|
||||||
|
x += main_window->ui->statusbar->layout()->spacing();
|
||||||
|
}
|
||||||
|
else painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, 4, pixmap.height() + 4, QColor(0, 0, 0, 127));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (main_window->status->getMessage().isEmpty() == false)
|
||||||
|
{
|
||||||
|
auto curStatusMsg = main_window->status->getMessage();
|
||||||
|
auto textSize = painter->fontMetrics().size(Qt::TextSingleLine, curStatusMsg);
|
||||||
|
painter->setPen(QColor(0, 0, 0, 127));
|
||||||
|
painter->fillRect(painter->device()->width() - textSize.width(), painter->device()->height() - textSize.height(), textSize.width(), textSize.height(), QColor(0, 0, 0, 127));
|
||||||
|
painter->setPen(QColor(255, 255, 255, 255));
|
||||||
|
painter->drawText(QRectF(painter->device()->width() - textSize.width(), painter->device()->height() - textSize.height(), textSize.width(), textSize.height()), Qt::TextSingleLine, curStatusMsg);
|
||||||
|
}
|
||||||
|
painter->setCompositionMode(prevcompositionMode);
|
||||||
|
}
|
||||||
|
|
||||||
bool RendererCommon::eventDelegate(QEvent *event, bool& result)
|
bool RendererCommon::eventDelegate(QEvent *event, bool& result)
|
||||||
{
|
{
|
||||||
switch (event->type())
|
switch (event->type())
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public:
|
|||||||
virtual std::vector<std::tuple<uint8_t*, std::atomic_flag*>> getBuffers() = 0;
|
virtual std::vector<std::tuple<uint8_t*, std::atomic_flag*>> getBuffers() = 0;
|
||||||
protected:
|
protected:
|
||||||
bool eventDelegate(QEvent* event, bool& result);
|
bool eventDelegate(QEvent* event, bool& result);
|
||||||
|
void drawStatusBarIcons(QPainter* painter);
|
||||||
|
|
||||||
QRect source, destination;
|
QRect source, destination;
|
||||||
QWidget* parentWidget{nullptr};
|
QWidget* parentWidget{nullptr};
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <86box/86box.h>
|
#include <86box/86box.h>
|
||||||
|
#include <86box/plat.h>
|
||||||
#include <86box/video.h>
|
#include <86box/video.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +84,7 @@ void SoftwareRenderer::onPaint(QPaintDevice* device) {
|
|||||||
#endif
|
#endif
|
||||||
painter.setCompositionMode(QPainter::CompositionMode_Plus);
|
painter.setCompositionMode(QPainter::CompositionMode_Plus);
|
||||||
painter.drawImage(destination, *images[cur_image], source);
|
painter.drawImage(destination, *images[cur_image], source);
|
||||||
|
if (video_fullscreen && status_icons_fullscreen) drawStatusBarIcons(&painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::tuple<uint8_t*, std::atomic_flag*>> SoftwareRenderer::getBuffers()
|
std::vector<std::tuple<uint8_t*, std::atomic_flag*>> SoftwareRenderer::getBuffers()
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ extern wchar_t sdl_win_title[512];
|
|||||||
plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
|
plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
|
||||||
joystick_t joystick_state[MAX_JOYSTICKS];
|
joystick_t joystick_state[MAX_JOYSTICKS];
|
||||||
int joysticks_present;
|
int joysticks_present;
|
||||||
|
int status_icons_fullscreen = 0; /* unused. */
|
||||||
SDL_mutex *blitmtx;
|
SDL_mutex *blitmtx;
|
||||||
SDL_threadID eventthread;
|
SDL_threadID eventthread;
|
||||||
static int exit_event = 0;
|
static int exit_event = 0;
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ int fixed_size_x = 0, fixed_size_y = 0;
|
|||||||
int kbd_req_capture = 0;
|
int kbd_req_capture = 0;
|
||||||
int hide_status_bar = 0;
|
int hide_status_bar = 0;
|
||||||
int hide_tool_bar = 0;
|
int hide_tool_bar = 0;
|
||||||
|
int status_icons_fullscreen = 0; /* unused. */
|
||||||
int dpi = 96;
|
int dpi = 96;
|
||||||
|
|
||||||
extern char openfilestring[512];
|
extern char openfilestring[512];
|
||||||
|
|||||||
Reference in New Issue
Block a user