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

List:       kde-pim
Subject:    [Kde-pim] [PATCH] #68340 When Kontact is running starting Kontact
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2003-11-20 16:06:45
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi,

the attached patch solves http://bugs.kde.org/show_bug.cgi?id=68340
Ok to commit?

Ciao,
Tobias
-- 
Can a government that shoots at reporters be democratic?
Separate politics from religion and economy!

["kontact_kunique_front.patch" (text/plain)]

? kontact_kunique_front.patch
Index: main.cpp
===================================================================
RCS file: /home/kde/kdepim/kontact/src/main.cpp,v
retrieving revision 1.30
diff -p -u -b -r1.30 main.cpp
--- main.cpp	26 Oct 2003 17:46:35 -0000	1.30
+++ main.cpp	20 Nov 2003 16:03:32 -0000
@@ -22,9 +22,12 @@
 #include <dcopclient.h>
 #include <kaboutdata.h>
 #include <kcmdlineargs.h>
+#include <kdebug.h>
 #include <kiconloader.h>
 #include <klocale.h>
+#include <kstartupinfo.h>
 #include <kuniqueapplication.h>
+#include <kwin.h>
 
 #include <qlabel.h>
 #if (QT_VERSION-0 >= 0x030200)
@@ -40,20 +43,19 @@ static const char description[] =
 
 static const char version[] = "0.7.3 (Beta 1)";
 
-int main(int argc, char **argv)
-{
-  KAboutData about( "kontact", I18N_NOOP( "Kontact" ), version, description,
-                    KAboutData::License_GPL, I18N_NOOP("(C) 2001-2003 The Kontact \
                developers"), 0, "http://kontact.kde.org", "kde-pim@kde.org" );
-  about.addAuthor( "Daniel Molkentin", 0, "molkentin@kde.org" );
-  about.addAuthor( "Don Sanders", 0, "sanders@kde.org" );
-  about.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" );
-  about.addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
-  about.addAuthor( "Sven Lüppken", 0, "sven@kde.org" );
-  about.addAuthor( "Matthias Hoelzer-Kluepfel", I18N_NOOP("Original Author"), \
                "mhk@kde.org" );
-
-  KCmdLineArgs::init( argc, argv, &about );
-  KUniqueApplication app;
+class KontactApp : public KUniqueApplication {
+  public:
+    KontactApp() : mMainWindow( 0 ) {}
+    ~KontactApp() {}
+
+    int newInstance();
+
+  private:
+    Kontact::MainWindow *mMainWindow;
+};
 
+int KontactApp::newInstance()
+{
   // show splash
 #if (QT_VERSION-0 >= 0x030200)
   QPixmap splashPixmap( UserIcon( "splash" ) );
@@ -65,22 +67,52 @@ int main(int argc, char **argv)
   splash->show();
 #endif
 
-  // see if we are starting with session management
-  if ( app.isRestored() ) {
-      if (Kontact::MainWindow::canBeRestored(1))
-	  //only restore a single main window! (Don);
-	  (new Kontact::MainWindow)->restore(1);
+  if ( isRestored() ) {
+    // There can only be one main window
+    if ( KMainWindow::canBeRestored( 1 ) ) {
+      mMainWindow = new Kontact::MainWindow;
+      mMainWindow->show();
+      mMainWindow->restore( 1 );
+    }
   } else {
-    // no session.. just start up normally
-    Kontact::MainWindow *mw = new Kontact::MainWindow;
-     mw->show();
+    if ( mMainWindow ) {
+      mMainWindow->show();
+      KWin::forceActiveWindow( mMainWindow->winId() );
+      KStartupInfo::appStarted();
+    } else {
+      mMainWindow = new Kontact::MainWindow;
+      mMainWindow->show();
+    }
   }
 
-  // delete splash
   delete splash;
 
+  return 0;
+}
+
+int main(int argc, char **argv)
+{
+  KAboutData about( "kontact", I18N_NOOP( "Kontact" ), version, description,
+                    KAboutData::License_GPL, I18N_NOOP("(C) 2001-2003 The Kontact \
developers"), 0, "http://kontact.kde.org", "kde-pim@kde.org" ); +  about.addAuthor( \
"Daniel Molkentin", 0, "molkentin@kde.org" ); +  about.addAuthor( "Don Sanders", 0, \
"sanders@kde.org" ); +  about.addAuthor( "Cornelius Schumacher", 0, \
"schumacher@kde.org" ); +  about.addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
+  about.addAuthor( "Sven Lüppken", 0, "sven@kde.org" );
+  about.addAuthor( "Matthias Hoelzer-Kluepfel", I18N_NOOP("Original Author"), \
"mhk@kde.org" ); +
+  KCmdLineArgs::init( argc, argv, &about );
+
+  if ( !KontactApp::start() ) {
+    kdError() << "Kontact is already running!" << endl;
+    return 0;
+  }
+
+  KontactApp app;
+
   bool ret = app.exec();
-  while (KMainWindow::memberList->first())
+  while ( KMainWindow::memberList->first() )
       delete KMainWindow::memberList->first();
+
   return ret;
 }


["signature.asc" (application/pgp-signature)]

_______________________________________________
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