From 80686f179699aee92481693f2f40e1e2593c52dc Mon Sep 17 00:00:00 2001 From: Radius Date: Mon, 13 Apr 2015 00:29:46 -0400 Subject: [PATCH] add window initialization code, update credits, add settitle window to test --- ui/drivers/qt/wimp/wimp.cpp | 30 ++++++++++++++++++++++++++---- ui/drivers/qt/wimp/wimp.h | 16 ++++++++++++++++ ui/drivers/qt/wimp/wimp_global.h | 16 ++++++++++++++++ ui/drivers/qt/wrapper/wrapper.cpp | 21 +++++++++++++++++++++ ui/drivers/qt/wrapper/wrapper.h | 20 ++++++++++++++++++++ ui/drivers/ui_qt.cpp | 26 ++++++++++++++++++-------- 6 files changed, 117 insertions(+), 12 deletions(-) diff --git a/ui/drivers/qt/wimp/wimp.cpp b/ui/drivers/qt/wimp/wimp.cpp index a0b5f72289..9e7f918fe7 100644 --- a/ui/drivers/qt/wimp/wimp.cpp +++ b/ui/drivers/qt/wimp/wimp.cpp @@ -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 . + */ + #include "wimp.h" #include "stdio.h" #include #include #include +#include + +QObject *topLevel; +QQuickWindow *window; int Wimp::CreateMainWindow() { - - QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + topLevel = engine.rootObjects().value(0); + window = qobject_cast(topLevel); + SetTitle("Hello QT"); return this->exec(); } - - +void Wimp::SetTitle(char* title) +{ + window->setTitle(title); +} diff --git a/ui/drivers/qt/wimp/wimp.h b/ui/drivers/qt/wimp/wimp.h index 7df55a6198..aa30b0b7f9 100644 --- a/ui/drivers/qt/wimp/wimp.h +++ b/ui/drivers/qt/wimp/wimp.h @@ -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 . + */ + #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); }; diff --git a/ui/drivers/qt/wimp/wimp_global.h b/ui/drivers/qt/wimp/wimp_global.h index aacd72fedb..0974927311 100644 --- a/ui/drivers/qt/wimp/wimp_global.h +++ b/ui/drivers/qt/wimp/wimp_global.h @@ -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 . + */ + + #ifndef WIMP_GLOBAL_H #define WIMP_GLOBAL_H diff --git a/ui/drivers/qt/wrapper/wrapper.cpp b/ui/drivers/qt/wrapper/wrapper.cpp index 4e5cb2a9e7..38fa6a17dc 100644 --- a/ui/drivers/qt/wrapper/wrapper.cpp +++ b/ui/drivers/qt/wrapper/wrapper.cpp @@ -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 . + */ + + #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 diff --git a/ui/drivers/qt/wrapper/wrapper.h b/ui/drivers/qt/wrapper/wrapper.h index dd76a28cc4..96f5fe2dab 100644 --- a/ui/drivers/qt/wrapper/wrapper.h +++ b/ui/drivers/qt/wrapper/wrapper.h @@ -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 . + */ + + #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 } diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 5dc2ff3ce6..0b2b1ba611 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -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", };