summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b664a5a)
Add a toggle to Settings -> Interface -> Chat View so sender brackets
can be enabled and disabled as desired. Keeping with the timestamp
change, brackets are disabled by default but can be easily reenabled.
Revert Chat Monitor to include ':' as a separator between the
network:buffer:sender line, for otherwise it can be hard to read.
ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
: MessageFilter(model, parent)
{
ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
: MessageFilter(model, parent)
{
+ // Global configuration
+ ChatViewSettings defaultSettings;
+ _showSenderBrackets = defaultSettings.showSenderBrackets();
+ defaultSettings.notify("ShowSenderBrackets", this, SLOT(showSenderBracketsSettingChanged(const QVariant &)));
+
+ // Chat Monitor specific configuration
ChatViewSettings viewSettings(idString());
_showFields = viewSettings.value("ShowFields", AllFields).toInt();
_showOwnMessages = viewSettings.value("ShowOwnMsgs", true).toBool();
ChatViewSettings viewSettings(idString());
_showFields = viewSettings.value("ShowFields", AllFields).toInt();
_showOwnMessages = viewSettings.value("ShowOwnMsgs", true).toBool();
QString sender = MessageFilter::data(index, ChatLineModel::EditRole).toString();
fields << sender;
}
QString sender = MessageFilter::data(index, ChatLineModel::EditRole).toString();
fields << sender;
}
- return QString("%1").arg(fields.join(" "));
+ if (_showSenderBrackets)
+ return QString("<%1>").arg(fields.join(":"));
+ else
+ return QString("%1").arg(fields.join(":"));
void ChatMonitorFilter::includeReadSettingChanged(const QVariant &newValue) {
_includeRead = newValue.toBool();
}
void ChatMonitorFilter::includeReadSettingChanged(const QVariant &newValue) {
_includeRead = newValue.toBool();
}
+
+void ChatMonitorFilter::showSenderBracketsSettingChanged(const QVariant &newValue)
+{
+ _showSenderBrackets = newValue.toBool();
+}
void buffersSettingChanged(const QVariant &newValue);
void showBacklogSettingChanged(const QVariant &newValue);
void includeReadSettingChanged(const QVariant &newValue);
void buffersSettingChanged(const QVariant &newValue);
void showBacklogSettingChanged(const QVariant &newValue);
void includeReadSettingChanged(const QVariant &newValue);
+ /**
+ * Updates the local setting cache of whether or not to show sender brackets
+ *
+ * @param[in] newValue If true, sender brackets are enabled, otherwise false.
+ */
+ void showSenderBracketsSettingChanged(const QVariant &newValue);
private:
int _showFields;
private:
int _showFields;
int _operationMode;
bool _showBacklog;
bool _includeRead;
int _operationMode;
bool _showBacklog;
bool _includeRead;
+ bool _showSenderBrackets; /// If true, show brackets around sender names
_showWebPreview = defaultSettings.showWebPreview();
defaultSettings.notify("ShowWebPreview", this, SLOT(showWebPreviewChanged()));
_showWebPreview = defaultSettings.showWebPreview();
defaultSettings.notify("ShowWebPreview", this, SLOT(showWebPreviewChanged()));
+ _showSenderBrackets = defaultSettings.showSenderBrackets();
+ defaultSettings.notify("ShowSenderBrackets", this, SLOT(showSenderBracketsChanged()));
+
_clickTimer.setInterval(QApplication::doubleClickInterval());
_clickTimer.setSingleShot(true);
connect(&_clickTimer, SIGNAL(timeout()), SLOT(clickTimeout()));
_clickTimer.setInterval(QApplication::doubleClickInterval());
_clickTimer.setSingleShot(true);
connect(&_clickTimer, SIGNAL(timeout()), SLOT(clickTimeout()));
result += _lines[l]->item(ChatLineModel::TimestampColumn)->data(MessageModel::DisplayRole).toString() + " ";
if (_selectionMinCol <= ChatLineModel::SenderColumn) {
ChatItem *item = _lines[l]->item(ChatLineModel::SenderColumn);
result += _lines[l]->item(ChatLineModel::TimestampColumn)->data(MessageModel::DisplayRole).toString() + " ";
if (_selectionMinCol <= ChatLineModel::SenderColumn) {
ChatItem *item = _lines[l]->item(ChatLineModel::SenderColumn);
- if (item->chatLine()->msgType() == Message::Plain) {
- // Copying to plain-text, re-add the sender brackets
+ if (!_showSenderBrackets && item->chatLine()->msgType() == Message::Plain) {
+ // Copying to plain-text. Only re-add the sender brackets if they're normally
+ // hidden.
result += QString("<%1> ").arg(item->data(MessageModel::DisplayRole)
.toString());
} else {
result += QString("<%1> ").arg(item->data(MessageModel::DisplayRole)
.toString());
} else {
// end of webkit only
// ========================================
// end of webkit only
// ========================================
+// Local configuration caching
void ChatScene::showWebPreviewChanged()
{
ChatViewSettings settings;
_showWebPreview = settings.showWebPreview();
}
void ChatScene::showWebPreviewChanged()
{
ChatViewSettings settings;
_showWebPreview = settings.showWebPreview();
}
+
+void ChatScene::showSenderBracketsChanged()
+{
+ ChatViewSettings settings;
+ _showSenderBrackets = settings.showSenderBrackets();
+}
#endif
void showWebPreviewChanged();
#endif
void showWebPreviewChanged();
+ /**
+ * Updates the local setting cache of whether or not to show sender brackets
+ */
+ void showSenderBracketsChanged();
+
void rowsRemoved();
void clickTimeout();
void rowsRemoved();
void clickTimeout();
+ bool _showSenderBrackets; /// If true, show brackets around sender names
+
static const int _webSearchSelectionTextMaxVisible = 24;
#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
static const int _webSearchSelectionTextMaxVisible = 24;
#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
inline bool showWebPreview() { return localValue("ShowWebPreview", true).toBool(); }
inline void enableWebPreview(bool enabled) { setLocalValue("ShowWebPreview", enabled); }
inline bool showWebPreview() { return localValue("ShowWebPreview", true).toBool(); }
inline void enableWebPreview(bool enabled) { setLocalValue("ShowWebPreview", enabled); }
+ /**
+ * Gets the format string for chat log timestamps
+ *
+ * @returns String representing timestamp format, e.g. "[hh:mm:ss]" or " hh:mm:ss"
+ */
inline QString timestampFormatString() { return localValue("TimestampFormat", " hh:mm:ss").toString(); }
inline QString timestampFormatString() { return localValue("TimestampFormat", " hh:mm:ss").toString(); }
+ // 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.
+ /**
+ * Sets the format string for chat log timestamps
+ *
+ * @param[in] format String representing timestamp format, e.g. "[hh:mm:ss]" or " hh:mm:ss"
+ */
inline void setTimestampFormatString(const QString &format) { setLocalValue("TimestampFormat", format); }
inline void setTimestampFormatString(const QString &format) { setLocalValue("TimestampFormat", format); }
+ /**
+ * Gets if brackets are shown around sender names
+ *
+ * @returns True if sender brackets enabled, otherwise false
+ */
+ inline bool showSenderBrackets() { return localValue("ShowSenderBrackets", true).toBool(); }
+ /**
+ * Sets whether brackets are shown around around sender names.
+ *
+ * @param[in] enabled True if enabling sender brackets, otherwise false
+ */
+ inline void enableSenderBrackets(bool enabled) { setLocalValue("ShowSenderBrackets", enabled); }
+
inline QString webSearchUrlFormatString() { return localValue("WebSearchUrlFormat", "https://www.google.com/search?q=%s").toString(); }
inline void setWebSearchUrlFormatString(const QString &format) { setLocalValue("WebSearchUrlFormat", format); }
};
inline QString webSearchUrlFormatString() { return localValue("WebSearchUrlFormat", "https://www.google.com/search?q=%s").toString(); }
inline void setWebSearchUrlFormatString(const QString &format) { setLocalValue("WebSearchUrlFormat", format); }
};
-Q_DECLARE_METATYPE(ChatViewSettings::OperationMode);
+Q_DECLARE_METATYPE(ChatViewSettings::OperationMode)
#endif //CHATVIEWSETTINGS_H
#endif //CHATVIEWSETTINGS_H
ChatViewSettings s;
s.notify("TimestampFormat", this, SLOT(updateTimestampFormatString()));
updateTimestampFormatString();
ChatViewSettings s;
s.notify("TimestampFormat", this, SLOT(updateTimestampFormatString()));
updateTimestampFormatString();
+ s.notify("ShowSenderBrackets", this, SLOT(updateShowSenderBrackets()));
+ updateShowSenderBrackets();
setTimestampFormatString(s.timestampFormatString());
}
setTimestampFormatString(s.timestampFormatString());
}
+void QtUiStyle::updateShowSenderBrackets()
+{
+ ChatViewSettings s;
+ enableSenderBrackets(s.showSenderBrackets());
+}
+
void QtUiStyle::generateSettingsQss() const
{
void QtUiStyle::generateSettingsQss() const
{
private slots:
void updateTimestampFormatString();
private slots:
void updateTimestampFormatString();
+ /**
+ * Updates knowledge of whether or not to show sender brackets
+ */
+ void updateShowSenderBrackets();
private:
QString fontDescription(const QFont &font) const;
private:
QString fontDescription(const QFont &font) const;
<x>0</x>
<y>0</y>
<width>486</width>
<x>0</x>
<y>0</y>
<width>486</width>
</rect>
</property>
<property name="windowTitle">
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<property name="defaultValue" stdset="0">
<string/>
</property>
<property name="defaultValue" stdset="0">
- <string>[hh:mm:ss]</string>
+ <string> hh:mm:ss</string>
</property>
<property name="settingsKey" stdset="0">
<string notr="true">TimestampFormat</string>
</property>
<property name="settingsKey" stdset="0">
<string notr="true">TimestampFormat</string>
</item>
</layout>
</item>
</item>
</layout>
</item>
+ <item>
+ <widget class="QCheckBox" name="showSenderBrackets">
+ <property name="toolTip">
+ <string>Shows <brackets> around the names of senders</string>
+ </property>
+ <property name="text">
+ <string>Show brackets around sender names</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>false</bool>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string notr="true">ShowSenderBrackets</string>
+ </property>
+ </widget>
+ </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
</customwidgets>
<tabstops>
<tabstop>timestampFormat</tabstop>
</customwidgets>
<tabstops>
<tabstop>timestampFormat</tabstop>
+ <tabstop>showSenderBrackets</tabstop>
<tabstop>customChatViewFont</tabstop>
<tabstop>allowMircColors</tabstop>
<tabstop>showWebPreview</tabstop>
<tabstop>customChatViewFont</tabstop>
<tabstop>allowMircColors</tabstop>
<tabstop>showWebPreview</tabstop>
#include "util.h"
QHash<QString, UiStyle::FormatType> UiStyle::_formatCodes;
#include "util.h"
QHash<QString, UiStyle::FormatType> UiStyle::_formatCodes;
-QString UiStyle::_timestampFormatString;
+QString UiStyle::_timestampFormatString; /// Timestamp format
+bool UiStyle::_showSenderBrackets; /// If true, show brackets around sender names
UiStyle::UiStyle(QObject *parent)
: QObject(parent),
UiStyle::UiStyle(QObject *parent)
: QObject(parent),
_formatCodes["%DM"] = ModeFlags;
_formatCodes["%DU"] = Url;
_formatCodes["%DM"] = ModeFlags;
_formatCodes["%DU"] = Url;
- setTimestampFormatString("[hh:mm:ss]");
+ // Initialize fallback defaults
+ // NOTE: If you change this, update qtui/chatviewsettings.h, too. More explanations available
+ // in there.
+ setTimestampFormatString(" hh:mm:ss");
+ enableSenderBrackets(true);
// BufferView / NickView settings
UiStyleSettings s;
// BufferView / NickView settings
UiStyleSettings s;
+// FIXME The following should trigger a reload/refresh of the chat view.
void UiStyle::setTimestampFormatString(const QString &format)
{
if (_timestampFormatString != format) {
_timestampFormatString = format;
void UiStyle::setTimestampFormatString(const QString &format)
{
if (_timestampFormatString != format) {
_timestampFormatString = format;
+ }
+}
+
+void UiStyle::enableSenderBrackets(bool enabled)
+{
+ if (_showSenderBrackets != enabled) {
+ _showSenderBrackets = enabled;
{
switch (type()) {
case Message::Plain:
{
switch (type()) {
case Message::Plain:
- return QString("%1").arg(plainSender()); break;
+ if (_showSenderBrackets)
+ return QString("<%1>").arg(plainSender());
+ else
+ return QString("%1").arg(plainSender());
+ break;
case Message::Notice:
return QString("[%1]").arg(plainSender()); break;
case Message::Action:
case Message::Notice:
return QString("[%1]").arg(plainSender()); break;
case Message::Action:
static FormatType formatType(const QString &code);
static QString formatCode(FormatType);
static void setTimestampFormatString(const QString &format);
static FormatType formatType(const QString &code);
static QString formatCode(FormatType);
static void setTimestampFormatString(const QString &format);
+ /**
+ * Updates the local setting cache of whether or not to show sender brackets
+ *
+ * @param[in] enabled If true, sender brackets are enabled, otherwise false.
+ */
+ static void enableSenderBrackets(bool enabled);
QVariant itemData(int role, const QTextCharFormat &format) const;
QVariant itemData(int role, const QTextCharFormat &format) const;
QHash<quint32, QTextCharFormat> _listItemFormats;
static QHash<QString, FormatType> _formatCodes;
static QString _timestampFormatString;
QHash<quint32, QTextCharFormat> _listItemFormats;
static QHash<QString, FormatType> _formatCodes;
static QString _timestampFormatString;
+ static bool _showSenderBrackets; /// If true, show brackets around sender names
QIcon _channelJoinedIcon;
QIcon _channelPartedIcon;
QIcon _channelJoinedIcon;
QIcon _channelPartedIcon;