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

List:       kde-pim
Subject:    Re: I'm Terribly Sorry - Was: Re: [Kde-pim] [PATCH] Version 2 of my
From:       Nathan Toone <nathan () toonetown ! com>
Date:       2004-05-29 4:56:45
Message-ID: 200405282256.47513.nathan () toonetown ! com
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> However, I really want to help out.  I am going to try and fix what I've
> messed up.  Don't feel obligated to commit it, however.

OK - here it is.  This should fix it, according to what Ingo mentioned.

Each plugin's queryClose() method is called IF it's not a standalone 
application.  If ANY queryClose() returns with false, mainwindow doesn't 
close.  However, ALL plugins are scanned regardless of the return value (I 
figured it's not fair for one plugin to prevent others from running their 
queryClose method, just because it's listed first...)

I added the queryClose method with a default return value of true to plugin.h.  
As was mentioned before, I don't know what problems this might cause 
third-party plugins.  They should (in theory) just recompile and be ready to 
go.  (I still don't know what BIC and BC are...so I can't address that 
concern)

Again, I'm sorry for the problems that I've caused.  I hope that this helps 
make things better.  :)

- -Nathan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAuBgO+lPSZRR0T30RAvgyAJ9m3IbTP5comT46PnGAAUQH5id/9QCbBtEs
Pz0MlMsSI9EmAOPzPm0Ut4M=
=p1//
-----END PGP SIGNATURE-----

["iconbehaviour.v5.patch" (text/x-diff)]

Index: kmail/kmailIface.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmailIface.h,v
retrieving revision 1.30
diff -u -r1.30 kmailIface.h
--- kmail/kmailIface.h	28 May 2004 22:49:38 -0000	1.30
+++ kmail/kmailIface.h	29 May 2004 04:38:26 -0000
@@ -84,6 +84,7 @@
   virtual QStringList folderList() const =0;
   virtual DCOPRef getFolder( const QString& vpath ) =0;
   virtual void selectFolder( QString folder ) =0;
+  virtual bool canQueryClose() =0;
 
 k_dcop_signals:
   void unreadCountChanged();
Index: kontact/interfaces/plugin.h
===================================================================
RCS file: /home/kde/kdepim/kontact/interfaces/plugin.h,v
retrieving revision 1.37
diff -u -r1.37 plugin.h
--- kontact/interfaces/plugin.h	4 Jan 2004 23:57:11 -0000	1.37
+++ kontact/interfaces/plugin.h	29 May 2004 04:38:26 -0000
@@ -179,6 +179,13 @@
     virtual bool showInSideBar() const { return true; }
 
     /**
+      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.
 
       The clients name is taken from the name argument in the constructor.
Index: kontact/plugins/kmail/kmail_plugin.cpp
===================================================================
RCS file: /home/kde/kdepim/kontact/plugins/kmail/kmail_plugin.cpp,v
retrieving revision 1.34
diff -u -r1.34 kmail_plugin.cpp
--- kontact/plugins/kmail/kmail_plugin.cpp	6 Apr 2004 10:35:58 -0000	1.34
+++ kontact/plugins/kmail/kmail_plugin.cpp	29 May 2004 04:38:26 -0000
@@ -164,4 +164,10 @@
     return 0;
 }
 
+bool KMailPlugin::queryClose() const {
+  KMailIface_stub stub( kapp->dcopClient(), "kmail", "KMailIface" );
+  bool canClose=stub.canQueryClose();
+  return canClose;
+}
+
 #include "kmail_plugin.moc"
Index: kontact/plugins/kmail/kmail_plugin.h
===================================================================
RCS file: /home/kde/kdepim/kontact/plugins/kmail/kmail_plugin.h,v
retrieving revision 1.20
diff -u -r1.20 kmail_plugin.h
--- kontact/plugins/kmail/kmail_plugin.h	30 Jan 2004 19:53:32 -0000	1.20
+++ kontact/plugins/kmail/kmail_plugin.h	29 May 2004 04:38:26 -0000
@@ -57,7 +57,7 @@
     virtual QString tipFile() const;
 
     virtual QStringList invisibleToolbarActions() const;
-
+    virtual bool queryClose() const;
   protected:
     virtual KParts::Part* createPart();
     void openComposer( const KURL& );
Index: kontact/src/mainwindow.cpp
===================================================================
RCS file: /home/kde/kdepim/kontact/src/mainwindow.cpp,v
retrieving revision 1.109
diff -u -r1.109 mainwindow.cpp
--- kontact/src/mainwindow.cpp	28 May 2004 22:48:08 -0000	1.109
+++ kontact/src/mainwindow.cpp	29 May 2004 04:38:26 -0000
@@ -66,7 +66,7 @@
 
 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(
       QString::fromLatin1( "Kontact/Plugin" ),
@@ -556,6 +556,7 @@
 
 void MainWindow::slotQuit()
 {
+  mReallyClose=true;
   close();
 }
 
@@ -710,5 +711,21 @@
   applyMainWindowSettings( KGlobal::config(), "MainWindow" );
 }
 
+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
Index: kontact/src/mainwindow.h
===================================================================
RCS file: /home/kde/kdepim/kontact/src/mainwindow.h,v
retrieving revision 1.47
diff -u -r1.47 mainwindow.h
--- kontact/src/mainwindow.h	28 May 2004 22:48:08 -0000	1.47
+++ kontact/src/mainwindow.h	29 May 2004 04:38:26 -0000
@@ -112,6 +112,7 @@
     void setupActions();
     void initHeaderWidget( QVBox *vBox );
     void showTip( bool );
+    virtual bool queryClose ();
 
   private slots:
     void pluginsChanged();
@@ -145,6 +146,7 @@
     //QStringList mActivePlugins;
 
     AboutDialog *mAboutDialog;
+    bool mReallyClose;
 };
 
 }


_______________________________________________
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