Monolithic build features now zero setup configuration: click and run
[quassel.git] / src / qtui / monoapplication.cpp
index 7b05c73..a63ec55 100644 (file)
 #include "qtui.h"
 
 MonolithicApplication::MonolithicApplication(int &argc, char **argv)
-  : QtUiApplication(argc, argv)
+  : QtUiApplication(argc, argv),
+    _internalInitDone(false)
 {
   _internal = new CoreApplicationInternal(); // needed for parser options
   setRunMode(Monolithic);
 }
 
 bool MonolithicApplication::init() {
-  connect(Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *)), this, SLOT(newClientSyncer(ClientSyncer *)));
-  if(QtUiApplication::init()) {
-    return true;
+  if(!Quassel::init()) // parse args
+    return false;
+
+  if(isOptionSet("port")) {
+    _internal->init();
+    _internalInitDone = true;
   }
-  return false;
+
+  connect(Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *)), this, SLOT(newClientSyncer(ClientSyncer *)));
+  return QtUiApplication::init();
 }
 
 MonolithicApplication::~MonolithicApplication() {
@@ -51,7 +57,10 @@ void MonolithicApplication::newClientSyncer(ClientSyncer *syncer) {
 }
 
 void MonolithicApplication::startInternalCore() {
-  _internal->init();
+  if(!_internalInitDone) {
+    _internal->init();
+    _internalInitDone = true;
+  }
   Core *core = Core::instance();
   ClientSyncer *syncer = static_cast<ClientSyncer *>(sender());
   connect(syncer, SIGNAL(connectToInternalCore(SignalProxy *)), core, SLOT(setupInternalClientSession(SignalProxy *)));