Version: (using KDE KDE 3.0.3) Installed from: SuSE RPMs Compiler: gcc 3.2 OS: Linux I would like a "Edit/Insert clipboard as attachment" function in KMail. For now, you can only add an attachment as a file to a new message. So when you have data in the clipboard that you wnat to attch to a message youhave to call another program first, insert the clipboard content, save into a file and then attch the file in KMail. It would be better if this procedure could be made directly in KMail. Sure, a selection dialog is perhaps needed if the clipboard holds a few formats. Have a nice day/evening/night!
Sorry, it seems that I have written "attach" always as "attch".
I would also love to see this feature. One occasion where I have that wish regularly is when I want to send someone a screenshot. It would be so conveniant to start a new mail, launch ksnapshot, take a snapshot and drag it into the mail. No more saving to /tmp, clicking "attach", going to the /tmp folder with kmail. Btw. this works between kword and ksnapshot for instance.
The problem is that there isn't a real good clipboard on linux; I guess that ksnapshot and kwrod do this using dcop?
> The problem is that there isn't a real good clipboard on linux; I guess that ksnapshot and kwrod do this using dcop? Certainly not - we use the clipboard, which works very well for this kind of thing.
*** Bug 91364 has been marked as a duplicate of this bug. ***
CVS commit by eschepers: Ability to paste into an attachment (Edit menu) BUG: 50912 M +2 -1 kmcomposerui.rc 1.36 M +48 -23 kmcomposewin.cpp 1.874 M +6 -0 kmcomposewin.h 1.258 --- kdepim/kmail/kmcomposerui.rc #1.35:1.36 @@ -1,3 +1,3 @@ -<!DOCTYPE kpartgui ><kpartgui version="22" name="kmcomposer" > +<!DOCTYPE kpartgui ><kpartgui version="23" name="kmcomposer" > <MenuBar> <Menu noMerge="1" name="file" > @@ -18,4 +18,5 @@ <text>&Edit</text> <Action name="paste_quoted" append="edit_paste_merge"/> + <Action name="paste_att" append="edit_paste_merge"/> <Action name="clean_spaces" /> <Separator/> --- kdepim/kmail/kmcomposewin.cpp #1.873:1.874 @@ -400,5 +400,31 @@ void KMComposeWin::addAttachment(const Q } } +//----------------------------------------------------------------------------- +void KMComposeWin::addImageFromClipboard() +{ + bool ok; + QFile *tmpFile; + + QString attName = KInputDialog::getText( "KMail", i18n("Name of the attachment:"), QString::null, &ok, this ); + if ( !ok ) + return; + + mTempDir = new KTempDir(); + mTempDir->setAutoDelete( true ); + + if ( attName.lower().endsWith(".png") ) + tmpFile = new QFile(mTempDir->name() + attName ); + else + tmpFile = new QFile(mTempDir->name() + attName + ".png" ); + + if ( !QApplication::clipboard()->image().save( tmpFile->name(), "PNG" ) ) { + KMessageBox::error( this, i18n("Unknown error trying to save image"), i18n("Attaching image failed") ); + delete mTempDir; + mTempDir = 0; + return; + } + addAttach( tmpFile->name() ); +} //----------------------------------------------------------------------------- void KMComposeWin::setBody(QString body) @@ -985,4 +1011,7 @@ void KMComposeWin::setupActions(void) actionCollection(), "paste_quoted"); + (void) new KAction (i18n("Paste as Attac&hment"),0,this,SLOT( slotPasteAsAttachment()), + actionCollection(), "paste_att"); + (void) new KAction(i18n("Add &Quote Characters"), 0, this, SLOT(slotAddQuotes()), actionCollection(), "tools_quote"); @@ -2680,4 +2709,22 @@ void KMComposeWin::slotPasteAsQuotation( } +void KMComposeWin::slotPasteAsAttachment() +{ + if ( QApplication::clipboard()->image().isNull() ) { + bool ok; + QString attName = KInputDialog::getText( "KMail", i18n("Name of the attachment:"), QString::null, &ok, this ); + if ( !ok ) + return; + KMMessagePart *msgPart = new KMMessagePart; + msgPart->setName(attName); + QValueList<int> dummy; + msgPart->setBodyAndGuessCte(QCString(QApplication::clipboard()->text().latin1()), dummy, + kmkernel->msgSender()->sendQuotedPrintable()); + addAttach(msgPart); + } + else + addImageFromClipboard(); + +} void KMComposeWin::slotAddQuotes() @@ -2789,27 +2836,5 @@ void KMComposeWin::slotPaste() if ( ! QApplication::clipboard()->image().isNull() ) { - bool ok; - QFile *tmpFile; - - QString attName = KInputDialog::getText( "KMail", i18n("Name of the attachment:"), QString::null, &ok ); - if ( !ok ) - return; - - mTempDir = new KTempDir(); - mTempDir->setAutoDelete( true ); - - if ( attName.lower().endsWith(".png") ) - tmpFile = new QFile(mTempDir->name() + attName ); - else - tmpFile = new QFile(mTempDir->name() + attName + ".png" ); - - if ( !QApplication::clipboard()->image().save( tmpFile->name(), "PNG" ) ) { - KMessageBox::error( this, i18n("Unknown error trying to save image"), i18n("Attaching image failed") ); - delete mTempDir; - mTempDir = 0; - return; - } - - addAttach( tmpFile->name() ); + addImageFromClipboard(); } else { --- kdepim/kmail/kmcomposewin.h #1.257:1.258 @@ -394,4 +394,5 @@ public slots: void slotPaste(); void slotPasteAsQuotation(); + void slotPasteAsAttachment(); void slotAddQuotes(); void slotRemoveQuotes(); @@ -573,4 +574,9 @@ public slots: void addAttach(const KMMessagePart* msgPart); + /** + * Add an image from the clipboard as attachment + */ + void addImageFromClipboard(); + public: const KPIM::Identity & identity() const;