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
9
#include "
actionresultreporter.h
"
10
#include <QMessageBox>
11
#include <
interfaces/core/ientitymanager.h
>
12
#include <
util/xpc/util.h
>
13
14
namespace
LC::Util
15
{
16
using namespace
std::chrono_literals;
17
18
ActionResultReporter::ActionResultReporter
(
IEntityManager
& iem,
Config
config, QWidget *parent)
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
;
39
case
Priority::Warning
:
40
QMessageBox::warning (Parent_, Context_, error);
41
break
;
42
case
Priority::Critical
:
43
QMessageBox::critical (Parent_, Context_, error);
44
break
;
45
}
46
}
47
}
actionresultreporter.h
IEntityManager
Proxy to core entity manager.
Definition
ientitymanager.h:32
LC::Util::ActionResultReporter::ActionResultReporter
ActionResultReporter(IEntityManager &iem, Config config, QWidget *parent=nullptr)
Definition
actionresultreporter.cpp:18
LC::Util::ActionResultReporter::operator()
void operator()(const QString &)
Definition
actionresultreporter.cpp:27
ientitymanager.h
LC::Util
Definition
icoreproxy.h:34
LC::Util::MakeNotification
Entity MakeNotification(const QString &header, const QString &text, Priority priority)
An utility function to make a Entity with notification.
Definition
util.cpp:95
LC::Priority::Warning
@ Warning
Definition
structures.h:217
LC::Priority::Critical
@ Critical
Definition
structures.h:218
LC::Priority::Info
@ Info
Definition
structures.h:216
LC::Util::ActionResultReporter::Config
Definition
actionresultreporter.h:36
util.h
src
util
gui
actionresultreporter.cpp
Generated by
1.14.0