diff --git a/kmmainwidget.cpp b/kmmainwidget.cpp index f09f42404..47b169088 100644 --- a/kmmainwidget.cpp +++ b/kmmainwidget.cpp @@ -410,7 +410,6 @@ void KMMainWidget::readConfig(void) } updateMessageMenu(); updateFileMenu(); - updateViewMenu(); } @@ -1576,83 +1575,7 @@ void KMMainWidget::slotViewChange() } -void KMMainWidget::slotFancyHeaders() { - mMsgView->setHeaderStyleAndStrategy( HeaderStyle::fancy(), - HeaderStrategy::rich() ); -} - -void KMMainWidget::slotBriefHeaders() { - mMsgView->setHeaderStyleAndStrategy( HeaderStyle::brief(), - HeaderStrategy::brief() ); -} - -void KMMainWidget::slotStandardHeaders() { - mMsgView->setHeaderStyleAndStrategy( HeaderStyle::plain(), - HeaderStrategy::standard()); -} - -void KMMainWidget::slotLongHeaders() { - mMsgView->setHeaderStyleAndStrategy( HeaderStyle::plain(), - HeaderStrategy::rich() ); -} - -void KMMainWidget::slotAllHeaders() { - mMsgView->setHeaderStyleAndStrategy( HeaderStyle::plain(), - HeaderStrategy::all() ); -} - -void KMMainWidget::slotCycleHeaderStyles() { - const HeaderStrategy * strategy = mMsgView->headerStrategy(); - const HeaderStyle * style = mMsgView->headerStyle(); - - const char * actionName = 0; - if ( style == HeaderStyle::fancy() ) { - slotBriefHeaders(); - actionName = "view_headers_brief"; - } else if ( style == HeaderStyle::brief() ) { - slotStandardHeaders(); - actionName = "view_headers_standard"; - } else if ( style == HeaderStyle::plain() ) { - if ( strategy == HeaderStrategy::standard() ) { - slotLongHeaders(); - actionName = "view_headers_long"; - } else if ( strategy == HeaderStrategy::rich() ) { - slotAllHeaders(); - actionName = "view_headers_all"; - } else if ( strategy == HeaderStrategy::all() ) { - slotFancyHeaders(); - actionName = "view_headers_fancy"; - } - } - - if ( actionName ) - static_cast( actionCollection()->action( actionName ) )->setChecked( true ); -} - - -void KMMainWidget::slotIconicAttachments() { - mMsgView->setAttachmentStrategy( AttachmentStrategy::iconic() ); -} - -void KMMainWidget::slotSmartAttachments() { - mMsgView->setAttachmentStrategy( AttachmentStrategy::smart() ); -} - -void KMMainWidget::slotInlineAttachments() { - mMsgView->setAttachmentStrategy( AttachmentStrategy::inlined() ); -} - -void KMMainWidget::slotHideAttachments() { - mMsgView->setAttachmentStrategy( AttachmentStrategy::hidden() ); -} - -void KMMainWidget::slotCycleAttachmentStrategy() { - mMsgView->setAttachmentStrategy( mMsgView->attachmentStrategy()->next() ); - KRadioAction * action = actionForAttachmentStrategy( mMsgView->attachmentStrategy() ); - assert( action ); - action->setChecked( true ); -} - +//----------------------------------------------------------------------------- void KMMainWidget::folderSelectedUnread( KMFolder* aFolder ) { folderSelected( aFolder, true ); @@ -2179,45 +2102,6 @@ void KMMainWidget::getAccountMenu() mActMenu->insertItem((*it).replace("&", "&&"), id); } -// little helper function -KRadioAction * KMMainWidget::actionForHeaderStyle( const HeaderStyle * style, const HeaderStrategy * strategy ) { - const char * actionName = 0; - if ( style == HeaderStyle::fancy() ) - actionName = "view_headers_fancy"; - else if ( style == HeaderStyle::brief() ) - actionName = "view_headers_brief"; - else if ( style == HeaderStyle::plain() ) { - if ( strategy == HeaderStrategy::standard() ) - actionName = "view_headers_standard"; - else if ( strategy == HeaderStrategy::rich() ) - actionName = "view_headers_long"; - else if ( strategy == HeaderStrategy::all() ) - actionName = "view_headers_all"; - } - if ( actionName ) - return static_cast(actionCollection()->action(actionName)); - else - return 0; -} - -KRadioAction * KMMainWidget::actionForAttachmentStrategy( const AttachmentStrategy * as ) { - const char * actionName = 0; - if ( as == AttachmentStrategy::iconic() ) - actionName = "view_attachments_as_icons"; - else if ( as == AttachmentStrategy::smart() ) - actionName = "view_attachments_smart"; - else if ( as == AttachmentStrategy::inlined() ) - actionName = "view_attachments_inline"; - else if ( as == AttachmentStrategy::hidden() ) - actionName = "view_attachments_hide"; - - if ( actionName ) - return static_cast(actionCollection()->action(actionName)); - else - return 0; -} - - //----------------------------------------------------------------------------- void KMMainWidget::setupActions() { @@ -2598,7 +2482,7 @@ void KMMainWidget::setupActions() actionCollection(), "thread_queued"); mToggleThreadQueuedAction->setCheckedState( i18n("Mark Thread as Not &Queued") ); mThreadStatusMenu->insert( mToggleThreadQueuedAction ); - + mToggleThreadSentAction = new KToggleAction(i18n("Mark Thread as &Sent"), "kmmsgsent", 0, this, SLOT(slotSetThreadStatusSent()), actionCollection(), "thread_sent"); @@ -2648,90 +2532,6 @@ void KMMainWidget::setupActions() "apply_filter_actions" ); //----- View Menu - KRadioAction * raction = 0; - - // "Headers" submenu: - KActionMenu * headerMenu = - new KActionMenu( i18n("View->", "&Headers"), - actionCollection(), "view_headers" ); - headerMenu->setToolTip( i18n("Choose display style of message headers") ); - - connect( headerMenu, SIGNAL(activated()), SLOT(slotCycleHeaderStyles()) ); - - raction = new KRadioAction( i18n("View->headers->", "&Fancy Headers"), 0, this, - SLOT(slotFancyHeaders()), - actionCollection(), "view_headers_fancy" ); - raction->setToolTip( i18n("Show the list of headers in a fancy format") ); - raction->setExclusiveGroup( "view_headers_group" ); - headerMenu->insert( raction ); - - raction = new KRadioAction( i18n("View->headers->", "&Brief Headers"), 0, this, - SLOT(slotBriefHeaders()), - actionCollection(), "view_headers_brief" ); - raction->setToolTip( i18n("Show brief list of message headers") ); - raction->setExclusiveGroup( "view_headers_group" ); - headerMenu->insert( raction ); - - raction = new KRadioAction( i18n("View->headers->", "&Standard Headers"), 0, this, - SLOT(slotStandardHeaders()), - actionCollection(), "view_headers_standard" ); - raction->setToolTip( i18n("Show standard list of message headers") ); - raction->setExclusiveGroup( "view_headers_group" ); - headerMenu->insert( raction ); - - raction = new KRadioAction( i18n("View->headers->", "&Long Headers"), 0, this, - SLOT(slotLongHeaders()), - actionCollection(), "view_headers_long" ); - raction->setToolTip( i18n("Show long list of message headers") ); - raction->setExclusiveGroup( "view_headers_group" ); - headerMenu->insert( raction ); - - raction = new KRadioAction( i18n("View->headers->", "&All Headers"), 0, this, - SLOT(slotAllHeaders()), - actionCollection(), "view_headers_all" ); - raction->setToolTip( i18n("Show all message headers") ); - raction->setExclusiveGroup( "view_headers_group" ); - headerMenu->insert( raction ); - - - - // "Attachments" submenu: - KActionMenu * attachmentMenu = - new KActionMenu( i18n("View->", "&Attachments"), - actionCollection(), "view_attachments" ); - connect( attachmentMenu, SIGNAL(activated()), - SLOT(slotCycleAttachmentStrategy()) ); - - attachmentMenu->setToolTip( i18n("Choose display style of attachments") ); - - raction = new KRadioAction( i18n("View->attachments->", "&As Icons"), 0, this, - SLOT(slotIconicAttachments()), - actionCollection(), "view_attachments_as_icons" ); - raction->setToolTip( i18n("Show all attachments as icons. Click to see them.") ); - raction->setExclusiveGroup( "view_attachments_group" ); - attachmentMenu->insert( raction ); - - raction = new KRadioAction( i18n("View->attachments->", "&Smart"), 0, this, - SLOT(slotSmartAttachments()), - actionCollection(), "view_attachments_smart" ); - raction->setToolTip( i18n("Show attachments as suggested by sender.") ); - raction->setExclusiveGroup( "view_attachments_group" ); - attachmentMenu->insert( raction ); - - raction = new KRadioAction( i18n("View->attachments->", "&Inline"), 0, this, - SLOT(slotInlineAttachments()), - actionCollection(), "view_attachments_inline" ); - raction->setToolTip( i18n("Show all attachments inline (if possible)") ); - raction->setExclusiveGroup( "view_attachments_group" ); - attachmentMenu->insert( raction ); - - raction = new KRadioAction( i18n("View->attachments->", "&Hide"), 0, this, - SLOT(slotHideAttachments()), - actionCollection(), "view_attachments_hide" ); - raction->setToolTip( i18n("Do not show attachments in the message viewer") ); - raction->setExclusiveGroup( "view_attachments_group" ); - attachmentMenu->insert( raction ); - // Unread Submenu KActionMenu * unreadMenu = new KActionMenu( i18n("View->", "&Unread Count"), @@ -3542,22 +3342,6 @@ void KMMainWidget::updateFileMenu() } -//----------------------------------------------------------------------------- -void KMMainWidget::updateViewMenu() -{ - bool previewPaneVisible = ( mMsgView != 0 ); - if ( previewPaneVisible ) { - KRadioAction *raction = actionForHeaderStyle( mMsgView->headerStyle(), mMsgView->headerStrategy() ); - if ( raction ) - raction->setChecked( true ); - raction = actionForAttachmentStrategy( mMsgView->attachmentStrategy() ); - if ( raction ) - raction->setChecked( true ); - } - actionCollection()->action("view_headers")->setEnabled( previewPaneVisible ); - actionCollection()->action("view_attachments")->setEnabled( previewPaneVisible ); -} - //----------------------------------------------------------------------------- KMSystemTray *KMMainWidget::systray() const { diff --git a/kmmainwidget.h b/kmmainwidget.h index 63f10f3b0..f07771824 100644 --- a/kmmainwidget.h +++ b/kmmainwidget.h @@ -141,7 +141,7 @@ public: static QPtrList* mainWidgetList() { return s_mainWidgetList; } KMSystemTray *systray() const; - + /** Checks a shortcut against the actioncollection and returns whether it * is already used and therefor not valid or not. */ bool shortcutIsValid( const KShortcut& ) const; @@ -193,10 +193,10 @@ public slots: /** Clear and create actions for marked filters */ void clearFilterActions(); void initializeFilterActions(); - + /** Create actions for the folder shortcuts. */ void initializeFolderShortcutActions(); - + /** Add, remove or adjust the folder's shortcut. */ void slotShortcutChanged( KMFolder *folder ); @@ -210,14 +210,9 @@ protected: void activatePanners(); void showMsg(KMReaderWin *win, KMMessage *msg); void updateFileMenu(); - void updateViewMenu(); KActionCollection * actionCollection() const { return mActionCollection; } - KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *, - const KMail::HeaderStrategy * ); - KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * ); - /** @return the correct config dialog depending on whether the parent of the mainWidget * is a KPart or a KMMainWindow. When dealing with geometries, use this pointer */ @@ -300,17 +295,6 @@ protected slots: void slotSetThreadStatusIgnored(); void slotToggleUnread(); void slotToggleTotalColumn(); - void slotBriefHeaders(); - void slotFancyHeaders(); - void slotStandardHeaders(); - void slotLongHeaders(); - void slotAllHeaders(); - void slotIconicAttachments(); - void slotSmartAttachments(); - void slotInlineAttachments(); - void slotHideAttachments(); - void slotCycleHeaderStyles(); - void slotCycleAttachmentStrategy(); void slotSetEncoding(); void slotSendQueued(); void slotMsgPopup(KMMessage &msg, const KURL &aUrl, const QPoint&); @@ -491,7 +475,7 @@ private: KMSystemTray *mSystemTray; KConfig *mConfig; KXMLGUIClient *mGUIClient; - + static QPtrList* s_mainWidgetList; }; diff --git a/kmreaderwin.cpp b/kmreaderwin.cpp index eccc91c1f..1861c720b 100644 --- a/kmreaderwin.cpp +++ b/kmreaderwin.cpp @@ -488,6 +488,7 @@ KMReaderWin::KMReaderWin(QWidget *aParent, mCSSHelper( 0 ), mRootNode( 0 ), mMainWindow( mainWindow ), + mActionCollection( actionCollection ), mHtmlWriter( 0 ) { mSplitterSizes << 180 << 100; @@ -523,6 +524,86 @@ void KMReaderWin::createActions( KActionCollection * ac ) { if ( !ac ) return; + KRadioAction *raction = 0; + + // header style + KActionMenu *headerMenu = + new KActionMenu( i18n("View->", "&Headers"), ac, "view_headers" ); + headerMenu->setToolTip( i18n("Choose display style of message headers") ); + + connect( headerMenu, SIGNAL(activated()), + this, SLOT(slotCycleHeaderStyles()) ); + + raction = new KRadioAction( i18n("View->headers->", "&Fancy Headers"), 0, + this, SLOT(slotFancyHeaders()), + ac, "view_headers_fancy" ); + raction->setToolTip( i18n("Show the list of headers in a fancy format") ); + raction->setExclusiveGroup( "view_headers_group" ); + headerMenu->insert( raction ); + + raction = new KRadioAction( i18n("View->headers->", "&Brief Headers"), 0, + this, SLOT(slotBriefHeaders()), + ac, "view_headers_brief" ); + raction->setToolTip( i18n("Show brief list of message headers") ); + raction->setExclusiveGroup( "view_headers_group" ); + headerMenu->insert( raction ); + + raction = new KRadioAction( i18n("View->headers->", "&Standard Headers"), 0, + this, SLOT(slotStandardHeaders()), + ac, "view_headers_standard" ); + raction->setToolTip( i18n("Show standard list of message headers") ); + raction->setExclusiveGroup( "view_headers_group" ); + headerMenu->insert( raction ); + + raction = new KRadioAction( i18n("View->headers->", "&Long Headers"), 0, + this, SLOT(slotLongHeaders()), + ac, "view_headers_long" ); + raction->setToolTip( i18n("Show long list of message headers") ); + raction->setExclusiveGroup( "view_headers_group" ); + headerMenu->insert( raction ); + + raction = new KRadioAction( i18n("View->headers->", "&All Headers"), 0, + this, SLOT(slotAllHeaders()), + ac, "view_headers_all" ); + raction->setToolTip( i18n("Show all message headers") ); + raction->setExclusiveGroup( "view_headers_group" ); + headerMenu->insert( raction ); + + // attachment style + KActionMenu *attachmentMenu = + new KActionMenu( i18n("View->", "&Attachments"), ac, "view_attachments" ); + attachmentMenu->setToolTip( i18n("Choose display style of attachments") ); + connect( attachmentMenu, SIGNAL(activated()), + this, SLOT(slotCycleAttachmentStrategy()) ); + + raction = new KRadioAction( i18n("View->attachments->", "&As Icons"), 0, + this, SLOT(slotIconicAttachments()), + ac, "view_attachments_as_icons" ); + raction->setToolTip( i18n("Show all attachments as icons. Click to see them.") ); + raction->setExclusiveGroup( "view_attachments_group" ); + attachmentMenu->insert( raction ); + + raction = new KRadioAction( i18n("View->attachments->", "&Smart"), 0, + this, SLOT(slotSmartAttachments()), + ac, "view_attachments_smart" ); + raction->setToolTip( i18n("Show attachments as suggested by sender.") ); + raction->setExclusiveGroup( "view_attachments_group" ); + attachmentMenu->insert( raction ); + + raction = new KRadioAction( i18n("View->attachments->", "&Inline"), 0, + this, SLOT(slotInlineAttachments()), + ac, "view_attachments_inline" ); + raction->setToolTip( i18n("Show all attachments inline (if possible)") ); + raction->setExclusiveGroup( "view_attachments_group" ); + attachmentMenu->insert( raction ); + + raction = new KRadioAction( i18n("View->attachments->", "&Hide"), 0, + this, SLOT(slotHideAttachments()), + ac, "view_attachments_hide" ); + raction->setToolTip( i18n("Do not show attachments in the message viewer") ); + raction->setExclusiveGroup( "view_attachments_group" ); + attachmentMenu->insert( raction ); + mMailToComposeAction = new KAction( i18n("New Message To..."), 0, this, SLOT(slotMailtoCompose()), ac, "mailto_compose" ); @@ -559,6 +640,121 @@ void KMReaderWin::createActions( KActionCollection * ac ) { SLOT(slotIMChat()), ac, "start_im_chat" ); } +// little helper function +KRadioAction *KMReaderWin::actionForHeaderStyle( const HeaderStyle * style, const HeaderStrategy * strategy ) { + const char * actionName = 0; + if ( style == HeaderStyle::fancy() ) + actionName = "view_headers_fancy"; + else if ( style == HeaderStyle::brief() ) + actionName = "view_headers_brief"; + else if ( style == HeaderStyle::plain() ) { + if ( strategy == HeaderStrategy::standard() ) + actionName = "view_headers_standard"; + else if ( strategy == HeaderStrategy::rich() ) + actionName = "view_headers_long"; + else if ( strategy == HeaderStrategy::all() ) + actionName = "view_headers_all"; + } + if ( actionName ) + return static_cast(mActionCollection->action(actionName)); + else + return 0; +} + +KRadioAction *KMReaderWin::actionForAttachmentStrategy( const AttachmentStrategy * as ) { + const char * actionName = 0; + if ( as == AttachmentStrategy::iconic() ) + actionName = "view_attachments_as_icons"; + else if ( as == AttachmentStrategy::smart() ) + actionName = "view_attachments_smart"; + else if ( as == AttachmentStrategy::inlined() ) + actionName = "view_attachments_inline"; + else if ( as == AttachmentStrategy::hidden() ) + actionName = "view_attachments_hide"; + + if ( actionName ) + return static_cast(mActionCollection->action(actionName)); + else + return 0; +} + +void KMReaderWin::slotFancyHeaders() { + setHeaderStyleAndStrategy( HeaderStyle::fancy(), + HeaderStrategy::rich() ); +} + +void KMReaderWin::slotBriefHeaders() { + setHeaderStyleAndStrategy( HeaderStyle::brief(), + HeaderStrategy::brief() ); +} + +void KMReaderWin::slotStandardHeaders() { + setHeaderStyleAndStrategy( HeaderStyle::plain(), + HeaderStrategy::standard()); +} + +void KMReaderWin::slotLongHeaders() { + setHeaderStyleAndStrategy( HeaderStyle::plain(), + HeaderStrategy::rich() ); +} + +void KMReaderWin::slotAllHeaders() { + setHeaderStyleAndStrategy( HeaderStyle::plain(), + HeaderStrategy::all() ); +} + +void KMReaderWin::slotCycleHeaderStyles() { + const HeaderStrategy * strategy = headerStrategy(); + const HeaderStyle * style = headerStyle(); + + const char * actionName = 0; + if ( style == HeaderStyle::fancy() ) { + slotBriefHeaders(); + actionName = "view_headers_brief"; + } else if ( style == HeaderStyle::brief() ) { + slotStandardHeaders(); + actionName = "view_headers_standard"; + } else if ( style == HeaderStyle::plain() ) { + if ( strategy == HeaderStrategy::standard() ) { + slotLongHeaders(); + actionName = "view_headers_long"; + } else if ( strategy == HeaderStrategy::rich() ) { + slotAllHeaders(); + actionName = "view_headers_all"; + } else if ( strategy == HeaderStrategy::all() ) { + slotFancyHeaders(); + actionName = "view_headers_fancy"; + } + } + + if ( actionName ) + static_cast( mActionCollection->action( actionName ) )->setChecked( true ); +} + + +void KMReaderWin::slotIconicAttachments() { + setAttachmentStrategy( AttachmentStrategy::iconic() ); +} + +void KMReaderWin::slotSmartAttachments() { + setAttachmentStrategy( AttachmentStrategy::smart() ); +} + +void KMReaderWin::slotInlineAttachments() { + setAttachmentStrategy( AttachmentStrategy::inlined() ); +} + +void KMReaderWin::slotHideAttachments() { + setAttachmentStrategy( AttachmentStrategy::hidden() ); +} + +void KMReaderWin::slotCycleAttachmentStrategy() { + setAttachmentStrategy( attachmentStrategy()->next() ); + KRadioAction * action = actionForAttachmentStrategy( attachmentStrategy() ); + assert( action ); + action->setChecked( true ); +} + //----------------------------------------------------------------------------- KMReaderWin::~KMReaderWin() diff --git a/kmreaderwin.h b/kmreaderwin.h index e5c2b5528..7633b8d84 100644 --- a/kmreaderwin.h +++ b/kmreaderwin.h @@ -22,15 +22,19 @@ class QScrollBar; class QString; class QTabDialog; class QTextCodec; + class DwHeaders; class DwMediaType; + class KActionCollection; class KAction; class KActionMenu; +class KRadioAction; class KToggleAction; class KConfigBase; class KHTMLPart; class KURL; + class KMFolder; class KMMessage; class KMMessagePart; @@ -324,6 +328,19 @@ public slots: void contactStatusChanged( const QString &uid); protected slots: + void slotCycleHeaderStyles(); + void slotBriefHeaders(); + void slotFancyHeaders(); + void slotStandardHeaders(); + void slotLongHeaders(); + void slotAllHeaders(); + + void slotCycleAttachmentStrategy(); + void slotIconicAttachments(); + void slotSmartAttachments(); + void slotInlineAttachments(); + void slotHideAttachments(); + /** Some attachment operations. */ void slotAtmOpen(); void slotDoAtmOpen(); @@ -387,6 +404,11 @@ private: void saveSplitterSizes( KConfigBase & c ) const; QString createAtmFileLink() const; + KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *, + const KMail::HeaderStrategy * ); + KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * ); + + private: bool mHtmlMail, mHtmlOverride; int mAtmCurrent; @@ -429,6 +451,7 @@ private: partNode* mRootNode; QString mIdOfLastViewedMessage; QWidget *mMainWindow; + KActionCollection *mActionCollection; KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction, *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction, *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction;