Bug 76323

Summary: no mainWindow restore on exec kopete
Product: [Applications] kopete Reporter: Kees van Wijk <cvanwijk>
Component: generalAssignee: Kopete Developers <kopete-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description Kees van Wijk 2004-02-28 00:22:59 UTC
Version:            (using KDE KDE 3.2.0)
Installed from:    Gentoo Packages

Many kde applications startup only one instance, Examples are juk or kmail. 
So the effect of starting a second juk or kmail by typing into a konsole kmail or juk is only (as far as I, the user, see) to raise the existing instance. Probably through something like 
"dcop kmail kmail-mainwindow restore" 
This is a very nice feature but it is missing from kopete. 

When I type "kopete" in my terminal while there is already one instance running that instance should by restored (raised).

Groeten,
Kees
Comment 1 Matt Rogers 2004-03-01 03:12:06 UTC
working on it! (or as lilachaze would say, "Mine!")
Comment 2 Matt Rogers 2004-03-01 05:43:58 UTC
CVS commit by mattr: 

Fix bug 76323. Restore the window when attempting to run a second instance
of kopete. [BACKPORT]

CCMAIL: 76323-done@bugs.kde.org


  M +22 -0     kopete.cpp   1.170.2.2
  M +2 -0      kopete.h   1.81.2.1


--- kdenetwork/kopete/kopete/kopete.cpp  #1.170.2.1:1.170.2.2
@@ -216,4 +216,26 @@ void  Kopete::slotAllPluginsLoaded()
 }
 
+int Kopete::newInstance()
+{
+        kdDebug(14000) << k_funcinfo << endl;
+
+        /** The following three lines work around the problem that
+         * Kopete has multiple main windows, so qapp->mainWidget()
+         * returns 0, which breaks the normal
+         * KUniqueApplication::newInstance() that raises the window
+         * when we run a new instance.
+         *
+         * 1. Set the main widget to the contact list window
+         * 2. Call KUniqueApplication::newInstance()
+         * 3. Set the main widget back to 0
+         */
+
+        setMainWidget( m_mainWindow );
+        int kUniqAppReturnCode = KUniqueApplication::newInstance();
+        setMainWidget( 0L );
+
+        return kUniqAppReturnCode;
+}
+
 void Kopete::quitKopete()
 {

--- kdenetwork/kopete/kopete/kopete.h  #1.81:1.81.2.1
@@ -49,4 +49,6 @@ public:
         bool isShuttingDown() const { return m_isShuttingDown; }
 
+        virtual int newInstance();
+
 public slots:
         /**