diff --git a/examples/qt-lib/CMakeLists.txt b/examples/qt-lib/CMakeLists.txt index 605509d..f59eeac 100644 --- a/examples/qt-lib/CMakeLists.txt +++ b/examples/qt-lib/CMakeLists.txt @@ -1,15 +1,17 @@ cmake_minimum_required(VERSION 3.0.0) project(SnoreToastQtExample VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Core) find_package(Qt5Gui) find_package(Qt5Network) +find_package(LibSnoreToast QUIET) + add_executable(${PROJECT_NAME} "main.cpp") -target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui libsnoretoast) +target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui SnoreToast::LibSnoreToast SnoreToast::LibSnoreToastActions) diff --git a/examples/qt-lib/main.cpp b/examples/qt-lib/main.cpp index 2d28cf0..4cda69d 100644 --- a/examples/qt-lib/main.cpp +++ b/examples/qt-lib/main.cpp @@ -1,52 +1,51 @@ /* SnoreToast is capable to invoke Windows 8 toast notifications. Copyright (C) 2019 Hannah von Reth SnoreToast is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SnoreToast is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SnoreToast. If not, see . */ #include #include #include #include #include "../../src/snoretoasts.h" #include "../../src/snoretoastactions.h" #include "../../src/linkhelper.h" namespace { const auto appId = QStringLiteral("Snore.DesktopToasts%1.QtLib").arg(SnoreToasts::version()).toStdWString(); } int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); qDebug() << SUCCEEDED(LinkHelper::tryCreateShortcut( std::filesystem::path(L"SnoreToast") / SnoreToasts::version() / L"SnoreToastQtLib", appId)); QTimer::singleShot(0, &a, [&] { SnoreToasts toast(appId); // app.setPipeName(pipe); // app.setApplication(app.applicationDirPath().); toast.displayToast(L"Test", L"Message", L"", true); std::wcout << "Result" << SnoreToastActions::getActionString(toast.userAction()) << std::endl; a.quit(); }); return a.exec(); } -#include "main.moc" diff --git a/examples/qt/CMakeLists.txt b/examples/qt/CMakeLists.txt index 2f82e72..1e50361 100644 --- a/examples/qt/CMakeLists.txt +++ b/examples/qt/CMakeLists.txt @@ -1,14 +1,19 @@ cmake_minimum_required(VERSION 3.0.0) project(SnoreToastCliQtExample VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Core) find_package(Qt5Network) +find_package(LibSnoreToast QUIET) + +if (NOT TARGET SnoreToast::SnoreToast) + message(FATAL_ERROR "LibSnoreToasts is requried") +endif() add_executable(${PROJECT_NAME} "main.cpp") target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network)