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

List:       kde-core-devel
Subject:    KUniqueApplication available
From:       pbrown () redhat ! com
Date:       1999-10-19 18:57:27
[Download RAW message or body]

Does everyone know how when you use x11amp/xmms, the second time you try
to fire one up, it simply passes the command line arguments you give to
the running instance and returns?  How about how kdehelp knows how to open
a new window when you try and run it again, instead of starting a new
copy?  Well through the magic of DCOP I have made available a very small
general solution for doing this with a subclass of KApplication, which I
have called KUniqueApplication.

To use this, you only have to change from using KApplication to
KUniqueAppilcation in your main() function, and override ONE virtual
function, newInstance(QValueList<QCString> params).  The argument is a
bundled up list of parameters that were passed when the second instance
was requested, if any.  It will have at least the application name, i.e.
argv[0].  Be aware that this list has already been processed through the
QApplication parameter munging.

In this method, either pass on arguments to your GUI about what should
happen, like xmms does, or like kdehelp, open a new window and then pass
it an (optional) URL or filename that you get from the params list.

That's all you should have to do.  Try it.  Suggestions and discussion are
welcome.

---
  Preston Brown                                    Systems Engineer
  pbrown@redhat.com                                Red Hat, Inc. 

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

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