* fix highlighting (i just broke it by not negating a boolean expression)
authorsheepluva
Sat, 29 Oct 2011 15:31:45 +0200
changeset 6229 4c834af76c3b
parent 6227 ce60b734fff1
child 6231 810b9ced2b67
* fix highlighting (i just broke it by not negating a boolean expression) * fix issues with first display: none; being ignored + allow css to hide hours / seconds of timestamp
QTfrontend/res/css/chat.css
QTfrontend/ui/widget/chatwidget.cpp
QTfrontend/ui/widget/chatwidget.h
--- a/QTfrontend/res/css/chat.css	Sat Oct 29 11:47:37 2011 +0200
+++ b/QTfrontend/res/css/chat.css	Sat Oct 29 15:31:45 2011 +0200
@@ -8,8 +8,9 @@
  * see http://doc.qt.nokia.com/4.5/richtext-html-subset.html#css-properties
  *
  * In the QTfrontend of hedgewars also display:none; will work for class names
- * that start with msg_ and .TimeStamp -  as long as they are referenced
- * directly and not within any hierachy.
+ * that start with msg_ and .timestamp -  as long as they are referenced
+ * directly and not within any class hierachy.
+ * Note: Will only effect new lines!
  *
  ******************************************************************************
  *
@@ -48,6 +49,9 @@
 .msg_FriendAction { color: #ff00ff; }
 .msg_FriendAction .nick { color: #ff30ff; }
 
+/* uncomment next line to disable join and leave messages of non-friends */
+/* .msg_UserJoin { display:none; } */
+
 /* timestamps */
 .timestamp {
     color: #e0d8e0;
@@ -58,6 +62,9 @@
     /* display: none; */
 }
 
+.timestamp:hours { display: none; }
+/* .timestamp:seconds { display: none; } */
+
 /* you can also set timestamp style for different msg types */
 .msg_FriendChat .timestamp { color: #ffffff; }
 
@@ -65,9 +72,6 @@
 .highlight {  }
 .highlight .nick { color: red; } /* nicknames in highlighted messages */
 
-/* uncomment next line to disable join and leave messages of non-friends */
-/* .msg_UserJoin { display:none; } */
-
 /* system messages */
 .msg_Error { color: #ff0000; }
 .msg_Warning { color: #ff8000; }
--- a/QTfrontend/ui/widget/chatwidget.cpp	Sat Oct 29 11:47:37 2011 +0200
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Sat Oct 29 15:31:45 2011 +0200
@@ -34,6 +34,8 @@
 #include <QDateTime>
 #include <QTime>
 
+#include <QMessageBox>
+
 
 #include "HWDataManager.h"
 #include "hwconsts.h"
@@ -103,6 +105,7 @@
 QString * HWChatWidget::s_styleSheet = NULL;
 QStringList * HWChatWidget::s_displayNone = NULL;
 bool HWChatWidget::s_isTimeStamped = true;
+QString HWChatWidget::s_tsFormat = ":mm:ss";
 
 const QString & HWChatWidget::styleSheet()
 {
@@ -173,6 +176,7 @@
 
     QStringList victims = QString(style).
                                 remove(displayed). // remove visible stuff
+                                trimmed().
                                 split(split). // get a list of the names
                                 filter(nohierarchy). // only direct class names
                                 replaceInStrings(QRegExp("^."),""); // crop .
@@ -183,6 +187,17 @@
         s_isTimeStamped = false;
         victims.removeAll("timestamp");
     }
+    else
+    {
+        s_isTimeStamped = true;
+        s_tsFormat =
+            ((victims.contains("timestamp:hours"))?"":"hh") +
+            QString(":mm:") +
+            ((victims.contains("timestamp:seconds"))?"":"ss");
+    }
+
+    victims.removeAll("timestamp:hours");
+    victims.removeAll("timestamp:seconds");
 
     victims.removeDuplicates();
 
@@ -540,7 +555,7 @@
     bool isHL = false;
 
     if ((c != 3) && (!nick.isEmpty()) &&
-        (nick != m_userNick) && (m_userNick.isEmpty()))
+        (nick != m_userNick) && (!m_userNick.isEmpty()))
     {
         QString lcStr = str.toLower();
 
@@ -569,7 +584,7 @@
     {
         QString tsMarkUp = "<span class=\"timestamp\">[%1]</span> ";
         QTime now = QDateTime::currentDateTime().time();
-        line = tsMarkUp.arg(now.toString(":mm:ss")) + line;
+        line = tsMarkUp.arg(now.toString(s_tsFormat)) + line;
     }
 
     line = QString("<span class=\"%1\">%2</span>").arg(cssClass).arg(line);
--- a/QTfrontend/ui/widget/chatwidget.h	Sat Oct 29 11:47:37 2011 +0200
+++ b/QTfrontend/ui/widget/chatwidget.h	Sat Oct 29 15:31:45 2011 +0200
@@ -25,6 +25,7 @@
 #include <QString>
 #include <QGridLayout>
 #include <QList>
+#include <QPair>
 #include <QRegExp>
 
 #include "SDLInteraction.h"
@@ -88,6 +89,7 @@
   static QString * s_styleSheet;
   static QStringList * s_displayNone;
   static bool s_isTimeStamped;
+  static QString s_tsFormat;
   static const QRegExp URLREGEXP;
 
   static void setStyleSheet(const QString & styleSheet = "");