X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclientsettings.cpp;h=dfed519f752f0b8d10d174f3441f3d973397da78;hp=664ee4c3c13826234061f032b6a0ab030b032058;hb=84381d6b74a31c8b1b6468fa490621f8a7a32c23;hpb=3bb1d366e9c13f087458bd4e219bac8760b7e38b diff --git a/src/client/clientsettings.cpp b/src/client/clientsettings.cpp index 664ee4c3..dfed519f 100644 --- a/src/client/clientsettings.cpp +++ b/src/client/clientsettings.cpp @@ -47,7 +47,7 @@ CoreAccountSettings::CoreAccountSettings(const QString &subgroup) } void CoreAccountSettings::notify(const QString &key, QObject *receiver, const char *slot) { - ClientSettings::notify(QString("%1/%2/%3").arg(Client::currentCoreAccount().toInt()).arg(_subgroup).arg(key), receiver, slot); + ClientSettings::notify(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), receiver, slot); } QList CoreAccountSettings::knownAccounts() { @@ -76,6 +76,22 @@ void CoreAccountSettings::setAutoConnectAccount(AccountId account) { setLocalValue("AutoConnectAccount", account.toInt()); } +bool CoreAccountSettings::autoConnectOnStartup() { + return localValue("AutoConnectOnStartup", false).toBool(); +} + +void CoreAccountSettings::setAutoConnectOnStartup(bool b) { + setLocalValue("AutoConnectOnStartup", b); +} + +bool CoreAccountSettings::autoConnectToFixedAccount() { + return localValue("AutoConnectToFixedAccount", false).toBool(); +} + +void CoreAccountSettings::setAutoConnectToFixedAccount(bool b) { + setLocalValue("AutoConnectToFixedAccount", b); +} + void CoreAccountSettings::storeAccountData(AccountId id, const QVariantMap &data) { QString base = QString::number(id.toInt()); foreach(const QString &key, data.keys()) { @@ -109,6 +125,7 @@ QVariantMap CoreAccountSettings::retrieveAccountData(AccountId id) { map["ProxyUser"] = oldmap.value("proxyUser"); map["ProxyPassword"] = oldmap.value("proxyPassword"); map["ProxyType"] = oldmap.value("proxyType"); + map["Internal"] = oldmap.value("InternalAccount"); map["AccountId"] = id.toInt(); map["Uuid"] = QUuid::createUuid().toString(); @@ -120,13 +137,13 @@ QVariantMap CoreAccountSettings::retrieveAccountData(AccountId id) { void CoreAccountSettings::setAccountValue(const QString &key, const QVariant &value) { if(!Client::currentCoreAccount().isValid()) return; - setLocalValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().toInt()).arg(_subgroup).arg(key), value); + setLocalValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), value); } QVariant CoreAccountSettings::accountValue(const QString &key, const QVariant &def) { if(!Client::currentCoreAccount().isValid()) return QVariant(); - return localValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().toInt()).arg(_subgroup).arg(key), def); + return localValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), def); } void CoreAccountSettings::setJumpKeyMap(const QHash &keyMap) { @@ -150,78 +167,104 @@ QHash CoreAccountSettings::jumpKeyMap() { return keyMap; } +void CoreAccountSettings::setBufferViewOverlay(const QSet &viewIds) { + QVariantList variants; + foreach(int viewId, viewIds) { + variants << qVariantFromValue(viewId); + } + setAccountValue("BufferViewOverlay", variants); +} + +QSet CoreAccountSettings::bufferViewOverlay() { + QSet viewIds; + QVariantList variants = accountValue("BufferViewOverlay").toList(); + QVariantList::const_iterator iter = variants.constBegin(); + for(QVariantList::const_iterator iter = variants.constBegin(); iter != variants.constEnd(); iter++) { + viewIds << iter->toInt(); + } + return viewIds; +} + void CoreAccountSettings::removeAccount(AccountId id) { removeLocalKey(QString("%1").arg(id.toInt())); } +void CoreAccountSettings::clearAccounts() { + foreach(const QString &key, localChildGroups()) + removeLocalKey(key); +} /***********************************************************************************************/ -// NotificationSettings: +// CoreConnectionSettings: -NotificationSettings::NotificationSettings() : ClientSettings("Notification") { -} +CoreConnectionSettings::CoreConnectionSettings() : ClientSettings("CoreConnection") {} -void NotificationSettings::setHighlightList(const QVariantList &highlightList) { - setLocalValue("Highlights/CustomList", highlightList); +void CoreConnectionSettings::setNetworkDetectionMode(NetworkDetectionMode mode) { + setLocalValue("NetworkDetectionMode", mode); } -QVariantList NotificationSettings::highlightList() { - return localValue("Highlights/CustomList").toList(); +CoreConnectionSettings::NetworkDetectionMode CoreConnectionSettings::networkDetectionMode() { +#ifdef HAVE_KDE + NetworkDetectionMode def = UseSolid; +#else + NetworkDetectionMode def = UsePingTimeout; +#endif + return (NetworkDetectionMode)localValue("NetworkDetectionMode", def).toInt(); } -void NotificationSettings::setHighlightNick(NotificationSettings::HighlightNickType highlightNickType) { - setLocalValue("Highlights/HighlightNick", highlightNickType); +void CoreConnectionSettings::setAutoReconnect(bool autoReconnect) { + setLocalValue("AutoReconnect", autoReconnect); } -NotificationSettings::HighlightNickType NotificationSettings::highlightNick() { - return (NotificationSettings::HighlightNickType) localValue("Highlights/HighlightNick", CurrentNick).toInt(); +bool CoreConnectionSettings::autoReconnect() { + return localValue("AutoReconnect", true).toBool(); } -void NotificationSettings::setNicksCaseSensitive(bool cs) { - setLocalValue("Highlights/NicksCaseSensitive", cs); +void CoreConnectionSettings::setPingTimeoutInterval(int interval) { + setLocalValue("PingTimeoutInterval", interval); } -bool NotificationSettings::nicksCaseSensitive() { - return localValue("Highlights/NicksCaseSensitive", false).toBool(); +int CoreConnectionSettings::pingTimeoutInterval() { + return localValue("PingTimeoutInterval", 60).toInt(); } +void CoreConnectionSettings::setReconnectInterval(int interval) { + setLocalValue("ReconnectInterval", interval); +} -// ======================================== -// KnownHostsSettings -// ======================================== -KnownHostsSettings::KnownHostsSettings() - : ClientSettings("KnownHosts") -{ +int CoreConnectionSettings::reconnectInterval() { + return localValue("ReconnectInterval", 60).toInt(); } -QByteArray KnownHostsSettings::knownDigest(const QHostAddress &address) { - return localValue(address.toString(), QByteArray()).toByteArray(); +/***********************************************************************************************/ +// NotificationSettings: + +NotificationSettings::NotificationSettings() : ClientSettings("Notification") { } -void KnownHostsSettings::saveKnownHost(const QHostAddress &address, const QByteArray &certDigest) { - setLocalValue(address.toString(), certDigest); +void NotificationSettings::setHighlightList(const QVariantList &highlightList) { + setLocalValue("Highlights/CustomList", highlightList); } -bool KnownHostsSettings::isKnownHost(const QHostAddress &address, const QByteArray &certDigest) { - return certDigest == localValue(address.toString(), QByteArray()).toByteArray(); +QVariantList NotificationSettings::highlightList() { + return localValue("Highlights/CustomList").toList(); } -#ifdef HAVE_SSL -QByteArray KnownHostsSettings::knownDigest(const QSslSocket *socket) { - return knownDigest(socket->peerAddress()); +void NotificationSettings::setHighlightNick(NotificationSettings::HighlightNickType highlightNickType) { + setLocalValue("Highlights/HighlightNick", highlightNickType); } -void KnownHostsSettings::saveKnownHost(const QSslSocket *socket) { - Q_ASSERT(socket); - saveKnownHost(socket->peerAddress(), socket->peerCertificate().digest()); +NotificationSettings::HighlightNickType NotificationSettings::highlightNick() { + return (NotificationSettings::HighlightNickType) localValue("Highlights/HighlightNick", CurrentNick).toInt(); } -bool KnownHostsSettings::isKnownHost(const QSslSocket *socket) { - Q_ASSERT(socket); - return isKnownHost(socket->peerAddress(), socket->peerCertificate().digest()); +void NotificationSettings::setNicksCaseSensitive(bool cs) { + setLocalValue("Highlights/NicksCaseSensitive", cs); } -#endif +bool NotificationSettings::nicksCaseSensitive() { + return localValue("Highlights/NicksCaseSensitive", false).toBool(); +} // ======================================== // TabCompletionSettings @@ -238,6 +281,14 @@ QString TabCompletionSettings::completionSuffix() { return localValue("CompletionSuffix", ": ").toString(); } +void TabCompletionSettings::setAddSpaceMidSentence(const bool &space) { + setLocalValue("AddSpaceMidSentence", space); +} + +bool TabCompletionSettings::addSpaceMidSentence() { + return localValue("AddSpaceMidSentence", false).toBool(); +} + void TabCompletionSettings::setSortMode(SortMode mode) { setLocalValue("SortMode", mode); }