File indexing completed on 2024-06-23 05:49:22

0001 /*
0002     This file is part of the Kasten Framework, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2008, 2011 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include "jobmanager.hpp"
0010 
0011 // KF
0012 #include <KJob>
0013 #include <KMessageBox>
0014 // Qt
0015 #include <QGuiApplication>
0016 
0017 namespace Kasten {
0018 
0019 bool JobManager::executeJob(KJob* job)
0020 {
0021     if (!job) {
0022         return false;
0023     }
0024 
0025     QGuiApplication::setOverrideCursor(Qt::WaitCursor);
0026 
0027     job->exec();
0028     const bool success = (job->error() == KJob::NoError);
0029 
0030     QGuiApplication::restoreOverrideCursor();
0031 
0032     if (!success) {
0033         KMessageBox::error(nullptr, job->errorText());   // TODO: feed into notification system
0034 
0035     }
0036     return success;
0037 }
0038 
0039 }