From b32a3e55f4f79abc7be1aec76af787f135a35733 Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 1 Sep 2015 17:37:23 -0500 Subject: [PATCH 1/2] Settings are now being passed correctly to the QT side --- ui/drivers/qt/wimp/wimp.cpp | 19 ++++--------------- ui/drivers/qt/wimp/wimp.h | 25 +++++++++++++++++++++---- ui/drivers/qt/wrapper/wrapper.cpp | 8 ++++---- ui/drivers/qt/wrapper/wrapper.h | 10 ++++++++-- ui/drivers/ui_qt.c | 12 ++++-------- 5 files changed, 41 insertions(+), 33 deletions(-) diff --git a/ui/drivers/qt/wimp/wimp.cpp b/ui/drivers/qt/wimp/wimp.cpp index cfab987dce..0508385049 100644 --- a/ui/drivers/qt/wimp/wimp.cpp +++ b/ui/drivers/qt/wimp/wimp.cpp @@ -22,29 +22,18 @@ QObject *topLevel; -static settings_t *settings; - -int Wimp::CreateMainWindow(char* windowTitle) +int Wimp::CreateMainWindow() { QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); topLevel = engine.rootObjects().value(0); window = qobject_cast(topLevel); - SetTitle(windowTitle); return this->exec(); + } - -void Wimp::SetTitle(char* title) +void Wimp::GetSettings(settings_t *s) { - window->setTitle(title); -} - -void Wimp::ConfigGetPtr(settings_t *g_config) -{ - settings = g_config; - /* test print the value of max users to compare with the value in RA */ - printf("Max Users: %d\n",g_config->input.max_users); - fflush(stdout); + settings = s; } diff --git a/ui/drivers/qt/wimp/wimp.h b/ui/drivers/qt/wimp/wimp.h index 4de50e63de..4b6748e31f 100644 --- a/ui/drivers/qt/wimp/wimp.h +++ b/ui/drivers/qt/wimp/wimp.h @@ -16,12 +16,22 @@ #ifndef WIMP_H #define WIMP_H +/* this is the only define missing from config.h remove these once + * we can build everything with a single makefile + */ + +#ifndef HAVE_MENU +#define HAVE_MENU +#endif + +#include "config.h" +#include "configuration.h" + #include "wimp_global.h" #include #include #include #include -#include "configuration.h" class WIMPSHARED_EXPORT Wimp : public QGuiApplication { @@ -30,9 +40,16 @@ class WIMPSHARED_EXPORT Wimp : public QGuiApplication Q_OBJECT public: Wimp(int argc, char *argv[]): QGuiApplication(argc, argv) {} - int CreateMainWindow(char* windowTitle); - void SetTitle(char* title); - void ConfigGetPtr(settings_t *g_config); + + /* create the main QT window */ + int CreateMainWindow(); + + /* get a pointer to RetroArch settings */ + void GetSettings(settings_t *s); + + private: + /* pointer to RetroArch settings */ + settings_t *settings; }; diff --git a/ui/drivers/qt/wrapper/wrapper.cpp b/ui/drivers/qt/wrapper/wrapper.cpp index 3e1877a626..c3573e40a5 100644 --- a/ui/drivers/qt/wrapper/wrapper.cpp +++ b/ui/drivers/qt/wrapper/wrapper.cpp @@ -29,14 +29,14 @@ Wimp* ctrWimp(int argc, char *argv[]){ return new Wimp(argc,argv); } -int CreateMainWindow(Wimp* p, char* windowTitle) +int CreateMainWindow(Wimp* p) { - return p->CreateMainWindow(windowTitle); + return p->CreateMainWindow(); } -void ConfigGetPtr(Wimp*p, settings_t *g_config) +void GetSettings(Wimp* p, settings_t *s) { - return p->ConfigGetPtr(g_config); + return p->GetSettings(s); } #ifdef __cplusplus diff --git a/ui/drivers/qt/wrapper/wrapper.h b/ui/drivers/qt/wrapper/wrapper.h index 98b392063c..5329613c7d 100644 --- a/ui/drivers/qt/wrapper/wrapper.h +++ b/ui/drivers/qt/wrapper/wrapper.h @@ -13,6 +13,11 @@ * If not, see . */ +#ifndef HAVE_MENU +#define HAVE_MENU +#endif + +#include "config.h" #include "configuration.h" #ifndef WRAPPER_H @@ -23,11 +28,12 @@ extern "C" { #endif typedef struct Wimp Wimp; +typedef settings_t (*config_get_ptr_cb); Wimp* ctrWimp(int argc, char *argv[]); -int CreateMainWindow(Wimp* p, char* windowTitle); -void ConfigGetPtr(Wimp*p, settings_t *g_config); +int CreateMainWindow(Wimp* p); +void GetSettings(Wimp* p, settings_t *s); #ifdef __cplusplus } diff --git a/ui/drivers/ui_qt.c b/ui/drivers/ui_qt.c index e8ca4008a7..2068afdb8d 100644 --- a/ui/drivers/ui_qt.c +++ b/ui/drivers/ui_qt.c @@ -29,7 +29,7 @@ struct Wimp* wimp; char* args[] = {""}; - +settings_t *settings; typedef struct ui_companion_qt { @@ -41,16 +41,12 @@ typedef struct ui_companion_qt static void qt_thread(void *data) { - settings_t *settings = config_get_ptr(); - /* test print the value of max users to compare with the value in QT */ - RARCH_LOG("Max Users: %d\n", settings->input.max_users); - ui_companion_qt_t *handle = (ui_companion_qt_t*)data; wimp = ctrWimp(0, NULL); if(wimp) { - ConfigGetPtr(wimp, settings); - CreateMainWindow(wimp, "RetroArch QT"); + GetSettings(wimp, settings); + CreateMainWindow(wimp); } return; @@ -74,7 +70,7 @@ static void *ui_companion_qt_init(void) ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle)); if (!handle) return NULL; - + settings = config_get_ptr(); handle->lock = slock_new(); handle->thread = sthread_create(qt_thread, handle); if (!handle->thread) From 51a4370dda4e27b590fd67193dbdc4d3d143c35f Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 1 Sep 2015 23:48:48 -0500 Subject: [PATCH 2/2] Populate core list and collection list --- ui/drivers/qt/wimp/main.qml | 482 +++++++++++++++--------------------- ui/drivers/qt/wimp/wimp.cpp | 56 ++++- ui/drivers/qt/wimp/wimp.h | 7 + 3 files changed, 257 insertions(+), 288 deletions(-) diff --git a/ui/drivers/qt/wimp/main.qml b/ui/drivers/qt/wimp/main.qml index 3bc9d70838..1ebcbfbf80 100644 --- a/ui/drivers/qt/wimp/main.qml +++ b/ui/drivers/qt/wimp/main.qml @@ -1,301 +1,211 @@ -import QtQuick 2.4 -import QtQuick.Window 2.2 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.1 +import QtQuick 2.2 +import Material 0.1 +import Material.ListItems 0.1 as ListItem - -Window { +ApplicationWindow { id: mainWindow title: "RetroArch" width: 1280 height: 720 color: "#211822" visible: true - - SplitView { - anchors.fill: parent - orientation: Qt.Horizontal - - Rectangle { - id: consoleBar; - color: "#2b2b2b"; - height: 500; - width: 250; - Layout.maximumWidth: 400 - - Rectangle { - id: rightBord; - anchors { - top: parent.top; - bottom: parent.bottom; - right: parent.right; - } - width: 1; - color: "#1a1a1a"; - } - - Row { - id: leftBord; - anchors { - left: parent.left; - top: parent.top; - bottom: parent.bottom; - } - } - - - Rectangle { - id: consoleHeader; - height: 36; - color: parent.color; - - anchors { - top: parent.top; - //topMargin: 12; - left: parent.left; - right: parent.right; - rightMargin: 1; - } - } - - MouseArea { - id: mouse; - anchors.fill: parent; - onClicked: { - if (listView.retractList) - listView.retractList = false; - else - listView.retractList = true; - } - } - Row { - anchors { - left: parent.left; - top: parent.top; - topMargin: 12; - leftMargin: 12; - horizontalCenter: parent.horizontalCenter; - } - Text { - renderType: Text.QtRendering; - text: "Platforms"; - color: "#f1f1f1"; - font { - bold: true; - family: "Sans"; - pixelSize: 12; - } - } - } - ListModel { - id: platformsModel - ListElement { name: "Megadrive" } - ListElement { name: "Nintendo" } - ListElement { name: "Playstation" } - } - ListView { - id: listView; - visible: (height !== 0); - anchors { - top: consoleHeader.bottom; - //bottom: parent.bottom; - right: parent.right; - left: parent.left; - topMargin: 0; - } - - height: retractList ? 0 : 500; - - Behavior on height { - PropertyAnimation {} - } - - snapMode: ListView.SnapToItem; - orientation: ListView.Vertical; - interactive: true; - highlightFollowsCurrentItem: false; - - property bool retractList: false; - - highlight: Item { - id: highlightItem; - visible: !listView.retractList; - height: listView.currentItem.height; - width: listView.width; - anchors.verticalCenter: listView.currentItem.verticalCenter; - y: listView.currentItem.y; - Item { - id: innerItem; - height: parent.height; - width: parent.width; - - - - - Rectangle { - id: mainColor; - anchors { - left: parent.left; - right: parent.right; - top: parent.top; - bottom: parent.bottom; - } - color: listView.currentItem ? "#171717" : "#000000FF"; - Rectangle { - id: topBorder; - color: "#f27b77"; - anchors { - left: parent.left; - leftMargin: leftBord.width; - top: parent.top; - } - height: 2; - width: 4; - } - - Row { - // leftAccent; - anchors { - left: parent.left; - leftMargin: leftBord.width; - bottom: bottomB.top; - top: topBorder.bottom; - } - - Rectangle { - anchors { - top: parent.top; - bottom: parent.bottom; - } - width: 1; - color: "#db5753"; - } - - Rectangle { - anchors { - top: parent.top; - bottom: parent.bottom; - } - width: 3; - color: "#e8433f"; - } - - } - - Column { - id: bottomB; - anchors { - right: parent.right; - rightMargin: rightBord.width; - left: parent.left; - leftMargin: leftBord.width; - bottom: parent.bottom; - } - - Rectangle { - color: "#a22f2c"; - anchors { - left: parent.left; - } - width: 4; - height: 2; - } - Rectangle { - color: "#474747"; - anchors { - left: parent.left; - right: parent.right; - } - height: 1; - } - } - } - - - } - } - - anchors { - right: parent.right; - left: parent.left; - top: consoleLabel.bottom; - topMargin: 10; - } - - model: platformsModel; - - ExclusiveGroup { - id: consoleGroup - } - - delegate: Item { - //visible: !listView.retractList; - height: 22; - width: consoleBar.width; - Row { - id: row; - anchors { - fill: parent; - leftMargin: 25; - } - spacing: 7; - - Image { - anchors.verticalCenter: parent.verticalCenter; - fillMode: Image.PreserveAspectFit; - sourceSize { - height: 24; - width: 24; - } - height: 20; - width: 20; - } - - Text { - id: consoleItem; - anchors.verticalCenter: parent.verticalCenter; - width: 140; - text: modelData; - color: "#f1f1f1"; - renderType: Text.QtRendering; - elide: Text.ElideRight; - font { - family: "Sans"; - pixelSize: 11; - } - } - } - - MouseArea { - anchors.fill: parent; - onClicked: { - listView.currentIndex = index; - - } - } - } - } - - - } - - Rectangle { - id: centerItem - Layout.minimumWidth: 50 - Layout.fillWidth: true - color: "lightgray" - Text { - text: "Content View" - anchors.centerIn: parent - } - - } - + theme { + primaryColor: Palette.colors["blue"]["500"] + primaryDarkColor: Palette.colors["blue"]["700"] + accentColor: Palette.colors["red"]["A200"] + tabHighlightColor: "white" } + /* temporary top level folder list */ + property var folders: [ + "C:\\", "D:\\" + ] + + property var sections: [ collections, cores, folders ] + property var sectionTitles: [ "Collections", "Cores", "File Browser" ] + + property string selectedItem: collections[0] + initialPage: Page { + id: page + + title: "RetroArch" + + tabs: navDrawer.enabled ? [] : sectionTitles + + actionBar.maxActionCount: navDrawer.enabled ? 3 : 4 + + actions: [ + Action { + iconName: "action/search" + name: "Search" + enabled: true + }, + + Action { + iconName: "image/color_lens" + name: "Colors" + onTriggered: colorPicker.show() + }, + + Action { + iconName: "action/settings" + name: "Settings" + hoverAnimation: true + }, + Action { + iconName: "action/language" + name: "Language" + enabled: true + }, + + Action { + iconName: "action/account_circle" + name: "Accounts" + } + ] + + backAction: navDrawer.action + + NavigationDrawer { + id: navDrawer + enabled: page.width < Units.dp(500) + + + Flickable { + anchors.fill: parent + + contentHeight: Math.max(content.implicitHeight, height) + + Column { + id: content + anchors.fill: parent + + Repeater { + model: sections + + delegate: ListItem.Standard { + width: parent.width + ListItem.Subheader { + text: sectionTitles[index] + } + } + } + } + } + } + + TabView { + id: tabView + anchors.fill: parent + currentIndex: page.selectedTab + model: sections + + + delegate: Item { + width: tabView.width + height: tabView.height + clip: true + + Sidebar { + id: sidebar + + expanded: !navDrawer.enabled + + Column { + width: parent.width + + Repeater { + model: modelData + delegate: ListItem.Standard { + text: modelData + selected: modelData == selectedItem + onClicked: selectedItem = modelData + } + } + } + } + Flickable { + id: flickable + anchors { + left: sidebar.right + right: parent.right + top: parent.top + bottom: parent.bottom + } + clip: true + Column { + width: parent.width + } + + } + Scrollbar { + flickableItem: flickable + } + } + } + } + + Dialog { + id: colorPicker + title: "Pick color" + + positiveButtonText: "Done" + + MenuField { + id: selection + model: ["Primary color", "Accent color", "Background color"] + width: Units.dp(160) + } + + Grid { + columns: 7 + spacing: Units.dp(8) + + Repeater { + model: [ + "red", "pink", "purple", "deepPurple", "indigo", + "blue", "lightBlue", "cyan", "teal", "green", + "lightGreen", "lime", "yellow", "amber", "orange", + "deepOrange", "grey", "blueGrey", "brown", "black", + "white" + ] + + Rectangle { + width: Units.dp(30) + height: Units.dp(30) + radius: Units.dp(2) + color: Palette.colors[modelData]["500"] + border.width: modelData === "white" ? Units.dp(2) : 0 + border.color: Theme.alpha("#000", 0.26) + + Ink { + anchors.fill: parent + + onPressed: { + switch(selection.selectedIndex) { + case 0: + theme.primaryColor = parent.color + break; + case 1: + theme.accentColor = parent.color + break; + case 2: + theme.backgroundColor = parent.color + break; + } + } + } + } + } + } + + onRejected: { + // TODO set default colors again but we currently don't know what that is + } + } } diff --git a/ui/drivers/qt/wimp/wimp.cpp b/ui/drivers/qt/wimp/wimp.cpp index 0508385049..cd75373fea 100644 --- a/ui/drivers/qt/wimp/wimp.cpp +++ b/ui/drivers/qt/wimp/wimp.cpp @@ -17,18 +17,34 @@ #include "stdio.h" #include #include -#include #include +#include +#include +#include QObject *topLevel; int Wimp::CreateMainWindow() { - QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); topLevel = engine.rootObjects().value(0); window = qobject_cast(topLevel); + if(settings->playlist_directory[0] != '\0') + GetCollections(settings->playlist_directory); + else + collections.append("Collection dir not defined"); + + engine.rootContext()->setContextProperty("collections", QVariant::fromValue(collections)); + + if(settings->libretro_directory[0] != '\0') + GetCores(settings->libretro_directory); + else + cores.append("Core dir not defined"); + + engine.rootContext()->setContextProperty("cores", QVariant::fromValue(cores)); + return this->exec(); } @@ -37,3 +53,39 @@ void Wimp::GetSettings(settings_t *s) { settings = s; } + +void Wimp::GetCollections(char* path) +{ + QDir dir(path); + dir.setNameFilters(QStringList("*.lpl")); + QStringList fileList = dir.entryList(); + + if(fileList.count() == 0) + collections.append("Empty"); + + for (int i=0; i < fileList.count(); i++) + { + QString collection = fileList[i].section('.',0,0); + collections.append(collection); + qDebug() << "Found file: " << collection; + } + +} + +void Wimp::GetCores(char* path) +{ + QDir dir(path); + dir.setNameFilters(QStringList("*.dll")); + QStringList fileList = dir.entryList(); + + if(fileList.count() == 0) + cores.append("Empty"); + + for (int i=0; i < fileList.count(); i++) + { + QString core = fileList[i].section('.',0,0); + cores.append(core); + qDebug() << "Found file: " << core; + } + +} diff --git a/ui/drivers/qt/wimp/wimp.h b/ui/drivers/qt/wimp/wimp.h index 4b6748e31f..6c7c368677 100644 --- a/ui/drivers/qt/wimp/wimp.h +++ b/ui/drivers/qt/wimp/wimp.h @@ -47,10 +47,17 @@ class WIMPSHARED_EXPORT Wimp : public QGuiApplication /* get a pointer to RetroArch settings */ void GetSettings(settings_t *s); + void GetCollections(char* path); + void GetCores(char* path); + private: /* pointer to RetroArch settings */ settings_t *settings; + QStringList collections; + QStringList cores; + QQmlApplicationEngine engine; }; #endif // WIMP_H +