24 #include "kernel/mailkernel.h"
28 #include "customtemplatesmenu.h"
30 #include "messagecore/widgets/annotationdialog.h"
31 #include "messagecore/settings/globalsettings.h"
32 #include "messagecore/misc/mailinglist.h"
33 #include "messagecore/helpers/messagehelpers.h"
34 #include "messageviewer/viewer/csshelper.h"
35 #include "messageviewer/settings/globalsettings.h"
37 #include <Nepomuk2/Resource>
39 #include <akonadi/itemfetchjob.h>
40 #include <akonadi/kmime/messageparts.h>
42 #include <KActionMenu>
43 #include <KActionCollection>
44 #include <KToggleAction>
47 #include <KXMLGUIClient>
48 #include <KStandardDirs>
51 #include <KUriFilterData>
52 #include <KToolInvocation>
54 #include <KStringHandler>
55 #include <KPrintPreview>
59 #include <akonadi/collection.h>
60 #include <Akonadi/Monitor>
61 #include <util/mailutil.h>
62 #include <nepomukutil/asyncnepomukresourceretriever.h>
63 #include <nepomuk2/resourcemanager.h>
64 #include <Soprano/Vocabulary/NAO>
66 using namespace KMail;
73 mPrintPreviewAction( 0 ),
74 mAsynNepomukRetriever( new MessageCore::AsyncNepomukResourceRetriever( QVector<QUrl>() << Soprano::Vocabulary::NAO::annotation().toString()
75 << Soprano::Vocabulary::NAO::description().toString(), this ) ),
76 mCustomTemplatesMenu( 0 )
78 mReplyActionMenu =
new KActionMenu( KIcon(QLatin1String(
"mail-reply-sender")), i18nc(
"Message->",
"&Reply"),
this );
79 ac->addAction( QLatin1String(
"message_reply_menu"), mReplyActionMenu );
80 connect( mReplyActionMenu, SIGNAL(triggered(
bool)),
81 this, SLOT(slotReplyToMsg()) );
83 mReplyAction =
new KAction( KIcon(QLatin1String(
"mail-reply-sender")), i18n(
"&Reply..."),
this );
84 ac->addAction( QLatin1String(
"reply"), mReplyAction );
85 mReplyAction->setShortcut(Qt::Key_R);
86 connect( mReplyAction, SIGNAL(triggered(
bool)),
87 this, SLOT(slotReplyToMsg()) );
88 mReplyActionMenu->addAction( mReplyAction );
90 mReplyAuthorAction =
new KAction( KIcon(QLatin1String(
"mail-reply-sender")), i18n(
"Reply to A&uthor..."),
this );
91 ac->addAction( QLatin1String(
"reply_author"), mReplyAuthorAction );
92 mReplyAuthorAction->setShortcut(Qt::SHIFT+Qt::Key_A);
93 connect( mReplyAuthorAction, SIGNAL(triggered(
bool)),
94 this, SLOT(slotReplyAuthorToMsg()) );
95 mReplyActionMenu->addAction( mReplyAuthorAction );
97 mReplyAllAction =
new KAction( KIcon(QLatin1String(
"mail-reply-all")), i18n(
"Reply to &All..."),
this );
98 ac->addAction( QLatin1String(
"reply_all"), mReplyAllAction );
99 mReplyAllAction->setShortcut( Qt::Key_A );
100 connect( mReplyAllAction, SIGNAL(triggered(
bool)),
101 this, SLOT(slotReplyAllToMsg()) );
102 mReplyActionMenu->addAction( mReplyAllAction );
104 mReplyListAction =
new KAction( KIcon(QLatin1String(
"mail-reply-list")), i18n(
"Reply to Mailing-&List..."),
this );
105 ac->addAction( QLatin1String(
"reply_list"), mReplyListAction );
106 mReplyListAction->setShortcut( Qt::Key_L );
107 connect( mReplyListAction, SIGNAL(triggered(
bool)),
108 this, SLOT(slotReplyListToMsg()) );
109 mReplyActionMenu->addAction( mReplyListAction );
111 mNoQuoteReplyAction =
new KAction( i18n(
"Reply Without &Quote..."),
this );
112 ac->addAction(QLatin1String(
"noquotereply"), mNoQuoteReplyAction );
113 mNoQuoteReplyAction->setShortcut( Qt::SHIFT+Qt::Key_R );
114 connect( mNoQuoteReplyAction, SIGNAL(triggered(
bool)),
115 this, SLOT(slotNoQuoteReplyToMsg()) );
118 mListFilterAction =
new KAction(i18n(
"Filter on Mailing-&List..."),
this);
119 ac->addAction(QLatin1String(
"mlist_filter"), mListFilterAction );
120 connect(mListFilterAction, SIGNAL(triggered(
bool)), SLOT(slotMailingListFilter()));
122 mCreateTodoAction =
new KAction( KIcon( QLatin1String(
"task-new") ), i18n(
"Create To-do/Reminder..." ),
this );
123 mCreateTodoAction->setIconText( i18n(
"Create To-do" ) );
124 mCreateTodoAction->setHelpText( i18n(
"Allows you to create a calendar to-do or reminder from this message" ) );
125 mCreateTodoAction->setWhatsThis( i18n(
"This option starts the KOrganizer to-do editor with initial values taken from the currently selected message. Then you can edit the to-do to your liking before saving it to your calendar." ) );
126 ac->addAction( QLatin1String(
"create_todo"), mCreateTodoAction );
127 connect( mCreateTodoAction, SIGNAL(triggered(
bool)),
128 this, SLOT(slotCreateTodo()) );
129 mKorganizerIsOnSystem = !KStandardDirs::findExe(QLatin1String(
"korganizer")).isEmpty();
130 mCreateTodoAction->setEnabled( mKorganizerIsOnSystem );
132 mStatusMenu =
new KActionMenu ( i18n(
"Mar&k Message" ),
this );
133 ac->addAction( QLatin1String(
"set_status"), mStatusMenu );
138 KAction * action = mainwin->
akonadiStandardAction( Akonadi::StandardMailActionManager::MarkMailAsRead );
139 mStatusMenu->addAction( action );
142 mStatusMenu->addAction( action );
144 mStatusMenu->addSeparator();
146 mStatusMenu->addAction( action );
149 mStatusMenu->addAction( action );
153 mEditAction =
new KAction( KIcon(QLatin1String(
"accessories-text-editor")), i18n(
"&Edit Message"),
this );
154 ac->addAction( QLatin1String(
"edit"), mEditAction );
155 connect( mEditAction, SIGNAL(triggered(
bool)),
157 mEditAction->setShortcut( Qt::Key_T );
159 mAnnotateAction =
new KAction( KIcon( QLatin1String(
"view-pim-notes") ), i18n(
"Add Note..."),
this );
160 ac->addAction( QLatin1String(
"annotate"), mAnnotateAction );
161 connect( mAnnotateAction, SIGNAL(triggered(
bool)),
164 mPrintAction = KStandardAction::print(
this, SLOT(slotPrintMsg()), ac );
165 if(KPrintPreview::isAvailable())
166 mPrintPreviewAction = KStandardAction::printPreview(
this, SLOT(slotPrintPreviewMsg()), ac );
168 mForwardActionMenu =
new KActionMenu(KIcon(QLatin1String(
"mail-forward")), i18nc(
"Message->",
"&Forward"),
this);
169 ac->addAction(QLatin1String(
"message_forward"), mForwardActionMenu );
171 mForwardAttachedAction =
new KAction( KIcon(QLatin1String(
"mail-forward")),
172 i18nc(
"@action:inmenu Message->Forward->",
173 "As &Attachment..." ),
175 connect( mForwardAttachedAction, SIGNAL(triggered(
bool)),
176 parent, SLOT(slotForwardAttachedMsg()) );
177 ac->addAction( QLatin1String(
"message_forward_as_attachment"), mForwardAttachedAction );
179 mForwardInlineAction =
new KAction( KIcon( QLatin1String(
"mail-forward") ),
180 i18nc(
"@action:inmenu Message->Forward->",
183 connect( mForwardInlineAction, SIGNAL(triggered(
bool)),
184 parent, SLOT(slotForwardInlineMsg()) );
185 ac->addAction( QLatin1String(
"message_forward_inline"), mForwardInlineAction );
189 mRedirectAction =
new KAction(i18nc(
"Message->Forward->",
"&Redirect..."),
this );
190 ac->addAction( QLatin1String(
"message_forward_redirect"), mRedirectAction );
191 connect( mRedirectAction, SIGNAL(triggered(
bool)),
192 parent, SLOT(slotRedirectMsg()) );
193 mRedirectAction->setShortcut( QKeySequence( Qt::Key_E ) );
194 mForwardActionMenu->addAction( mRedirectAction );
198 mMailingListActionMenu =
new KActionMenu( i18nc(
"Message->",
"Mailing-&List" ),
this );
199 connect( mMailingListActionMenu->menu(), SIGNAL(triggered(QAction*)),
200 this, SLOT(slotRunUrl(QAction*)) );
201 ac->addAction( QLatin1String(
"mailing_list"), mMailingListActionMenu );
202 mMailingListActionMenu->setEnabled(
false);
204 mMonitor =
new Akonadi::Monitor(
this );
206 mMonitor->itemFetchScope().fetchPayloadPart( Akonadi::MessagePart::Header );
207 connect( mMonitor, SIGNAL(itemChanged(Akonadi::Item,QSet<QByteArray>)), SLOT(slotItemModified(Akonadi::Item,QSet<QByteArray>)));
208 connect( mMonitor, SIGNAL(itemRemoved(Akonadi::Item)), SLOT(slotItemRemoved(Akonadi::Item)));
210 connect( mAsynNepomukRetriever, SIGNAL(resourceReceived(QUrl,Nepomuk2::Resource)), SLOT(updateAnnotateAction(QUrl,Nepomuk2::Resource)) );
212 mCustomTemplatesMenu =
new TemplateParser::CustomTemplatesMenu( parent, ac );
214 connect( mCustomTemplatesMenu, SIGNAL(replyTemplateSelected(QString)),
215 parent, SLOT(slotCustomReplyToMsg(QString)) );
216 connect( mCustomTemplatesMenu, SIGNAL(replyAllTemplateSelected(QString)),
217 parent, SLOT(slotCustomReplyAllToMsg(QString)) );
218 connect( mCustomTemplatesMenu, SIGNAL(forwardTemplateSelected(QString)),
219 parent, SLOT(slotCustomForwardMsg(QString)) );
220 connect(
KMKernel::self(), SIGNAL(customTemplatesChanged()), mCustomTemplatesMenu, SLOT(update()) );
223 forwardMenu()->addAction( mCustomTemplatesMenu->forwardActionMenu() );
225 replyMenu()->addAction( mCustomTemplatesMenu->replyActionMenu() );
226 replyMenu()->addAction( mCustomTemplatesMenu->replyAllActionMenu() );
233 delete mCustomTemplatesMenu;
238 return mCustomTemplatesMenu;
243 mMonitor->setItemMonitored( mCurrentItem,
false );
246 if (!items.isEmpty()) {
247 Q_FOREACH(
const Akonadi::Item& item, mVisibleItems ) {
248 mMonitor->setItemMonitored( item,
false );
250 if (!msg.isValid()) {
251 mVisibleItems.clear();
253 mVisibleItems = items;
254 Q_FOREACH(
const Akonadi::Item& item, items ) {
255 mMonitor->setItemMonitored( item,
true );
260 if ( !msg.isValid() ) {
261 mVisibleItems.clear();
262 clearMailingListActions();
265 mMonitor->setItemMonitored( mCurrentItem,
true );
269 void MessageActions::slotItemRemoved(
const Akonadi::Item& item)
271 if ( item == mCurrentItem ) {
272 mCurrentItem = Akonadi::Item();
277 void MessageActions::slotItemModified(
const Akonadi::Item & item,
const QSet< QByteArray > & partIdentifiers )
279 Q_UNUSED( partIdentifiers );
280 if ( item == mCurrentItem ) {
282 const int numberOfVisibleItems = mVisibleItems.count();
283 for (
int i = 0; i < numberOfVisibleItems; ++i ) {
284 Akonadi::Item it = mVisibleItems.at(i);
286 mVisibleItems[i] = item;
293 void MessageActions::updateActions()
295 const bool hasPayload = mCurrentItem.hasPayload<KMime::Message::Ptr>();
296 bool itemValid = mCurrentItem.isValid();
297 Akonadi::Collection parent;
299 parent = mCurrentItem.parentCollection();
300 if ( parent.isValid() ) {
301 if ( CommonKernel->folderIsTemplates(parent) )
305 const bool multiVisible = mVisibleItems.count() > 0 || mCurrentItem.isValid();
306 const bool uniqItem = ( itemValid||hasPayload ) && ( mVisibleItems.count()<=1 );
307 mCreateTodoAction->setEnabled( itemValid && ( mVisibleItems.count()<=1 ) && mKorganizerIsOnSystem);
308 mReplyActionMenu->setEnabled( hasPayload );
309 mReplyAction->setEnabled( hasPayload );
310 mNoQuoteReplyAction->setEnabled( hasPayload );
311 mReplyAuthorAction->setEnabled( hasPayload );
312 mReplyAllAction->setEnabled( hasPayload );
313 mReplyListAction->setEnabled( hasPayload );
314 mNoQuoteReplyAction->setEnabled( hasPayload );
316 if ( Nepomuk2::ResourceManager::instance()->initialized() ) {
317 mAnnotateAction->setEnabled( uniqItem );
318 mAsynNepomukRetriever->requestResource( mCurrentItem.url() );
320 mAnnotateAction->setEnabled(
false );
323 mStatusMenu->setEnabled( multiVisible );
325 if ( mCurrentItem.hasPayload<KMime::Message::Ptr>() ) {
326 if ( mCurrentItem.loadedPayloadParts().contains(
"RFC822") ) {
327 updateMailingListActions( mCurrentItem );
329 Akonadi::ItemFetchJob *job =
new Akonadi::ItemFetchJob( mCurrentItem );
330 job->fetchScope().fetchAllAttributes();
331 job->fetchScope().fetchFullPayload(
true );
332 job->fetchScope().fetchPayloadPart( Akonadi::MessagePart::Header );
333 connect( job, SIGNAL(result(
KJob*)), SLOT(slotUpdateActionsFetchDone(
KJob*)) );
336 mEditAction->setEnabled( uniqItem );
339 void MessageActions::slotUpdateActionsFetchDone(
KJob* job)
344 Akonadi::ItemFetchJob *fetchJob =
static_cast<Akonadi::ItemFetchJob*
>( job );
345 if ( fetchJob->items().isEmpty() )
347 Akonadi::Item messageItem = fetchJob->items().first();
348 if ( messageItem == mCurrentItem ) {
349 mCurrentItem = messageItem;
350 updateMailingListActions( messageItem );
354 void MessageActions::clearMailingListActions()
356 mMailingListActionMenu->setEnabled(
false );
357 mListFilterAction->setEnabled(
false );
358 mListFilterAction->setText( i18n(
"Filter on Mailing-List...") );
361 void MessageActions::updateMailingListActions(
const Akonadi::Item& messageItem )
363 KMime::Message::Ptr message = messageItem.payload<KMime::Message::Ptr>();
364 const MessageCore::MailingList mailList = MessageCore::MailingList::detect( message );
366 if ( mailList.features() == MessageCore::MailingList::None ) {
367 clearMailingListActions();
372 if ( mailList.features() & MessageCore::MailingList::Id ) {
375 listId = mailList.id();
376 const int start = listId.indexOf( QLatin1Char(
'<' ) );
378 listId.truncate( start - 1 );
379 }
else if ( start == 0 ) {
380 const int end = listId.lastIndexOf( QLatin1Char(
'>' ) );
382 listId.remove( 0, 1 );
384 listId = listId.mid( 1, end-1 );
388 mMailingListActionMenu->menu()->clear();
389 qDeleteAll(mMailListActionList);
390 mMailListActionList.clear();
391 if ( !listId.isEmpty() )
392 mMailingListActionMenu->menu()->addTitle( listId );
394 if ( mailList.features() & MessageCore::MailingList::ArchivedAt )
396 addMailingListActions( i18n(
"Open Message in List Archive" ), mailList.archivedAtUrls() );
397 if ( mailList.features() & MessageCore::MailingList::Post )
398 addMailingListActions( i18n(
"Post New Message" ), mailList.postUrls() );
399 if ( mailList.features() & MessageCore::MailingList::Archive )
400 addMailingListActions( i18n(
"Go to Archive" ), mailList.archiveUrls() );
401 if ( mailList.features() & MessageCore::MailingList::Help )
402 addMailingListActions( i18n(
"Request Help" ), mailList.helpUrls() );
403 if ( mailList.features() & MessageCore::MailingList::Owner )
404 addMailingListActions( i18nc(
"Contact the owner of the mailing list",
"Contact Owner" ), mailList.ownerUrls() );
405 if ( mailList.features() & MessageCore::MailingList::Subscribe )
406 addMailingListActions( i18n(
"Subscribe to List" ), mailList.subscribeUrls() );
407 if ( mailList.features() & MessageCore::MailingList::Unsubscribe )
408 addMailingListActions( i18n(
"Unsubscribe from List" ), mailList.unsubscribeUrls() );
409 mMailingListActionMenu->setEnabled(
true );
413 const QString lname = MailingList::name( message, name, value );
414 if ( !lname.isEmpty() ) {
415 mListFilterAction->setEnabled(
true );
416 mListFilterAction->setText( i18n(
"Filter on Mailing-List %1...", lname ) );
422 void MessageActions::replyCommand(MessageComposer::ReplyStrategy strategy)
424 if ( !mCurrentItem.hasPayload<KMime::Message::Ptr>() )
return;
426 const QString
text = mMessageView ? mMessageView->
copyText() : QString();
428 connect( command, SIGNAL(completed(
KMCommand*)),
433 void MessageActions::slotCreateTodo()
435 if ( !mCurrentItem.isValid() )
438 MailCommon::Util::createTodoFromMail( mCurrentItem );
443 mMessageView = msgView;
448 disconnect( mForwardActionMenu, SIGNAL(triggered(
bool)), 0, 0 );
449 mForwardActionMenu->removeAction( mForwardInlineAction );
450 mForwardActionMenu->removeAction( mForwardAttachedAction );
453 mForwardActionMenu->insertAction( mRedirectAction, mForwardInlineAction );
454 mForwardActionMenu->insertAction( mRedirectAction, mForwardAttachedAction );
455 mForwardInlineAction->setShortcut(QKeySequence(Qt::Key_F));
456 mForwardAttachedAction->setShortcut(QKeySequence(Qt::SHIFT+Qt::Key_F));
457 QObject::connect( mForwardActionMenu, SIGNAL(triggered(
bool)),
458 mParent, SLOT(slotForwardInlineMsg()) );
460 mForwardActionMenu->insertAction( mRedirectAction, mForwardAttachedAction );
461 mForwardActionMenu->insertAction( mRedirectAction, mForwardInlineAction );
462 mForwardInlineAction->setShortcut(QKeySequence(Qt::Key_F));
463 mForwardAttachedAction->setShortcut(QKeySequence(Qt::SHIFT+Qt::Key_F));
464 QObject::connect( mForwardActionMenu, SIGNAL(triggered(
bool)),
465 mParent, SLOT(slotForwardAttachedMsg()) );
472 guiClient->unplugActionList( QLatin1String(
"forward_action_list") );
474 forwardActionList.append( mForwardInlineAction );
475 forwardActionList.append( mForwardAttachedAction );
477 forwardActionList.append( mForwardAttachedAction );
478 forwardActionList.append( mForwardInlineAction );
480 forwardActionList.append( mRedirectAction );
481 guiClient->plugActionList( QLatin1String(
"forward_action_list"), forwardActionList );
485 void MessageActions::slotReplyToMsg()
487 replyCommand( MessageComposer::ReplySmart );
490 void MessageActions::slotReplyAuthorToMsg()
492 replyCommand( MessageComposer::ReplyAuthor );
495 void MessageActions::slotReplyListToMsg()
497 replyCommand( MessageComposer::ReplyList );
500 void MessageActions::slotReplyAllToMsg()
502 replyCommand( MessageComposer::ReplyAll );
505 void MessageActions::slotNoQuoteReplyToMsg()
507 if ( !mCurrentItem.hasPayload<KMime::Message::Ptr>() )
509 KMCommand *command =
new KMReplyCommand( mParent, mCurrentItem, MessageComposer::ReplySmart, QString(),
true );
513 void MessageActions::slotRunUrl( QAction *urlAction )
515 const QVariant q = urlAction->data();
516 if ( q.type() == QVariant::String ) {
517 new KRun( KUrl( q.toString() ) , mParent );
521 void MessageActions::slotMailingListFilter()
523 if ( !mCurrentItem.hasPayload<KMime::Message::Ptr>() )
530 void MessageActions::printMessage(
bool preview)
533 if ( mMessageView ) {
534 if (MessageViewer::GlobalSettings::self()->printSelectedText()) {
539 const bool useFixedFont = MessageViewer::GlobalSettings::self()->useFixedFont();
540 const QString overrideEncoding = MessageCore::GlobalSettings::self()->overrideCharacterEncoding();
542 const Akonadi::Item message = mCurrentItem;
545 mMessageView->
viewer()->headerStyle(), mMessageView->
viewer()->headerStrategy(),
546 mMessageView->
viewer()->htmlOverride(), mMessageView->
viewer()->htmlLoadExternal(),
547 useFixedFont, overrideEncoding );
553 void MessageActions::slotPrintPreviewMsg()
558 void MessageActions::slotPrintMsg()
571 void MessageActions::addMailingListActions(
const QString &item,
const KUrl::List &list )
573 foreach (
const KUrl& url, list ) {
574 addMailingListAction( item, url );
582 void MessageActions::addMailingListAction(
const QString &item,
const KUrl &url )
584 QString protocol = url.protocol().toLower();
585 QString prettyUrl = url.prettyUrl();
586 if ( protocol == QLatin1String(
"mailto") ) {
587 protocol = i18n(
"email" );
588 prettyUrl.remove( 0, 7 );
589 }
else if ( protocol.startsWith( QLatin1String(
"http" ) ) ) {
590 protocol = i18n(
"web" );
593 KAction *act =
new KAction( i18nc(
"%1 is a 'Contact Owner' or similar action. %2 is a protocol normally web or email though could be irc/ftp or other url variant",
"%1 (%2)", item, protocol ) ,
this );
594 mMailListActionList.append(act);
595 const QVariant v( url.url() );
597 act->setHelpText( prettyUrl );
598 mMailingListActionMenu->addAction( act );
604 if ( mCurrentItem.isValid() ) {
605 Akonadi::Collection col = mCurrentItem.parentCollection();
606 qDebug()<<
" mCurrentItem.parentCollection()"<<mCurrentItem.parentCollection();
610 && ( CommonKernel->folderIsDraftOrOutbox( col ) ||
611 CommonKernel->folderIsTemplates( col ) )
617 }
else if ( mCurrentItem.hasPayload<KMime::Message::Ptr>() ) {
625 if ( !mCurrentItem.isValid() )
628 const QUrl url = mCurrentItem.url();
629 MessageCore::AnnotationEditDialog *dialog =
new MessageCore::AnnotationEditDialog( url );
630 dialog->setAttribute( Qt::WA_DeleteOnClose );
631 if ( dialog->exec() )
632 mAsynNepomukRetriever->requestResource( url );
635 void MessageActions::updateAnnotateAction(
const QUrl &url,
const Nepomuk2::Resource &resource )
637 if( mCurrentItem.isValid() && mCurrentItem.url() == url ) {
638 if ( resource.description().isEmpty() )
639 mAnnotateAction->setText( i18n(
"Add Note..." ) );
641 mAnnotateAction->setText( i18n(
"Edit Note...") );
647 if ( text.isEmpty() )
650 QString searchText =
text;
651 searchText = searchText.replace( QLatin1Char(
'\n'), QLatin1Char(
' ') ).replace( QLatin1Char(
'\r'), QLatin1Char(
' ') ).simplified();
653 if ( searchText.isEmpty() )
656 KUriFilterData filterData( searchText );
658 filterData.setSearchFilteringOptions( KUriFilterData::RetrievePreferredSearchProvidersOnly );
660 if ( KUriFilter::self()->filterSearchUri( filterData, KUriFilter::NormalTextFilter ) ) {
661 const QStringList searchProviders = filterData.preferredSearchProviders();
663 if ( !searchProviders.isEmpty() ) {
664 KMenu *webShortcutsMenu =
new KMenu( menu );
665 webShortcutsMenu->setIcon( KIcon( QLatin1String(
"preferences-web-browser-shortcuts") ) );
667 const QString squeezedText = KStringHandler::rsqueeze( searchText, 21 );
668 webShortcutsMenu->setTitle( i18n(
"Search for '%1' with", squeezedText ) );
672 foreach(
const QString &searchProvider, searchProviders ) {
673 action =
new KAction( searchProvider, webShortcutsMenu );
674 action->setIcon( KIcon( filterData.iconNameForPreferredSearchProvider( searchProvider ) ) );
675 action->setData( filterData.queryForPreferredSearchProvider( searchProvider ) );
676 connect( action, SIGNAL(triggered()),
this, SLOT(slotHandleWebShortcutAction()) );
677 webShortcutsMenu->addAction( action );
680 webShortcutsMenu->addSeparator();
682 action =
new KAction( i18n(
"Configure Web Shortcuts..." ), webShortcutsMenu );
683 action->setIcon( KIcon( QLatin1String(
"configure") ) );
684 connect( action, SIGNAL(triggered()),
this, SLOT(slotConfigureWebShortcuts()) );
685 webShortcutsMenu->addAction( action );
687 menu->addMenu(webShortcutsMenu);
692 void MessageActions::slotHandleWebShortcutAction()
694 KAction *action = qobject_cast<KAction*>( sender() );
697 KUriFilterData filterData( action->data().toString() );
698 if ( KUriFilter::self()->filterSearchUri( filterData, KUriFilter::WebShortcutFilter ) ) {
699 KToolInvocation::invokeBrowser( filterData.uri().url() );
704 void MessageActions::slotConfigureWebShortcuts()
706 KToolInvocation::kdeinitExec( QLatin1String(
"kcmshell4"), QStringList() << QLatin1String(
"ebrowsing") );
709 #include "messageactions.moc"
void addWebShortcutsMenu(KMenu *menu, const QString &text)
void editCurrentMessage()
void replyActionFinished()
KAction * akonadiStandardAction(Akonadi::StandardActionManager::Type type)
This class implements a "reader window", that is a window used for reading or viewing messages...
MessageViewer::Viewer * viewer()
virtual QByteArray text(quint32 serialNumber) const =0
MessageActions(KActionCollection *ac, QWidget *parent)
TemplateParser::CustomTemplatesMenu * customTemplatesMenu() const
static KMKernel * self()
normal control stuff
void setupForwardingActionsList(KXMLGUIClient *guiClient)
Sets up action list for forward menu.
Small helper structure which encapsulates the KMMessage created when creating a reply, and.
KActionMenu * forwardMenu() const
void setCurrentMessage(const Akonadi::Item &item, const Akonadi::Item::List &items=Akonadi::Item::List())
static GlobalSettings * self()
KActionMenu * replyMenu() const
void setPrintPreview(bool preview)
void setMessageView(KMReaderWin *msgView)
QString copyText() const
Return selected text.
bool printSelectedText(bool preview)
void setupForwardActions()
This function adds or updates the actions of the forward action menu, taking the preference whether t...