#include "client.h"
#include "networkmodel.h"
+#include "jumpkeyhandler.h"
InputWidget::InputWidget(QWidget *parent)
: QWidget(parent),
connect(ui.ownNick, SIGNAL(activated(QString)), this, SLOT(changeNick(QString)));
connect(this, SIGNAL(userInput(BufferInfo, QString)), Client::instance(), SIGNAL(sendInput(BufferInfo, QString)));
setFocusProxy(ui.inputEdit);
+
+ ui.inputEdit->installEventFilter(new JumpKeyHandler(this));
}
InputWidget::~InputWidget() {
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-08 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "jumpkeyhandler.h"
+
+#include <QKeyEvent>
+
+#include "client.h"
+#include "networkmodel.h"
+#include "buffermodel.h"
+
+JumpKeyHandler::JumpKeyHandler(QObject *parent)
+ : QObject(parent),
+#ifdef Q_WS_MAC
+ bindModifier(Qt::ControlModifier | Qt::AltModifier),
+ jumpModifier(Qt::ControlModifier)
+#else
+ bindModifier(Qt::ControlModifier),
+ jumpModifier(Qt::AltModifier)
+#endif
+{
+}
+
+bool JumpKeyHandler::eventFilter(QObject *obj, QEvent *event) {
+ if(event->type() != QEvent::KeyPress)
+ return QObject::eventFilter(obj, event);
+
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+
+ const int key = keyEvent->key();
+
+ if(key < Qt::Key_0 || Qt::Key_9 < key)
+ return QObject::eventFilter(obj, event);
+
+ if(keyEvent->modifiers() == bindModifier) {
+ bindKey(key);
+ return true;
+ }
+
+ if(keyEvent->modifiers() == jumpModifier) {
+ jumpKey(key);
+ return true;
+ }
+
+ return false;
+}
+
+void JumpKeyHandler::bindKey(int key) {
+ QModelIndex bufferIdx = Client::bufferModel()->standardSelectionModel()->currentIndex();
+ NetworkId netId = bufferIdx.data(NetworkModel::NetworkIdRole).value<NetworkId>();
+ const Network *net = Client::network(netId);
+ if(!net)
+ return;
+
+ QString bufferName = bufferIdx.sibling(bufferIdx.row(), 0).data().toString();
+ BufferId bufferId = bufferIdx.data(NetworkModel::BufferIdRole).value<BufferId>();
+
+ _keyboardJump[key] = bufferId;
+ CoreAccountSettings().setJumpKeyMap(_keyboardJump);
+ //emit statusMessage(tr("Bound Buffer %1::%2 to Key %3").arg(net->networkName()).arg(bufferName).arg(key - Qt::Key_0), 10000);
+ //statusBar()->showMessage(tr("Bound Buffer %1::%2 to Key %3").arg(net->networkName()).arg(bufferName).arg(key - Qt::Key_0), 10000);
+}
+
+void JumpKeyHandler::jumpKey(int key) {
+ if(key < Qt::Key_0 || Qt::Key_9 < key)
+ return;
+
+ if(_keyboardJump.isEmpty())
+ _keyboardJump = CoreAccountSettings().jumpKeyMap();
+
+ if(!_keyboardJump.contains(key))
+ return;
+
+ QModelIndex source_bufferIdx = Client::networkModel()->bufferIndex(_keyboardJump[key]);
+ QModelIndex bufferIdx = Client::bufferModel()->mapFromSource(source_bufferIdx);
+
+ if(bufferIdx.isValid())
+ Client::bufferModel()->standardSelectionModel()->setCurrentIndex(bufferIdx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-08 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef JUMPKEYHANDLER_H
+#define JUMPKEYHANDLER_H
+
+#include <QObject>
+#include <QHash>
+#include "types.h"
+
+class JumpKeyHandler : public QObject {
+ Q_OBJECT
+
+public:
+ JumpKeyHandler(QObject *parent = 0);
+
+ void jumpKey(int key);
+ void bindKey(int key);
+
+ virtual bool eventFilter(QObject *obj, QEvent *event);
+
+private:
+ int bindModifier;
+ int jumpModifier;
+ QHash<int, BufferId> _keyboardJump;
+};
+
+#endif //JUMPKEYHANDLER_H
#include "verticaldock.h"
#include "uisettings.h"
#include "qtuisettings.h"
+#include "jumpkeyhandler.h"
#include "selectionmodelsynchronizer.h"
#include "mappedselectionmodel.h"
#include "debugconsole.h"
-MainWin::MainWin(QtUi *_gui, QWidget *parent) : QMainWindow(parent), gui(_gui) {
+MainWin::MainWin(QtUi *_gui, QWidget *parent)
+ : QMainWindow(parent),
+ gui(_gui),
+ settingsDlg(new SettingsDlg(this)),
+ debugConsole(new DebugConsole(this))
+{
ui.setupUi(this);
setWindowTitle("Quassel IRC");
setWindowIcon(QIcon(":icons/quassel-icon.png"));
setWindowIconText("Quassel IRC");
statusBar()->showMessage(tr("Waiting for core..."));
- settingsDlg = new SettingsDlg(this);
- debugConsole = new DebugConsole(this);
+
+ installEventFilter(new JumpKeyHandler(this));
}
void MainWin::init() {
else net->requestDisconnect();
}
-void MainWin::keyPressEvent(QKeyEvent *event) {
-#ifdef Q_WS_MAC
- int bindModifier = Qt::ControlModifier | Qt::AltModifier;
- int jumpModifier = Qt::ControlModifier;
-#else
- int bindModifier = Qt::ControlModifier;
- int jumpModifier = Qt::AltModifier;
-#endif
-
- if(event->modifiers() == bindModifier) {
- event->accept();
- return bindKey(event->key());
- }
-
- if(event->modifiers() == jumpModifier) {
- event->accept();
- return jumpKey(event->key());
- }
-
- event->ignore();
-}
-
-void MainWin::bindKey(int key) {
- if(key < Qt::Key_0 || Qt::Key_9 < key)
- return;
-
- QModelIndex bufferIdx = Client::bufferModel()->standardSelectionModel()->currentIndex();
- NetworkId netId = bufferIdx.data(NetworkModel::NetworkIdRole).value<NetworkId>();
- const Network *net = Client::network(netId);
- if(!net)
- return;
-
- QString bufferName = bufferIdx.sibling(bufferIdx.row(), 0).data().toString();
- BufferId bufferId = bufferIdx.data(NetworkModel::BufferIdRole).value<BufferId>();
-
- _keyboardJump[key] = bufferId;
- CoreAccountSettings().setJumpKeyMap(_keyboardJump);
- statusBar()->showMessage(tr("Bound Buffer %1::%2 to Key %3").arg(net->networkName()).arg(bufferName).arg(key - Qt::Key_0), 10000);
-}
-
-void MainWin::jumpKey(int key) {
- if(key < Qt::Key_0 || Qt::Key_9 < key)
- return;
-
- if(_keyboardJump.isEmpty())
- _keyboardJump = CoreAccountSettings().jumpKeyMap();
-
- if(!_keyboardJump.contains(key))
- return;
-
- QModelIndex source_bufferIdx = Client::networkModel()->bufferIndex(_keyboardJump[key]);
- QModelIndex bufferIdx = Client::bufferModel()->mapFromSource(source_bufferIdx);
-
- if(bufferIdx.isValid())
- Client::bufferModel()->standardSelectionModel()->setCurrentIndex(bufferIdx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
-
-}
protected:
void closeEvent(QCloseEvent *event);
virtual void changeEvent(QEvent *event);
- virtual void keyPressEvent(QKeyEvent *event);
protected slots:
void connectedToCore();
void enableMenus();
- void bindKey(int key);
- void jumpKey(int key);
-
- QHash<int, BufferId> _keyboardJump;
QSystemTrayIcon *systray;
CoreConnectDlg *coreConnectDlg;
SettingsDlg *settingsDlg;
+ DebugConsole *debugConsole;
BufferId currentBuffer;
QString currentProfile;
QAction *actionEditNetworks;
QList<QAction *> networkActions;
- DebugConsole *debugConsole;
friend class QtUi;
};
SRCS += aboutdlg.cpp bufferwidget.cpp chatline-old.cpp chatwidget.cpp coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \
mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \
- topicwidget.cpp verticaldock.cpp
+ topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
HDRS += aboutdlg.h bufferwidget.h chatline-old.h chatwidget.h coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \
coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \
- topicwidget.h verticaldock.h
+ topicwidget.h verticaldock.h jumpkeyhandler.h
FORMNAMES = aboutdlg.ui mainwin.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \
settingspagedlg.ui topicwidget.ui debugconsole.ui inputwidget.ui \
idx(0),
tabCompleter(new TabCompleter(this))
{
-
-#ifdef Q_WS_MAC
- bindModifier = Qt::ControlModifier | Qt::AltModifier;
- jumpModifier = Qt::ControlModifier;
-#else
- bindModifier = Qt::ControlModifier;
- jumpModifier = Qt::AltModifier;
-#endif
-
connect(this, SIGNAL(returnPressed()), this, SLOT(on_returnPressed()));
connect(this, SIGNAL(textChanged(QString)), this, SLOT(on_textChanged(QString)));
-
}
InputLine::~InputLine() {
}
void InputLine::keyPressEvent(QKeyEvent * event) {
- if((event->modifiers() == jumpModifier || event->modifiers() == bindModifier) &&
- (Qt::Key_0 <= event->key() && event->key() <= Qt::Key_9)) {
- event->ignore();
- return;
- }
-
if(event->key() == Qt::Key_Up) {
if(idx > 0) { idx--; setText(history[idx]); }
event->accept();
{ using namespace Global;
quasselVersion = "0.2.0-pre";
- quasselDate = "2008-02-08";
- quasselBuild = 489;
+ quasselDate = "2008-02-10";
+ quasselBuild = 495;
//! Minimum client build number the core needs
clientBuildNeeded = 480;