1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-11-21 16:55:17 +00:00

Make libJellyfinQt a proper qml plugin

This commit is contained in:
Chris Josten 2021-09-04 22:23:54 +02:00
parent 96ecd8e7d8
commit 64ad37707c
9 changed files with 1923 additions and 58 deletions

View file

@ -14,16 +14,20 @@ option(BUILD_PRECOMPILED_HEADERS "Build with precompiled headers for faster comp
option(USE_MLITE "Build with mlite (MeeGo lite library), only available on Linux-based platforms. Used to store settings using DConf." OFF)
if (NOT SAILFIN_VERSION)
set(SAILFIN_VERSION "1.0.0")
set(SAILFIN_VERSION "1.0.0")
endif()
if(PLATFORM_SAILFISHOS)
# Hardcode this less?
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/share/harbour-sailfin/lib")
set(USE_MLITE ON)
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/share/harbour-sailfin/nl/netsoj/chris/Jellyfin")
set(USE_MLITE ON)
endif()
if (PLATFORM_SAILFISHOS)
set(CMAKE_BUILD_SHARED_LIBS NO)
endif()
add_subdirectory(core)
if(PLATFORM_SAILFISHOS)
add_subdirectory(sailfish)
elseif(PLATFORM_QTQUICK)

View file

@ -101,7 +101,7 @@ endif()
add_library(JellyfinQt ${JellyfinQt_SOURCES} ${JellyfinQt_HEADERS})
add_library(JellyfinQt ${JellyfinQt_SOURCES} ${JellyfinQt_HEADERS} qmldir JellyfinQt.qmltypes)
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
if(BUILD_PRECOMPILED_HEADERS)
@ -128,4 +128,29 @@ install(TARGETS JellyfinQt
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
add_custom_target(qmltypes
COMMAND qmlplugindump -nonrelocatable nl.netsoj.chris.Jellyfin 1.0 > $$PWD/JellyfinQt.qmltypes)
add_custom_command(
TARGET JellyfinQt
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_LIST_DIR}/qmldir
$<TARGET_FILE_DIR:JellyfinQt>/qmldir
)
add_custom_command(
TARGET JellyfinQt
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_LIST_DIR}/JellyfinQt.qmltypes
$<TARGET_FILE_DIR:JellyfinQt>/JellyfinQt.qmltypes
)
set(QML_IMPORT_PATH $<TARGET_FILE_DIR:JellyfinQt> CACHE PATH "")
install(FILES $<TARGET_FILE_DIR:JellyfinQt>/qmldir DESTINATION ${CMAKE_INSTALL_LIBDIR})
export(TARGETS JellyfinQt FILE JellyfinQtConfig.cmake)

1828
core/JellyfinQt.qmltypes Normal file

File diff suppressed because it is too large Load diff

View file

@ -19,35 +19,18 @@
#ifndef JELLYFIN_H
#define JELLYFIN_H
#include <QQmlExtensionPlugin>
#include <QtQml>
#include "model/item.h"
#include "dto/itemfields.h"
#include "dto/mediastream.h"
#include "dto/nameguidpair.h"
#include "dto/userdto.h"
#include "dto/useritemdatadto.h"
#include "apiclient.h"
#include "apimodel.h"
#include "serverdiscoverymodel.h"
#include "websocket.h"
#include "viewmodel/item.h"
#include "viewmodel/itemmodel.h"
#include "viewmodel/loader.h"
#include "viewmodel/mediastream.h"
#include "viewmodel/modelstatus.h"
#include "viewmodel/platformmediacontrol.h"
#include "viewmodel/playbackmanager.h"
#include "viewmodel/playlist.h"
#include "viewmodel/settings.h"
#include "viewmodel/userdata.h"
#include "viewmodel/usermodel.h"
#include "viewmodel/user.h"
namespace Jellyfin {
void registerTypes(const char *uri = "nl.netsoj.chris.Jellyfin");
class JellyfinPlugin : public QQmlExtensionPlugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char *uri) override;
};
}

View file

@ -0,0 +1,2 @@
module nl.netsoj.chris.Jellyfin
plugin JellyfinQt

View file

@ -17,9 +17,34 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "JellyfinQt/jellyfin.h"
#include "JellyfinQt/model/item.h"
#include "JellyfinQt/dto/itemfields.h"
#include "JellyfinQt/dto/mediastream.h"
#include "JellyfinQt/dto/nameguidpair.h"
#include "JellyfinQt/dto/userdto.h"
#include "JellyfinQt/dto/useritemdatadto.h"
#include "JellyfinQt/apiclient.h"
#include "JellyfinQt/apimodel.h"
#include "JellyfinQt/serverdiscoverymodel.h"
#include "JellyfinQt/websocket.h"
#include "JellyfinQt/viewmodel/item.h"
#include "JellyfinQt/viewmodel/itemmodel.h"
#include "JellyfinQt/viewmodel/loader.h"
#include "JellyfinQt/viewmodel/mediastream.h"
#include "JellyfinQt/viewmodel/modelstatus.h"
#include "JellyfinQt/viewmodel/platformmediacontrol.h"
#include "JellyfinQt/viewmodel/playbackmanager.h"
#include "JellyfinQt/viewmodel/playlist.h"
#include "JellyfinQt/viewmodel/settings.h"
#include "JellyfinQt/viewmodel/userdata.h"
#include "JellyfinQt/viewmodel/usermodel.h"
#include "JellyfinQt/viewmodel/user.h"
namespace Jellyfin {
void registerTypes(const char *uri) {
void JellyfinPlugin::registerTypes(const char *uri) {
qmlRegisterType<ApiClient>(uri, 1, 0, "ApiClient");
qmlRegisterType<ServerDiscoveryModel>(uri, 1, 0, "ServerDiscoveryModel");
qmlRegisterType<ViewModel::PlaybackManager>(uri, 1, 0, "PlaybackManager");

View file

@ -14,6 +14,9 @@
int main(int argc, char** argv) {
QGuiApplication app(argc, argv);
app.setApplicationDisplayName(QStringLiteral("Sailfin QtQuick"));
app.setApplicationName("Sailfin QtQuick");
app.setOrganizationDomain("nl.netsoj.chris");
app.setOrganizationName("Chris Josten");
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
// Disable Qt nagging about "implicitly defined onFoo properties in connections are deprecated",
@ -25,7 +28,8 @@ int main(int argc, char** argv) {
QQmlApplicationEngine engine;
qDebug() << "Registering types";
Jellyfin::registerTypes();
Jellyfin::JellyfinPlugin plugin;
plugin.registerTypes("nl.netsoj.chris.Jellyfin");
qDebug() << "Loading file";
engine.load(QStringLiteral("qrc:/qml/main.qml"));

View file

@ -5,11 +5,11 @@ include(ExternalProject)
# FIXME: don't hardcode /home/deploy/installroot/
set(DEPLOY_ROOT /home/deploy/installroot/)
ExternalProject_Add(BlurhashQt
# PREFIX ${CMAKE_CURRENT_BINARY_DIR}/lib/blurhash-qt
GIT_REPOSITORY https://github.com/HenkKalkwater/BlurhashQt.git
GIT_TAG 61ae7f0feca6ab67da1bfdbcb222bbd12e8f7e07
# PREFIX ${CMAKE_CURRENT_BINARY_DIR}/lib/blurhash-qt
GIT_REPOSITORY https://github.com/HenkKalkwater/BlurhashQt.git
GIT_TAG 61ae7f0feca6ab67da1bfdbcb222bbd12e8f7e07
CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=ON -DENABLE_EXPORT=OFF -DQML_PLUGIN_PATH=${PROJECT_BINARY_DIR}/plugins/)
CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=ON -DENABLE_EXPORT=OFF -DQML_PLUGIN_PATH=${PROJECT_BINARY_DIR}/plugins/)
find_package(Qt5 COMPONENTS Gui Qml Quick)
find_package(SailfishApp 1.0 REQUIRED)
@ -26,8 +26,8 @@ set(sailfin_QML_SOURCES
qml/components/videoplayer/VideoError.qml
qml/components/videoplayer/VideoHud.qml
qml/components/IconListItem.qml
qml/components/JItem.qml
qml/components/LibraryItemDelegate.qml
qml/components/JItem.qml
qml/components/LibraryItemDelegate.qml
qml/components/MoreSection.qml
qml/components/PlainLabel.qml
qml/components/PlaybackBar.qml
@ -58,9 +58,10 @@ set(sailfin_QML_SOURCES
qml/pages/itemdetails/UnsupportedPage.qml
qml/pages/itemdetails/VideoPage.qml
qml/pages/settings/DebugPage.qml
qml/pages/settings/StreamingPage.qml
qml/pages/setup/AddServerConnectingPage.qml
qml/pages/setup/AddServerPage.qml
qml/pages/setup/LoginDialog.qml
qml/pages/setup/AddServerPage.qml
qml/pages/setup/LoginDialog.qml
qml/qmldir)
add_executable(harbour-sailfin ${harbour-sailfin_SOURCES} ${sailfin_QML_SOURCES})
@ -69,35 +70,33 @@ target_link_libraries(harbour-sailfin PRIVATE Qt5::Gui Qt5::Qml Qt5::Quick Sailf
# invoker/booster to work
JellyfinQt "-Wl,-rpath,${CMAKE_INSTALL_LIBDIR} -rdynamic -pie")
target_compile_definitions(harbour-sailfin
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
install(TARGETS harbour-sailfin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${PROJECT_BINARY_DIR}/plugins/
DESTINATION share/harbour-sailfin/)
DESTINATION share/harbour-sailfin/)
install(DIRECTORY qml
DESTINATION share/harbour-sailfin
DESTINATION share/harbour-sailfin
)
install(DIRECTORY translations
DESTINATION share/harbour-sailfin
FILES_MATCHING PATTERN "*.qm"
DESTINATION share/harbour-sailfin
FILES_MATCHING PATTERN "*.qm"
)
install(FILES harbour-sailfin.desktop
DESTINATION share/applications
DESTINATION share/applications
)
install(FILES icons/86x86/harbour-sailfin.png
DESTINATION share/icons/hicolor/86x86/apps
DESTINATION share/icons/hicolor/86x86/apps
)
install(FILES icons/108x108/harbour-sailfin.png
DESTINATION share/icons/hicolor/108x108/apps
)
DESTINATION share/icons/hicolor/108x108/apps )
install(FILES icons/128x128/harbour-sailfin.png
DESTINATION share/icons/hicolor/128x128/apps
DESTINATION share/icons/hicolor/128x128/apps
)
install(FILES icons/172x172/harbour-sailfin.png
DESTINATION share/icons/hicolor/172x172/apps
)
DESTINATION share/icons/hicolor/172x172/apps )
# Tell Qt Creator where the application executable(s) would be located on the
# device.
@ -111,6 +110,6 @@ install(FILES icons/172x172/harbour-sailfin.png
# Search the Qt Creator Manual to learn about the QtCreatorDeployment.txt file
# format.
file(WRITE "${CMAKE_BINARY_DIR}/QtCreatorDeployment.txt"
"${CMAKE_INSTALL_PREFIX}
${CMAKE_BINARY_DIR}/sailfish/harbour-sailfin:bin
"${CMAKE_INSTALL_PREFIX}
${CMAKE_BINARY_DIR}/sailfish/harbour-sailfin:bin
")

View file

@ -33,10 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <sailfishapp.h>
#include <JellyfinQt/jellyfin.h>
static const char *SANDBOX_PROGRAM = "/usr/bin/sailjail";
int main(int argc, char *argv[]) {
//QQmlDebuggingEnabler enabler;
//enabler.startTcpDebugServer(9999);
@ -60,7 +56,6 @@ int main(int argc, char *argv[]) {
cmdParser.addHelpOption();
cmdParser.addVersionOption();
Jellyfin::registerTypes();
QQuickView *view = SailfishApp::createView();
view->setSource(SailfishApp::pathToMainQml());
view->show();