Ticket #4116: 4116-v1.patch
File 4116-v1.patch, 8.7 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/osdtypes.cpp
660 660 661 661 OSDTypeText::OSDTypeText(const QString &name, TTFFont *font, 662 662 const QString &text, QRect displayrect, 663 float wmult, float hmult) 664 : OSDType(name) 665 { 666 m_message = text; 667 m_default_msg = text; 668 m_font = font; 663 float wmult, float hmult) : 664 OSDType(name), 665 m_lock(true), 666 m_displaysize(displayrect), 667 m_screensize(displayrect), 668 m_unbiasedsize(unbias(m_screensize, wmult, hmult)), 669 m_message(QDeepCopy<QString>(text)), 670 m_default_msg(QDeepCopy<QString>(text)), 669 671 670 m_altfont = NULL; 671 672 m_displaysize = displayrect; 673 m_screensize = displayrect; 674 m_multiline = false; 675 m_centered = false; 676 m_right = false; 677 m_usingalt = false; 672 m_font(font), 673 m_altfont(NULL), 678 674 679 m_selected = false; 680 m_button = false; 681 m_entrynum = -1; 682 m_cursorpos = 0; 675 m_centered(false), 676 m_right(false), 683 677 684 m_scroller = false; 685 m_scrollx = m_scrolly = 0; 686 m_scrollinit = false; 678 m_multiline(false), 679 m_usingalt(false), 687 680 688 m_linespacing = 1.5; 681 m_selected(false), 682 m_button(false), 683 m_entrynum(-1), 684 m_cursorpos(0), 689 685 690 m_unbiasedsize = unbias(m_screensize, wmult, hmult); 686 m_scroller(false), 687 m_scrollx(0), 688 m_scrolly(0), 691 689 692 m_draw_info_str = ""; 693 m_draw_info_len = 0; 690 m_scrollinit(false), 691 692 m_linespacing(1.5f), 693 694 m_draw_info_str(""), 695 m_draw_info_len(0) 696 { 694 697 } 695 698 696 OSDTypeText::OSDTypeText(const OSDTypeText &other) 697 : OSDType(other.m_name) 699 OSDTypeText::OSDTypeText(const OSDTypeText &other) : 700 OSDType(other.m_name), 701 m_draw_info_str(""), 702 m_draw_info_len(0) 698 703 { 699 m_message = other.m_message; 700 m_default_msg = other.m_default_msg; 704 QMutexLocker locker(&other.m_lock); 705 706 m_displaysize = other.m_displaysize; 707 m_screensize = other.m_screensize; 708 m_unbiasedsize = other.m_unbiasedsize; 709 710 m_message = QDeepCopy<QString>(other.m_message); 711 m_default_msg = QDeepCopy<QString>(other.m_default_msg); 712 701 713 m_font = other.m_font; 702 703 714 m_altfont = other.m_altfont; 704 715 705 m_displaysize = other.m_displaysize;706 m_screensize = other.m_screensize;707 m_multiline = other.m_multiline;708 716 m_centered = other.m_centered; 709 717 m_right = other.m_right; 710 m_usingalt = other.m_usingalt; 711 712 m_selected = other.m_selected; 713 m_button = other.m_button; 714 m_entrynum = other.m_entrynum; 715 m_cursorpos = other.m_cursorpos; 716 718 719 m_multiline = other.m_multiline; 720 m_usingalt = other.m_usingalt; 721 722 m_selected = other.m_selected; 723 m_button = other.m_button; 724 m_entrynum = other.m_entrynum; 725 m_cursorpos = other.m_cursorpos; 726 717 727 m_scroller = other.m_scroller; 718 728 m_scrollx = other.m_scrollx; 719 729 m_scrolly = other.m_scrolly; 730 720 731 m_scrollinit = other.m_scrollinit; 721 732 722 733 m_linespacing = other.m_linespacing; 723 724 m_unbiasedsize = other.m_unbiasedsize;725 726 m_draw_info_str = "";727 m_draw_info_len = 0;728 734 } 729 735 730 736 OSDTypeText::~OSDTypeText() … … 733 739 734 740 void OSDTypeText::SetAltFont(TTFFont *font) 735 741 { 742 QMutexLocker locker(&m_lock); 736 743 m_altfont = font; 737 744 } 738 745 … … 777 784 } 778 785 } 779 786 780 m_message = rtl_string_composer.join("");781 787 QMutexLocker locker(&m_lock); 788 m_message = QDeepCopy<QString>(rtl_string_composer.join("")); 782 789 m_cursorpos = text.length(); 783 790 m_scrollinit = false; 784 791 } 785 792 793 QString OSDTypeText::GetText(void) const 794 { 795 QMutexLocker locker(&m_lock); 796 return QDeepCopy<QString>(m_message); 797 } 798 786 799 void OSDTypeText::SetDefaultText(const QString &text) 787 800 { 788 m_message = text; 789 m_default_msg = text; 790 m_scrollinit = false; 801 QMutexLocker locker(&m_lock); 802 m_message = QDeepCopy<QString>(text); 803 m_default_msg = QDeepCopy<QString>(text); 804 m_scrollinit = false; 791 805 } 792 806 807 QString OSDTypeText::GetDefaultText(void) const 808 { 809 QMutexLocker locker(&m_lock); 810 return QDeepCopy<QString>(m_default_msg); 811 } 812 813 void OSDTypeText::SetMultiLine(bool multi) 814 { 815 QMutexLocker locker(&m_lock); 816 m_multiline = multi; 817 } 818 819 void OSDTypeText::SetCentered(bool docenter) 820 { 821 QMutexLocker locker(&m_lock); 822 m_centered = docenter; 823 } 824 825 void OSDTypeText::SetRightJustified(bool right) 826 { 827 QMutexLocker locker(&m_lock); 828 m_right = right; 829 } 830 831 void OSDTypeText::SetScrolling(int x, int y) 832 { 833 QMutexLocker locker(&m_lock); 834 m_scroller = true; 835 m_scrollx = x; 836 m_scrolly = y; 837 } 838 839 void OSDTypeText::SetLineSpacing(float linespacing) 840 { 841 QMutexLocker locker(&m_lock); 842 m_linespacing = linespacing; 843 } 844 793 845 void OSDTypeText::Reinit(float wmult, float hmult) 794 846 { 847 QMutexLocker locker(&m_lock); 795 848 m_displaysize = m_screensize = bias(m_unbiasedsize, wmult, hmult); 796 849 } 797 850 798 851 void OSDTypeText::Draw(OSDSurface *surface, int fade, int maxfade, int xoff, 799 852 int yoff) 800 853 { 854 QMutexLocker locker(&m_lock); 855 856 // initialize regular expressions once, this is a very slow operation 857 static QMutex regexp_lock; 858 static QRegExp br("%BR%"); 859 static QRegExp nl("\n"); 860 801 861 int textlength = 0; 802 862 803 863 if (m_message == QString::null) … … 815 875 816 876 if (m_multiline) 817 877 { 818 QString tmp_msg = m_message; 819 tmp_msg.replace(QRegExp("%BR%"), "\n"); 820 tmp_msg.replace(QRegExp("\n")," \n "); 878 QString tmp_msg = QDeepCopy<QString>(m_message); 879 regexp_lock.lock(); 880 tmp_msg.replace(br, "\n"); 881 tmp_msg.replace(nl," \n "); 882 regexp_lock.unlock(); 821 883 822 884 QStringList wordlist = QStringList::split(" ", tmp_msg); 823 885 int length = 0; … … 944 1006 const QString &text, int fade, int maxfade, 945 1007 int xoff, int yoff, bool double_size) 946 1008 { 1009 QMutexLocker locker(&m_lock); 1010 947 1011 if (m_draw_info_str != text) 948 1012 { 949 1013 m_draw_info_str = QDeepCopy<QString>(text); … … 1057 1121 const QString &text, int fade, int maxfade, 1058 1122 int xoff, int yoff, bool doubl) 1059 1123 { 1124 QMutexLocker locker(&m_lock); 1125 1060 1126 if (m_centered || m_right) 1061 1127 { 1062 1128 int textlength = 0; … … 1109 1175 1110 1176 bool OSDTypeText::MoveCursor(int dir) 1111 1177 { 1178 QMutexLocker locker(&m_lock); 1179 1112 1180 if (!IsEntry() || IsButton()) 1113 1181 return false; 1114 1182 … … 1119 1187 1120 1188 bool OSDTypeText::Delete(int dir) 1121 1189 { 1190 QMutexLocker locker(&m_lock); 1191 1122 1192 if (!IsEntry() || IsButton()) 1123 1193 return false; 1124 1194 … … 1141 1211 1142 1212 void OSDTypeText::InsertCharacter(QChar ch) 1143 1213 { 1214 QMutexLocker locker(&m_lock); 1215 1144 1216 if (!IsEntry() || IsButton()) 1145 1217 return; 1146 1218 -
libs/libmythtv/osdtypes.h
202 202 void SetUseAlt(bool usealt) { m_usingalt = usealt; } 203 203 204 204 void SetText(const QString &text); 205 QString GetText( ) { return m_message; }205 QString GetText(void) const; 206 206 207 207 void SetDefaultText(const QString &text); 208 QString GetDefaultText( ) { return m_default_msg; }208 QString GetDefaultText(void) const; 209 209 210 void SetMultiLine(bool multi) { m_multiline = multi; }211 bool GetMultiLine( ){ return m_multiline; }210 void SetMultiLine(bool multi); 211 bool GetMultiLine(void) const { return m_multiline; } 212 212 213 void SetCentered(bool docenter) { m_centered = docenter; }214 bool GetCentered( ){ return m_centered; }213 void SetCentered(bool docenter); 214 bool GetCentered(void) const { return m_centered; } 215 215 216 void SetRightJustified(bool right) { m_right = right; }217 bool GetRightJustified( ){ return m_right; }216 void SetRightJustified(bool right); 217 bool GetRightJustified(void) const { return m_right; } 218 218 219 void SetScrolling(int x, int y) { m_scroller = true; m_scrollx = x; 220 m_scrolly = y; } 219 void SetScrolling(int x, int y); 221 220 222 void SetLineSpacing(float linespacing) { m_linespacing = linespacing; }223 float GetLineSpacing( ){ return m_linespacing; }221 void SetLineSpacing(float linespacing); 222 float GetLineSpacing(void) const { return m_linespacing; } 224 223 225 224 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff); 226 225 bool MoveCursor(int dir); … … 245 244 const QString &text, int fade, int maxfade, 246 245 int xoff, int yoff, bool double_size = false); 247 246 247 mutable QMutex m_lock; 248 248 249 QRect m_displaysize; 249 250 QRect m_screensize; 250 251 QRect m_unbiasedsize;