1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 This file is part of KMail, the KDE mail client.
3 Copyright (c) 2009 Martin Koller <kollix@aon.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include <config-messageviewer.h>
22 #include <attachmentdialog.h>
25 #include <kmessagebox.h>
28 using namespace MessageViewer
;
30 //---------------------------------------------------------------------
32 AttachmentDialog::AttachmentDialog( QWidget
*parent
, const QString
&filenameText
,
33 const QString
&application
, const QString
&dontAskAgainName
)
34 : dontAskName( dontAskAgainName
)
36 text
= i18n( "Open attachment '%1'?\n"
37 "Note that opening an attachment may compromise "
38 "your system's security.",
41 dialog
= new KDialog( parent
);
42 dialog
->setCaption( i18n("Open Attachment?") );
43 dialog
->setObjectName( "attachmentSaveOpen" );
45 if ( application
.isEmpty() )
46 dialog
->setButtons( KDialog::User3
| KDialog::User1
| KDialog::Cancel
);
48 dialog
->setButtons( KDialog::User3
| KDialog::User2
| KDialog::User1
| KDialog::Cancel
);
49 dialog
->setButtonText( KDialog::User2
, i18n("&Open with '%1'", application
) );
52 dialog
->setButtonGuiItem( KDialog::User3
, KStandardGuiItem::saveAs() );
53 dialog
->setButtonText( KDialog::User1
, i18n("&Open With...") );
54 dialog
->setDefaultButton( KDialog::User3
);
56 connect( dialog
, SIGNAL(user3Clicked()), this, SLOT(saveClicked()) );
57 connect( dialog
, SIGNAL(user2Clicked()), this, SLOT(openClicked()) );
58 connect( dialog
, SIGNAL(user1Clicked()), this, SLOT(openWithClicked()) );
61 //---------------------------------------------------------------------
63 int AttachmentDialog::exec()
65 KConfigGroup
cg( KGlobal::config().data(), "Notification Messages" );
66 if ( cg
.hasKey( dontAskName
) )
67 return cg
.readEntry( dontAskName
, int(0) );
71 KMessageBox::createKMessageBox( dialog
, QMessageBox::Question
, text
, QStringList(),
72 i18n( "Do not ask again" ), &again
, 0 );
74 if ( ret
== QDialog::Rejected
)
78 KConfigGroup::WriteConfigFlags flags
= KConfig::Persistent
;
79 KConfigGroup
cg( KGlobal::config().data(), "Notification Messages" );
80 cg
.writeEntry( dontAskName
, ret
, flags
);
88 //---------------------------------------------------------------------
90 void AttachmentDialog::saveClicked()
95 //---------------------------------------------------------------------
97 void AttachmentDialog::openClicked()
102 //---------------------------------------------------------------------
104 void AttachmentDialog::openWithClicked()
106 dialog
->done( OpenWith
);
109 //---------------------------------------------------------------------
111 #include "attachmentdialog.moc"