author | zecke <zecke> | 2004-09-06 23:51:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-06 23:51:20 (UTC) |
commit | e6798d7ec0a3b86e412bd67faad24a737a67aa5f (patch) (side-by-side diff) | |
tree | ff10e927aff440d8dca2e0fe8976aadb3ff011d2 /noncore/net/opieirc/ircmisc.cpp | |
parent | 8f18e8b46dfaaa7e03b9ed1f3faed12da5b30cd5 (diff) | |
download | opie-e6798d7ec0a3b86e412bd67faad24a737a67aa5f.zip opie-e6798d7ec0a3b86e412bd67faad24a737a67aa5f.tar.gz opie-e6798d7ec0a3b86e412bd67faad24a737a67aa5f.tar.bz2 |
Use OKeyConfigWidget/Manager for managing next and prev tab
keyboard shortcuts
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 @@ -4,4 +4,7 @@ #include <opie2/odebug.h> +#include <opie2/oconfig.h> +#include <opie2/okeyconfigmanager.h> using namespace Opie::Core; + IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { @@ -44,2 +47,31 @@ void IRCTabWidget::setTabColor(int index, QColor color) { + +static OKeyConfigManager* s_manager = 0; +OKeyConfigManager* IRCHistoryLineEdit::keyConfigInstance() { + if ( !s_manager ) { + /* + * black list with the DeviceButtons as default + * because we do not grab the keyboard and they + * wouldn't work + */ + OKeyPair::List blackList = OKeyPair::hardwareKeys(); + blackList.append( OKeyPair::returnKey() ); + blackList.append( OKeyPair::leftArrowKey() ); + blackList.append( OKeyPair::upArrowKey() ); + blackList.append( OKeyPair::downArrowKey() ); + + s_manager = new OKeyConfigManager(new OConfig("opieirc-keys"), + "keys", blackList, + false, 0, "irc_history_line_keyconfigm" ); + s_manager->addKeyConfig( OKeyConfigItem( tr("Next Tab"), "next_tab", QPixmap(), + KeyNextTab, OKeyPair(Qt::Key_N, Qt::ControlButton) )); + s_manager->addKeyConfig( OKeyConfigItem( tr("Previous Tab"), "prev_tab", QPixmap(), + KeyPrevTab, OKeyPair(Qt::Key_P, Qt::ControlButton) )); + s_manager->load(); + } + + return s_manager; +} + + IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { @@ -68,11 +100,13 @@ void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { m_index = -1; - } else if (key == Key_N && event->state() == Qt::ControlButton) { + } + + switch( keyConfigInstance()->handleKeyEventId( event ) ) { + case KeyNextTab: emit nextTab(); return; - } else if ( ( key == Key_Y || key == Key_Z ) && event->state() == Qt::ControlButton) { - emit closeTab(); - return; - } else if (key == Key_P && event->state() == Qt::ControlButton) { + case KeyPrevTab: emit prevTab(); return; + default: + break; } |