Migrate to KDE configurations
Can be not complete: link error
This commit is contained in:
parent
a6f818864a
commit
3d92ac2abc
9 changed files with 115 additions and 47 deletions
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
|
@ -1,10 +1,8 @@
|
|||
{
|
||||
"cmake.generator": "Ninja",
|
||||
"cmake.configureSettings": {
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS:BOOL": "ON",
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
|
||||
"QT_MAJOR_VERSION": "6"
|
||||
},
|
||||
"cmake.configureArgs": [
|
||||
"${env:cmakeFlags}"
|
||||
],
|
||||
"cmake.buildDirectory": "${workspaceFolder}/build",
|
||||
"C_Cpp.intelliSenseEngine": "disabled",
|
||||
}
|
|
@ -1,18 +1,32 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(tutorial_kirigami2 VERSION 0.1.0 LANGUAGES CXX)
|
||||
|
||||
set(KF_MIN_VERSION "6.0.0")
|
||||
set(QT_MIN_VERSION "6.6")
|
||||
set(QT_MIN_VERSION 6.6)
|
||||
set(KF_MIN_VERSION 6.8)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
|
||||
|
||||
# only enable QML debugging on debug builds
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG ")
|
||||
|
||||
include(FeatureSummary)
|
||||
include(KDEInstallDirs)
|
||||
include(KDECMakeSettings)
|
||||
include(KDECompilerSettings NO_POLICY_SCOPE)
|
||||
include(ECMQmlModule)
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
include(ECMDeprecationSettings)
|
||||
include(ECMAddTests)
|
||||
include(KDEGitCommitHooks)
|
||||
include(KDEClangFormat)
|
||||
include(GenerateExportHeader)
|
||||
include(ECMGenerateHeaders)
|
||||
include(ECMSetupVersion)
|
||||
include(ECMAddQch)
|
||||
|
||||
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
|
||||
Core
|
||||
|
@ -24,11 +38,33 @@ find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
|
|||
)
|
||||
|
||||
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS
|
||||
Kirigami2
|
||||
Kirigami
|
||||
I18n
|
||||
Config
|
||||
CoreAddons
|
||||
IconThemes
|
||||
ColorScheme
|
||||
)
|
||||
|
||||
ecm_set_disabled_deprecation_versions(QT ${QT_MIN_VERSION} KF ${KF_MIN_VERSION})
|
||||
|
||||
ecm_setup_version(${PROJECT_VERSION}
|
||||
VARIABLE_PREFIX TUTORIAL_KIRIGAMI2
|
||||
VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/tutorial-kirigami2-version.h
|
||||
)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_definitions(-DBUILD_TESTING)
|
||||
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES src/*.cpp src/*.h)
|
||||
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
|
||||
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
|
||||
|
||||
ki18n_install(po)
|
||||
|
||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
1. `direnv allow`
|
||||
2. `cmake $cmakeFlags -B build -G Ninja .`
|
||||
3. `cd build`
|
||||
3. `ninja`
|
||||
4. `./bin/tutorial_kirigami2`
|
||||
3. `source build/prefix.sh`
|
||||
4. `cd build`
|
||||
5. `ninja`
|
||||
6. `./bin/tutorial_kirigami2`
|
||||
|
||||
For use gammaray, you need to disable yama security.
|
||||
|
||||
|
|
12
flake.nix
12
flake.nix
|
@ -11,8 +11,7 @@
|
|||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
||||
kdeDependencies = with pkgs.kdePackages; [
|
||||
qtbase
|
||||
qmlDependencies = with pkgs.kdePackages; [
|
||||
qtdeclarative
|
||||
kirigami.unwrapped
|
||||
ki18n
|
||||
|
@ -21,6 +20,11 @@
|
|||
sonnet
|
||||
];
|
||||
|
||||
kdeDependencies = with pkgs.kdePackages; [
|
||||
qtbase
|
||||
extra-cmake-modules
|
||||
];
|
||||
|
||||
makeQmlImportPath = pkgs.lib.makeSearchPathOutput "bin" "lib/qt-6/qml";
|
||||
in
|
||||
{
|
||||
|
@ -39,7 +43,7 @@
|
|||
|
||||
# For translation generation
|
||||
ruby
|
||||
] ++ kdeDependencies;
|
||||
] ++ kdeDependencies ++ qmlDependencies;
|
||||
|
||||
dontFixCmake = true;
|
||||
cmakeFlags = [
|
||||
|
@ -47,7 +51,7 @@
|
|||
"-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo"
|
||||
];
|
||||
|
||||
QML2_IMPORT_PATH = makeQmlImportPath kdeDependencies;
|
||||
QML2_IMPORT_PATH = makeQmlImportPath qmlDependencies;
|
||||
};
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,18 +1,31 @@
|
|||
add_executable(tutorial_kirigami2)
|
||||
add_library(tutorial_kirigami2_static STATIC)
|
||||
ecm_add_qml_module(tutorial_kirigami2_static
|
||||
URI fr.mrdev023.tutorial_kirigami2
|
||||
GENERATE_PLUGIN_SOURCE
|
||||
QML_FILES
|
||||
qml/Main.qml
|
||||
|
||||
target_sources(tutorial_kirigami2 PRIVATE
|
||||
main.cpp
|
||||
counter.cpp
|
||||
resources.qrc
|
||||
SOURCES
|
||||
counter.cpp counter.h
|
||||
)
|
||||
|
||||
target_link_libraries(tutorial_kirigami2
|
||||
Qt${QT_MAJOR_VERSION}::Quick
|
||||
Qt${QT_MAJOR_VERSION}::Qml
|
||||
target_link_libraries(tutorial_kirigami2_static PUBLIC
|
||||
Qt${QT_MAJOR_VERSION}::Core
|
||||
Qt${QT_MAJOR_VERSION}::Gui
|
||||
Qt${QT_MAJOR_VERSION}::Qml
|
||||
Qt${QT_MAJOR_VERSION}::Quick
|
||||
Qt${QT_MAJOR_VERSION}::QuickControls2
|
||||
Qt${QT_MAJOR_VERSION}::Widgets
|
||||
KF${QT_MAJOR_VERSION}::I18n
|
||||
KF${QT_MAJOR_VERSION}::ConfigCore
|
||||
KF${QT_MAJOR_VERSION}::ConfigGui
|
||||
KF${QT_MAJOR_VERSION}::CoreAddons
|
||||
KF${QT_MAJOR_VERSION}::IconThemes
|
||||
KF${QT_MAJOR_VERSION}::ColorScheme
|
||||
)
|
||||
|
||||
add_executable(tutorial_kirigami2 main.cpp)
|
||||
target_link_libraries(tutorial_kirigami2 PRIVATE tutorial_kirigami2_static tutorial_kirigami2_staticplugin)
|
||||
|
||||
install(TARGETS tutorial_kirigami2 ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <qqmlintegration.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class Counter: QObject {
|
||||
class Counter: public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(uint counter READ counter WRITE setCounter NOTIFY counterChanged)
|
||||
QML_ELEMENT
|
||||
|
|
43
src/main.cpp
43
src/main.cpp
|
@ -1,29 +1,50 @@
|
|||
#include <KAboutData>
|
||||
#include <KIconTheme>
|
||||
#include <KLocalizedContext>
|
||||
#include <KLocalizedQmlContext>
|
||||
#include <KLocalizedString>
|
||||
#include <QApplication>
|
||||
#include <QIcon>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickStyle>
|
||||
#include <QUrl>
|
||||
#include <QtQml>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qstringliteral.h>
|
||||
|
||||
#include "../tutorial-kirigami2-version.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
KIconTheme::initTheme();
|
||||
QIcon::setFallbackThemeName(u"breeze"_s);
|
||||
QApplication app(argc, argv);
|
||||
KLocalizedString::setApplicationDomain("myapplication");
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("My application of test"));
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral("0.1.0"));
|
||||
|
||||
// Default to org.kde.desktop style unless the user forces another style
|
||||
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
|
||||
QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
|
||||
QQuickStyle::setStyle(u"org.kde.desktop"_s);
|
||||
}
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
KLocalizedString::setApplicationDomain("tutorial_kirigami2");
|
||||
QGuiApplication::setWindowIcon(QIcon::fromTheme(u"fr.mrdev023.tutorial_kirigami2"_s));
|
||||
|
||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
KAboutData about(u"tutorial_kirigami2"_s,
|
||||
i18nc("Application name", "Tutorial Kirigami 2"),
|
||||
QStringLiteral(TUTORIAL_KIRIGAMI2_VERSION_STRING),
|
||||
i18n("Note taking application"),
|
||||
KAboutLicense::MIT,
|
||||
i18n("© 2025-2025 Florian RICHER"));
|
||||
about.addAuthor(i18n("Florian RICHER"),
|
||||
i18n("Maintainer"),
|
||||
u"florian.richer@protonmail.com"_s,
|
||||
u"https://invent.kde.org/florianricher"_s,
|
||||
QUrl(u"https://gravatar.com/avatar/f9c35f242fe79337bf8746ca9fccc189?size=256.png"_s));
|
||||
|
||||
KAboutData::setApplicationData(about);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
KLocalization::setupLocalizedContext(&engine);
|
||||
|
||||
engine.loadFromModule(u"fr.mrdev023.tutorial_kirigami2"_s, u"Main"_s);
|
||||
|
||||
if (engine.rootObjects().isEmpty()) {
|
||||
return -1;
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file alias="main.qml">contents/ui/main.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
Loading…
Add table
Add a link
Reference in a new issue