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

List:       kde-pim
Subject:    [Kde-pim] kdepim
From:       David Faure <faure () kde ! org>
Date:       2004-07-01 10:44:22
Message-ID: 20040701104422.9C04090DA () office ! kde ! org
[Download RAW message or body]

CVS commit by faure: 

Finally applying last version of the patch by Nathan Toone <nathan toonetown com>
to improve handling of the kmail-systray in kontact (so that closing kontact leaves
it running, as per the kde style guide).

This commit is BINARY INCOMPATIBLE for kontact plugins. This means you must recompile
all of kdepim/kontact, but also kdeaddons/kontact.

While I was at it I added a virtual_hook to Plugin so that we can do this is
an uglier, but BC, manner next time.
CCMAIL: kde-pim@kde.org


  M +1 -0      kmail/kmailIface.h   1.35
  M +6 -2      kmail/kmsystemtray.cpp   1.51
  M +9 -0      kontact/interfaces/plugin.h   1.39
  M +6 -0      kontact/plugins/kmail/kmail_plugin.cpp   1.35
  M +1 -1      kontact/plugins/kmail/kmail_plugin.h   1.21
  M +18 -1     kontact/src/mainwindow.cpp   1.112
  M +2 -0      kontact/src/mainwindow.h   1.48


--- kdepim/kontact/interfaces/plugin.h  #1.38:1.39
@@ -180,4 +180,11 @@ class Plugin : public QObject, virtual p
 
     /**
+      Reimplement this method if you want to add checks before closing down the main kontact
+      window.  Return true if it's OK to close the window.  If any loaded plugin returns false 
+      from this method, then the main kontact window will not close.
+    */
+    virtual bool queryClose() const { return true; }
+
+    /**
       Retrieve the current DCOP Client for the plugin.
 
@@ -232,4 +239,6 @@ class Plugin : public QObject, virtual p
     KParts::Part *loadPart();
 
+    virtual void virtual_hook(  int id, void* data );
+
   private slots:
     void partDestroyed();

--- kdepim/kontact/plugins/kmail/kmail_plugin.cpp  #1.34:1.35
@@ -165,3 +165,9 @@ int KMailUniqueAppHandler::newInstance()
 }
 
+bool KMailPlugin::queryClose() const {
+  KMailIface_stub stub( kapp->dcopClient(), "kmail", "KMailIface" );
+  bool canClose=stub.canQueryClose();
+  return canClose;
+}
+
 #include "kmail_plugin.moc"

--- kdepim/kontact/plugins/kmail/kmail_plugin.h  #1.20:1.21
@@ -58,5 +58,5 @@ class KMailPlugin : public Kontact::Plug
 
     virtual QStringList invisibleToolbarActions() const;
-
+    virtual bool queryClose() const;
   protected:
     virtual KParts::Part* createPart();

--- kdepim/kontact/src/mainwindow.cpp  #1.111:1.112
@@ -69,5 +69,5 @@ using namespace Kontact;
 MainWindow::MainWindow()
   : Kontact::Core(), mTopWidget( 0 ), mHeaderText( 0 ), mHeaderPixmap( 0 ), mSplitter( 0 ),
-    mCurrentPlugin( 0 ), mLastInfoExtension( 0 ), mAboutDialog( 0 )
+    mCurrentPlugin( 0 ), mLastInfoExtension( 0 ), mAboutDialog( 0 ), mReallyClose( false )
 {
   KTrader::OfferList offers = KTrader::self()->query(
@@ -572,4 +572,5 @@ void MainWindow::showTip(bool force)
 void MainWindow::slotQuit()
 {
+  mReallyClose=true;
   close();
 }
@@ -726,4 +727,20 @@ void MainWindow::slotNewToolbarConfig()
 }
 
+bool MainWindow::queryClose()
+{
+  if (mReallyClose)
+    return true;
+  bool localClose=true;
+  QValueList<Plugin*>::ConstIterator end = mPlugins.end();
+  QValueList<Plugin*>::ConstIterator it = mPlugins.begin();
+  for ( ; it != end; ++it ) {
+    Plugin *plugin = *it;
+    if (!plugin->isRunningStandalone())
+      if ( !plugin->queryClose())
+        localClose=false;
+  }
+  return localClose;
+}
+
 #include "mainwindow.moc"
 // vim: sw=2 sts=2 et

--- kdepim/kontact/src/mainwindow.h  #1.47:1.48
@@ -113,4 +113,5 @@ class MainWindow : public Kontact::Core,
     void initHeaderWidget( QVBox *vBox );
     void showTip( bool );
+    virtual bool queryClose ();
 
   private slots:
@@ -146,4 +147,5 @@ class MainWindow : public Kontact::Core,
 
     AboutDialog *mAboutDialog;
+    bool mReallyClose;
 };
 

--- kdepim/kmail/kmailIface.h  #1.34:1.35
@@ -102,4 +102,5 @@ k_dcop:
   virtual DCOPRef getFolder( const QString& vpath ) =0;
   virtual void selectFolder( QString folder ) =0;
+  virtual bool canQueryClose() =0;
 
   virtual int timeOfLastMessageCountChange() const =0;

--- kdepim/kmail/kmsystemtray.cpp  #1.50:1.51
@@ -27,4 +27,5 @@
 
 #include <kapplication.h>
+#include <kmainwindow.h>
 #include <kglobalsettings.h>
 #include <kiconloader.h>
@@ -123,5 +124,8 @@ void KMSystemTray::buildPopupMenu()
     action->plug( mPopupMenu );
   mPopupMenu->insertSeparator();
-  if ( ( action = mainWidget->action("file_quit") ) )
+  
+  KMainWindow *mainWin = ::qt_cast<KMainWindow*>(getKMMainWidget()->topLevelWidget());
+  if(mainWin)
+    if ( ( action=mainWin->actionCollection()->action("file_quit") ) )
     action->plug( mPopupMenu );
 }


_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

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