-void Quassel::registerMetaTypes() {
- // Complex types
- qRegisterMetaType<QVariant>("QVariant");
- qRegisterMetaType<Message>("Message");
- qRegisterMetaType<BufferInfo>("BufferInfo");
- qRegisterMetaType<NetworkInfo>("NetworkInfo");
- qRegisterMetaType<Network::Server>("Network::Server");
- qRegisterMetaType<Identity>("Identity");
- qRegisterMetaType<Network::ConnectionState>("Network::ConnectionState");
-
- qRegisterMetaTypeStreamOperators<QVariant>("QVariant");
- qRegisterMetaTypeStreamOperators<Message>("Message");
- qRegisterMetaTypeStreamOperators<BufferInfo>("BufferInfo");
- qRegisterMetaTypeStreamOperators<NetworkInfo>("NetworkInfo");
- qRegisterMetaTypeStreamOperators<Network::Server>("Network::Server");
- qRegisterMetaTypeStreamOperators<Identity>("Identity");
- qRegisterMetaTypeStreamOperators<qint8>("Network::ConnectionState");
-
- qRegisterMetaType<IdentityId>("IdentityId");
- qRegisterMetaType<BufferId>("BufferId");
- qRegisterMetaType<NetworkId>("NetworkId");
- qRegisterMetaType<UserId>("UserId");
- qRegisterMetaType<AccountId>("AccountId");
- qRegisterMetaType<MsgId>("MsgId");
-
- qRegisterMetaTypeStreamOperators<IdentityId>("IdentityId");
- qRegisterMetaTypeStreamOperators<BufferId>("BufferId");
- qRegisterMetaTypeStreamOperators<NetworkId>("NetworkId");
- qRegisterMetaTypeStreamOperators<UserId>("UserId");
- qRegisterMetaTypeStreamOperators<AccountId>("AccountId");
- qRegisterMetaTypeStreamOperators<MsgId>("MsgId");
+void Quassel::registerMetaTypes()
+{
+ // Complex types
+ qRegisterMetaType<Message>("Message");
+ qRegisterMetaType<BufferInfo>("BufferInfo");
+ qRegisterMetaType<NetworkInfo>("NetworkInfo");
+ qRegisterMetaType<Network::Server>("Network::Server");
+ qRegisterMetaType<Identity>("Identity");
+
+ qRegisterMetaTypeStreamOperators<Message>("Message");
+ qRegisterMetaTypeStreamOperators<BufferInfo>("BufferInfo");
+ qRegisterMetaTypeStreamOperators<NetworkInfo>("NetworkInfo");
+ qRegisterMetaTypeStreamOperators<Network::Server>("Network::Server");
+ qRegisterMetaTypeStreamOperators<Identity>("Identity");
+
+ qRegisterMetaType<IdentityId>("IdentityId");
+ qRegisterMetaType<BufferId>("BufferId");
+ qRegisterMetaType<NetworkId>("NetworkId");
+ qRegisterMetaType<UserId>("UserId");
+ qRegisterMetaType<AccountId>("AccountId");
+ qRegisterMetaType<MsgId>("MsgId");
+
+ qRegisterMetaType<QHostAddress>("QHostAddress");
+ qRegisterMetaTypeStreamOperators<QHostAddress>("QHostAddress");
+ qRegisterMetaType<QUuid>("QUuid");
+ qRegisterMetaTypeStreamOperators<QUuid>("QUuid");
+
+ qRegisterMetaTypeStreamOperators<IdentityId>("IdentityId");
+ qRegisterMetaTypeStreamOperators<BufferId>("BufferId");
+ qRegisterMetaTypeStreamOperators<NetworkId>("NetworkId");
+ qRegisterMetaTypeStreamOperators<UserId>("UserId");
+ qRegisterMetaTypeStreamOperators<AccountId>("AccountId");
+ qRegisterMetaTypeStreamOperators<MsgId>("MsgId");
+
+ qRegisterMetaType<Protocol::SessionState>("Protocol::SessionState");
+ qRegisterMetaType<PeerPtr>("PeerPtr");
+ qRegisterMetaTypeStreamOperators<PeerPtr>("PeerPtr");
+
+ // Versions of Qt prior to 4.7 didn't define QVariant as a meta type
+ if (!QMetaType::type("QVariant")) {
+ qRegisterMetaType<QVariant>("QVariant");
+ qRegisterMetaTypeStreamOperators<QVariant>("QVariant");
+ }
+}
+
+
+void Quassel::setupEnvironment()
+{
+ // On modern Linux systems, XDG_DATA_DIRS contains a list of directories containing application data. This
+ // is, for example, used by Qt for finding icons and other things. In case Quassel is installed in a non-standard
+ // prefix (or run from the build directory), it makes sense to add this to XDG_DATA_DIRS so we don't have to
+ // hack extra search paths into various places.
+#ifdef Q_OS_UNIX
+ QString xdgDataVar = QFile::decodeName(qgetenv("XDG_DATA_DIRS"));
+ if (xdgDataVar.isEmpty())
+ xdgDataVar = QLatin1String("/usr/local/share:/usr/share"); // sane defaults
+
+ QStringList xdgDirs = xdgDataVar.split(QLatin1Char(':'), QString::SkipEmptyParts);
+
+ // Add our install prefix (if we're not in a bindir, this just adds the current workdir)
+ QString appDir = QCoreApplication::applicationDirPath();
+ int binpos = appDir.lastIndexOf("/bin");
+ if (binpos >= 0) {
+ appDir.replace(binpos, 4, "/share");
+ xdgDirs.append(appDir);
+ // Also append apps/quassel, this is only for QIconLoader to find icons there
+ xdgDirs.append(appDir + "/apps/quassel");
+ } else
+ xdgDirs.append(appDir); // build directory is always the last fallback
+
+ xdgDirs.removeDuplicates();
+
+ qputenv("XDG_DATA_DIRS", QFile::encodeName(xdgDirs.join(":")));
+#endif