7 #include "fwGuiQt/widget/SlideBar.hpp" 9 #include "fwGuiQt/QtMainFrame.hpp" 13 #include <QHBoxLayout> 14 #include <QParallelAnimationGroup> 15 #include <QPropertyAnimation> 16 #include <QPushButton> 17 #include <QVBoxLayout> 29 m_buttonSize(buttonSize),
34 this->setParent(parent);
42 this->setObjectName(
"SlideBar");
46 this->setGeometry(m_hiddenPosition);
49 this->setWindowFlags(Qt::Tool
50 | Qt::FramelessWindowHint
51 | Qt::NoDropShadowWindowHint
55 this->setAttribute(Qt::WA_TranslucentBackground);
59 this->parent()->installEventFilter(
this);
61 auto activeWindow = qApp->activeWindow();
64 activeWindow->installEventFilter(
this);
78 int height = this->parentWidget()->height();
79 int width = this->parentWidget()->width();
85 width = std::min(width, m_buttonSize);
86 this->setFixedWidth(width);
87 this->setFixedHeight(height);
91 height = std::min(height, m_buttonSize);
92 this->setFixedHeight(height);
93 this->setFixedWidth(width);
99 QPoint pos = this->parentWidget()->rect().topLeft();
100 pos = this->parentWidget()->mapToGlobal(pos);
102 m_shownPosition = QRect(pos.x(), pos.y(), width, height);
103 m_hiddenPosition = QRect(pos.x()-width, pos.y(), 0, height);
105 else if (m_align == RIGHT)
107 QPoint pos = this->parentWidget()->rect().topRight();
108 pos = this->parentWidget()->mapToGlobal(pos);
110 m_shownPosition = QRect(pos.x()-width, pos.y(), width, height);
111 m_hiddenPosition = QRect(pos.x(), pos.y(), 0, height);
113 else if (m_align == TOP)
115 QPoint pos = this->parentWidget()->rect().topLeft();
116 pos = this->parentWidget()->mapToGlobal(pos);
118 m_shownPosition = QRect(pos.x(), pos.y(), width, height);
119 m_hiddenPosition = QRect(pos.x(), pos.y()-height, width, 0);
123 QPoint pos = this->parentWidget()->rect().bottomLeft();
124 pos = this->parentWidget()->mapToGlobal(pos);
126 m_shownPosition = QRect(pos.x(), pos.y()-height, width, height);
127 m_hiddenPosition = QRect(pos.x(), pos.y(), width, 0);
132 this->setGeometry(m_shownPosition);
136 this->setGeometry(m_hiddenPosition);
151 this->slide(visible);
156 void SlideBar::forceHide()
158 this->QGroupBox::setVisible(
false);
163 void SlideBar::forceShow()
165 this->QGroupBox::setVisible(
true);
170 void SlideBar::slide(
bool visible)
175 this->setWindowOpacity(m_isShown ? m_opacity : 0);
178 QParallelAnimationGroup* animations =
new QParallelAnimationGroup();
181 QPropertyAnimation* geomAnimation =
new QPropertyAnimation(
this,
"geometry");
182 geomAnimation->setDuration(500);
183 geomAnimation->setEasingCurve(QEasingCurve::InBack);
184 geomAnimation->setStartValue(this->geometry());
188 geomAnimation->setEndValue(m_shownPosition);
192 geomAnimation->setEndValue(m_hiddenPosition);
195 QObject::connect(animations, &QAbstractAnimation::finished,
this, &SlideBar::forceHide);
199 QPropertyAnimation* opacityAnimation =
new QPropertyAnimation(
this,
"windowOpacity");
200 opacityAnimation->setDuration(500);
201 opacityAnimation->setEndValue(visible ? m_opacity : 0);
203 animations->addAnimation(geomAnimation);
204 animations->addAnimation(opacityAnimation);
206 animations->start(QPropertyAnimation::DeleteWhenStopped);
215 if (event->type() == QEvent::Resize
216 ||
event->type() == QEvent::Move)
220 else if (event->type() == QEvent::WindowActivate)
222 auto activeWindow = qApp->activeWindow();
224 activeWindow->installEventFilter(
this);
227 else if (event->type() == QEvent::WindowDeactivate)
232 mainFrame->removeEventFilter(
this);
235 return QObject::eventFilter(obj, event);
The namespace fwGuiQt contains classes which provide the implementation of the Gui using Qt library...
A qt panel used to control a VTK 2D Negatoscope view.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
This file defines SpyLog macros. These macros are used to log messages to a file or to the console du...