1 /***************************************************************************
2 kfullscreenpanel.cpp - auto-hideable toolbar
4 begin : Tue May 13 23:07:42 CET 2002
5 copyright : (C) 2002 by Tim Jansen
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #include "kfullscreenpanel.h"
21 #include <QVBoxLayout>
24 Counter::Counter(float start
) :
25 m_currentValue(start
) {
26 connect(&m_timer
, SIGNAL(timeout()), SLOT(timeout()));
29 void Counter::count(float stop
, float stepSize
, float frequency
) {
32 m_stepSize
= stepSize
;
33 m_timeoutMs
= (int)(1000.0 / frequency
);
37 void Counter::timeout() {
39 if (m_currentValue
<= m_stopValue
) {
40 m_currentValue
= m_stopValue
;
41 emit
counted(m_currentValue
);
42 emit
countingDownFinished();
46 if (m_currentValue
>= m_stopValue
) {
47 m_currentValue
= m_stopValue
;
48 emit
counted(m_currentValue
);
49 emit
countingUpFinished();
53 emit
counted(m_currentValue
);
55 m_currentValue
+= m_stepSize
;
56 m_timer
.setSingleShot(true);
57 m_timer
.start(m_timeoutMs
);
61 KFullscreenPanel::KFullscreenPanel(QWidget
* parent
,
63 const QSize
&resolution
) :
67 m_fsResolution(resolution
),
71 connect(&m_counter
, SIGNAL(countingDownFinished()), SLOT(hide()));
72 connect(&m_counter
, SIGNAL(counted(float)), SLOT(movePanel(float)));
75 KFullscreenPanel::~KFullscreenPanel() {
78 void KFullscreenPanel::movePanel(float posY
) {
84 void KFullscreenPanel::setChild(QWidget
*child
) {
90 m_layout
= new QVBoxLayout(this);
91 m_layout
->addWidget(child
);
95 void KFullscreenPanel::doLayout() {
98 setGeometry((m_fsResolution
.width() - s
.width())/2, 0,
99 s
.width(), s
.height());
102 void KFullscreenPanel::startShow() {
103 m_counter
.count(0, height()/3.0, 24);
106 void KFullscreenPanel::startHide() {
107 m_counter
.count(-height(), -height()/12.0, 24);
110 void KFullscreenPanel::enterEvent(QEvent
*) {
114 void KFullscreenPanel::leaveEvent(QEvent
*) {
119 #include "kfullscreenpanel.moc"