mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 06:40:18 +00:00
Merge pull request #2090 from fr500/master
[QT] populate core list and collection list
This commit is contained in:
commit
d16ec2fc3b
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,34 +17,75 @@
|
||||
#include "stdio.h"
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QListView>
|
||||
#include <QQuickWindow>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QQmlContext>
|
||||
|
||||
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<QQuickWindow *>(topLevel);
|
||||
SetTitle(windowTitle);
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Wimp::SetTitle(char* title)
|
||||
void Wimp::GetSettings(settings_t *s)
|
||||
{
|
||||
window->setTitle(title);
|
||||
settings = s;
|
||||
}
|
||||
|
||||
void Wimp::ConfigGetPtr(settings_t *g_config)
|
||||
void Wimp::GetCollections(char* path)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 <QtWidgets/qwidget.h>
|
||||
#include <QtWidgets/qapplication.h>
|
||||
#include <QtQml/qqmlapplicationengine.h>
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include "configuration.h"
|
||||
|
||||
class WIMPSHARED_EXPORT Wimp : public QGuiApplication
|
||||
{
|
||||
@ -30,10 +40,24 @@ 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);
|
||||
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
|
@ -13,6 +13,11 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user