From adde49fbb3635967f88818fa07af7142cab88b35 Mon Sep 17 00:00:00 2001 From: Quentin Rouland Date: Sat, 21 Sep 2019 23:43:01 +0200 Subject: [PATCH] Add git plugin TG-41 closed --- plugins/CMakeLists.txt | 1 + plugins/Git/CMakeLists.txt | 39 ++++++++++++++++++++++++++++++++++++++ plugins/Git/git.cpp | 10 ++++++++++ plugins/Git/git.h | 17 +++++++++++++++++ plugins/Git/plugin.cpp | 10 ++++++++++ plugins/Git/plugin.h | 16 ++++++++++++++++ plugins/Git/qmldir | 2 ++ plugins/Pass/gpg.cpp | 1 - 8 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 plugins/Git/CMakeLists.txt create mode 100644 plugins/Git/git.cpp create mode 100644 plugins/Git/git.h create mode 100644 plugins/Git/plugin.cpp create mode 100644 plugins/Git/plugin.h create mode 100644 plugins/Git/qmldir diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 6b05459..d10ae09 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,2 +1,3 @@ +add_subdirectory(Git) add_subdirectory(Pass) add_subdirectory(Utils) diff --git a/plugins/Git/CMakeLists.txt b/plugins/Git/CMakeLists.txt new file mode 100644 index 0000000..74c5426 --- /dev/null +++ b/plugins/Git/CMakeLists.txt @@ -0,0 +1,39 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +set(PLUGIN "Git") + +set( + SRC + plugin.cpp + git.cpp +) + +set(CMAKE_AUTOMOC ON) + +execute_process( + COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH + OUTPUT_VARIABLE ARCH_TRIPLET + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +if(ARCH_TRIPLET STREQUAL "") + set(ARCH_TRIPLET x86_64-linux-gnu) +endif() + +add_library(${PLUGIN} MODULE ${SRC}) +set_target_properties(${PLUGIN} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN}) +qt5_use_modules(${PLUGIN} Qml Quick DBus) + +set(EXTERNAL_LIBS "${CMAKE_SOURCE_DIR}/build/${ARCH_TRIPLET}/libgit2/install/") + +INCLUDE_DIRECTORIES(${EXTERNAL_LIBS}/include) + +add_library(libgit2 STATIC IMPORTED) +set_property(TARGET libgit2 PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgit2.a") + +target_link_libraries(${PLUGIN} libgit2) + + +set(QT_IMPORTS_DIR "/lib/${ARCH_TRIPLET}") + +install(TARGETS ${PLUGIN} DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/) +install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/) diff --git a/plugins/Git/git.cpp b/plugins/Git/git.cpp new file mode 100644 index 0000000..96134c8 --- /dev/null +++ b/plugins/Git/git.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +#include "git.h" + + + +Git::Git() {}; + diff --git a/plugins/Git/git.h b/plugins/Git/git.h new file mode 100644 index 0000000..59b4c48 --- /dev/null +++ b/plugins/Git/git.h @@ -0,0 +1,17 @@ +#ifndef GIT_H +#define GIT_H + +#include +#include + +class Git : public QObject +{ + Q_OBJECT + +public: + Git(); + ~Git() override = default; + +}; + +#endif diff --git a/plugins/Git/plugin.cpp b/plugins/Git/plugin.cpp new file mode 100644 index 0000000..8d375d6 --- /dev/null +++ b/plugins/Git/plugin.cpp @@ -0,0 +1,10 @@ +#include + +#include "plugin.h" +#include "git.h" + +void GitPlugin::registerTypes(const char *uri) +{ + //@uri Utils + qmlRegisterSingletonType(uri, 1, 0, "Git", [](QQmlEngine *, QJSEngine *) -> QObject * { return new Git; }); +} diff --git a/plugins/Git/plugin.h b/plugins/Git/plugin.h new file mode 100644 index 0000000..cce3028 --- /dev/null +++ b/plugins/Git/plugin.h @@ -0,0 +1,16 @@ +#ifndef GITPLUGIN_H +#define GITPLUGIN_H + +#include + +class GitPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID + "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri) override; +}; + +#endif diff --git a/plugins/Git/qmldir b/plugins/Git/qmldir new file mode 100644 index 0000000..5e2e41c --- /dev/null +++ b/plugins/Git/qmldir @@ -0,0 +1,2 @@ +module Git +plugin Git diff --git a/plugins/Pass/gpg.cpp b/plugins/Pass/gpg.cpp index 122fd80..1f53105 100644 --- a/plugins/Pass/gpg.cpp +++ b/plugins/Pass/gpg.cpp @@ -4,7 +4,6 @@ #include #include - #include #include #include