From kde-core-devel Tue Oct 19 18:57:27 1999 From: pbrown () redhat ! com Date: Tue, 19 Oct 1999 18:57:27 +0000 To: kde-core-devel Subject: KUniqueApplication available X-MARC-Message: https://marc.info/?l=kde-core-devel&m=94035935417451 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 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.