CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxWidgetObscuredListener.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
13 
14 #include <QWidget>
15 #include <QTimer>
16 
17 namespace cx
18 {
19 
20 WidgetObscuredListener::WidgetObscuredListener(QWidget *listenedTo) : mWidget(listenedTo)
21 {
22  mRemoveTimer = new QTimer(this);
23  connect(mRemoveTimer, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
24  mRemoveTimer->start(500);
25 
26  mObscuredAtLastCheck = this->isObscured();
27 }
28 
30 {
31  return mWidget->visibleRegion().isEmpty();
32 }
33 
34 void WidgetObscuredListener::timeoutSlot()
35 {
36  if (mObscuredAtLastCheck == this->isObscured())
37  return;
38 
39  mObscuredAtLastCheck = this->isObscured();
40  emit obscured(mObscuredAtLastCheck);
41 }
42 
43 }
WidgetObscuredListener(QWidget *listenedTo)
void obscured(bool visible)
Namespace for all CustusX production code.