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;
|
AVOpenGLWidget *av_widget;
|
||||||
|
|
||||||
|
void Init(const StreamSessionConnectInfo &connect_info);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
void keyReleaseEvent(QKeyEvent *event) override;
|
void keyReleaseEvent(QKeyEvent *event) override;
|
||||||
|
@ -45,6 +47,7 @@ class StreamWindow: public QMainWindow
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void SessionQuit(ChiakiQuitReason reason, const QString &reason_str);
|
void SessionQuit(ChiakiQuitReason reason, const QString &reason_str);
|
||||||
|
void ToggleFullscreen();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHIAKI_GUI_STREAMWINDOW_H
|
#endif // CHIAKI_GUI_STREAMWINDOW_H
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
StreamWindow::StreamWindow(const StreamSessionConnectInfo &connect_info, QWidget *parent)
|
StreamWindow::StreamWindow(const StreamSessionConnectInfo &connect_info, QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
|
@ -30,19 +31,7 @@ StreamWindow::StreamWindow(const StreamSessionConnectInfo &connect_info, QWidget
|
||||||
setWindowTitle(qApp->applicationName());
|
setWindowTitle(qApp->applicationName());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
session = new StreamSession(connect_info, this);
|
Init(connect_info);
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
catch(const Exception &e)
|
catch(const Exception &e)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +48,28 @@ StreamWindow::~StreamWindow()
|
||||||
delete av_widget;
|
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)
|
void StreamWindow::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if(session)
|
if(session)
|
||||||
|
@ -87,3 +98,17 @@ void StreamWindow::SessionQuit(ChiakiQuitReason reason, const QString &reason_st
|
||||||
QMessageBox::critical(this, tr("Session has quit"), m);
|
QMessageBox::critical(this, tr("Session has quit"), m);
|
||||||
close();
|
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