diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ find_package(KF5WidgetsAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Package ${KF5_DEP_VERSION} REQUIRED) find_package(KF5NewStuff ${KF5_DEP_VERSION} REQUIRED) +find_package(KF5I18n ${KF5_DEP_VERSION} REQUIRED) find_package(packagekitqt5) find_package(AppStreamQt 0.10.4) diff --git a/src/kpackage-install-handlers/kns/CMakeLists.txt b/src/kpackage-install-handlers/kns/CMakeLists.txt --- a/src/kpackage-install-handlers/kns/CMakeLists.txt +++ b/src/kpackage-install-handlers/kns/CMakeLists.txt @@ -1,10 +1,10 @@ add_executable(knshandler main.cpp) -target_link_libraries(knshandler KF5::NewStuffCore) +target_link_libraries(knshandler KF5::NewStuffCore KF5::I18n KF5::Notifications) install(TARGETS knshandler DESTINATION ${KDE_INSTALL_LIBEXECDIR_KF5}/kpackagehandlers) add_executable(knshandlertest main.cpp) -target_link_libraries(knshandlertest KF5::NewStuffCore) +target_link_libraries(knshandlertest KF5::NewStuffCore KF5::I18n KF5::Notifications) target_compile_definitions(knshandlertest PRIVATE -DTEST) if(EXISTS "${CMAKE_INSTALL_PREFIX}/${CONFIG_INSTALL_DIR}/colorschemes.knsrc") diff --git a/src/kpackage-install-handlers/kns/main.cpp b/src/kpackage-install-handlers/kns/main.cpp --- a/src/kpackage-install-handlers/kns/main.cpp +++ b/src/kpackage-install-handlers/kns/main.cpp @@ -24,7 +24,12 @@ #include #include +#include + +#include + #include +#include int main(int argc, char** argv) { @@ -54,8 +59,33 @@ const auto providerid = pathParts.at(0); const auto entryid = pathParts.at(1); + KNSCore::Engine engine; int installedCount = 0; + QObject::connect(KNSCore::QuestionManager::instance(), &KNSCore::QuestionManager::askQuestion, &engine, [](KNSCore::Question* question){ + auto discardQuestion = [question]() { question->setResponse(KNSCore::Question::InvalidResponse); }; + switch(question->questionType()) { + case KNSCore::Question::YesNoQuestion: { + auto f = KNotification::event(KNotification::StandardEvent::Notification, question->title(), question->question()); + f->setActions({i18n("Yes"), i18n("No")}); + QObject::connect(f, &KNotification::action1Activated, question, [question](){ question->setResponse(KNSCore::Question::YesResponse); }); + QObject::connect(f, &KNotification::action2Activated, question, [question](){ question->setResponse(KNSCore::Question::NoResponse); }); + QObject::connect(f, &KNotification::closed, question, discardQuestion); + } break; + case KNSCore::Question::ContinueCancelQuestion: { + auto f = KNotification::event(KNotification::StandardEvent::Notification, question->title(), question->question()); + f->setActions({i18n("Continue"), i18n("Cancel")}); + QObject::connect(f, &KNotification::action1Activated, question, [question](){ question->setResponse(KNSCore::Question::ContinueResponse); }); + QObject::connect(f, &KNotification::action2Activated, question, [question](){ question->setResponse(KNSCore::Question::CancelResponse); }); + QObject::connect(f, &KNotification::closed, question, discardQuestion); + } break; + case KNSCore::Question::InputTextQuestion: + case KNSCore::Question::SelectFromListQuestion: + case KNSCore::Question::PasswordQuestion: + discardQuestion(); + break; + } + }); QObject::connect(&engine, &KNSCore::Engine::signalProvidersLoaded, &engine, [&engine, entryid](){ engine.fetchEntryById(entryid);