File indexing completed on 2025-01-05 04:59:44
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Mario Bensi <mbensi@ipsquad.net> 0003 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #include "errorhandler.h" 0007 0008 #include <QCoreApplication> 0009 #include <KJob> 0010 0011 #include "utils/jobhandler.h" 0012 #include "utils/mem_fn.h" 0013 0014 using namespace Presentation; 0015 0016 ErrorHandler::~ErrorHandler() 0017 { 0018 } 0019 0020 void ErrorHandler::installHandler(KJob *job, const QString &message) 0021 { 0022 auto resultHandler = std::function<void()>(std::bind(Utils::mem_fn(&ErrorHandler::displayMessage), 0023 this, job, message)); 0024 Utils::JobHandler::install(job, resultHandler); 0025 } 0026 0027 void ErrorHandler::displayMessage(KJob *job, const QString &message) 0028 { 0029 if (job->error() != KJob::NoError) { 0030 doDisplayMessage(QCoreApplication::translate("ErrorHandler", "%1: %2").arg(message, job->errorString())); 0031 } 0032 }