commit a694946fb9e88550096b63758ec8c5f9262f7db2 Author: Fries Date: Sun Jun 25 22:24:48 2023 -0700 start a KDELearningProject to learn kde stuff. kirigami will come later. diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..7e13c85 --- /dev/null +++ b/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: WebKit +UseTab: Always +TabWidth: 4 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c2e08b7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*] +indent_style = tab +end_of_line = lf +insert_final_newline = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..80a6844 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/build* +/.cache diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..cf0628f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug", + "program": "${command:cmake.launchTargetPath}", + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8b2d7e6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.18) +project(KDELearningProject) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_CXX_STANDARD 20) + +set(QT_MIN_VERSION "5.15.2") +set(KF5_MIN_VERSION "5.78.0") + +find_package(ECM 1.0.0 REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) +include(FeatureSummary) + +find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS + Core + Widgets +) + +find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS + CoreAddons + I18n + WidgetsAddons +) + +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) + +add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..69264a0 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,15 @@ +add_executable(hello hello.cc) +target_link_libraries(hello + Qt5::Widgets + KF5::CoreAddons + KF5::WidgetsAddons +) + +add_executable(internationalization internationalization.cc) + +target_link_libraries(internationalization + Qt5::Widgets + KF5::CoreAddons + KF5::WidgetsAddons + KF5::I18n +) diff --git a/src/hello.cc b/src/hello.cc new file mode 100644 index 0000000..b2de05b --- /dev/null +++ b/src/hello.cc @@ -0,0 +1,16 @@ +#include +#include + +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + + KGuiItem primaryAction( + "Meow", QString(), + "Meow", "A Meowy button." + ); + + return KMessageBox::questionTwoActions( + nullptr, "Meowy World", "Meowy Title", + primaryAction, KStandardGuiItem::cancel() + ) == KMessageBox::PrimaryAction ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/src/internationalization.cc b/src/internationalization.cc new file mode 100644 index 0000000..d7639ef --- /dev/null +++ b/src/internationalization.cc @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + + KAboutData aboutData( + // Internal name + QStringLiteral("internationalization"), + // Displayed name + i18n("Internationalization"), + // Version + QStringLiteral("1.0"), + // Short Description + i18n("an experiment that displays a KMessageBox."), + KAboutLicense::Custom, + // Long Description + i18n("this is an experiment app to learn how to use KMessageBox's."), + // Program homepage + QStringLiteral("https://git.fries.gay/fries/KDELearningProject")); + + KAboutData::setApplicationData(aboutData); + + KGuiItem primaryAction( + i18n("Meow"), QString(), + i18n("This is a Meowy tooltip."), + i18n("This is Meowy help text.")); + + KMessageBox::ButtonCode box = KMessageBox::questionTwoActions( + // Parent + nullptr, + // Message Box content + i18n("Meowy World!"), + // Title + i18n("Meowy Title"), + // Primary button + primaryAction, + // Secondary button + KStandardGuiItem::cancel()); + + return box == KMessageBox::PrimaryAction ? EXIT_SUCCESS : EXIT_FAILURE; +}