-
Notifications
You must be signed in to change notification settings - Fork 14
/
pqAbstractBooleanEventPlayer.cxx
52 lines (44 loc) · 1.2 KB
/
pqAbstractBooleanEventPlayer.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
// SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
// SPDX-License-Identifier: BSD-3-Clause
#include "pqAbstractBooleanEventPlayer.h"
#include <QAbstractButton>
#include <QAction>
#include <QGroupBox>
#include <QtDebug>
pqAbstractBooleanEventPlayer::pqAbstractBooleanEventPlayer(QObject* p)
: pqWidgetEventPlayer(p)
{
}
bool pqAbstractBooleanEventPlayer::playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
{
if (Command != "set_boolean")
return false;
const bool value = Arguments == "true" ? true : false;
if (QAbstractButton* const object = qobject_cast<QAbstractButton*>(Object))
{
if (value != object->isChecked())
object->click();
return true;
}
if (QAction* const action = qobject_cast<QAction*>(Object))
{
if (action->isChecked() != value)
{
action->trigger();
}
return true;
}
if (QGroupBox* const object = qobject_cast<QGroupBox*>(Object))
{
if (value != object->isChecked())
{
object->setChecked(value);
}
return true;
}
qCritical() << "calling set_boolean on unhandled type " << Object;
Error = true;
return true;
}