SVN_SILENT made messages (.desktop file)
[rsibreak.git] / src / boxdialog.cpp
blob7244bc7b7991c9b889b085d19382219546616476
1 /*
2 Copyright (C) 2007 Tom Albers <tomalbers@kde.nl>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (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 GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "boxdialog.h"
20 #include "rsitimer_dpms.h"
22 #include <QApplication>
23 #include <QDesktopWidget>
24 #include <QLabel>
26 #include <KDialog>
27 #include <KLocale>
29 // Yes, this is where you want to hack something cool ;-) Toma
31 BoxDialog::BoxDialog( QWidget *parent, Qt::WFlags flags )
32 : QWidget( parent, flags ), m_showMinimize( true ), m_disableShort( false )
34 hide();
35 m_dialog = new KDialog( this, Qt::Popup );
37 // for the counter
38 m_label = new QLabel( this );
39 m_label->setAlignment( Qt::AlignHCenter );
41 loadDialog();
44 BoxDialog::~BoxDialog() {}
46 void BoxDialog::showDialog()
48 if ( m_dialog && !m_dialog->isHidden() )
49 return;
51 m_dialog->exec();
54 void BoxDialog::loadDialog()
56 if ( m_showMinimize ) {
57 m_dialog->setButtons( KDialog::User1 | KDialog::User2 );
58 m_dialog->setButtonText( KDialog::User2, i18n( "Skip" ) );
59 m_dialog->setEscapeButton( KDialog::User2 );
60 } else
61 m_dialog->setButtons( KDialog::User1 );
62 m_dialog->setButtonText( KDialog::User1, i18n( "Lock" ) );
63 if ( m_disableShort || !m_showMinimize )
64 m_dialog->setEscapeButton( KDialog::User1 );
65 m_dialog->setMainWidget( m_label );
67 m_dialog->adjustSize();
68 QRect rect = QApplication::desktop()->availableGeometry(
69 QApplication::desktop()->screenNumber( m_dialog ) );
70 m_dialog->move( rect.center().x() - m_dialog->width() / 2,
71 rect.center().y() - m_dialog->height() / 2 );
73 connect( m_dialog, SIGNAL( user1Clicked() ), this, SIGNAL( lock() ) );
74 connect( m_dialog, SIGNAL( user2Clicked() ), this, SIGNAL( skip() ) );
77 void BoxDialog::showMinimize( bool ok )
79 m_showMinimize = ok;
80 loadDialog();
83 void BoxDialog::disableShortcut( bool ok )
85 m_disableShort = ok;
86 loadDialog();
89 void BoxDialog::setLabel( const QString& time )
91 m_label->setText( i18n( "Remaining time:\n%1", time ) );
95 #include "boxdialog.moc"