Qt: Show a dummy shader settings tab if shaders aren't supported

This commit is contained in:
Vicki Pfau 2024-10-11 21:52:48 -07:00
parent 67c3c40989
commit afff68cfc0
5 changed files with 33 additions and 17 deletions

View File

@ -58,6 +58,7 @@ Misc:
- Qt: Pass logging context through to video proxy thread (fixes mgba.io/i/3095)
- Qt: Show maker code and game version in ROM info
- Qt: Make window corners square on Windows 11 (fixes mgba.io/i/3285)
- Qt: Show a dummy shader settings tab if shaders aren't supported
- Res: Port NSO-gba-colors shader (closes mgba.io/i/2834)
- Scripting: Add `callbacks:oneshot` for single-call callbacks
- Switch: Add bilinear filtering option (closes mgba.io/i/3111)

View File

@ -397,29 +397,38 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC
shortcutView->setController(shortcutController);
shortcutView->setInputController(inputController);
addPage(tr("Shortcuts"), shortcutView, Page::SHORTCUTS);
#if defined(BUILD_GLES2) || defined(USE_EPOXY)
m_dummyShader = new QLabel(tr("Shaders are not supported when the display driver is not OpenGL.\n\n"
"If it is set to OpenGL and you still see this, your graphics card or drivers may be too old."));
m_dummyShader->setWordWrap(true);
m_dummyShader->setAlignment(Qt::AlignCenter);
addPage(tr("Shaders"), m_dummyShader, Page::SHADERS);
#endif
}
SettingsView::~SettingsView() {
#if defined(BUILD_GL) || defined(BUILD_GLES2)
setShaderSelector(nullptr);
#if defined(BUILD_GLES2) || defined(USE_EPOXY)
if (m_shader) {
m_shader->setParent(nullptr);
}
#endif
}
void SettingsView::setShaderSelector(ShaderSelector* shaderSelector) {
#if defined(BUILD_GL) || defined(BUILD_GLES2)
if (m_shader) {
auto items = m_ui.tabs->findItems(tr("Shaders"), Qt::MatchFixedString);
for (const auto& item : items) {
m_ui.tabs->removeItemWidget(item);
}
m_ui.stackedWidget->removeWidget(m_shader);
m_shader->setParent(nullptr);
#if defined(BUILD_GLES2) || defined(USE_EPOXY)
auto items = m_ui.tabs->findItems(tr("Shaders"), Qt::MatchFixedString);
for (QListWidgetItem* item : items) {
delete item;
}
if (!m_shader) {
m_ui.stackedWidget->removeWidget(m_dummyShader);
}
m_shader = shaderSelector;
if (shaderSelector) {
m_ui.stackedWidget->addWidget(m_shader);
m_ui.tabs->addItem(tr("Shaders"));
connect(m_ui.buttonBox, &QDialogButtonBox::accepted, m_shader, &ShaderSelector::saved);
addPage(tr("Shaders"), m_shader, Page::SHADERS);
} else {
addPage(tr("Shaders"), m_dummyShader, Page::SHADERS);
}
#endif
}
@ -579,7 +588,6 @@ void SettingsView::updateConfig() {
if (displayDriver != m_controller->getQtOption("displayDriver")) {
m_controller->setQtOption("displayDriver", displayDriver);
Display::setDriver(static_cast<Display::Driver>(displayDriver.toInt()));
setShaderSelector(nullptr);
emit displayDriverChanged();
}

View File

@ -51,8 +51,6 @@ public:
SettingsView(ConfigController* controller, InputController* inputController, ShortcutController* shortcutController, LogController* logController, QWidget* parent = nullptr);
~SettingsView();
void setShaderSelector(ShaderSelector* shaderSelector);
signals:
void biosLoaded(int platform, const QString&);
void audioDriverChanged();
@ -66,6 +64,7 @@ signals:
public slots:
void selectPage(Page);
void setShaderSelector(ShaderSelector* shaderSelector);
private slots:
void selectBios(QLineEdit*);
@ -81,6 +80,7 @@ private:
ConfigController* m_controller;
InputController* m_input;
ShaderSelector* m_shader = nullptr;
QLabel* m_dummyShader;
LogConfigModel m_logModel;
QTimer m_checkTimer;

View File

@ -550,6 +550,7 @@ void Window::openSettingsWindow(SettingsView::Page page) {
#ifdef USE_SQLITE3
connect(settingsWindow, &SettingsView::libraryCleared, m_libraryView, &LibraryController::clear);
#endif
connect(this, &Window::shaderSelectorAdded, settingsWindow, &SettingsView::setShaderSelector);
openView(settingsWindow);
settingsWindow->selectPage(page);
}
@ -1050,7 +1051,12 @@ void Window::reloadDisplayDriver() {
}
#if defined(BUILD_GL) || defined(BUILD_GLES2)
m_shaderView.reset();
m_shaderView = std::make_unique<ShaderSelector>(m_display.get(), m_config);
if (m_display->supportsShaders()) {
m_shaderView = std::make_unique<ShaderSelector>(m_display.get(), m_config);
emit shaderSelectorAdded(m_shaderView.get());
} else {
emit shaderSelectorAdded(nullptr);
}
#endif
connect(m_display.get(), &QGBA::Display::hideCursor, [this]() {

View File

@ -73,6 +73,7 @@ signals:
void startDrawing();
void shutdown();
void paused(bool);
void shaderSelectorAdded(ShaderSelector*);
public slots:
void setController(CoreController* controller, const QString& fname);