Merge pull request #1625 from fr500/master

Basic QT app initialization
This commit is contained in:
Twinaphex 2015-04-13 10:12:59 +02:00
commit c0d88e19d1
7 changed files with 117 additions and 24 deletions

View File

@ -1,18 +1,40 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Andres Suarez
*
* 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 "wimp.h"
#include "stdio.h"
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QListView>
#include <QQuickWindow>
QObject *topLevel;
QQuickWindow *window;
int Wimp::CreateMainWindow()
{
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
topLevel = engine.rootObjects().value(0);
window = qobject_cast<QQuickWindow *>(topLevel);
SetTitle("Hello QT");
return this->exec();
}
void Wimp::SetTitle(char* title)
{
window->setTitle(title);
}

View File

@ -1,3 +1,18 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Andres Suarez
*
* 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/>.
*/
#ifndef WIMP_H
#define WIMP_H
@ -13,6 +28,7 @@ class WIMPSHARED_EXPORT Wimp : public QGuiApplication
public:
Wimp(int argc, char *argv[]): QGuiApplication(argc, argv) {}
int CreateMainWindow();
void SetTitle(char* title);
};

View File

@ -1,3 +1,19 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Andres Suarez
*
* 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/>.
*/
#ifndef WIMP_GLOBAL_H
#define WIMP_GLOBAL_H

View File

@ -1,12 +0,0 @@
#ifndef WRAPPER_H
#define WRAPPER_H
extern "C" {
}
#endif // WRAPPER_H

View File

@ -1,3 +1,19 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Andres Suarez
*
* 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 "../wimp/wimp.h"
#include "../wimp/wimp_global.h"
#include "wrapper.h"
@ -18,6 +34,11 @@ int CreateMainWindow(Wimp* p)
return p->CreateMainWindow();
}
void SetTitle(Wimp*p, char* title)
{
return p->SetTitle(title);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,6 +1,25 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Andres Suarez
*
* 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/>.
*/
#ifndef WRAPPER_H
#define WRAPPER_H
#include "../wimp/wimp.h"
#include "../wimp/wimp_global.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -10,6 +29,7 @@ typedef struct Wimp Wimp;
Wimp* ctrWimp(int argc, char *argv[]);
int CreateMainWindow(Wimp* p);
void SetTitle(Wimp* p, char* title);
#ifdef __cplusplus
}

View File

@ -25,6 +25,10 @@
#include "qt/wrapper/wrapper.h"
struct Wimp* wimp;
char* args[] = {""};
typedef struct ui_companion_qt
{
volatile bool quit;
@ -36,14 +40,11 @@ static void qt_thread(void *data)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
struct Wimp* wimp;
char** args = (char**)NULL;
wimp = ctrWimp(0, args);
CreateMainWindow(wimp);
wimp = ctrWimp(0, NULL);
if(wimp)
CreateMainWindow(wimp);
return;
}
static void ui_companion_qt_deinit(void *data)
@ -63,6 +64,9 @@ static void *ui_companion_qt_init(void)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle));
fflush(stdout);
if (!handle)
return NULL;
@ -83,7 +87,8 @@ static int ui_companion_qt_iterate(void *data, unsigned action)
{
(void)data;
(void)action;
printf("Test");
fflush(stdout);
return 0;
}
@ -92,11 +97,16 @@ static void ui_companion_qt_notify_content_loaded(void *data)
(void)data;
}
static void ui_companion_qt_toggle(void *data)
{
ui_companion_qt_init();
}
const ui_companion_driver_t ui_companion_qt = {
ui_companion_qt_init,
ui_companion_qt_deinit,
ui_companion_qt_iterate,
NULL,
ui_companion_qt_toggle,
ui_companion_qt_notify_content_loaded,
"qt",
};