SVN_SILENT made messages (.desktop file)
[rsibreak.git] / src / graywidget.cpp
blob31b676fdaed6ecc837eca9aec66002987a157d39
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();
59 void GrayWidget::slotGrayEffect()
61 m_complete = takeScreenshot( QX11Info::appScreen() );
63 repaint(); //before show
65 show();
67 KWindowSystem::forceActiveWindow( winId() );
68 KWindowSystem::setOnAllDesktops( winId(), true );
69 KWindowSystem::setState( winId(), NET::KeepAbove );
70 KWindowSystem::setState( winId(), NET::FullScreen );
72 m_gray = new GrayOutEffect( this, &m_complete );
73 connect( m_gray, SIGNAL( ready() ), m_dialog, SLOT( showDialog() ) );
74 m_gray->start();
77 void GrayWidget::paintEvent( QPaintEvent* )
79 QPainter painter( this );
80 painter.setCompositionMode( QPainter::CompositionMode_Source );
81 painter.drawPixmap( 0, 0, m_complete );
84 #include "graywidget.moc"