• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • widgets
attachmentdialog.cpp
Go to the documentation of this file.
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>
4 
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.
9 
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.
14 
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.
18 */
19 
20 
21 
22 #include "attachmentdialog.h"
23 
24 #include <kdialog.h>
25 #include <kmessagebox.h>
26 #include <klocale.h>
27 
28 using namespace MessageViewer;
29 
30 //---------------------------------------------------------------------
31 
32 AttachmentDialog::AttachmentDialog( QWidget *parent, const QString &filenameText,
33  const QString &application, const QString &dontAskAgainName )
34  : dontAskName( dontAskAgainName )
35 {
36  text = i18n( "Open attachment '%1'?\n"
37  "Note that opening an attachment may compromise "
38  "your system's security.",
39  filenameText );
40 
41  dialog = new KDialog( parent );
42  dialog->setCaption( i18n("Open Attachment?") );
43  dialog->setObjectName( QLatin1String("attachmentSaveOpen") );
44 
45  if ( application.isEmpty() )
46  dialog->setButtons( KDialog::User3 | KDialog::User1 | KDialog::Cancel );
47  else {
48  dialog->setButtons( KDialog::User3 | KDialog::User2 | KDialog::User1 | KDialog::Cancel );
49  dialog->setButtonText( KDialog::User2, i18n("&Open with '%1'", application ) );
50  }
51 
52  dialog->setButtonGuiItem( KDialog::User3, KStandardGuiItem::saveAs() );
53  dialog->setButtonText( KDialog::User1, i18n("&Open With...") );
54  dialog->setDefaultButton( KDialog::User3 );
55 
56  connect( dialog, SIGNAL(user3Clicked()), this, SLOT(saveClicked()) );
57  connect( dialog, SIGNAL(user2Clicked()), this, SLOT(openClicked()) );
58  connect( dialog, SIGNAL(user1Clicked()), this, SLOT(openWithClicked()) );
59 }
60 
61 //---------------------------------------------------------------------
62 
63 int AttachmentDialog::exec()
64 {
65  KConfigGroup cg( KGlobal::config().data(), "Notification Messages" );
66  if ( cg.hasKey( dontAskName ) )
67  return cg.readEntry( dontAskName, 0 );
68 
69  bool again = false;
70  const int ret =
71  KMessageBox::createKMessageBox( dialog, QMessageBox::Question, text, QStringList(),
72  i18n( "Do not ask again" ), &again, 0 );
73 
74  if ( ret == QDialog::Rejected )
75  return Cancel;
76  else {
77  if ( again ) {
78  KConfigGroup::WriteConfigFlags flags = KConfig::Persistent;
79  KConfigGroup cg( KGlobal::config().data(), "Notification Messages" );
80  cg.writeEntry( dontAskName, ret, flags );
81  cg.sync();
82  }
83 
84  return ret;
85  }
86 }
87 
88 //---------------------------------------------------------------------
89 
90 void AttachmentDialog::saveClicked()
91 {
92  dialog->done( Save );
93 }
94 
95 //---------------------------------------------------------------------
96 
97 void AttachmentDialog::openClicked()
98 {
99  dialog->done( Open );
100 }
101 
102 //---------------------------------------------------------------------
103 
104 void AttachmentDialog::openWithClicked()
105 {
106  dialog->done( OpenWith );
107 }
108 
109 //---------------------------------------------------------------------
110 
111 #include "attachmentdialog.moc"
MessageViewer::AttachmentDialog::Open
Definition: attachmentdialog.h:42
QWidget
KDialog
MessageViewer::AttachmentDialog::Cancel
Definition: attachmentdialog.h:44
MessageViewer::AttachmentDialog::Save
Definition: attachmentdialog.h:41
MessageViewer::AttachmentDialog::AttachmentDialog
AttachmentDialog(QWidget *parent, const QString &filenameText, const QString &application, const QString &dontAskAgainName)
Definition: attachmentdialog.cpp:32
MessageViewer::AttachmentDialog::OpenWith
Definition: attachmentdialog.h:43
MessageViewer::AttachmentDialog::exec
int exec()
Definition: attachmentdialog.cpp:63
attachmentdialog.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal