Ticket #4454: UIRemoteEdit accepts numebrs only.patch
| File UIRemoteEdit accepts numebrs only.patch, 6.8 KB (added by , 18 years ago) |
|---|
-
libs/libmyth/mythwidgets.cpp
567 567 } 568 568 569 569 MythRemoteLineEdit::MythRemoteLineEdit(QWidget * parent, const char * name) 570 : QTextEdit(parent, name) 570 : QTextEdit(parent, name), m_acceptNumbersOnly(false) 571 571 { 572 572 my_font = NULL; 573 573 m_lines = 1; … … 576 576 577 577 MythRemoteLineEdit::MythRemoteLineEdit(const QString & contents, 578 578 QWidget * parent, const char * name) 579 : QTextEdit(parent, name) 579 : QTextEdit(parent, name), m_acceptNumbersOnly(false) 580 580 { 581 581 my_font = NULL; 582 582 m_lines = 1; … … 586 586 587 587 MythRemoteLineEdit::MythRemoteLineEdit(QFont *a_font, QWidget * parent, 588 588 const char * name) 589 : QTextEdit(parent, name) 589 : QTextEdit(parent, name), m_acceptNumbersOnly(false) 590 590 { 591 591 my_font = a_font; 592 592 m_lines = 1; … … 595 595 596 596 MythRemoteLineEdit::MythRemoteLineEdit(int lines, QWidget * parent, 597 597 const char * name) 598 : QTextEdit(parent, name) 598 : QTextEdit(parent, name), m_acceptNumbersOnly(false) 599 599 { 600 600 my_font = NULL; 601 601 m_lines = lines; … … 867 867 QString action = actions[i]; 868 868 handled = true; 869 869 870 if (action == "UP")870 if(!m_acceptNumbersOnly) 871 871 { 872 endCycle(); 873 // Need to call very base one because 874 // QTextEdit reimplements it to tab 875 // through links (even if you're in 876 // PlainText Mode !!) 877 QWidget::focusNextPrevChild(false); 878 emit tryingToLooseFocus(false); 872 if (action == "UP") 873 { 874 endCycle(); 875 // Need to call very base one because 876 // QTextEdit reimplements it to tab 877 // through links (even if you're in 878 // PlainText Mode !!) 879 QWidget::focusNextPrevChild(false); 880 emit tryingToLooseFocus(false); 881 } 882 else if (action == "DOWN") 883 { 884 endCycle(); 885 QWidget::focusNextPrevChild(true); 886 emit tryingToLooseFocus(true); 887 } 888 else if ((action == "SELECT") && 889 (!active_cycle) && 890 ((e->text().isEmpty()) || 891 (e->key() == Qt::Key_Enter) || 892 (e->key() == Qt::Key_Return))) 893 { 894 if (useVirtualKeyboard) 895 popupVirtualKeyboard(); 896 } 897 else 898 handled = false; 879 899 } 880 else if (action == "DOWN")900 else 881 901 { 882 endCycle(); 883 QWidget::focusNextPrevChild(true); 884 emit tryingToLooseFocus(true); 902 if (action == "UP") 903 { 904 // Need to call very base one because 905 // QTextEdit reimplements it to tab 906 // through links (even if you're in 907 // PlainText Mode !!) 908 QWidget::focusNextPrevChild(false); 909 emit tryingToLooseFocus(false); 910 } 911 else if (action == "DOWN") 912 { 913 QWidget::focusNextPrevChild(true); 914 emit tryingToLooseFocus(true); 915 } 916 else if(action == "LEFT") 917 { 918 backspace(); 919 return; 920 } 921 else 922 { 923 if(e->key() >= Key_0 && e->key() <= Key_9) 924 { 925 QTextEdit::keyPressEvent(e); 926 emit textChanged(this->text()); 927 } 928 } 929 return; 885 930 } 886 else if ((action == "SELECT") &&887 (!active_cycle) &&888 ((e->text().isEmpty()) ||889 (e->key() == Qt::Key_Enter) ||890 (e->key() == Qt::Key_Return)))891 {892 if (useVirtualKeyboard)893 popupVirtualKeyboard();894 }895 else896 handled = false;897 931 } 932 } 933 else if(m_acceptNumbersOnly){ 934 if(e->key() >= Key_0 && e->key() <= Key_9) 935 { 936 QTextEdit::keyPressEvent(e); 937 emit textChanged(this->text()); 938 } 939 handled = true; 898 940 } 899 941 900 942 if (handled) … … 906 948 QTextEdit::keyPressEvent(e); 907 949 emit textChanged(this->text()); 908 950 return; 909 } 951 } 910 952 911 953 switch (e->key()) 912 954 { -
libs/libmyth/uitypes.cpp
2818 2863 2819 2864 UIRemoteEditType::UIRemoteEditType(const QString &name, fontProp *font, 2820 2865 const QString &text, int dorder, QRect displayrect) 2821 : UIType(name) 2866 : UIType(name), m_acceptNumbersOnly(false) 2822 2867 { 2823 2868 m_font = font; 2824 2869 m_text = text; -
libs/libmyth/uitypes.h
969 977 void setFont(fontProp *font); 970 978 void setCharacterColors(QColor unselected, QColor selected, QColor special); 971 979 void calculateScreenArea(); 980 void setAcceptNumbersOnly(bool accept){ 981 if(edit){ 982 edit->setAcceptNumbersOnly(accept); 983 m_acceptNumbersOnly = accept; 984 } 985 } 972 986 973 987 public slots: 974 988 void takeFocusAwayFromEditor(bool up_or_down); … … 986 1000 QRect m_displaysize; 987 1001 QString m_text; 988 1002 fontProp *m_font; 989 QColor m_unselected; 1003 QColor m_unselected; 990 1004 QColor m_selected; 991 1005 QColor m_special; 1006 bool m_acceptNumbersOnly; 992 1007 993 1008 MythThemedDialog* m_parentDialog; 994 1009 }; -
libs/libmyth/mythwidgets.h
197 197 void del(); 198 198 void setPopupPosition(PopupPosition pos) { popupPosition = pos; }; 199 199 PopupPosition getPopupPosition(void) { return popupPosition; }; 200 void setAcceptNumbersOnly(bool accept){ 201 m_acceptNumbersOnly = accept; 202 } 200 203 201 204 virtual QString text(); 202 205 … … 262 265 VirtualKeyboard *popup; 263 266 bool useVirtualKeyboard; 264 267 PopupPosition popupPosition; 268 bool m_acceptNumbersOnly; 265 269 }; 266 270 267 271 class MPUBLIC MythTable : public QTable
