From c9f52b7223685d2e7fca925594171f94dd8c6e3b Mon Sep 17 00:00:00 2001 From: TrickyLeifa Date: Wed, 15 May 2024 00:00:17 +0200 Subject: Ported to CMake, ... * Ported the project to CMake * Android and Mac support dropped for the time being. * Tests, BASS and Discord-RPC are now options * Restructured and reformated the project. * Merged `include` and `src` * Renamed `resource` to `data` * Renamed various files * External libraries headers are no longer included in `src` * Replaced header guards with #pragma once * Multiple refactors (keywords, headers) * Added Qt6 compatibility * Removed various unused functions and headers * Reworked AOPacket * When content is passed to AOPacket, it should be ensured that the content is already decoded. * Encoding/decoding are now static methods. * Fixed various memory leaks * Removed animation code for AOImage * AOImage is always using static images * Simplified ChatLogPiece --- src/chatlogpiece.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/chatlogpiece.cpp') diff --git a/src/chatlogpiece.cpp b/src/chatlogpiece.cpp index 64ffefe8..662dc0d2 100644 --- a/src/chatlogpiece.cpp +++ b/src/chatlogpiece.cpp @@ -1,17 +1,15 @@ #include "chatlogpiece.h" -chatlogpiece::chatlogpiece() +ChatLogPiece::ChatLogPiece() { name = tr("UNKNOWN"); showname = tr("UNKNOWN"); message = tr("UNKNOWN"); color = 0; - action = ""; datetime = QDateTime::currentDateTimeUtc(); } -chatlogpiece::chatlogpiece(QString p_name, QString p_showname, - QString p_message, QString p_action, int p_color, bool p_selfname) +ChatLogPiece::ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname) { name = p_name; showname = p_showname; @@ -22,9 +20,7 @@ chatlogpiece::chatlogpiece(QString p_name, QString p_showname, datetime = QDateTime::currentDateTimeUtc(); } -chatlogpiece::chatlogpiece(QString p_name, QString p_showname, - QString p_message, QString p_action, int p_color, bool p_selfname, - QDateTime p_datetime) +ChatLogPiece::ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname, QDateTime p_datetime) { name = p_name; showname = p_showname; @@ -35,23 +31,30 @@ chatlogpiece::chatlogpiece(QString p_name, QString p_showname, datetime = p_datetime.toUTC(); } -QString chatlogpiece::get_full() +QString ChatLogPiece::get_datetime_as_string() +{ + return datetime.toString(); +} + +QString ChatLogPiece::get_full() { QString full = "["; full.append(get_datetime_as_string()); full.append("] "); - full.append(get_showname()); - if (get_showname() != get_name()) + full.append(showname); + if (showname != name) { full.append(" ("); - full.append(get_name()); + full.append(name); full.append(")"); } - if (!get_action().isEmpty()) - full.append(" " + get_action()); + if (!action.isEmpty()) + { + full.append(" " + action); + } full.append(": "); - full.append(get_message()); + full.append(message); return full; } -- cgit From 39e4354b1dae5d8487ea5b84be9f304b1950a61a Mon Sep 17 00:00:00 2001 From: TrickyLeifa Date: Thu, 16 May 2024 03:09:21 +0200 Subject: Reimplemented favorite server widget, ... * Reworked favorite server widget * Renamed `server_type` to `ServerInfo` * Renamed `connection_type` to `ServerConnectionType` * Refactored `AOCharButton` * Reimplemented `AOButton` * Partially reimplemented `AOEmoteButton` * Refactored `AOEvidenceButton` --- src/chatlogpiece.cpp | 67 ++++++++++++++++------------------------------------ 1 file changed, 20 insertions(+), 47 deletions(-) (limited to 'src/chatlogpiece.cpp') diff --git a/src/chatlogpiece.cpp b/src/chatlogpiece.cpp index 662dc0d2..d8ef2949 100644 --- a/src/chatlogpiece.cpp +++ b/src/chatlogpiece.cpp @@ -1,60 +1,33 @@ #include "chatlogpiece.h" -ChatLogPiece::ChatLogPiece() -{ - name = tr("UNKNOWN"); - showname = tr("UNKNOWN"); - message = tr("UNKNOWN"); - color = 0; - datetime = QDateTime::currentDateTimeUtc(); -} - -ChatLogPiece::ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname) -{ - name = p_name; - showname = p_showname; - message = p_message; - action = p_action; - color = p_color; - selfname = p_selfname; - datetime = QDateTime::currentDateTimeUtc(); -} - -ChatLogPiece::ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname, QDateTime p_datetime) -{ - name = p_name; - showname = p_showname; - message = p_message; - action = p_action; - color = p_color; - selfname = p_selfname; - datetime = p_datetime.toUTC(); -} +#include -QString ChatLogPiece::get_datetime_as_string() +QString ChatLogPiece::toString() { - return datetime.toString(); -} + auto maybe_unknown = [](QString str) -> QString { + if (str.isEmpty()) + { + return tr("UNKNOWN"); + } + else + { + return str; + } + }; -QString ChatLogPiece::get_full() -{ - QString full = "["; + QString details = QString("[%1] %2").arg(timestamp.toString(), maybe_unknown(character_name)); - full.append(get_datetime_as_string()); - full.append("] "); - full.append(showname); - if (showname != name) + if (character_name != character) { - full.append(" ("); - full.append(name); - full.append(")"); + details += " (" % maybe_unknown(character) % ")"; } + if (!action.isEmpty()) { - full.append(" " + action); + details += " " % action; } - full.append(": "); - full.append(message); - return full; + details += ": " % maybe_unknown(message); + + return details; } -- cgit