[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    online status fixes
From:       "Aaron J. Seigo" <aseigo () kde ! org>
Date:       2006-02-24 5:10:25
Message-ID: 200602232210.27229.aseigo () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


hi all...

switching the online/offline status doesn't work very well if you have 
multiple main windows open, and the text in the menu is misleading since you 
don't actually "go" online or offline you just set kmail to work in an online 
or offline mode.

eventually it would be nice to have this as a kontact wide setting, but that's 
probably something more for kde4. until then, the attached patch fixes these 
issues (i've been using this for quite some time and as someone who uses this 
feature regularly i appreciate the improvement)

note that the string change isn't a translation problem with Work Online and 
Work Offline are used in the confirmation dialog buttons (consistency is 
another bonus with this patch)

you can ignore (or not, i suppose ;) the other little change in here to remove 
the frame from around folder list which i personally find gratuitous and 
distracting from the folder list and message window. =)

i'd like to commit for 3.5.2 the online/offline status changes ... 

-- 
Aaron J. Seigo
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

Full time KDE developer sponsored by Trolltech (http://www.trolltech.com)

["kmail_onlinestatus.diff" (text/x-diff)]

Index: kmkernel.cpp
===================================================================
--- kmkernel.cpp	(revision 512913)
+++ kmkernel.cpp	(working copy)
@@ -10,6 +10,8 @@
 #include <weaverlogger.h>
 
 #include "globalsettings.h"
+#include "broadcaststatus.h"
+using KPIM::BroadcastStatus;
 #include "kmstartup.h"
 #include "index.h"
 #include "kmmainwin.h"
@@ -1142,7 +1144,8 @@
     return;
 
   GlobalSettings::setNetworkState( GlobalSettings::EnumNetworkState::Offline );
-
+  BroadcastStatus::instance()->setStatusMsg( i18n("KMail is set to be offline; all \
network jobs are suspended")); +  emit onlineStatusChanged( \
(GlobalSettings::EnumNetworkState::type)GlobalSettings::networkState() );  }
 
 void KMKernel::resumeNetworkJobs()
@@ -1151,6 +1154,8 @@
     return;
 
   GlobalSettings::setNetworkState( GlobalSettings::EnumNetworkState::Online );
+  BroadcastStatus::instance()->setStatusMsg( i18n("KMail is set to be online; all \
network jobs resumed")); +  emit onlineStatusChanged( \
(GlobalSettings::EnumNetworkState::type)GlobalSettings::networkState() );  
   if ( kmkernel->msgSender()->sendImmediate() ) {
     kmkernel->msgSender()->sendQueued();
Index: kmmainwidget.cpp
===================================================================
--- kmmainwidget.cpp	(revision 512913)
+++ kmmainwidget.cpp	(working copy)
@@ -202,6 +202,9 @@
   connect(kmkernel->searchFolderMgr(), SIGNAL(folderRemoved(KMFolder*)),
           this, SLOT(slotFolderRemoved(KMFolder*)));
 
+  connect( kmkernel, SIGNAL( onlineStatusChanged( \
GlobalSettings::EnumNetworkState::type ) ), +           this, SLOT( \
slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type ) ) ); +
   toggleSystemTray();
 
   // must be the last line of the constructor:
@@ -584,6 +587,7 @@
 
   // create list of folders
   mFolderTree = new KMFolderTree(this, folderParent, "folderTree");
+  mFolderTree->setFrameStyle( QFrame::NoFrame );
 
   connect(mFolderTree, SIGNAL(folderSelected(KMFolder*)),
 	  this, SLOT(folderSelected(KMFolder*)));
@@ -1646,18 +1650,25 @@
 
 void KMMainWidget::slotOnlineStatus()
 {
+  // KMKernel will emit a signal when we toggle the network state that is caught by
+  // KMMainWidget::slotUpdateOnlineStatus to update our GUI
   if ( GlobalSettings::self()->networkState() == \
GlobalSettings::EnumNetworkState::Online ) {  // if online; then toggle and set it \
                offline.
-    actionCollection()->action( "online_status" )->setText( i18n("Go Online") );
     kmkernel->stopNetworkJobs();
-    BroadcastStatus::instance()->setStatusMsg( i18n("KMail is set to be offline; all \
network jobs are suspended"));  } else {
-    actionCollection()->action( "online_status" )->setText( i18n("Go Offline") );
     kmkernel->resumeNetworkJobs();
-    BroadcastStatus::instance()->setStatusMsg( i18n("KMail is set to be online; all \
network jobs resumed"));  }
 }
 
+void KMMainWidget::slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type )
+{
+  if ( GlobalSettings::self()->networkState() == \
GlobalSettings::EnumNetworkState::Online ) +    actionCollection()->action( \
"online_status" )->setText( i18n("Work Offline") ); +  else
+    actionCollection()->action( "online_status" )->setText( i18n("Work Online") );
+}
+
+
 //-----------------------------------------------------------------------------
 void KMMainWidget::slotSendQueued()
 {
@@ -3004,10 +3015,7 @@
     actionCollection()->action( "go_prev_unread_message" )->setEnabled( \
                enable_goto_unread );
     actionCollection()->action( "send_queued" )->setEnabled( \
                kmkernel->outboxFolder()->count() > 0 );
     actionCollection()->action( "send_queued_via" )->setEnabled( \
                kmkernel->outboxFolder()->count() > 0 );
-    if ( GlobalSettings::self()->networkState() == \
                GlobalSettings::EnumNetworkState::Online )
-      actionCollection()->action( "online_status" )->setText( i18n("Go Offline") );
-    else
-      actionCollection()->action( "online_status" )->setText( i18n("Go Online") );
+    slotUpdateOnlineStatus( static_cast<GlobalSettingsBase::EnumNetworkState::type>( \
GlobalSettings::self()->networkState() ) );  if (action( "edit_undo" ))
       action( "edit_undo" )->setEnabled( mHeaders->canUndo() );
 
Index: kmkernel.h
===================================================================
--- kmkernel.h	(revision 512913)
+++ kmkernel.h	(working copy)
@@ -16,6 +16,7 @@
 
 #include "kmailIface.h"
 #include "kmmsgbase.h"
+#include "globalsettings.h"
 
 #define kmkernel KMKernel::self()
 #define kmconfig KMKernel::config()
@@ -400,6 +401,7 @@
 signals:
   void configChanged();
   void folderRemoved( KMFolder* aFolder );
+  void onlineStatusChanged( GlobalSettings::EnumNetworkState::type );
 
 private:
   void openReader( bool onlyCheck );
Index: kmmainwidget.h
===================================================================
--- kmmainwidget.h	(revision 512913)
+++ kmmainwidget.h	(working copy)
@@ -315,6 +315,7 @@
   void slotSendQueued();
   void slotSendQueuedVia( int item );
   void slotOnlineStatus();
+  void slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type );
   void slotMsgPopup(KMMessage &msg, const KURL &aUrl, const QPoint&);
   void slotMarkAll();
   void slotMemInfo();


[Attachment #8 (application/pgp-signature)]

_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic