mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
Create Qt5 implementation of msg window
This commit is contained in:
parent
a66a46ca25
commit
0f90a3352b
@ -250,7 +250,9 @@ ifeq ($(HAVE_QT), 1)
|
||||
HAVE_QT_WRAPPER=0
|
||||
OBJ += ui/drivers/ui_qt.o \
|
||||
ui/drivers/qt/ui_qt_application.o \
|
||||
ui/drivers/qt/ui_qt_window.o
|
||||
ui/drivers/qt/ui_qt_window.o \
|
||||
ui/drivers/qt/ui_qt_browser_window.o \
|
||||
ui/drivers/qt/ui_qt_msg_window.o
|
||||
|
||||
ifneq ($(findstring Linux,$(OS)),)
|
||||
DEFINES += -I/usr/include/qt -fPIC
|
||||
|
38
ui/drivers/qt/ui_qt_browser_window.cpp
Normal file
38
ui/drivers/qt/ui_qt_browser_window.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2016 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <boolean.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../ui_companion_driver.h"
|
||||
|
||||
static bool ui_browser_window_qt_open(ui_browser_window_state_t *state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ui_browser_window_qt_save(ui_browser_window_state_t *state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const ui_browser_window_t ui_browser_window_qt = {
|
||||
ui_browser_window_qt_open,
|
||||
ui_browser_window_qt_save,
|
||||
"qt"
|
||||
};
|
106
ui/drivers/qt/ui_qt_msg_window.cpp
Normal file
106
ui/drivers/qt/ui_qt_msg_window.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2016 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <boolean.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <QtWidgets/QMessageBox>
|
||||
|
||||
#include "../../ui_companion_driver.h"
|
||||
|
||||
static enum ui_msg_window_response ui_msg_window_qt_response(ui_msg_window_state *state, QMessageBox::StandardButtons response)
|
||||
{
|
||||
switch (response)
|
||||
{
|
||||
case QMessageBox::Ok:
|
||||
return UI_MSG_RESPONSE_OK;
|
||||
case QMessageBox::Cancel:
|
||||
return UI_MSG_RESPONSE_CANCEL;
|
||||
case QMessageBox::Yes:
|
||||
return UI_MSG_RESPONSE_YES;
|
||||
case QMessageBox::No:
|
||||
return UI_MSG_RESPONSE_NO;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (state->buttons)
|
||||
{
|
||||
case UI_MSG_WINDOW_OK:
|
||||
return UI_MSG_RESPONSE_OK;
|
||||
case UI_MSG_WINDOW_OKCANCEL:
|
||||
return UI_MSG_RESPONSE_CANCEL;
|
||||
case UI_MSG_WINDOW_YESNO:
|
||||
return UI_MSG_RESPONSE_NO;
|
||||
case UI_MSG_WINDOW_YESNOCANCEL:
|
||||
return UI_MSG_RESPONSE_CANCEL;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return UI_MSG_RESPONSE_NA;
|
||||
}
|
||||
|
||||
static QFlags<QMessageBox::StandardButton> ui_msg_window_qt_buttons(ui_msg_window_state *state)
|
||||
{
|
||||
switch (state->buttons)
|
||||
{
|
||||
case UI_MSG_WINDOW_OK:
|
||||
return QMessageBox::Ok;
|
||||
case UI_MSG_WINDOW_OKCANCEL:
|
||||
return QMessageBox::Cancel;
|
||||
case UI_MSG_WINDOW_YESNO:
|
||||
return (QMessageBox::Yes | QMessageBox::No);
|
||||
case UI_MSG_WINDOW_YESNOCANCEL:
|
||||
return (QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
||||
}
|
||||
|
||||
return QMessageBox::NoButton;
|
||||
}
|
||||
|
||||
static enum ui_msg_window_response ui_msg_window_qt_error(ui_msg_window_state *state)
|
||||
{
|
||||
QFlags<QMessageBox::StandardButton> flags = ui_msg_window_qt_buttons(state);
|
||||
return ui_msg_window_qt_response(state, QMessageBox::critical((QWidget*)state->window, state->title, state->text, flags));
|
||||
}
|
||||
|
||||
static enum ui_msg_window_response ui_msg_window_qt_information(ui_msg_window_state *state)
|
||||
{
|
||||
QFlags<QMessageBox::StandardButton> flags = ui_msg_window_qt_buttons(state);
|
||||
return ui_msg_window_qt_response(state, QMessageBox::information((QWidget*)state->window, state->title, state->text, flags));
|
||||
}
|
||||
|
||||
static enum ui_msg_window_response ui_msg_window_qt_question(ui_msg_window_state *state)
|
||||
{
|
||||
QFlags<QMessageBox::StandardButton> flags = ui_msg_window_qt_buttons(state);
|
||||
return ui_msg_window_qt_response(state, QMessageBox::question((QWidget*)state->window, state->title, state->text, flags));
|
||||
}
|
||||
|
||||
static enum ui_msg_window_response ui_msg_window_qt_warning(ui_msg_window_state *state)
|
||||
{
|
||||
QFlags<QMessageBox::StandardButton> flags = ui_msg_window_qt_buttons(state);
|
||||
return ui_msg_window_qt_response(state, QMessageBox::warning((QWidget*)state->window, state->title, state->text, flags));
|
||||
}
|
||||
|
||||
const ui_msg_window_t ui_msg_window_qt = {
|
||||
ui_msg_window_qt_error,
|
||||
ui_msg_window_qt_information,
|
||||
ui_msg_window_qt_question,
|
||||
ui_msg_window_qt_warning,
|
||||
"qt"
|
||||
};
|
@ -143,8 +143,8 @@ const ui_companion_driver_t ui_companion_qt = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&ui_browser_window_null,
|
||||
&ui_msg_window_null,
|
||||
&ui_browser_window_qt,
|
||||
&ui_msg_window_qt,
|
||||
&ui_window_qt,
|
||||
&ui_application_qt,
|
||||
"qt",
|
||||
|
@ -61,6 +61,7 @@ typedef struct ui_msg_window_state
|
||||
enum ui_msg_window_buttons buttons;
|
||||
char *text;
|
||||
char *title;
|
||||
void *window;
|
||||
} ui_msg_window_state;
|
||||
|
||||
typedef struct ui_browser_window_state
|
||||
@ -141,6 +142,7 @@ typedef struct ui_companion_driver
|
||||
|
||||
extern const ui_browser_window_t ui_browser_window_null;
|
||||
extern const ui_browser_window_t ui_browser_window_cocoa;
|
||||
extern const ui_browser_window_t ui_browser_window_qt;
|
||||
extern const ui_browser_window_t ui_browser_window_win32;
|
||||
|
||||
extern const ui_window_t ui_window_null;
|
||||
@ -150,6 +152,7 @@ extern const ui_window_t ui_window_win32;
|
||||
|
||||
extern const ui_msg_window_t ui_msg_window_null;
|
||||
extern const ui_msg_window_t ui_msg_window_win32;
|
||||
extern const ui_msg_window_t ui_msg_window_qt;
|
||||
extern const ui_msg_window_t ui_msg_window_cocoa;
|
||||
|
||||
extern const ui_application_t ui_application_null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user