X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatviewsettings.cpp;h=34fb4186fbabe6f27dc29f7000d001435f15153b;hp=496431edeed8c670c3931098998e952f3506de33;hb=HEAD;hpb=9996d2489e5e5ca23b0750f39f64d8d4b5990029 diff --git a/src/qtui/chatviewsettings.cpp b/src/qtui/chatviewsettings.cpp index 496431ed..51435018 100644 --- a/src/qtui/chatviewsettings.cpp +++ b/src/qtui/chatviewsettings.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-2022 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "chatviewsettings.h" @@ -23,18 +23,77 @@ #include "chatscene.h" #include "chatview.h" -ChatViewSettings::ChatViewSettings(const QString &id) - : QtUiSettings(QString("ChatView/%1").arg(id)) +ChatViewSettings::ChatViewSettings(const QString& id) + : QtUiSettings(QString("ChatView/%1").arg(id)) +{} + +ChatViewSettings::ChatViewSettings(ChatScene* scene) + : QtUiSettings(QString("ChatView/%1").arg(scene->idString())) +{} + +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(); } -ChatViewSettings::ChatViewSettings(ChatScene *scene) - : QtUiSettings(QString("ChatView/%1").arg(scene->idString())) +void ChatViewSettings::setTimestampFormatString(const QString& format) { + setLocalValue("TimestampFormat", format); } -ChatViewSettings::ChatViewSettings(ChatView *view) - : QtUiSettings(QString("ChatView/%1").arg(view->scene()->idString())) +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); +}