diff --git a/gui/include/streamwindow.h b/gui/include/streamwindow.h index 45d1e1b..ffe3524 100644 --- a/gui/include/streamwindow.h +++ b/gui/include/streamwindow.h @@ -38,6 +38,8 @@ class StreamWindow: public QMainWindow AVOpenGLWidget *av_widget; + void Init(const StreamSessionConnectInfo &connect_info); + protected: void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; @@ -45,6 +47,7 @@ class StreamWindow: public QMainWindow private slots: void SessionQuit(ChiakiQuitReason reason, const QString &reason_str); + void ToggleFullscreen(); }; #endif // CHIAKI_GUI_STREAMWINDOW_H diff --git a/gui/src/streamwindow.cpp b/gui/src/streamwindow.cpp index 1dd0d20..b5959ea 100644 --- a/gui/src/streamwindow.cpp +++ b/gui/src/streamwindow.cpp @@ -22,6 +22,7 @@ #include #include #include +#include StreamWindow::StreamWindow(const StreamSessionConnectInfo &connect_info, QWidget *parent) : QMainWindow(parent) @@ -30,19 +31,7 @@ StreamWindow::StreamWindow(const StreamSessionConnectInfo &connect_info, QWidget setWindowTitle(qApp->applicationName()); try { - session = new StreamSession(connect_info, this); - - connect(session, &StreamSession::SessionQuit, this, &StreamWindow::SessionQuit); - - av_widget = new AVOpenGLWidget(session->GetVideoDecoder(), this); - setCentralWidget(av_widget); - - grabKeyboard(); - - session->Start(); - - resize(connect_info.video_profile.width, connect_info.video_profile.height); - show(); + Init(connect_info); } catch(const Exception &e) { @@ -59,6 +48,28 @@ StreamWindow::~StreamWindow() delete av_widget; } +void StreamWindow::Init(const StreamSessionConnectInfo &connect_info) +{ + session = new StreamSession(connect_info, this); + + connect(session, &StreamSession::SessionQuit, this, &StreamWindow::SessionQuit); + + av_widget = new AVOpenGLWidget(session->GetVideoDecoder(), this); + setCentralWidget(av_widget); + + grabKeyboard(); + + session->Start(); + + auto fullscreen_action = new QAction(tr("Fullscreen"), this); + fullscreen_action->setShortcut(Qt::Key_F11); + addAction(fullscreen_action); + connect(fullscreen_action, &QAction::triggered, this, &StreamWindow::ToggleFullscreen); + + resize(connect_info.video_profile.width, connect_info.video_profile.height); + show(); +} + void StreamWindow::keyPressEvent(QKeyEvent *event) { if(session) @@ -87,3 +98,17 @@ void StreamWindow::SessionQuit(ChiakiQuitReason reason, const QString &reason_st QMessageBox::critical(this, tr("Session has quit"), m); close(); } + +void StreamWindow::ToggleFullscreen() +{ + if(isFullScreen()) + { + setCursor(Qt::ArrowCursor); + showNormal(); + } + else + { + setCursor(Qt::BlankCursor); + showFullScreen(); + } +} \ No newline at end of file