UI: Add helper class to translate message box buttons
This commit is contained in:
parent
1c5591e644
commit
bd34dce8b6
@ -16,6 +16,8 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "qt-wrappers.hpp"
|
#include "qt-wrappers.hpp"
|
||||||
|
#include "obs-app.hpp"
|
||||||
|
|
||||||
#include <graphics/graphics.h>
|
#include <graphics/graphics.h>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
@ -42,6 +44,50 @@ void OBSErrorBox(QWidget *parent, const char *msg, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMessageBox::StandardButton OBSMessageBox::question(
|
||||||
|
QWidget *parent,
|
||||||
|
const QString &title,
|
||||||
|
const QString &text,
|
||||||
|
QMessageBox::StandardButtons buttons,
|
||||||
|
QMessageBox::StandardButton defaultButton)
|
||||||
|
{
|
||||||
|
QMessageBox mb(QMessageBox::Question,
|
||||||
|
title, text, buttons,
|
||||||
|
parent);
|
||||||
|
mb.setDefaultButton(defaultButton);
|
||||||
|
#define translate_button(x) \
|
||||||
|
if (buttons & QMessageBox::x) \
|
||||||
|
mb.setButtonText(QMessageBox::x, QTStr(#x));
|
||||||
|
translate_button(Ok);
|
||||||
|
translate_button(Open);
|
||||||
|
translate_button(Save);
|
||||||
|
translate_button(Cancel);
|
||||||
|
translate_button(Close);
|
||||||
|
translate_button(Discard);
|
||||||
|
translate_button(Apply);
|
||||||
|
translate_button(Reset);
|
||||||
|
translate_button(Yes);
|
||||||
|
translate_button(No);
|
||||||
|
translate_button(No);
|
||||||
|
translate_button(Abort);
|
||||||
|
translate_button(Retry);
|
||||||
|
translate_button(Ignore);
|
||||||
|
#undef translate_button
|
||||||
|
return (QMessageBox::StandardButton)mb.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OBSMessageBox::information(
|
||||||
|
QWidget *parent,
|
||||||
|
const QString &title,
|
||||||
|
const QString &text)
|
||||||
|
{
|
||||||
|
QMessageBox mb(QMessageBox::Information,
|
||||||
|
title, text, QMessageBox::Ok,
|
||||||
|
parent);
|
||||||
|
mb.setButtonText(QMessageBox::Ok, QTStr("OK"));
|
||||||
|
mb.exec();
|
||||||
|
}
|
||||||
|
|
||||||
void QTToGSWindow(WId windowId, gs_window &gswindow)
|
void QTToGSWindow(WId windowId, gs_window &gswindow)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <obs.hpp>
|
#include <obs.hpp>
|
||||||
|
|
||||||
@ -29,8 +30,23 @@
|
|||||||
class QDataStream;
|
class QDataStream;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
class QLayout;
|
class QLayout;
|
||||||
|
class QString;
|
||||||
struct gs_window;
|
struct gs_window;
|
||||||
|
|
||||||
|
class OBSMessageBox {
|
||||||
|
public:
|
||||||
|
static QMessageBox::StandardButton question(
|
||||||
|
QWidget *parent,
|
||||||
|
const QString &title,
|
||||||
|
const QString &text,
|
||||||
|
QMessageBox::StandardButtons buttons = QMessageBox::StandardButtons( QMessageBox::Yes | QMessageBox::No ),
|
||||||
|
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||||
|
static void information(
|
||||||
|
QWidget *parent,
|
||||||
|
const QString &title,
|
||||||
|
const QString &text);
|
||||||
|
};
|
||||||
|
|
||||||
void OBSErrorBox(QWidget *parent, const char *msg, ...);
|
void OBSErrorBox(QWidget *parent, const char *msg, ...);
|
||||||
|
|
||||||
void QTToGSWindow(WId windowId, gs_window &gswindow);
|
void QTToGSWindow(WId windowId, gs_window &gswindow);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user