mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Show MessageBox on Stream Fail
This commit is contained in:
parent
d8a559214b
commit
44e9142886
3 changed files with 25 additions and 20 deletions
|
@ -161,7 +161,6 @@ int RunMain(QApplication &app, Settings *settings)
|
|||
int RunStream(QApplication &app, const StreamSessionConnectInfo &connect_info)
|
||||
{
|
||||
StreamWindow window(connect_info);
|
||||
window.show();
|
||||
app.setQuitOnLastWindowClosed(true);
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -225,15 +225,7 @@ void MainWindow::ServerItemWidgetTriggered()
|
|||
|
||||
QString host = server->GetHostAddr();
|
||||
StreamSessionConnectInfo info(settings, host, server->registered_host.GetRPRegistKey(), server->registered_host.GetRPKey());
|
||||
try
|
||||
{
|
||||
auto stream_window = new StreamWindow(info);
|
||||
stream_window->show();
|
||||
}
|
||||
catch(const ChiakiException &e)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Stream failed"), e.what());
|
||||
}
|
||||
new StreamWindow(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -25,18 +25,29 @@
|
|||
StreamWindow::StreamWindow(const StreamSessionConnectInfo &connect_info, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
session = new StreamSession(connect_info, this);
|
||||
try
|
||||
{
|
||||
session = new StreamSession(connect_info, this);
|
||||
|
||||
connect(session, &StreamSession::SessionQuit, this, &StreamWindow::SessionQuit);
|
||||
connect(session, &StreamSession::SessionQuit, this, &StreamWindow::SessionQuit);
|
||||
|
||||
av_widget = new AVOpenGLWidget(session->GetVideoDecoder(), this);
|
||||
setCentralWidget(av_widget);
|
||||
av_widget = new AVOpenGLWidget(session->GetVideoDecoder(), this);
|
||||
setCentralWidget(av_widget);
|
||||
|
||||
grabKeyboard();
|
||||
grabKeyboard();
|
||||
|
||||
session->Start();
|
||||
session->Start();
|
||||
|
||||
resize(connect_info.video_profile.width, connect_info.video_profile.height);
|
||||
resize(connect_info.video_profile.width, connect_info.video_profile.height);
|
||||
show();
|
||||
}
|
||||
catch(const Exception &e)
|
||||
{
|
||||
session = nullptr;
|
||||
av_widget = nullptr;
|
||||
QMessageBox::critical(this, tr("Stream failed"), tr("Failed to initialize Stream Session: %1").arg(e.what()));
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
StreamWindow::~StreamWindow()
|
||||
|
@ -47,17 +58,20 @@ StreamWindow::~StreamWindow()
|
|||
|
||||
void StreamWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
session->HandleKeyboardEvent(event);
|
||||
if(session)
|
||||
session->HandleKeyboardEvent(event);
|
||||
}
|
||||
|
||||
void StreamWindow::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
session->HandleKeyboardEvent(event);
|
||||
if(session)
|
||||
session->HandleKeyboardEvent(event);
|
||||
}
|
||||
|
||||
void StreamWindow::closeEvent(QCloseEvent *)
|
||||
{
|
||||
session->Stop();
|
||||
if(session)
|
||||
session->Stop();
|
||||
}
|
||||
|
||||
void StreamWindow::SessionQuit(ChiakiQuitReason reason, const QString &reason_str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue