mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 21:13:12 -07:00
Add Fullscreen Mode on F11 (Fix #9)
This commit is contained in:
parent
94431ab704
commit
8f539cc3fa
2 changed files with 41 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QAction>
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue