LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
actionresultreporter.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
10#include <QMessageBox>
12#include <util/xpc/util.h>
13
14namespace LC::Util
15{
16 using namespace std::chrono_literals;
17
19 : IEM_ { iem }
20 , Context_ { config.Context_ }
21 , Priority_ { config.Priority_ }
22 , Parent_ { parent }
23 , Timer_ { config.BackgroundDelay_.value_or (5s) }
24 {
25 }
26
27 void ActionResultReporter::operator() (const QString& error)
28 {
29 const auto isBackground = Timer_.hasExpired () || (!Parent_ && HadParent_);
30
31 if (isBackground)
32 IEM_.HandleEntity (MakeNotification (Context_, error, Priority_));
33 else
34 switch (Priority_)
35 {
36 case Priority::Info:
37 QMessageBox::information (Parent_, Context_, error);
38 break;
40 QMessageBox::warning (Parent_, Context_, error);
41 break;
43 QMessageBox::critical (Parent_, Context_, error);
44 break;
45 }
46 }
47}
Proxy to core entity manager.
ActionResultReporter(IEntityManager &iem, Config config, QWidget *parent=nullptr)
Entity MakeNotification(const QString &header, const QString &text, Priority priority)
An utility function to make a Entity with notification.
Definition util.cpp:95