Some a rather big memory leak
[rsibreak.git] / src / graywidget.cpp
blobaa8a65f986fe518ef2214b2eb75862cfba1a5242
1 /* This file is part of the KDE project
2 Copyright (C) 2005-2007 Tom Albers <tomalbers@kde.nl>
3 Copyright (C) 2006 Bram Schoenmakers <bramschoenmakers@kde.nl>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "graywidget.h"
21 #include "grayouteffect.h"
22 #include "rsitimer_dpms.h"
23 #include "boxdialog.h"
25 #include <QApplication>
26 #include <QDesktopWidget>
27 #include <QX11Info>
28 #include <QPainter>
29 #include <QTimer>
31 #include <KWindowSystem>
32 #include <KDebug>
34 GrayWidget::GrayWidget( QWidget *parent )
35 : QWidget( parent, Qt::Popup ), m_currentY( 0 ), m_first( true )
37 // full screen
38 setAttribute( Qt::WA_NoSystemBackground );
39 setAttribute( Qt::WA_PaintOnScreen );
40 QRect rect = QApplication::desktop()->screenGeometry(
41 QApplication::desktop()->primaryScreen() );
42 setGeometry( rect );
44 m_gray = 0;
46 m_dialog = new BoxDialog( this, Qt::Popup );
49 GrayWidget::~GrayWidget() {}
51 void GrayWidget::reset()
53 hide();
54 m_currentY = 0;
55 m_first = true;
56 m_dialog->reject();
57 delete m_gray;
58 m_gray = 0;
61 void GrayWidget::slotGrayEffect()
63 m_complete = takeScreenshot( QX11Info::appScreen() );
65 repaint(); //before show
67 show();
69 KWindowSystem::forceActiveWindow( winId() );
70 KWindowSystem::setOnAllDesktops( winId(), true );
71 KWindowSystem::setState( winId(), NET::KeepAbove );
72 KWindowSystem::setState( winId(), NET::FullScreen );
74 m_gray = new GrayOutEffect( this, &m_complete );
75 connect( m_gray, SIGNAL( ready() ), m_dialog, SLOT( showDialog() ) );
76 m_gray->start();
79 void GrayWidget::paintEvent( QPaintEvent* )
81 QPainter painter( this );
82 painter.setCompositionMode( QPainter::CompositionMode_Source );
83 painter.drawPixmap( 0, 0, m_complete );
86 #include "graywidget.moc"