From a956a9f8e8b83091fd2aeb2e148f415bde496325 Mon Sep 17 00:00:00 2001 From: Radius Date: Sun, 12 Apr 2015 15:20:57 -0400 Subject: [PATCH] Add QT projects --- ui/drivers/qt/wimp/main.qml | 301 +++++++++++++++++++++++++++ ui/drivers/qt/wimp/qml.qrc | 5 + ui/drivers/qt/wimp/wimp.cpp | 18 ++ ui/drivers/qt/wimp/wimp.h | 19 ++ ui/drivers/qt/wimp/wimp.pro | 27 +++ ui/drivers/qt/wimp/wimp_global.h | 12 ++ ui/drivers/qt/wimp/wrapper.h | 12 ++ ui/drivers/qt/wrapper/deployment.pri | 191 +++++++++++++++++ ui/drivers/qt/wrapper/wrapper.cpp | 23 ++ ui/drivers/qt/wrapper/wrapper.h | 18 ++ ui/drivers/qt/wrapper/wrapper.pro | 26 +++ ui/drivers/ui_qt.cpp | 31 +-- 12 files changed, 661 insertions(+), 22 deletions(-) create mode 100644 ui/drivers/qt/wimp/main.qml create mode 100644 ui/drivers/qt/wimp/qml.qrc create mode 100644 ui/drivers/qt/wimp/wimp.cpp create mode 100644 ui/drivers/qt/wimp/wimp.h create mode 100644 ui/drivers/qt/wimp/wimp.pro create mode 100644 ui/drivers/qt/wimp/wimp_global.h create mode 100644 ui/drivers/qt/wimp/wrapper.h create mode 100644 ui/drivers/qt/wrapper/deployment.pri create mode 100644 ui/drivers/qt/wrapper/wrapper.cpp create mode 100644 ui/drivers/qt/wrapper/wrapper.h create mode 100644 ui/drivers/qt/wrapper/wrapper.pro diff --git a/ui/drivers/qt/wimp/main.qml b/ui/drivers/qt/wimp/main.qml new file mode 100644 index 0000000000..3bc9d70838 --- /dev/null +++ b/ui/drivers/qt/wimp/main.qml @@ -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 + } + + } + + } + + + + + + +} diff --git a/ui/drivers/qt/wimp/qml.qrc b/ui/drivers/qt/wimp/qml.qrc new file mode 100644 index 0000000000..219fc5bcb4 --- /dev/null +++ b/ui/drivers/qt/wimp/qml.qrc @@ -0,0 +1,5 @@ + + + main.qml + + diff --git a/ui/drivers/qt/wimp/wimp.cpp b/ui/drivers/qt/wimp/wimp.cpp new file mode 100644 index 0000000000..a0b5f72289 --- /dev/null +++ b/ui/drivers/qt/wimp/wimp.cpp @@ -0,0 +1,18 @@ +#include "wimp.h" +#include "stdio.h" +#include +#include +#include + +int Wimp::CreateMainWindow() +{ + + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return this->exec(); +} + + + diff --git a/ui/drivers/qt/wimp/wimp.h b/ui/drivers/qt/wimp/wimp.h new file mode 100644 index 0000000000..7df55a6198 --- /dev/null +++ b/ui/drivers/qt/wimp/wimp.h @@ -0,0 +1,19 @@ +#ifndef WIMP_H +#define WIMP_H + +#include "wimp_global.h" +#include +#include +#include + + +class WIMPSHARED_EXPORT Wimp : public QGuiApplication +{ + Q_OBJECT + public: + Wimp(int argc, char *argv[]): QGuiApplication(argc, argv) {} + int CreateMainWindow(); + +}; + +#endif // WIMP_H diff --git a/ui/drivers/qt/wimp/wimp.pro b/ui/drivers/qt/wimp/wimp.pro new file mode 100644 index 0000000000..69c9bfbc3f --- /dev/null +++ b/ui/drivers/qt/wimp/wimp.pro @@ -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 diff --git a/ui/drivers/qt/wimp/wimp_global.h b/ui/drivers/qt/wimp/wimp_global.h new file mode 100644 index 0000000000..aacd72fedb --- /dev/null +++ b/ui/drivers/qt/wimp/wimp_global.h @@ -0,0 +1,12 @@ +#ifndef WIMP_GLOBAL_H +#define WIMP_GLOBAL_H + +#include + +#if defined(WIMP_LIBRARY) +# define WIMPSHARED_EXPORT Q_DECL_EXPORT +#else +# define WIMPSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // WIMP_GLOBAL_H diff --git a/ui/drivers/qt/wimp/wrapper.h b/ui/drivers/qt/wimp/wrapper.h new file mode 100644 index 0000000000..f7648eb0ce --- /dev/null +++ b/ui/drivers/qt/wimp/wrapper.h @@ -0,0 +1,12 @@ +#ifndef WRAPPER_H +#define WRAPPER_H + +extern "C" { + + + + +} + + +#endif // WRAPPER_H diff --git a/ui/drivers/qt/wrapper/deployment.pri b/ui/drivers/qt/wrapper/deployment.pri new file mode 100644 index 0000000000..4642d1b5ac --- /dev/null +++ b/ui/drivers/qt/wrapper/deployment.pri @@ -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) +} + diff --git a/ui/drivers/qt/wrapper/wrapper.cpp b/ui/drivers/qt/wrapper/wrapper.cpp new file mode 100644 index 0000000000..2dae2d2e2f --- /dev/null +++ b/ui/drivers/qt/wrapper/wrapper.cpp @@ -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 diff --git a/ui/drivers/qt/wrapper/wrapper.h b/ui/drivers/qt/wrapper/wrapper.h new file mode 100644 index 0000000000..dd76a28cc4 --- /dev/null +++ b/ui/drivers/qt/wrapper/wrapper.h @@ -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 diff --git a/ui/drivers/qt/wrapper/wrapper.pro b/ui/drivers/qt/wrapper/wrapper.pro new file mode 100644 index 0000000000..6b3cd35689 --- /dev/null +++ b/ui/drivers/qt/wrapper/wrapper.pro @@ -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 diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 5f0b496dc2..5dc2ff3ce6 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -23,13 +23,7 @@ #include #include "../ui_companion_driver.h" -#include -#include -#include -#include -#include -#include -#include +#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)