X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatviewsettings.cpp;h=2296989b3bd58f98917233bb43c7a8c31ac83369;hb=2c8434f74c68194d56f2084f637419123e61d18b;hp=b2e0060db89308c3afa72451165ffc117f6efb6a;hpb=695758015a80eb8c158a9ac4c0f1c0b547e70df3;p=quassel.git diff --git a/src/qtui/chatviewsettings.cpp b/src/qtui/chatviewsettings.cpp index b2e0060d..2296989b 100644 --- a/src/qtui/chatviewsettings.cpp +++ b/src/qtui/chatviewsettings.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -39,3 +39,79 @@ ChatViewSettings::ChatViewSettings(ChatView *view) : QtUiSettings(QString("ChatView/%1").arg(view->scene()->idString())) { } + + +bool ChatViewSettings::showWebPreview() const +{ + return localValue("ShowWebPreview", false).toBool(); +} + + +void ChatViewSettings::enableWebPreview(bool enabled) +{ + setLocalValue("ShowWebPreview", enabled); +} + + +bool ChatViewSettings::useCustomTimestampFormat() const +{ + return localValue("UseCustomTimestampFormat", false).toBool(); +} + + +void ChatViewSettings::setUseCustomTimestampFormat(bool enabled) +{ + setLocalValue("UseCustomTimestampFormat", enabled); +} + + +QString ChatViewSettings::timestampFormatString() const +{ + // Include a space in the default TimestampFormat to give the timestamp a small bit of padding + // between the border of the chat buffer window and the numbers. Helps with readability. + return localValue("TimestampFormat", " hh:mm:ss").toString(); +} + + +void ChatViewSettings::setTimestampFormatString(const QString &format) +{ + setLocalValue("TimestampFormat", format); +} + + +UiStyle::SenderPrefixMode ChatViewSettings::senderPrefixDisplay() const +{ + return static_cast( + localValue("SenderPrefixMode", + QVariant::fromValue( + UiStyle::SenderPrefixMode::HighestMode)).toInt()); + // Cast the QVariant to an integer, then cast that to the enum class. + // .canConvert() returned true, but + // .value(); always gave the default value 0. + // + // There's probably a cleaner way of doing this. I couldn't find it within 4 hours, so... +} + + +bool ChatViewSettings::showSenderBrackets() const +{ + return localValue("ShowSenderBrackets", false).toBool(); +} + + +void ChatViewSettings::enableSenderBrackets(bool enabled) +{ + setLocalValue("ShowSenderBrackets", enabled); +} + + +QString ChatViewSettings::webSearchUrlFormatString() const +{ + return localValue("WebSearchUrlFormat", "https://www.google.com/search?q=%s").toString(); +} + + +void ChatViewSettings::setWebSearchUrlFormatString(const QString &format) +{ + setLocalValue("WebSearchUrlFormat", format); +}