Diffstat (limited to 'noncore/net/opieirc/ircmisc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp index df6f874..9b9bff8 100644 --- a/noncore/net/opieirc/ircmisc.cpp +++ b/noncore/net/opieirc/ircmisc.cpp | |||
@@ -2,8 +2,11 @@ | |||
2 | 2 | ||
3 | /* OPIE */ | 3 | /* OPIE */ |
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | #include <opie2/oconfig.h> | ||
6 | #include <opie2/okeyconfigmanager.h> | ||
5 | using namespace Opie::Core; | 7 | using namespace Opie::Core; |
6 | 8 | ||
9 | |||
7 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { | 10 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { |
8 | } | 11 | } |
9 | 12 | ||
@@ -42,6 +45,35 @@ void IRCTabWidget::setTabColor(int index, QColor color) { | |||
42 | } | 45 | } |
43 | 46 | ||
44 | 47 | ||
48 | |||
49 | static OKeyConfigManager* s_manager = 0; | ||
50 | OKeyConfigManager* IRCHistoryLineEdit::keyConfigInstance() { | ||
51 | if ( !s_manager ) { | ||
52 | /* | ||
53 | * black list with the DeviceButtons as default | ||
54 | * because we do not grab the keyboard and they | ||
55 | * wouldn't work | ||
56 | */ | ||
57 | OKeyPair::List blackList = OKeyPair::hardwareKeys(); | ||
58 | blackList.append( OKeyPair::returnKey() ); | ||
59 | blackList.append( OKeyPair::leftArrowKey() ); | ||
60 | blackList.append( OKeyPair::upArrowKey() ); | ||
61 | blackList.append( OKeyPair::downArrowKey() ); | ||
62 | |||
63 | s_manager = new OKeyConfigManager(new OConfig("opieirc-keys"), | ||
64 | "keys", blackList, | ||
65 | false, 0, "irc_history_line_keyconfigm" ); | ||
66 | s_manager->addKeyConfig( OKeyConfigItem( tr("Next Tab"), "next_tab", QPixmap(), | ||
67 | KeyNextTab, OKeyPair(Qt::Key_N, Qt::ControlButton) )); | ||
68 | s_manager->addKeyConfig( OKeyConfigItem( tr("Previous Tab"), "prev_tab", QPixmap(), | ||
69 | KeyPrevTab, OKeyPair(Qt::Key_P, Qt::ControlButton) )); | ||
70 | s_manager->load(); | ||
71 | } | ||
72 | |||
73 | return s_manager; | ||
74 | } | ||
75 | |||
76 | |||
45 | IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { | 77 | IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { |
46 | m_index = -1; | 78 | m_index = -1; |
47 | installEventFilter(this); | 79 | installEventFilter(this); |
@@ -66,15 +98,17 @@ void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { | |||
66 | } else if (key == Key_Return) { | 98 | } else if (key == Key_Return) { |
67 | m_history.prepend(text()); | 99 | m_history.prepend(text()); |
68 | m_index = -1; | 100 | m_index = -1; |
69 | } else if (key == Key_N && event->state() == Qt::ControlButton) { | 101 | } |
102 | |||
103 | switch( keyConfigInstance()->handleKeyEventId( event ) ) { | ||
104 | case KeyNextTab: | ||
70 | emit nextTab(); | 105 | emit nextTab(); |
71 | return; | 106 | return; |
72 | } else if ( ( key == Key_Y || key == Key_Z ) && event->state() == Qt::ControlButton) { | 107 | case KeyPrevTab: |
73 | emit closeTab(); | ||
74 | return; | ||
75 | } else if (key == Key_P && event->state() == Qt::ControlButton) { | ||
76 | emit prevTab(); | 108 | emit prevTab(); |
77 | return; | 109 | return; |
110 | default: | ||
111 | break; | ||
78 | } | 112 | } |
79 | 113 | ||
80 | QLineEdit::keyPressEvent(event); | 114 | QLineEdit::keyPressEvent(event); |