Changeset View
Changeset View
Standalone View
Standalone View
src/viewer/ircview.cpp
Show First 20 Lines • Show All 530 Lines • ▼ Show 20 Line(s) | 511 | { | |||
---|---|---|---|---|---|
531 | if (!viewport()->styleSheet().isEmpty()) | 531 | if (!viewport()->styleSheet().isEmpty()) | ||
532 | viewport()->setStyleSheet(QString()); | 532 | viewport()->setStyleSheet(QString()); | ||
533 | 533 | | |||
534 | QPalette p; | 534 | QPalette p; | ||
535 | p.setColor(QPalette::Base, Preferences::self()->color(Preferences::TextViewBackground)); | 535 | p.setColor(QPalette::Base, Preferences::self()->color(Preferences::TextViewBackground)); | ||
536 | viewport()->setPalette(p); | 536 | viewport()->setPalette(p); | ||
537 | } | 537 | } | ||
538 | 538 | | |||
539 | bool IRCView::dateRtlDirection() | ||||
540 | { | ||||
541 | // Keep format synced with IRCView::timeStamp | ||||
542 | return QLocale().toString(QDate::currentDate(), QLocale::ShortFormat).isRightToLeft(); | ||||
543 | } | ||||
544 | | ||||
545 | // To minimize the use of bidi marks, for cases below, some bidi marks are | ||||
546 | // needed. | ||||
547 | // * left aligned lines in LTR locales, and | ||||
548 | // * right aligned lines in RTL locales | ||||
549 | // | ||||
550 | // First, check if the direction of the message is the same as the | ||||
551 | // direction of the timestamp, if not, then add a mark depending on | ||||
552 | // message's direction, so that timestamp don't be first strong character. | ||||
553 | // | ||||
554 | // If we have a LTR label, and the message is right-aligned, we prepend | ||||
555 | // it with LRM to look correct (check nickname case below), and then append | ||||
556 | // it with LRM also and then a RLM to preserve the direction of the | ||||
557 | // right-aligned line. | ||||
558 | // | ||||
559 | // Later, if the message is RTL, nicknames like "_nick]" will appear | ||||
560 | // as "[nick_". | ||||
561 | // First, add a LRM mark to make underscore on the left, next add the | ||||
562 | // nickname, and then another LRM mark. Since we use RTL/LTR count, the | ||||
563 | // message may start with a LTR word, and appear to the right of the | ||||
564 | // nickname. That's why we add a RLM mark before the nick to force it | ||||
565 | // appearing on left. | ||||
566 | QString IRCView::formatFinalLine(bool rtl, QString lineColor, QString label, QString nickLine, QString nickStar, QString text) | ||||
567 | { | ||||
568 | // Nick correctly displayed: <_nick]> | ||||
569 | QString line; | ||||
570 | // It's right-aligned under LTR locale, or left-aligned under RTL locale | ||||
571 | if (!rtl == dateRtlDirection()) | ||||
572 | line += (rtl ? RLM : LRM); | ||||
573 | if (!label.isEmpty()) { // Label correctly displayed: [_label.] | ||||
574 | if (rtl) line += LRM; // [.label_] -> [._label] | ||||
575 | line += "<font color=\"" + lineColor + "\"><b>[</b>%4<b>]</b></font>"; | ||||
576 | if (!label.isRightToLeft() == rtl) | ||||
577 | line += LRM + RLM; // [._label] -> [_label.] | ||||
578 | } | ||||
579 | line += "<font color=\"" + lineColor + "\">%1"; | ||||
580 | if (!nickStar.isEmpty()) // Used for [timeStamp] * nick action | ||||
581 | line += nickStar; | ||||
582 | if (rtl) line += LRM; // <[nick_> -> <[_nick]> | ||||
583 | line += nickLine; | ||||
584 | if (rtl) | ||||
585 | { | ||||
586 | line += LRM; // <[_nick]> -> <_nick]> | ||||
587 | // It might start with an English word, but it's RTL because of counting | ||||
588 | if (!text.isEmpty() && !text.isRightToLeft()) | ||||
589 | line += RLM; // ARABIC_TEXT <_nick]> Hi -> ARABIC_TEXT Hi <_nick]> | ||||
590 | } | ||||
591 | if (text.isEmpty()) line += "</font>"; | ||||
592 | else line += " %3</font>"; | ||||
593 | | ||||
594 | return line; | ||||
595 | } | ||||
539 | 596 | | |||
540 | // Data insertion | 597 | // Data insertion | ||
541 | 598 | | |||
542 | void IRCView::append(const QString& nick, const QString& message, const QHash<QString, QString> &messageTags, const QString& label) | 599 | void IRCView::append(const QString& nick, const QString& message, const QHash<QString, QString> &messageTags, const QString& label) | ||
543 | { | 600 | { | ||
544 | QString channelColor = Preferences::self()->color(Preferences::ChannelMessage).name(); | 601 | QString channelColor = Preferences::self()->color(Preferences::ChannelMessage).name(); | ||
545 | 602 | | |||
546 | m_tabNotification = Konversation::tnfNormal; | 603 | m_tabNotification = Konversation::tnfNormal; | ||
547 | 604 | | |||
548 | QString nickLine = createNickLine(nick, channelColor); | 605 | QString nickLine = createNickLine(nick, channelColor); | ||
argonel: The comments like this probably mean something, please expand into something more like… | |||||
549 | 606 | | |||
550 | QChar::Direction dir; | 607 | QChar::Direction dir; | ||
551 | QString text(filter(message, channelColor, nick, true, true, false, &dir)); | 608 | QString text(filter(message, channelColor, nick, true, true, false, &dir)); | ||
552 | QString line; | 609 | QString line; | ||
553 | bool rtl = (dir == QChar::DirR); | 610 | bool rtl = (dir == QChar::DirR); | ||
554 | 611 | | |||
555 | QChar directionOfLine = rtl ? RLM : LRM; | 612 | // Normal chat lines | ||
556 | line = directionOfLine; | 613 | // [timestamp] <nickname> chat message | ||
557 | if (!label.isEmpty()) { | 614 | line = formatFinalLine(rtl, channelColor, label, nickLine, QString(), text); | ||
558 | line += "<font color=\"" + channelColor + "\"><b>[</b>%4<b>]</b></font>"; | 615 | line = line.arg(timeStamp(messageTags, rtl), nick, text); | ||
559 | } | | |||
560 | line += "<font color=\"" + channelColor + "\">%1" + directionOfLine + nickLine + directionOfLine + " %3</font>"; | | |||
561 | line = line.arg(timeStamp(messageTags), nick, text); | | |||
562 | 616 | | |||
563 | if (!label.isEmpty()) | 617 | if (!label.isEmpty()) | ||
564 | { | 618 | { | ||
565 | line = line.arg(label); | 619 | line = line.arg(label); | ||
566 | } | 620 | } | ||
567 | 621 | | |||
568 | emit textToLog(QString("<%1>\t%2").arg(nick, message)); | 622 | emit textToLog(QString("<%1>\t%2").arg(nick, message)); | ||
569 | 623 | | |||
570 | doAppend(line, rtl); | 624 | doAppend(line, rtl); | ||
571 | } | 625 | } | ||
572 | 626 | | |||
573 | void IRCView::appendRaw(const QString& message, bool self) | 627 | void IRCView::appendRaw(const QString& message, bool self) | ||
574 | { | 628 | { | ||
575 | QColor color = self ? Preferences::self()->color(Preferences::ChannelMessage) | 629 | QColor color = self ? Preferences::self()->color(Preferences::ChannelMessage) | ||
576 | : Preferences::self()->color(Preferences::ServerMessage); | 630 | : Preferences::self()->color(Preferences::ServerMessage); | ||
577 | m_tabNotification = Konversation::tnfNone; | 631 | m_tabNotification = Konversation::tnfNone; | ||
578 | 632 | | |||
579 | QString line = QString(timeStamp(QHash<QString, QString>()) + " <font color=\"" + color.name() + "\">" + message + "</font>"); | 633 | // Raw log is always left-aligned | ||
634 | // [timestamp] << server line | ||||
635 | // If the timedate string is RTL, prepend a LTR mark to force the direction | ||||
636 | // to be LTR, as the datetime string is already returned as it's for a | ||||
637 | // left-aligned line. | ||||
638 | | ||||
639 | QString line; | ||||
640 | if (dateRtlDirection()) line += LRM; | ||||
641 | line += (timeStamp(QHash<QString, QString>(), false) + " <font color=\"" + color.name() + "\">" + message + "</font>"); | ||||
580 | 642 | | |||
581 | doAppend(line, false, self); | 643 | doAppend(line, false, self); | ||
582 | } | 644 | } | ||
583 | 645 | | |||
584 | void IRCView::appendLog(const QString & message) | 646 | void IRCView::appendLog(const QString & message) | ||
585 | { | 647 | { | ||
586 | QColor channelColor = Preferences::self()->color(Preferences::ChannelMessage); | 648 | QColor channelColor = Preferences::self()->color(Preferences::ChannelMessage); | ||
587 | m_tabNotification = Konversation::tnfNone; | 649 | m_tabNotification = Konversation::tnfNone; | ||
588 | 650 | | |||
651 | // Log view is plain log files. | ||||
652 | // Direction will be depending on the logfile line direction. | ||||
653 | | ||||
589 | QString line("<font color=\"" + channelColor.name() + "\">" + message + "</font>"); | 654 | QString line("<font color=\"" + channelColor.name() + "\">" + message + "</font>"); | ||
590 | 655 | | |||
591 | doRawAppend(line, !QApplication::isLeftToRight()); | 656 | doRawAppend(line, message.isRightToLeft()); | ||
592 | } | 657 | } | ||
593 | 658 | | |||
594 | void IRCView::appendQuery(const QString& nick, const QString& message, const QHash<QString, QString> &messageTags, bool inChannel) | 659 | void IRCView::appendQuery(const QString& nick, const QString& message, const QHash<QString, QString> &messageTags, bool inChannel) | ||
595 | { | 660 | { | ||
596 | QString queryColor=Preferences::self()->color(Preferences::QueryMessage).name(); | 661 | QString queryColor=Preferences::self()->color(Preferences::QueryMessage).name(); | ||
597 | 662 | | |||
598 | m_tabNotification = Konversation::tnfPrivate; | 663 | m_tabNotification = Konversation::tnfPrivate; | ||
599 | 664 | | |||
600 | QString nickLine = createNickLine(nick, queryColor, true, inChannel); | 665 | QString nickLine = createNickLine(nick, queryColor, true, inChannel); | ||
601 | 666 | | |||
602 | QString line; | 667 | QString line; | ||
603 | QChar::Direction dir; | 668 | QChar::Direction dir; | ||
604 | QString text(filter(message, queryColor, nick, true, true, false, &dir)); | 669 | QString text(filter(message, queryColor, nick, true, true, false, &dir)); | ||
605 | bool rtl = (dir == QChar::DirR); | 670 | bool rtl = (dir == QChar::DirR); | ||
606 | 671 | | |||
607 | QChar directionOfLine = rtl ? RLM : LRM; | 672 | // Private chat lines | ||
608 | line = directionOfLine + "<font color=\"" + queryColor + "\">%1" + directionOfLine + nickLine + directionOfLine + " %3"; | 673 | // [timestamp] <nickname> chat message | ||
609 | line = line.arg(timeStamp(messageTags), nick, text); | 674 | line = formatFinalLine(rtl, queryColor, QString(), nickLine, QString(), text); | ||
675 | line = line.arg(timeStamp(messageTags, rtl), nick, text); | ||||
610 | 676 | | |||
611 | if (inChannel) { | 677 | if (inChannel) { | ||
612 | emit textToLog(QString("<-> %1>\t%2").arg(nick, message)); | 678 | emit textToLog(QString("<-> %1>\t%2").arg(nick, message)); | ||
613 | } else { | 679 | } else { | ||
614 | emit textToLog(QString("<%1>\t%2").arg(nick, message)); | 680 | emit textToLog(QString("<%1>\t%2").arg(nick, message)); | ||
615 | } | 681 | } | ||
616 | 682 | | |||
617 | doAppend(line, rtl); | 683 | doAppend(line, rtl); | ||
Show All 16 Lines | 699 | { | |||
634 | QString actionColor = Preferences::self()->color(Preferences::ActionMessage).name(); | 700 | QString actionColor = Preferences::self()->color(Preferences::ActionMessage).name(); | ||
635 | 701 | | |||
636 | QString line; | 702 | QString line; | ||
637 | 703 | | |||
638 | QString nickLine = createNickLine(nick, actionColor, false); | 704 | QString nickLine = createNickLine(nick, actionColor, false); | ||
639 | 705 | | |||
640 | if (message.isEmpty()) | 706 | if (message.isEmpty()) | ||
641 | { | 707 | { | ||
642 | line = LRM + "<font color=\"" + actionColor + "\">%1 * " + nickLine + "</font>"; | 708 | // No text to check direction. Better to check last line, if it's RTL, | ||
709 | // treat it as that. | ||||
710 | QTextCursor formatCursor(document()->lastBlock()); | ||||
711 | bool rtl = (formatCursor.blockFormat().alignment().testFlag(Qt::AlignRight)); | ||||
643 | 712 | | |||
644 | line = line.arg(timeStamp(messageTags), nick); | 713 | line = formatFinalLine(rtl, actionColor, QString(), nickLine, QString(" * "), QString()); | ||
714 | line = line.arg(timeStamp(messageTags, rtl), nick); | ||||
645 | 715 | | |||
646 | emit textToLog(QString("\t * %1").arg(nick)); | 716 | emit textToLog(QString("\t * %1").arg(nick)); | ||
647 | 717 | | |||
648 | doAppend(line, false); | 718 | doAppend(line, rtl); | ||
649 | } | 719 | } | ||
650 | else | 720 | else | ||
651 | { | 721 | { | ||
652 | QChar::Direction dir; | 722 | QChar::Direction dir; | ||
653 | QString text(filter(message, actionColor, nick, true,true, false, &dir)); | 723 | QString text(filter(message, actionColor, nick, true,true, false, &dir)); | ||
654 | bool rtl = (dir == QChar::DirR); | 724 | bool rtl = (dir == QChar::DirR); | ||
655 | 725 | | |||
656 | QChar directionOfLine = rtl ? RLM : LRM; | 726 | // Actions line | ||
657 | line = directionOfLine + "<font color=\"" + actionColor + "\">%1 " + directionOfLine + "* " + nickLine + directionOfLine + " %3</font>"; | 727 | // [timestamp] * nickname action | ||
658 | line = line.arg(timeStamp(messageTags), nick, text); | 728 | line = formatFinalLine(rtl, actionColor, QString(), nickLine, QString(" * "), text); | ||
729 | line = line.arg(timeStamp(messageTags, rtl), nick, text); | ||||
659 | 730 | | |||
660 | emit textToLog(QString("\t * %1 %2").arg(nick, message)); | 731 | emit textToLog(QString("\t * %1 %2").arg(nick, message)); | ||
661 | 732 | | |||
662 | doAppend(line, rtl); | 733 | doAppend(line, rtl); | ||
663 | } | 734 | } | ||
664 | } | 735 | } | ||
665 | 736 | | |||
666 | void IRCView::appendServerMessage(const QString& type, const QString& message, const QHash<QString, QString> &messageTags, bool parseURL) | 737 | void IRCView::appendServerMessage(const QString& type, const QString& message, const QHash<QString, QString> &messageTags, bool parseURL) | ||
667 | { | 738 | { | ||
668 | QString serverColor = Preferences::self()->color(Preferences::ServerMessage).name(); | 739 | QString serverColor = Preferences::self()->color(Preferences::ServerMessage).name(); | ||
669 | m_tabNotification = Konversation::tnfControl; | 740 | m_tabNotification = Konversation::tnfControl; | ||
670 | 741 | | |||
671 | // Fixed width font option for MOTD | 742 | // Fixed width font option for MOTD | ||
672 | QString fixed; | 743 | QString fixed; | ||
673 | if(Preferences::self()->fixedMOTD() && !m_fontDataBase.isFixedPitch(font().family())) | 744 | if(Preferences::self()->fixedMOTD() && !m_fontDataBase.isFixedPitch(font().family())) | ||
674 | { | 745 | { | ||
675 | if(type == i18n("MOTD")) | 746 | if(type == i18n("MOTD")) | ||
676 | fixed=" face=\"" + QFontDatabase::systemFont(QFontDatabase::FixedFont).family() + "\""; | 747 | fixed=" face=\"" + QFontDatabase::systemFont(QFontDatabase::FixedFont).family() + "\""; | ||
677 | } | 748 | } | ||
678 | 749 | | |||
679 | QString line; | 750 | QString line; | ||
680 | QChar::Direction dir; | 751 | QChar::Direction dir; | ||
681 | QString text(filter(message, serverColor, 0 , true, parseURL, false, &dir)); | 752 | QString text(filter(message, serverColor, 0 , true, parseURL, false, &dir)); | ||
682 | bool rtl = (dir == QChar::DirR); | 753 | // Server text may be translated strings. It's not user input: treat with first strong. | ||
754 | bool rtl = text.isRightToLeft(); | ||||
683 | 755 | | |||
684 | QChar directionOfLine = rtl ? RLM : LRM; | 756 | // It's right-aligned under LTR locale, or left-aligned under RTL locale | ||
685 | line = directionOfLine + "<font color=\"" + serverColor + "\"" + fixed + ">%1 " + directionOfLine + "<b>[</b>%2<b>]</b>" + directionOfLine + " %3</font>"; | 757 | if (!rtl == dateRtlDirection()) | ||
686 | line = line.arg(timeStamp(messageTags), type, text); | 758 | line += (rtl ? RLM : LRM); | ||
759 | line += "<font color=\"" + serverColor + "\"" + fixed + ">%1 <b>[</b>%2<b>]</b>"; | ||||
760 | if (!rtl == type.isRightToLeft()) | ||||
761 | line += (rtl ? RLM : LRM); // [50 [ARABIC_TEXT users -> [ARABIC_TEXT] 50 users | ||||
762 | line += " %3</font>"; | ||||
763 | line = line.arg(timeStamp(messageTags, rtl), type, text); | ||||
687 | 764 | | |||
688 | emit textToLog(QString("%1\t%2").arg(type, message)); | 765 | emit textToLog(QString("%1\t%2").arg(type, message)); | ||
689 | 766 | | |||
690 | doAppend(line, rtl); | 767 | doAppend(line, rtl); | ||
691 | } | 768 | } | ||
692 | 769 | | |||
693 | void IRCView::appendCommandMessage(const QString& type, const QString& message, const QHash<QString, QString> &messageTags, bool parseURL, bool self) | 770 | void IRCView::appendCommandMessage(const QString& type, const QString& message, const QHash<QString, QString> &messageTags, bool parseURL, bool self) | ||
694 | { | 771 | { | ||
Show All 11 Lines | 782 | { | |||
706 | prefix="<--"; | 783 | prefix="<--"; | ||
707 | } | 784 | } | ||
708 | 785 | | |||
709 | prefix=prefix.toHtmlEscaped(); | 786 | prefix=prefix.toHtmlEscaped(); | ||
710 | 787 | | |||
711 | QString line; | 788 | QString line; | ||
712 | QChar::Direction dir; | 789 | QChar::Direction dir; | ||
713 | QString text(filter(message, commandColor, 0, true, parseURL, self, &dir)); | 790 | QString text(filter(message, commandColor, 0, true, parseURL, self, &dir)); | ||
791 | // Commands are translated and contain LTR IP addresses. Treat with first strong. | ||||
714 | bool rtl = text.isRightToLeft(); | 792 | bool rtl = text.isRightToLeft(); | ||
715 | 793 | | |||
716 | QChar directionOfLine = rtl ? RLM : LRM; | 794 | // It's right-aligned under LTR locale, or left-aligned under RTL locale | ||
717 | line = directionOfLine + "<font color=\"" + commandColor + "\">%1 %2 %3</font>"; | 795 | if (!rtl == dateRtlDirection()) | ||
718 | line = line.arg(timeStamp(messageTags), prefix, text); | 796 | line += (rtl ? RLM : LRM); | ||
797 | line += "<font color=\"" + commandColor + "\">%1 %2 %3</font>"; | ||||
798 | line = line.arg(timeStamp(messageTags, rtl), prefix, text); | ||||
719 | 799 | | |||
720 | emit textToLog(QString("%1\t%2").arg(type, message)); | 800 | emit textToLog(QString("%1\t%2").arg(type, message)); | ||
721 | 801 | | |||
722 | doAppend(line, rtl, self); | 802 | doAppend(line, rtl, self); | ||
723 | } | 803 | } | ||
724 | 804 | | |||
725 | void IRCView::appendBacklogMessage(const QString& firstColumn,const QString& rawMessage) | 805 | void IRCView::appendBacklogMessage(const QString& firstColumn,const QString& rawMessage) | ||
726 | { | 806 | { | ||
727 | QString time; | 807 | QString time; | ||
728 | QString message = rawMessage; | 808 | QString message = rawMessage; | ||
729 | QString nick = firstColumn; | 809 | QString nick = firstColumn; | ||
730 | QString backlogColor = Preferences::self()->color(Preferences::BacklogMessage).name(); | 810 | QString backlogColor = Preferences::self()->color(Preferences::BacklogMessage).name(); | ||
731 | m_tabNotification = Konversation::tnfNone; | 811 | m_tabNotification = Konversation::tnfNone; | ||
732 | 812 | | |||
733 | //The format in Chatwindow::logText is not configurable, so as long as nobody allows square brackets in a date/time format.... | 813 | //The format in Chatwindow::logText is not configurable, so as long as nobody allows square brackets in a date/time format.... | ||
734 | int eot = nick.lastIndexOf(' '); | 814 | int eot = nick.lastIndexOf(' '); | ||
735 | time = nick.left(eot); | 815 | time = nick.left(eot); | ||
736 | nick = nick.mid(eot+1); | 816 | nick = nick.mid(eot+1); | ||
737 | 817 | | |||
738 | if(!nick.isEmpty() && !nick.startsWith('<') && !nick.startsWith('*')) | 818 | if(!nick.isEmpty() && !nick.startsWith('<') && !nick.startsWith('*')) | ||
739 | { | 819 | { | ||
740 | nick = '|' + nick + '|'; | 820 | nick = '|' + nick + '|'; | ||
741 | } | 821 | } | ||
742 | else //It's a real nick | | |||
743 | { | | |||
744 | nick = LRM + nick + LRM; | | |||
745 | } | | |||
746 | 822 | | |||
747 | // Nicks are in "<nick>" format so replace the "<>" | 823 | // Nicks are in "<nick>" format so replace the "<>" | ||
748 | nick.replace('<',"<"); | 824 | nick.replace('<',"<"); | ||
749 | nick.replace('>',">"); | 825 | nick.replace('>',">"); | ||
750 | 826 | | |||
751 | QString line; | 827 | QString line; | ||
752 | QChar::Direction dir; | 828 | QChar::Direction dir; | ||
753 | QString text(filter(message, backlogColor, NULL, false, false, false, &dir)); | 829 | QString text(filter(message, backlogColor, NULL, false, false, false, &dir)); | ||
754 | bool rtl = nick.startsWith('|') ? text.isRightToLeft() : (dir == QChar::DirR); | 830 | bool rtl = nick.startsWith('|') ? text.isRightToLeft() : (dir == QChar::DirR); | ||
755 | 831 | | |||
756 | QChar directionOfLine = rtl ? RLM : LRM; | 832 | // It's right-aligned under LTR locale, or left-aligned under RTL locale | ||
757 | line = directionOfLine + "<font color=\"" + backlogColor + "\">%1 " + directionOfLine + "%2" + directionOfLine + " %3</font>"; | 833 | if (!rtl == time.isRightToLeft()) | ||
834 | line += (rtl ? RLM : LRM); | ||||
835 | | ||||
836 | line += "<font color=\"" + backlogColor + "\">"; | ||||
837 | // Prepend and append timestamp's correct bidi mark if the time and text | ||||
838 | // directions are different. | ||||
Should be two lines, ensure both the conditional and ternary are required. argonel: Should be two lines, ensure both the conditional and ternary are required. | |||||
839 | if (rtl == time.isRightToLeft()) | ||||
840 | line += "%1"; | ||||
Should be two lines, ensure both the conditional and ternary are required. argonel: Should be two lines, ensure both the conditional and ternary are required. | |||||
841 | else | ||||
842 | line += (time.isRightToLeft() ? RLM+"%1"+RLM : LRM+"%1"+LRM); | ||||
843 | | ||||
844 | // Partially copied from IRCView::formatFinalLine | ||||
845 | if (rtl) | ||||
846 | { | ||||
847 | // Return back to the normal direction after setting mark | ||||
848 | if (!rtl == time.isRightToLeft()) line += (!time.isRightToLeft() ? RLM : LRM); | ||||
849 | line += LRM; // <[nick_> -> <[_nick]> | ||||
850 | } | ||||
851 | line += "%2"; | ||||
852 | if (rtl) | ||||
853 | { | ||||
854 | line += LRM; // <[_nick]> -> <_nick]> | ||||
855 | if (!text.isRightToLeft()) | ||||
856 | line += RLM; // ARABIC_TEXT <_nick]> Hi -> ARABIC_TEXT Hi <_nick]> | ||||
857 | } | ||||
858 | | ||||
859 | line += " %3</font>"; | ||||
758 | line = line.arg(time, nick, text); | 860 | line = line.arg(time, nick, text); | ||
759 | 861 | | |||
760 | doAppend(line, rtl); | 862 | doAppend(line, rtl); | ||
761 | } | 863 | } | ||
762 | 864 | | |||
763 | void IRCView::doAppend(const QString& newLine, bool rtl, bool self) | 865 | void IRCView::doAppend(const QString& newLine, bool rtl, bool self) | ||
764 | { | 866 | { | ||
765 | if (m_rememberLineDirtyBit) | 867 | if (m_rememberLineDirtyBit) | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 903 | { | |||
808 | 910 | | |||
809 | QTextCursor formatCursor(document()->lastBlock()); | 911 | QTextCursor formatCursor(document()->lastBlock()); | ||
810 | QTextBlockFormat format = formatCursor.blockFormat(); | 912 | QTextBlockFormat format = formatCursor.blockFormat(); | ||
811 | 913 | | |||
812 | format.setAlignment(Qt::AlignAbsolute|(rtl ? Qt::AlignRight : Qt::AlignLeft)); | 914 | format.setAlignment(Qt::AlignAbsolute|(rtl ? Qt::AlignRight : Qt::AlignLeft)); | ||
813 | formatCursor.setBlockFormat(format); | 915 | formatCursor.setBlockFormat(format); | ||
814 | } | 916 | } | ||
815 | 917 | | |||
816 | QString IRCView::timeStamp(QHash<QString, QString> messageTags) | 918 | QString IRCView::timeStamp(QHash<QString, QString> messageTags, bool rtl) | ||
817 | { | 919 | { | ||
818 | if(Preferences::self()->timestamping()) | 920 | if(Preferences::self()->timestamping()) | ||
819 | { | 921 | { | ||
820 | QDateTime serverTime; | 922 | QDateTime serverTime; | ||
821 | 923 | | |||
822 | if (messageTags.contains(QStringLiteral("time"))) // If it exists use the supplied server time. | 924 | if (messageTags.contains(QStringLiteral("time"))) // If it exists use the supplied server time. | ||
823 | serverTime = QDateTime::fromString(messageTags[QStringLiteral("time")], Qt::ISODate).toLocalTime(); | 925 | serverTime = QDateTime::fromString(messageTags[QStringLiteral("time")], Qt::ISODate).toLocalTime(); | ||
824 | 926 | | |||
825 | QTime time = serverTime.isValid() ? serverTime.time() : QTime::currentTime(); | 927 | QTime time = serverTime.isValid() ? serverTime.time() : QTime::currentTime(); | ||
826 | QString timeColor = Preferences::self()->color(Preferences::Time).name(); | 928 | QString timeColor = Preferences::self()->color(Preferences::Time).name(); | ||
827 | QString timeFormat = Preferences::self()->timestampFormat(); | 929 | QString timeFormat = Preferences::self()->timestampFormat(); | ||
828 | QString timeString; | 930 | QString timeString; | ||
829 | 931 | | |||
830 | bool rtlLocale = (QLocale().zeroDigit() == QChar((ushort)0x0660)) || // ARABIC-INDIC DIGIT ZERO | 932 | bool dateRtl = dateRtlDirection(); | ||
831 | (QLocale().zeroDigit() == QChar((ushort)0x06F0)); // EXTENDED ARABIC-INDIC DIGIT ZERO | | |||
832 | 933 | | |||
833 | if(!Preferences::self()->showDate()) | 934 | if(!Preferences::self()->showDate()) | ||
834 | { | 935 | { | ||
835 | timeString = QString(QLatin1String("<font color=\"") + timeColor + QLatin1String("\">[%1]</font> ")).arg(time.toString(timeFormat)); | 936 | timeString = QString(QLatin1String("<font color=\"") + timeColor + QLatin1String("\">[%1]</font> ")).arg(time.toString(timeFormat)); | ||
836 | } | 937 | } | ||
837 | else | 938 | else | ||
838 | { | 939 | { | ||
839 | QDate date = serverTime.isValid() ? serverTime.date() : QDate::currentDate(); | 940 | QDate date = serverTime.isValid() ? serverTime.date() : QDate::currentDate(); | ||
840 | timeString = QString("<font color=\"" + | 941 | timeString = QString("<font color=\"" + | ||
841 | timeColor + "\">[%1%2 %3%4]</font> ") | 942 | timeColor + "\">[%1%2 %3%4]</font> ") | ||
842 | .arg(rtlLocale ? RLM : LRM, | 943 | .arg((dateRtl==rtl) ? QString() : (dateRtl ? RLM : LRM), | ||
843 | QLocale().toString(date, QLocale::ShortFormat), | 944 | QLocale().toString(date, QLocale::ShortFormat), | ||
844 | time.toString(timeFormat), | 945 | time.toString(timeFormat), | ||
845 | !rtlLocale ? RLM : LRM); | 946 | (dateRtl==rtl) ? QString() : (!dateRtl ? RLM : LRM)); | ||
846 | } | 947 | } | ||
847 | 948 | | |||
848 | return timeString; | 949 | return timeString; | ||
849 | } | 950 | } | ||
850 | 951 | | |||
851 | return QString(); | 952 | return QString(); | ||
852 | } | 953 | } | ||
853 | 954 | | |||
854 | QString IRCView::createNickLine(const QString& nick, const QString& defaultColor, bool encapsulateNick, bool privMsg) | 955 | QString IRCView::createNickLine(const QString& nick, const QString& defaultColor, bool encapsulateNick, bool privMsg) | ||
855 | { | 956 | { | ||
856 | QString nickLine = LRM + "%2" + LRM; | 957 | QString nickLine ="%2"; | ||
857 | QString nickColor; | 958 | QString nickColor; | ||
858 | 959 | | |||
859 | if (Preferences::self()->useColoredNicks()) | 960 | if (Preferences::self()->useColoredNicks()) | ||
860 | { | 961 | { | ||
861 | if (m_server) | 962 | if (m_server) | ||
862 | { | 963 | { | ||
863 | if (nick != m_server->getNickname()) | 964 | if (nick != m_server->getNickname()) | ||
864 | nickColor = Preferences::self()->nickColor(m_server->obtainNickInfo(nick)->getNickColor()).name(); | 965 | nickColor = Preferences::self()->nickColor(m_server->obtainNickInfo(nick)->getNickColor()).name(); | ||
▲ Show 20 Lines • Show All 1413 Lines • Show Last 20 Lines |
The comments like this probably mean something, please expand into something more like documentation.