properly update display type across all windows

(remind me to also propagate changes across instances)
This commit is contained in:
Arisotura 2024-10-27 02:42:27 +02:00
parent b2ae4c7dc5
commit 4ae4397547
3 changed files with 24 additions and 5 deletions

View File

@ -70,7 +70,7 @@ EmuThread::EmuThread(EmuInstance* inst, QObject* parent) : QThread(parent)
void EmuThread::attachWindow(MainWindow* window) void EmuThread::attachWindow(MainWindow* window)
{ {
connect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); //connect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint()));
connect(this, SIGNAL(windowTitleChange(QString)), window, SLOT(onTitleUpdate(QString))); connect(this, SIGNAL(windowTitleChange(QString)), window, SLOT(onTitleUpdate(QString)));
connect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart())); connect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart()));
connect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop())); connect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop()));
@ -89,7 +89,7 @@ void EmuThread::attachWindow(MainWindow* window)
void EmuThread::detachWindow(MainWindow* window) void EmuThread::detachWindow(MainWindow* window)
{ {
disconnect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); //disconnect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint()));
disconnect(this, SIGNAL(windowTitleChange(QString)), window, SLOT(onTitleUpdate(QString))); disconnect(this, SIGNAL(windowTitleChange(QString)), window, SLOT(onTitleUpdate(QString)));
disconnect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart())); disconnect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart()));
disconnect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop())); disconnect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop()));

View File

@ -701,6 +701,7 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
} }
show(); show();
panel = nullptr;
createScreenPanel(); createScreenPanel();
if (hasMenu) if (hasMenu)
@ -827,6 +828,9 @@ void MainWindow::closeEvent(QCloseEvent* event)
void MainWindow::createScreenPanel() void MainWindow::createScreenPanel()
{ {
if (panel) delete panel;
panel = nullptr;
hasOGL = globalCfg.GetBool("Screen.UseGL") || hasOGL = globalCfg.GetBool("Screen.UseGL") ||
(globalCfg.GetInt("3D.Renderer") != renderer3D_Software); (globalCfg.GetInt("3D.Renderer") != renderer3D_Software);
@ -852,6 +856,8 @@ void MainWindow::createScreenPanel()
actScreenFiltering->setEnabled(hasOGL); actScreenFiltering->setEnabled(hasOGL);
panel->osdSetEnabled(showOSD); panel->osdSetEnabled(showOSD);
connect(emuThread, SIGNAL(windowUpdate()), panel, SLOT(repaint()));
connect(this, SIGNAL(screenLayoutChange()), panel, SLOT(onScreenLayoutChanged())); connect(this, SIGNAL(screenLayoutChange()), panel, SLOT(onScreenLayoutChanged()));
emit screenLayoutChange(); emit screenLayoutChange();
} }
@ -2115,14 +2121,17 @@ void MainWindow::onEmuReset()
void MainWindow::onUpdateVideoSettings(bool glchange) void MainWindow::onUpdateVideoSettings(bool glchange)
{ {
MainWindow* parentwin = (MainWindow*)parentWidget();
if (parentwin)
return parentwin->onUpdateVideoSettings(glchange);
bool hadOGL = hasOGL;
if (glchange) if (glchange)
{ {
emuThread->emuPause(); emuThread->emuPause();
if (hasOGL) emuThread->deinitContext(windowID); if (hadOGL) emuThread->deinitContext(windowID);
delete panel;
createScreenPanel(); createScreenPanel();
connect(emuThread, SIGNAL(windowUpdate()), panel, SLOT(repaint()));
} }
emuThread->updateVideoSettings(); emuThread->updateVideoSettings();
@ -2130,6 +2139,15 @@ void MainWindow::onUpdateVideoSettings(bool glchange)
if (glchange) if (glchange)
{ {
if (hasOGL) emuThread->initContext(windowID); if (hasOGL) emuThread->initContext(windowID);
auto childwins = findChildren<MainWindow*>(Qt::FindDirectChildrenOnly);
for (auto child : childwins)
{
if (hadOGL) emuThread->deinitContext(child->windowID);
child->createScreenPanel();
if (hasOGL) emuThread->initContext(child->windowID);
}
emuThread->emuUnpause(); emuThread->emuUnpause();
} }
} }

View File

@ -110,6 +110,7 @@ public:
EmuInstance* getEmuInstance() { return emuInstance; } EmuInstance* getEmuInstance() { return emuInstance; }
Config::Table& getWindowConfig() { return windowCfg; } Config::Table& getWindowConfig() { return windowCfg; }
int getID() { return windowID; }
bool winHasMenu() { return hasMenu; } bool winHasMenu() { return hasMenu; }