Add QT projects

This commit is contained in:
Radius 2015-04-12 15:20:57 -04:00
parent 7fbbac544e
commit a956a9f8e8
12 changed files with 661 additions and 22 deletions

301
ui/drivers/qt/wimp/main.qml Normal file
View File

@ -0,0 +1,301 @@
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
Window {
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
}
}
}
}

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View File

@ -0,0 +1,18 @@
#include "wimp.h"
#include "stdio.h"
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QListView>
int Wimp::CreateMainWindow()
{
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return this->exec();
}

19
ui/drivers/qt/wimp/wimp.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef WIMP_H
#define WIMP_H
#include "wimp_global.h"
#include <QtWidgets/qwidget.h>
#include <QtWidgets/qapplication.h>
#include <QtQml/qqmlapplicationengine.h>
class WIMPSHARED_EXPORT Wimp : public QGuiApplication
{
Q_OBJECT
public:
Wimp(int argc, char *argv[]): QGuiApplication(argc, argv) {}
int CreateMainWindow();
};
#endif // WIMP_H

View File

@ -0,0 +1,27 @@
#-------------------------------------------------
#
# Project created by QtCreator 2014-10-21T21:15:44
#
#-------------------------------------------------
QT += qml quick widgets
TARGET = wimp
TEMPLATE = lib
DEFINES += WIMP_LIBRARY
SOURCES += \
wimp.cpp
HEADERS +=\
wimp.h \
wimp_global.h
unix {
target.path = /usr/lib
INSTALLS += target
}
RESOURCES += \
qml.qrc

View File

@ -0,0 +1,12 @@
#ifndef WIMP_GLOBAL_H
#define WIMP_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(WIMP_LIBRARY)
# define WIMPSHARED_EXPORT Q_DECL_EXPORT
#else
# define WIMPSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // WIMP_GLOBAL_H

View File

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

View File

@ -0,0 +1,191 @@
# This file was generated by an application wizard of Qt Creator.
# The code below handles deployment to Android and Maemo, aswell as copying
# of the application data to shadow build directories on desktop.
# It is recommended not to modify this file, since newer versions of Qt Creator
# may offer an updated version of it.
defineTest(qtcAddDeployment) {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
greaterThan(QT_MAJOR_VERSION, 4) {
itemsources = $${item}.files
} else {
itemsources = $${item}.sources
}
$$itemsources = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath= $$eval($${deploymentfolder}.target)
export($$itemsources)
export($$itempath)
DEPLOYMENT += $$item
}
MAINPROFILEPWD = $$PWD
android-no-sdk {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
itemfiles = $${item}.files
$$itemfiles = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath = /data/user/qt/$$eval($${deploymentfolder}.target)
export($$itemfiles)
export($$itempath)
INSTALLS += $$item
}
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
itemfiles = $${item}.files
$$itemfiles = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath = /assets/$$eval($${deploymentfolder}.target)
export($$itemfiles)
export($$itempath)
INSTALLS += $$item
}
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:win32 {
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
source = $$replace(source, /, \\)
sourcePathSegments = $$split(source, \\)
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
target = $$replace(target, /, \\)
target ~= s,\\\\\\.?\\\\,\\,
!isEqual(source,$$target) {
!isEmpty(copyCommand):copyCommand += &&
isEqual(QMAKE_DIR_SEP, \\) {
copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
} else {
source = $$replace(source, \\\\, /)
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
target = $$replace(target, \\\\, /)
copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\"
}
}
}
!isEmpty(copyCommand) {
copyCommand = @echo Copying application data... && $$copyCommand
copydeploymentfolders.commands = $$copyCommand
first.depends = $(first) copydeploymentfolders
export(first.depends)
export(copydeploymentfolders.commands)
QMAKE_EXTRA_TARGETS += first copydeploymentfolders
}
} else:ios {
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
source = $$replace(source, \\\\, /)
target = $CODESIGNING_FOLDER_PATH/$$eval($${deploymentfolder}.target)
target = $$replace(target, \\\\, /)
sourcePathSegments = $$split(source, /)
targetFullPath = $$target/$$last(sourcePathSegments)
targetFullPath ~= s,/\\.?/,/,
!isEqual(source,$$targetFullPath) {
!isEmpty(copyCommand):copyCommand += &&
copyCommand += mkdir -p \"$$target\"
copyCommand += && cp -r \"$$source\" \"$$target\"
}
}
!isEmpty(copyCommand) {
copyCommand = echo Copying application data... && $$copyCommand
!isEmpty(QMAKE_POST_LINK): QMAKE_POST_LINK += ";"
QMAKE_POST_LINK += "$$copyCommand"
export(QMAKE_POST_LINK)
}
} else:unix {
maemo5 {
desktopfile.files = $${TARGET}.desktop
desktopfile.path = /usr/share/applications/hildon
icon.files = $${TARGET}64.png
icon.path = /usr/share/icons/hicolor/64x64/apps
} else:!isEmpty(MEEGO_VERSION_MAJOR) {
desktopfile.files = $${TARGET}_harmattan.desktop
desktopfile.path = /usr/share/applications
icon.files = $${TARGET}80.png
icon.path = /usr/share/icons/hicolor/80x80/apps
} else { # Assumed to be a Desktop Unix
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
source = $$replace(source, \\\\, /)
macx {
target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
} else {
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
}
target = $$replace(target, \\\\, /)
sourcePathSegments = $$split(source, /)
targetFullPath = $$target/$$last(sourcePathSegments)
targetFullPath ~= s,/\\.?/,/,
!isEqual(source,$$targetFullPath) {
!isEmpty(copyCommand):copyCommand += &&
copyCommand += $(MKDIR) \"$$target\"
copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
}
}
!isEmpty(copyCommand) {
copyCommand = @echo Copying application data... && $$copyCommand
copydeploymentfolders.commands = $$copyCommand
first.depends = $(first) copydeploymentfolders
export(first.depends)
export(copydeploymentfolders.commands)
QMAKE_EXTRA_TARGETS += first copydeploymentfolders
}
}
!isEmpty(target.path) {
installPrefix = $${target.path}
} else {
installPrefix = /opt/$${TARGET}
}
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
itemfiles = $${item}.files
$$itemfiles = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target)
export($$itemfiles)
export($$itempath)
INSTALLS += $$item
}
!isEmpty(desktopfile.path) {
export(icon.files)
export(icon.path)
export(desktopfile.files)
export(desktopfile.path)
INSTALLS += icon desktopfile
}
isEmpty(target.path) {
target.path = $${installPrefix}/bin
export(target.path)
}
INSTALLS += target
}
export (ICON)
export (INSTALLS)
export (DEPLOYMENT)
export (LIBS)
export (QMAKE_EXTRA_TARGETS)
}

View File

@ -0,0 +1,23 @@
#include "../../wimp/wimp/wimp.h"
#include "../../wimp/wimp/wimp_global.h"
#include "wrapper.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Wimp Wimp;
Wimp* ctrWimp(int argc, char *argv[]){
return new Wimp(argc,argv);
}
int CreateMainWindow(Wimp* p)
{
return p->CreateMainWindow();
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,18 @@
#ifndef WRAPPER_H
#define WRAPPER_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Wimp Wimp;
Wimp* ctrWimp(int argc, char *argv[]);
int CreateMainWindow(Wimp* p);
#ifdef __cplusplus
}
#endif
#endif // WRAPPER_H

View File

@ -0,0 +1,26 @@
TEMPLATE = lib
CONFIG += console
CONFIG -= app_bundle
#CONFIG -= qt
QT += qml quick widgets
SOURCES += \
wrapper.cpp
include(deployment.pri)
qtcAddDeployment()
HEADERS += \
wrapper.h
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../wimp/build/release/ -lwimp
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../wimp/build/debug/ -lwimp
INCLUDEPATH += $$PWD/../../wimp/build/debug
DEPENDPATH += $$PWD/../../wimp/build/debug
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../wimp/build/release/libwimp.dll.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../wimp/build/debug/libwimp.dll.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../wimp/build/release/wimp.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../wimp/build/debug/wimp.lib

View File

@ -23,13 +23,7 @@
#include <rthreads/rthreads.h>
#include "../ui_companion_driver.h"
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QListView>
#include <QtWidgets/qwidget.h>
#include <QtWidgets/qapplication.h>
#include <QtQml/qqmlapplicationengine.h>
#include <QtCore/qglobal.h>
#include "qt/wrapper/wrapper.h"
typedef struct ui_companion_qt
{
@ -38,25 +32,18 @@ typedef struct ui_companion_qt
sthread_t *thread;
} ui_companion_qt_t;
class QtApp : public QGuiApplication
{
Q_OBJECT
public:
QtApp(int argc, char *argv[]): QGuiApplication(argc, argv) {}
int CreateMainWindow()
{
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return this->exec();
}
};
static void qt_thread(void *data)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
/* call CreateMainWindow here */
struct Wimp* wimp;
char** args = (char**)NULL;
wimp = ctrWimp(0, args);
CreateMainWindow(wimp);
return;
}
static void ui_companion_qt_deinit(void *data)