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.generator": "Ninja",
|
||||||
"cmake.configureSettings": {
|
"cmake.configureArgs": [
|
||||||
"CMAKE_EXPORT_COMPILE_COMMANDS:BOOL": "ON",
|
"${env:cmakeFlags}"
|
||||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
|
],
|
||||||
"QT_MAJOR_VERSION": "6"
|
|
||||||
},
|
|
||||||
"cmake.buildDirectory": "${workspaceFolder}/build",
|
"cmake.buildDirectory": "${workspaceFolder}/build",
|
||||||
"C_Cpp.intelliSenseEngine": "disabled",
|
"C_Cpp.intelliSenseEngine": "disabled",
|
||||||
}
|
}
|
|
@ -1,18 +1,32 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(tutorial_kirigami2 VERSION 0.1.0 LANGUAGES CXX)
|
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 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
|
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(KDEInstallDirs)
|
||||||
include(KDECMakeSettings)
|
include(KDECMakeSettings)
|
||||||
include(KDECompilerSettings NO_POLICY_SCOPE)
|
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
|
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
|
||||||
Core
|
Core
|
||||||
|
@ -24,11 +38,33 @@ find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS
|
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS
|
||||||
Kirigami2
|
Kirigami
|
||||||
I18n
|
I18n
|
||||||
|
Config
|
||||||
CoreAddons
|
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)
|
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)
|
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
1. `direnv allow`
|
1. `direnv allow`
|
||||||
2. `cmake $cmakeFlags -B build -G Ninja .`
|
2. `cmake $cmakeFlags -B build -G Ninja .`
|
||||||
3. `cd build`
|
3. `source build/prefix.sh`
|
||||||
3. `ninja`
|
4. `cd build`
|
||||||
4. `./bin/tutorial_kirigami2`
|
5. `ninja`
|
||||||
|
6. `./bin/tutorial_kirigami2`
|
||||||
|
|
||||||
For use gammaray, you need to disable yama security.
|
For use gammaray, you need to disable yama security.
|
||||||
|
|
||||||
|
|
12
flake.nix
12
flake.nix
|
@ -11,8 +11,7 @@
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
|
||||||
kdeDependencies = with pkgs.kdePackages; [
|
qmlDependencies = with pkgs.kdePackages; [
|
||||||
qtbase
|
|
||||||
qtdeclarative
|
qtdeclarative
|
||||||
kirigami.unwrapped
|
kirigami.unwrapped
|
||||||
ki18n
|
ki18n
|
||||||
|
@ -21,6 +20,11 @@
|
||||||
sonnet
|
sonnet
|
||||||
];
|
];
|
||||||
|
|
||||||
|
kdeDependencies = with pkgs.kdePackages; [
|
||||||
|
qtbase
|
||||||
|
extra-cmake-modules
|
||||||
|
];
|
||||||
|
|
||||||
makeQmlImportPath = pkgs.lib.makeSearchPathOutput "bin" "lib/qt-6/qml";
|
makeQmlImportPath = pkgs.lib.makeSearchPathOutput "bin" "lib/qt-6/qml";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -39,7 +43,7 @@
|
||||||
|
|
||||||
# For translation generation
|
# For translation generation
|
||||||
ruby
|
ruby
|
||||||
] ++ kdeDependencies;
|
] ++ kdeDependencies ++ qmlDependencies;
|
||||||
|
|
||||||
dontFixCmake = true;
|
dontFixCmake = true;
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
|
@ -47,7 +51,7 @@
|
||||||
"-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo"
|
"-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
|
SOURCES
|
||||||
main.cpp
|
counter.cpp counter.h
|
||||||
counter.cpp
|
|
||||||
resources.qrc
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(tutorial_kirigami2
|
target_link_libraries(tutorial_kirigami2_static PUBLIC
|
||||||
Qt${QT_MAJOR_VERSION}::Quick
|
Qt${QT_MAJOR_VERSION}::Core
|
||||||
Qt${QT_MAJOR_VERSION}::Qml
|
|
||||||
Qt${QT_MAJOR_VERSION}::Gui
|
Qt${QT_MAJOR_VERSION}::Gui
|
||||||
|
Qt${QT_MAJOR_VERSION}::Qml
|
||||||
|
Qt${QT_MAJOR_VERSION}::Quick
|
||||||
Qt${QT_MAJOR_VERSION}::QuickControls2
|
Qt${QT_MAJOR_VERSION}::QuickControls2
|
||||||
Qt${QT_MAJOR_VERSION}::Widgets
|
Qt${QT_MAJOR_VERSION}::Widgets
|
||||||
KF${QT_MAJOR_VERSION}::I18n
|
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})
|
install(TARGETS tutorial_kirigami2 ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <qqmlintegration.h>
|
#include <qqmlintegration.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
class Counter: QObject {
|
class Counter: public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(uint counter READ counter WRITE setCounter NOTIFY counterChanged)
|
Q_PROPERTY(uint counter READ counter WRITE setCounter NOTIFY counterChanged)
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
55
src/main.cpp
55
src/main.cpp
|
@ -1,33 +1,54 @@
|
||||||
|
#include <KAboutData>
|
||||||
|
#include <KIconTheme>
|
||||||
#include <KLocalizedContext>
|
#include <KLocalizedContext>
|
||||||
|
#include <KLocalizedQmlContext>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QIcon>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQuickStyle>
|
#include <QQuickStyle>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
#include <qcoreapplication.h>
|
#include <qcoreapplication.h>
|
||||||
#include <qstringliteral.h>
|
|
||||||
|
#include "../tutorial-kirigami2-version.h"
|
||||||
|
|
||||||
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
QApplication app(argc, argv);
|
KIconTheme::initTheme();
|
||||||
KLocalizedString::setApplicationDomain("myapplication");
|
QIcon::setFallbackThemeName(u"breeze"_s);
|
||||||
QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
|
QApplication app(argc, argv);
|
||||||
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
|
// Default to org.kde.desktop style unless the user forces another style
|
||||||
QCoreApplication::setApplicationName(QStringLiteral("My application of test"));
|
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
|
||||||
QCoreApplication::setApplicationVersion(QStringLiteral("0.1.0"));
|
QQuickStyle::setStyle(u"org.kde.desktop"_s);
|
||||||
|
}
|
||||||
|
|
||||||
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
|
KLocalizedString::setApplicationDomain("tutorial_kirigami2");
|
||||||
QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
|
QGuiApplication::setWindowIcon(QIcon::fromTheme(u"fr.mrdev023.tutorial_kirigami2"_s));
|
||||||
}
|
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
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);
|
||||||
|
|
||||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
QQmlApplicationEngine engine;
|
||||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
KLocalization::setupLocalizedContext(&engine);
|
||||||
|
|
||||||
if (engine.rootObjects().isEmpty()) {
|
engine.loadFromModule(u"fr.mrdev023.tutorial_kirigami2"_s, u"Main"_s);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return app.exec();
|
if (engine.rootObjects().isEmpty()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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