NCL Composer  0.1.5
 All Classes Functions Variables Pages
ClickableDockWidget.cpp
1 /*
2  * Copyright 2011-2013 TeleMidia/PUC-Rio.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see
16  * <http://www.gnu.org/licenses/>.
17  */
18 
19 #include "ClickableDockWidget.h"
20 
21 namespace composer {
22  namespace gui {
23 
25  QWidget *parent,
26  Qt::WindowFlags flags)
27  : QDockWidget(title, parent, flags)
28 {
29  setFocusPolicy(Qt::StrongFocus);
30 
31  connect(this, SIGNAL(visibilityChanged(bool)),
32  this, SLOT(visibilityHasChange(bool)));
33 
34  connect(this, SIGNAL(topLevelChanged(bool)),
35  this, SLOT(topLevelHasChanged(bool)));
36 }
37 
38 bool ClickableQDockWidget::event(QEvent *event)
39 {
40  if(event->type() == QEvent::MouseButtonPress)
41  {
42  emit clicked();
43  }
44 
45  return QDockWidget::event(event);
46 }
47 
48 void ClickableQDockWidget::visibilityHasChange(bool visible)
49 {
50  if(visible)
51  emit clicked();
52 }
53 
54 void ClickableQDockWidget::topLevelHasChanged(bool a)
55 {
56  emit clicked();
57  raise();
58  setFocus();
59 }
60 
61 } }