KUniqueApplication Class Reference
Maintains only a single instance of a running application at a time. More...
#include <kuniqueapplication.h>
Inheritance diagram for KUniqueApplication:

Public Methods | |
KUniqueApplication (bool allowStyles=true, bool GUIenabled=true, bool configUnique=false) | |
virtual | ~KUniqueApplication () |
bool | process (const QCString &fun, const QByteArray &data, QCString &replyType, QByteArray &replyData) |
virtual int | newInstance () |
Static Public Methods | |
void | addCmdLineOptions () |
bool | start () |
Protected Methods | |
virtual void | virtual_hook (int id, void *data) |
Detailed Description
Maintains only a single instance of a running application at a time.If another instance is started, it will determine (via DCOP) whether it is the first instance or a second instance. If it is a second instance, it will forward on the information to the first instance and then quit.
- See also:
- KApplication DCOPObject
- Author:
- Preston Brown <pbrown@kde.org>
Definition at line 41 of file kuniqueapplication.h.
Constructor & Destructor Documentation
|
Constructor. Takes command line arguments from KCmdLineArgs
Definition at line 301 of file kuniqueapplication.cpp. References QTimer::singleShot(). |
|
Destructor.
Definition at line 314 of file kuniqueapplication.cpp. |
Member Function Documentation
|
Adds command line options specific for KUniqueApplication. Should be called before calling KUniqueApplication constructor and / or start(). Reimplemented from KApplication. Definition at line 86 of file kuniqueapplication.cpp. References KCmdLineArgs::addCmdLineOptions(). Referenced by start(). |
|
Forks and registers with dcop. The command line arguments are being sent via DCOP to newInstance() and will be received once the application enters the event loop. Typically this is used like: int main(int argc, char **argv) { KAboutData about("myappname", "myAppName", .....); KCmdLineArgs::init(argc, argv, &about); KCmdLineArgs::addCmdLineOptions( myCmdOptions ); KUniqueApplication::addCmdLineOptions(); if (!KUniqueApplication::start()) { fprintf(stderr, "myAppName is already running!\n"); exit(0); } KUniqueApplication a; a.exec(); }
Definition at line 92 of file kuniqueapplication.cpp. References addCmdLineOptions(), KStartupInfoData::addPid(), QCString::append(), KAboutData::appName(), DCOPClient::attach(), DCOPClient::call(), KStartupInfo::currentStartupIdEnv(), KApplication::dcopClient(), endl(), KStartupInfoId::id(), KStartupInfoId::initId(), DCOPClient::isApplicationRegistered(), QCString::isEmpty(), KCmdLineArgs::isSet(), KStartupInfoId::none(), KCmdLineArgs::parsedArgs(), DCOPClient::registerAs(), KStartupInfo::sendChangeX(), KStartupInfo::sendFinishX(), and QCString::setNum(). |
|
Dispatches any incoming DCOP message for a new instance. If it is not a request for a new instance, return false. Overloaded from DCOPObject to make sure that the application stays unique.
Reimplemented from DCOPObject. Definition at line 348 of file kuniqueapplication.cpp. References DCOPObject::process(). |
|
Creates a new "instance" of the application. Usually this will involve making some calls into the GUI portion of your application asking for a new window to be created, possibly with some data already loaded based on the arguments received. Command line arguments have been passed to KCmdLineArgs before this function is called and can be checked in the usual way. The default implementation ensures the mainwindow of the already running instance is shown and activated if necessary. You should prefer using it from your overridden method instead of doing it directly. Note that newInstance() is called also in the first started application process.
Definition at line 416 of file kuniqueapplication.cpp. References QApplication::mainWidget(), and KStartupInfo::setNewStartupId(). |
The documentation for this class was generated from the following files: