Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Add Fullscreen Mode on F11 (Fix #9)
Browse files Browse the repository at this point in the history
  • Loading branch information
thestr4ng3r committed Aug 22, 2019
1 parent 94431ab commit 8f539cc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
3 changes: 3 additions & 0 deletions gui/include/streamwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ class StreamWindow: public QMainWindow

AVOpenGLWidget *av_widget;

void Init(const StreamSessionConnectInfo &connect_info);

protected:
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
void closeEvent(QCloseEvent *event) override;

private slots:
void SessionQuit(ChiakiQuitReason reason, const QString &reason_str);
void ToggleFullscreen();
};

#endif // CHIAKI_GUI_STREAMWINDOW_H
51 changes: 38 additions & 13 deletions gui/src/streamwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QLabel>
#include <QMessageBox>
#include <QCoreApplication>
#include <QAction>

StreamWindow::StreamWindow(const StreamSessionConnectInfo &connect_info, QWidget *parent)
: QMainWindow(parent)
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 8f539cc

Please sign in to comment.