From 33e95af983c2665c5fd5ef6e6117649f8550284f Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Mon, 9 Jun 2025 22:54:06 +0200 Subject: [PATCH] Configure vscode + Update flake.lock --- .gitignore | 1 - .vscode/c_cpp_properties.json | 14 +++++++++++ .vscode/extensions.json | 9 +++++++ .vscode/launch.json | 15 ++++++++++++ .vscode/settings.json | 10 ++++++++ .vscode/tasks.json | 19 +++++++++++++++ flake.lock | 12 +++++----- flake.nix | 31 ++++++++++++++---------- src/main.cpp | 45 +++++++++++++++++------------------ 9 files changed, 114 insertions(+), 42 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.gitignore b/.gitignore index 8b815eb..f0bae22 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.vscode build/ .cache/ .direnv/ diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..6a9c834 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,14 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "intelliSenseMode": "${default}", + "compileCommands": "${workspaceFolder}/build/compile_commands.json" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..f87f633 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "ms-vscode.cpptools-extension-pack", + "llvm-vs-code-extensions.vscode-clangd", + "theqtcompany.qt", + "knv.qt6renderer", + "deerawan.vscode-dash", + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3cd99f0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/src/tutorial_kirigami2", + "args": [], + "preLaunchTask": "CMake: build", + "cwd": "${workspaceFolder}", + "environment": [], + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3180563 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "cmake.generator": "Ninja", + "cmake.configureSettings": { + "CMAKE_EXPORT_COMPILE_COMMANDS:BOOL": "ON", + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "QT_MAJOR_VERSION": "6" + }, + "cmake.buildDirectory": "${workspaceFolder}/build", + "C_Cpp.intelliSenseEngine": "disabled", +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..432442d --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,19 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "CMake: build", + "type": "cmake", + "command": "build", + "group": "build", + "problemMatcher": [], + "detail": "CMake build" + }, + { + "label": "CMake: clean", + "type": "cmake", + "command": "clean", + "group": "build", + } + ] +} \ No newline at end of file diff --git a/flake.lock b/flake.lock index d0e250f..3c69683 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1719436386, - "narHash": "sha256-NBGYaic5FLRg8AWSj6yr4g2IlMPUxNCVjRK6+RNuQBc=", + "lastModified": 1749401433, + "narHash": "sha256-HXIQzULIG/MEUW2Q/Ss47oE3QrjxvpUX7gUl4Xp6lnc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c66e984bda09e7230ea7b364e677c5ba4f0d36d0", + "rev": "08fcb0dcb59df0344652b38ea6326a2d8271baff", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 15fcb2c..d59e765 100644 --- a/flake.nix +++ b/flake.nix @@ -14,23 +14,30 @@ { devShells = rec { default = pkgs.mkShell { - buildInputs = [ - pkgs.kdePackages.qtbase - pkgs.kdePackages.kirigami - pkgs.kdePackages.ki18n - pkgs.kdePackages.kcoreaddons - pkgs.ninja - pkgs.cmake - pkgs.gcc + packages = with pkgs; [ + kdePackages.qtbase + kdePackages.kirigami + kdePackages.ki18n + kdePackages.kcoreaddons + ninja + cmake + gcc # Not required at compile time - pkgs.gammaray - pkgs.gdb # Required for gammaray - pkgs.lldb # Required for gammaray + gammaray + gdb # Required for gammaray + lldb # Required for gammaray + + # For translation generation + ruby ]; dontFixCmake = true; - cmakeFlags = ["-DQT_MAJOR_VERSION=6"]; + cmakeFlags = [ + "-DQT_MAJOR_VERSION=6" + "-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON" + "-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo" + ]; }; }; }); diff --git a/src/main.cpp b/src/main.cpp index 72df967..28ff074 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,34 +1,33 @@ -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include #include #include -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - KLocalizedString::setApplicationDomain("helloworld"); - QCoreApplication::setOrganizationName(QStringLiteral("KDE")); - QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); - QCoreApplication::setApplicationName(QStringLiteral("Hello World")); - QCoreApplication::setApplicationVersion(QStringLiteral("0.1.0")); +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + KLocalizedString::setApplicationDomain("helloworld"); + QCoreApplication::setOrganizationName(QStringLiteral("KDE")); + QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); + QCoreApplication::setApplicationName(QStringLiteral("Hello World")); + QCoreApplication::setApplicationVersion(QStringLiteral("0.1.0")); - if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) { - QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); - } + if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) { + QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); + } - QQmlApplicationEngine engine; + QQmlApplicationEngine engine; - engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - if (engine.rootObjects().isEmpty()) { - return -1; - } + if (engine.rootObjects().isEmpty()) { + return -1; + } - return app.exec(); + return app.exec(); }