Qt: Clean up some technical debt with opening views

This commit is contained in:
Jeffrey Pfau 2015-04-05 17:59:34 -07:00
parent 6a320bb923
commit 190ace3003
2 changed files with 15 additions and 21 deletions

View File

@ -247,58 +247,50 @@ void Window::selectPatch() {
}
}
void Window::openView(QWidget* widget) {
connect(this, SIGNAL(shutdown()), widget, SLOT(close()));
widget->setAttribute(Qt::WA_DeleteOnClose);
widget->show();
}
void Window::openKeymapWindow() {
GBAKeyEditor* keyEditor = new GBAKeyEditor(&m_inputController, InputController::KEYBOARD);
connect(this, SIGNAL(shutdown()), keyEditor, SLOT(close()));
keyEditor->setAttribute(Qt::WA_DeleteOnClose);
keyEditor->show();
openView(keyEditor);
}
void Window::openSettingsWindow() {
SettingsView* settingsWindow = new SettingsView(m_config);
connect(this, SIGNAL(shutdown()), settingsWindow, SLOT(close()));
connect(settingsWindow, SIGNAL(biosLoaded(const QString&)), m_controller, SLOT(loadBIOS(const QString&)));
connect(settingsWindow, SIGNAL(audioDriverChanged()), m_controller, SLOT(reloadAudioDriver()));
settingsWindow->setAttribute(Qt::WA_DeleteOnClose);
settingsWindow->show();
openView(settingsWindow);
}
void Window::openShortcutWindow() {
ShortcutView* shortcutView = new ShortcutView();
shortcutView->setController(m_shortcutController);
connect(this, SIGNAL(shutdown()), shortcutView, SLOT(close()));
shortcutView->setAttribute(Qt::WA_DeleteOnClose);
shortcutView->show();
openView(shortcutView);
}
void Window::openOverrideWindow() {
OverrideView* overrideWindow = new OverrideView(m_controller, m_config);
connect(this, SIGNAL(shutdown()), overrideWindow, SLOT(close()));
overrideWindow->setAttribute(Qt::WA_DeleteOnClose);
overrideWindow->show();
openView(overrideWindow);
}
void Window::openSensorWindow() {
SensorView* sensorWindow = new SensorView(m_controller);
connect(this, SIGNAL(shutdown()), sensorWindow, SLOT(close()));
sensorWindow->setAttribute(Qt::WA_DeleteOnClose);
sensorWindow->show();
openView(sensorWindow);
}
void Window::openCheatsWindow() {
CheatsView* cheatsWindow = new CheatsView(m_controller);
connect(this, SIGNAL(shutdown()), cheatsWindow, SLOT(close()));
cheatsWindow->setAttribute(Qt::WA_DeleteOnClose);
cheatsWindow->show();
openView(cheatsWindow);
}
#ifdef BUILD_SDL
void Window::openGamepadWindow() {
const char* profile = m_inputController.profileForType(SDL_BINDING_BUTTON);
GBAKeyEditor* keyEditor = new GBAKeyEditor(&m_inputController, SDL_BINDING_BUTTON, profile);
connect(this, SIGNAL(shutdown()), keyEditor, SLOT(close()));
keyEditor->setAttribute(Qt::WA_DeleteOnClose);
keyEditor->show();
openView(keyEditor);
}
#endif

View File

@ -122,6 +122,8 @@ private:
void appendMRU(const QString& fname);
void updateMRU();
void openView(QWidget* widget);
QAction* addControlledAction(QMenu* menu, QAction* action, const QString& name);
GameController* m_controller;