summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircmisc.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/ircmisc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmisc.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp
index 9b9bff8..6fc5ba0 100644
--- a/noncore/net/opieirc/ircmisc.cpp
+++ b/noncore/net/opieirc/ircmisc.cpp
@@ -46,88 +46,93 @@ void IRCTabWidget::setTabColor(int index, QColor color) {
46 46
47 47
48 48
49static OKeyConfigManager* s_manager = 0; 49static OKeyConfigManager* s_manager = 0;
50OKeyConfigManager* IRCHistoryLineEdit::keyConfigInstance() { 50OKeyConfigManager* IRCHistoryLineEdit::keyConfigInstance() {
51 if ( !s_manager ) { 51 if ( !s_manager ) {
52 /* 52 /*
53 * black list with the DeviceButtons as default 53 * black list with the DeviceButtons as default
54 * because we do not grab the keyboard and they 54 * because we do not grab the keyboard and they
55 * wouldn't work 55 * wouldn't work
56 */ 56 */
57 OKeyPair::List blackList = OKeyPair::hardwareKeys(); 57 OKeyPair::List blackList = OKeyPair::hardwareKeys();
58 blackList.append( OKeyPair::returnKey() ); 58 blackList.append( OKeyPair::returnKey() );
59 blackList.append( OKeyPair::leftArrowKey() ); 59 blackList.append( OKeyPair::leftArrowKey() );
60 blackList.append( OKeyPair::upArrowKey() ); 60 blackList.append( OKeyPair::upArrowKey() );
61 blackList.append( OKeyPair::downArrowKey() ); 61 blackList.append( OKeyPair::downArrowKey() );
62 62
63 s_manager = new OKeyConfigManager(new OConfig("opieirc-keys"), 63 s_manager = new OKeyConfigManager(new OConfig("opieirc-keys"),
64 "keys", blackList, 64 "keys", blackList,
65 false, 0, "irc_history_line_keyconfigm" ); 65 false, 0, "irc_history_line_keyconfigm" );
66 s_manager->addKeyConfig( OKeyConfigItem( tr("Next Tab"), "next_tab", QPixmap(), 66 s_manager->addKeyConfig( OKeyConfigItem( tr("Next Tab"), "next_tab", QPixmap(),
67 KeyNextTab, OKeyPair(Qt::Key_N, Qt::ControlButton) )); 67 KeyNextTab, OKeyPair(Qt::Key_N, Qt::ControlButton) ));
68 s_manager->addKeyConfig( OKeyConfigItem( tr("Previous Tab"), "prev_tab", QPixmap(), 68 s_manager->addKeyConfig( OKeyConfigItem( tr("Previous Tab"), "prev_tab", QPixmap(),
69 KeyPrevTab, OKeyPair(Qt::Key_P, Qt::ControlButton) )); 69 KeyPrevTab, OKeyPair(Qt::Key_P, Qt::ControlButton) ));
70 s_manager->addKeyConfig( OKeyConfigItem( tr("Close Tab"), "close_tab",
71 QPixmap(), KeyCloseTab,
72 OKeyPair(Qt::Key_C, Qt::ControlButton) ));
70 s_manager->load(); 73 s_manager->load();
71 } 74 }
72 75
73 return s_manager; 76 return s_manager;
74} 77}
75 78
76 79
77IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { 80IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) {
78 m_index = -1; 81 m_index = -1;
79 installEventFilter(this); 82 installEventFilter(this);
80} 83}
81 84
82void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { 85void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) {
83 int key = event->key(); 86 int key = event->key();
84 if (key == Key_Up) { 87 if (key == Key_Up) {
85 if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { 88 if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) {
86 m_index++; 89 m_index++;
87 setText(m_history[m_index]); 90 setText(m_history[m_index]);
88 } 91 }
89 } else if (key == Key_Down) { 92 } else if (key == Key_Down) {
90 if (m_history.count() > 0 && m_index > 0) { 93 if (m_history.count() > 0 && m_index > 0) {
91 m_index--; 94 m_index--;
92 setText(m_history[m_index]); 95 setText(m_history[m_index]);
93 } 96 }
94 if (m_index == 0) { 97 if (m_index == 0) {
95 m_index = -1; 98 m_index = -1;
96 setText(""); 99 setText("");
97 } 100 }
98 } else if (key == Key_Return) { 101 } else if (key == Key_Return) {
99 m_history.prepend(text()); 102 m_history.prepend(text());
100 m_index = -1; 103 m_index = -1;
101 } 104 }
102 105
103 switch( keyConfigInstance()->handleKeyEventId( event ) ) { 106 switch( keyConfigInstance()->handleKeyEventId( event ) ) {
104 case KeyNextTab: 107 case KeyNextTab:
105 emit nextTab(); 108 emit nextTab();
106 return; 109 return;
107 case KeyPrevTab: 110 case KeyPrevTab:
108 emit prevTab(); 111 emit prevTab();
109 return; 112 return;
113 case KeyCloseTab:
114 emit closeTab();
110 default: 115 default:
111 break; 116 break;
112 } 117 }
113 118
114 QLineEdit::keyPressEvent(event); 119 QLineEdit::keyPressEvent(event);
115} 120}
116 121
117bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) { 122bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) {
118 if (event->type() == QEvent::KeyPress) { 123 if (event->type() == QEvent::KeyPress) {
119 QKeyEvent *k = (QKeyEvent *) event; 124 QKeyEvent *k = (QKeyEvent *) event;
120 /* Catch tab characters */ 125 /* Catch tab characters */
121 if (k->key() == Key_Tab) { 126 if (k->key() == Key_Tab) {
122 emit nextTab(); 127 emit nextTab();
123 return TRUE; 128 return TRUE;
124 } 129 }
125 } 130 }
126 return QLineEdit::eventFilter(object, event); 131 return QLineEdit::eventFilter(object, event);
127} 132}
128 133
129 134
130void IRCHistoryLineEdit::setEditFocus() { 135void IRCHistoryLineEdit::setEditFocus() {
131 setActiveWindow(); 136 setActiveWindow();
132 setFocus(); 137 setFocus();
133} 138}