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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/***************************************************************************
kfullscreenpanel.cpp - auto-hideable toolbar
-------------------
begin : Tue May 13 23:07:42 CET 2002
copyright : (C) 2002 by Tim Jansen
email : tim@tjansen.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "kfullscreenpanel.h"
#include <kdebug.h>
Counter::Counter(float start) :
m_currentValue(start) {
connect(&m_timer, TQ_SIGNAL(timeout()), TQ_SLOT(timeout()));
}
void Counter::count(float stop, float stepSize, float frequency) {
m_timer.stop();
m_stopValue = stop;
m_stepSize = stepSize;
m_timeoutMs = (int)(1000.0 / frequency);
timeout();
}
void Counter::timeout() {
if (m_stepSize < 0) {
if (m_currentValue <= m_stopValue) {
m_currentValue = m_stopValue;
emit counted(m_currentValue);
emit countingDownFinished();
return;
}
} else {
if (m_currentValue >= m_stopValue) {
m_currentValue = m_stopValue;
emit counted(m_currentValue);
emit countingUpFinished();
return;
}
}
emit counted(m_currentValue);
m_currentValue += m_stepSize;
m_timer.start(m_timeoutMs, true);
}
KFullscreenPanel::KFullscreenPanel(TQWidget* parent,
const char *name,
const TQSize &resolution) :
TQWidget(parent, name),
m_child(0),
m_layout(0),
m_fsResolution(resolution),
m_counter(0)
{
connect(&m_counter, TQ_SIGNAL(countingDownFinished()), TQ_SLOT(hide()));
connect(&m_counter, TQ_SIGNAL(counted(float)), TQ_SLOT(movePanel(float)));
}
KFullscreenPanel::~KFullscreenPanel() {
}
void KFullscreenPanel::movePanel(float posY) {
move(x(), (int)posY);
if (!isVisible())
show();
}
void KFullscreenPanel::setChild(TQWidget *child) {
if (m_layout)
delete m_layout;
m_child = child;
m_layout = new TQVBoxLayout(this);
m_layout->addWidget(child);
doLayout();
}
void KFullscreenPanel::doLayout() {
TQSize s = sizeHint();
setFixedSize(s);
setGeometry((m_fsResolution.width() - s.width())/2, 0,
s.width(), s.height());
}
void KFullscreenPanel::startShow() {
m_counter.count(0, height()/3.0, 24);
}
void KFullscreenPanel::startHide() {
m_counter.count(-height(), -height()/12.0, 24);
}
void KFullscreenPanel::enterEvent(TQEvent*) {
emit mouseEnter();
}
void KFullscreenPanel::leaveEvent(TQEvent*) {
emit mouseLeave();
}
#include "kfullscreenpanel.moc"
|