2 * Copyright (C) 2007777777 Aaron J. Seigo <aseigo@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include <QTimerEvent>
22 #include <QPaintEvent>
29 #include "snapshottimer.h"
31 SnapshotTimer::SnapshotTimer() : QWidget(0)
33 setWindowFlags( Qt::WindowStaysOnTopHint
| Qt::FramelessWindowHint
| Qt::X11BypassWindowManagerHint
);
35 connect(&timer
, SIGNAL(timeout()), this, SLOT(bell()));
38 SnapshotTimer::~SnapshotTimer()
42 void SnapshotTimer::start(int seconds
)
50 void SnapshotTimer::stop()
57 void SnapshotTimer::bell()
59 if (time
== length
- 1) {
71 void SnapshotTimer::paintEvent( QPaintEvent
* e
)
75 QPainter
painter( this );
78 QPalette
pal(QToolTip::palette());
79 QColor handleColor
= pal
.color( QPalette::Active
, QPalette::Highlight
);
80 handleColor
.setAlpha( 160 );
81 QColor
overlayColor( 0, 0, 0, 160 );
82 QColor textColor
= pal
.color( QPalette::Active
, QPalette::Text
);
83 QColor textBackgroundColor
= pal
.color( QPalette::Active
, QPalette::Base
);
85 painter
.setPen( textColor
);
86 painter
.setBrush( textBackgroundColor
);
87 QString helpText
= i18np( "Snapshot will be taken in 1 second",
88 "Snapshot will be taken in %1 seconds", ( length
-time
) );
89 QRect textRect
= painter
.boundingRect( rect().adjusted( 2, 2, -2, -2 ), Qt::TextWordWrap
, helpText
);
90 textRect
.adjust( -2, -2, 4, 2 );
91 painter
.drawRect( rect().adjusted(0,0,-1,-1) );
92 textRect
.moveTopLeft( QPoint( 3, 3 ) );
93 painter
.drawText(textRect
, helpText
);