New upstream version 23.2.1+dfsg1

This commit is contained in:
Simon Chopin 2019-07-27 14:47:10 +02:00
parent cdc9a9fc87
commit b14f9eae6d
1017 changed files with 37232 additions and 11111 deletions

View file

@ -19,6 +19,7 @@
#include "obs-app.hpp"
#include <graphics/graphics.h>
#include <util/threading.h>
#include <QWidget>
#include <QLayout>
#include <QMessageBox>
@ -89,6 +90,33 @@ void OBSMessageBox::information(
mb.exec();
}
void OBSMessageBox::warning(
QWidget *parent,
const QString &title,
const QString &text,
bool enableRichText)
{
QMessageBox mb(QMessageBox::Warning,
title, text, QMessageBox::Ok,
parent);
if (enableRichText)
mb.setTextFormat(Qt::RichText);
mb.setButtonText(QMessageBox::Ok, QTStr("OK"));
mb.exec();
}
void OBSMessageBox::critical(
QWidget *parent,
const QString &title,
const QString &text)
{
QMessageBox mb(QMessageBox::Critical,
title, text, QMessageBox::Ok,
parent);
mb.setButtonText(QMessageBox::Ok, QTStr("OK"));
mb.exec();
}
void QTToGSWindow(WId windowId, gs_window &gswindow)
{
#ifdef _WIN32
@ -203,3 +231,87 @@ void DeleteLayout(QLayout *layout)
delete layout;
}
class QuickThread : public QThread {
public:
explicit inline QuickThread(std::function<void()> func_)
: func(func_)
{}
private:
virtual void run() override
{
func();
}
std::function<void()> func;
};
QThread *CreateQThread(std::function<void()> func)
{
return new QuickThread(func);
}
volatile long insideEventLoop = 0;
void ExecuteFuncSafeBlock(std::function<void()> func)
{
QEventLoop eventLoop;
auto wait = [&] ()
{
func();
QMetaObject::invokeMethod(&eventLoop, "quit",
Qt::QueuedConnection);
};
os_atomic_inc_long(&insideEventLoop);
QScopedPointer<QThread> thread(CreateQThread(wait));
thread->start();
eventLoop.exec();
thread->wait();
os_atomic_dec_long(&insideEventLoop);
}
void ExecuteFuncSafeBlockMsgBox(
std::function<void()> func,
const QString &title,
const QString &text)
{
QMessageBox dlg;
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowCloseButtonHint);
dlg.setWindowTitle(title);
dlg.setText(text);
dlg.setStandardButtons(0);
auto wait = [&] ()
{
func();
QMetaObject::invokeMethod(&dlg, "accept", Qt::QueuedConnection);
};
os_atomic_inc_long(&insideEventLoop);
QScopedPointer<QThread> thread(CreateQThread(wait));
thread->start();
dlg.exec();
thread->wait();
os_atomic_dec_long(&insideEventLoop);
}
static bool enable_message_boxes = false;
void EnableThreadedMessageBoxes(bool enable)
{
enable_message_boxes = enable;
}
void ExecThreadedWithoutBlocking(
std::function<void()> func,
const QString &title,
const QString &text)
{
if (!enable_message_boxes)
ExecuteFuncSafeBlock(func);
else
ExecuteFuncSafeBlockMsgBox(func, title, text);
}