Qt: Move display attaching code

This commit is contained in:
Vicki Pfau 2021-04-15 20:01:35 -07:00
parent 0208c7456a
commit 4de01a4576
3 changed files with 13 additions and 8 deletions

View File

@ -80,6 +80,17 @@ Display::Display(QWidget* parent)
setMouseTracking(true);
}
void Display::attach(std::shared_ptr<CoreController> controller) {
connect(controller.get(), &CoreController::stateLoaded, this, &Display::resizeContext);
connect(controller.get(), &CoreController::stateLoaded, this, &Display::forceDraw);
connect(controller.get(), &CoreController::rewound, this, &Display::forceDraw);
connect(controller.get(), &CoreController::paused, this, &Display::pauseDrawing);
connect(controller.get(), &CoreController::unpaused, this, &Display::unpauseDrawing);
connect(controller.get(), &CoreController::frameAvailable, this, &Display::framePosted);
connect(controller.get(), &CoreController::statusPosted, this, &Display::showMessage);
connect(controller.get(), &CoreController::didReset, this, &Display::resizeContext);
}
void Display::resizeEvent(QResizeEvent*) {
m_messagePainter.resize(size(), m_lockAspectRatio, devicePixelRatio());
}

View File

@ -42,6 +42,7 @@ public:
bool isFiltered() const { return m_filter; }
bool isShowOSD() const { return m_showOSD; }
void attach(std::shared_ptr<CoreController>);
virtual void startDrawing(std::shared_ptr<CoreController>) = 0;
virtual bool isDrawing() const = 0;
virtual bool supportsShaders() const = 0;

View File

@ -1960,14 +1960,7 @@ void Window::setController(CoreController* controller, const QString& fname) {
}
void Window::attachDisplay() {
connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::resizeContext);
connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::forceDraw);
connect(m_controller.get(), &CoreController::rewound, m_display.get(), &Display::forceDraw);
connect(m_controller.get(), &CoreController::paused, m_display.get(), &Display::pauseDrawing);
connect(m_controller.get(), &CoreController::unpaused, m_display.get(), &Display::unpauseDrawing);
connect(m_controller.get(), &CoreController::frameAvailable, m_display.get(), &Display::framePosted);
connect(m_controller.get(), &CoreController::statusPosted, m_display.get(), &Display::showMessage);
connect(m_controller.get(), &CoreController::didReset, m_display.get(), &Display::resizeContext);
m_display->attach(m_controller);
connect(m_display.get(), &Display::drawingStarted, this, &Window::changeRenderer);
m_display->startDrawing(m_controller);
}