init
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
project(cppbridge LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Qml)
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_qml_module(cppbridgeplugin
|
||||
URI cppbridge
|
||||
VERSION 1.0
|
||||
OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/../package/contents/ui/cppbridge"
|
||||
SOURCES
|
||||
src/timebridge.h
|
||||
src/timebridge.cpp
|
||||
)
|
||||
|
||||
target_include_directories(cppbridgeplugin PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
target_link_libraries(cppbridgeplugin PRIVATE Qt6::Core Qt6::Qml)
|
||||
set_target_properties(cppbridgeplugin PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
)
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"version": 6,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 23,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "clang-default",
|
||||
"displayName": "Clang Default",
|
||||
"description": "Configure build/cpp with clang/clang++ and export compile commands.",
|
||||
"generator": "Unix Makefiles",
|
||||
"binaryDir": "${sourceDir}/../build/cpp",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "clang",
|
||||
"CMAKE_CXX_COMPILER": "clang++",
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "clang-default",
|
||||
"configurePreset": "clang-default"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "timebridge.h"
|
||||
|
||||
#include <QLocale>
|
||||
#include <QTime>
|
||||
|
||||
QString TimeBridge::currentTimeString(bool includeSeconds) const {
|
||||
const auto format =
|
||||
includeSeconds ? QLocale::LongFormat : QLocale::ShortFormat;
|
||||
return QLocale().toString(QTime::currentTime(), format);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <qqmlintegration.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class TimeBridge : public QObject {
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
|
||||
public:
|
||||
using QObject::QObject;
|
||||
|
||||
Q_INVOKABLE QString currentTimeString(bool includeSeconds) const;
|
||||
};
|
||||
Reference in New Issue
Block a user