krop's commit fixes my problem in a better way, reverting
[kdepim.git] / kmail / mdnadvicedialog.cpp
blob0a308e73dc9f94e1a2adaac88fe7869c52b28423
1 /*
2 Copyright (c) 2009 Michael Leupold <lemma@confuego.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU 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 General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "mdnadvicedialog.h"
21 #include <KMessageBox>
22 #include <KLocalizedString>
23 #include <QtCore/QPointer>
25 MDNAdviceDialog::MDNAdviceDialog( const QString &text, bool canDeny, QWidget *parent )
26 : KDialog( parent ), m_result(MDNIgnore)
28 setCaption( i18n( "Message Disposition Notification Request" ) );
29 if ( canDeny ) {
30 setButtons( KDialog::Yes | KDialog::User1 | KDialog::User2 );
31 setButtonText( KDialog::User2, "Send \"&denied\"" );
32 } else {
33 setButtons( KDialog::Yes | KDialog::User1 );
35 setButtonText( KDialog::Yes, "&Ignore" );
36 setButtonText( KDialog::User1, "&Send" );
37 setEscapeButton( KDialog::Yes );
38 KMessageBox::createKMessageBox( this, QMessageBox::Question, text,
39 QStringList(), QString(), 0, KMessageBox::NoExec );
40 connect( this, SIGNAL( buttonClicked( KDialog::ButtonCode ) ),
41 this, SLOT( slotButtonClicked( KDialog::ButtonCode ) ) );
44 MDNAdviceDialog::~MDNAdviceDialog()
48 MDNAdviceDialog::MDNAdvice MDNAdviceDialog::questionIgnoreSend( const QString &text, bool canDeny )
50 MDNAdvice rc = MDNIgnore;
51 QPointer<MDNAdviceDialog> dlg( new MDNAdviceDialog( text, canDeny ) );
52 dlg->exec();
53 if ( dlg ) {
54 rc = dlg->m_result;
56 delete dlg;
57 return rc;
60 void MDNAdviceDialog::slotButtonClicked( int button )
62 switch ( button ) {
64 case KDialog::User1:
65 m_result = MDNSend;
66 accept();
67 break;
69 case KDialog::User2:
70 m_result = MDNSendDenied;
71 accept();
72 break;
74 case KDialog::Yes:
75 default:
76 m_result = MDNIgnore;
77 break;
80 reject();
83 #include "mdnadvicedialog.moc"