+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2005-09 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_1 || Qt::Key_9 < key)
- return QObject::eventFilter(obj, event);
-
- int mod = keyEvent->modifiers() & ~(Qt::KeypadModifier|Qt::ShiftModifier);
- if(mod == bindModifier) {
- bindKey(key);
- return true;
- }
-
- if(mod == 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-09 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 "inputwidget.h"
#include "irclistmodel.h"
#include "ircconnectionwizard.h"
-#include "jumpkeyhandler.h"
#include "legacysystemtray.h"
#include "msgprocessorstatuswidget.h"
#include "nicklistwidget.h"
setWindowTitle("Quassel IRC");
setWindowIconText("Quassel IRC");
updateIcon();
-
- installEventFilter(new JumpKeyHandler(this));
}
void MainWin::init() {
coll->addAction("JumpHotBuffer", new Action(tr("Jump to hot chat"), coll,
this, SLOT(on_jumpHotBuffer_triggered()), QKeySequence(Qt::META + Qt::Key_A)));
+
+ // Jump keys
+#ifdef Q_WS_MAC
+ const int bindModifier = Qt::ControlModifier | Qt::AltModifier;
+ const int jumpModifier = Qt::ControlModifier;
+#else
+ const int bindModifier = Qt::ControlModifier;
+ const int jumpModifier = Qt::AltModifier;
+#endif
+
+ coll->addAction("BindJumpKey0", new Action(tr("Set Quick Access #0"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_0)))->setProperty("Index", 0);
+ coll->addAction("BindJumpKey1", new Action(tr("Set Quick Access #1"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_1)))->setProperty("Index", 1);
+ coll->addAction("BindJumpKey2", new Action(tr("Set Quick Access #2"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_2)))->setProperty("Index", 2);
+ coll->addAction("BindJumpKey3", new Action(tr("Set Quick Access #3"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_3)))->setProperty("Index", 3);
+ coll->addAction("BindJumpKey4", new Action(tr("Set Quick Access #4"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_4)))->setProperty("Index", 4);
+ coll->addAction("BindJumpKey5", new Action(tr("Set Quick Access #5"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_5)))->setProperty("Index", 5);
+ coll->addAction("BindJumpKey6", new Action(tr("Set Quick Access #6"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_6)))->setProperty("Index", 6);
+ coll->addAction("BindJumpKey7", new Action(tr("Set Quick Access #7"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_7)))->setProperty("Index", 7);
+ coll->addAction("BindJumpKey8", new Action(tr("Set Quick Access #8"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_8)))->setProperty("Index", 8);
+ coll->addAction("BindJumpKey9", new Action(tr("Set Quick Access #9"), coll, this, SLOT(bindJumpKey()),
+ QKeySequence(bindModifier + Qt::Key_9)))->setProperty("Index", 9);
+
+ coll->addAction("JumpKey0", new Action(tr("Quick Access #0"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_0)))->setProperty("Index", 0);
+ coll->addAction("JumpKey1", new Action(tr("Quick Access #1"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_1)))->setProperty("Index", 1);
+ coll->addAction("JumpKey2", new Action(tr("Quick Access #2"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_2)))->setProperty("Index", 2);
+ coll->addAction("JumpKey3", new Action(tr("Quick Access #3"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_3)))->setProperty("Index", 3);
+ coll->addAction("JumpKey4", new Action(tr("Quick Access #4"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_4)))->setProperty("Index", 4);
+ coll->addAction("JumpKey5", new Action(tr("Quick Access #5"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_5)))->setProperty("Index", 5);
+ coll->addAction("JumpKey6", new Action(tr("Quick Access #6"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_6)))->setProperty("Index", 6);
+ coll->addAction("JumpKey7", new Action(tr("Quick Access #7"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_7)))->setProperty("Index", 7);
+ coll->addAction("JumpKey8", new Action(tr("Quick Access #8"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_8)))->setProperty("Index", 8);
+ coll->addAction("JumpKey9", new Action(tr("Quick Access #9"), coll, this, SLOT(onJumpKey()),
+ QKeySequence(jumpModifier + Qt::Key_9)))->setProperty("Index", 9);
}
void MainWin::setupMenus() {
Client::bufferModel()->switchToBuffer(bufferId);
}
+void MainWin::onJumpKey() {
+ QAction *action = qobject_cast<QAction *>(sender());
+ if(!action || !Client::bufferModel())
+ return;
+ int idx = action->property("Index").toInt();
+
+ if(_jumpKeyMap.isEmpty())
+ _jumpKeyMap = CoreAccountSettings().jumpKeyMap();
+
+ if(!_jumpKeyMap.contains(idx))
+ return;
+
+ BufferId buffer = _jumpKeyMap.value(idx);
+ if(buffer.isValid())
+ Client::bufferModel()->switchToBuffer(buffer);
+
+}
+
+void MainWin::bindJumpKey() {
+ QAction *action = qobject_cast<QAction *>(sender());
+ if(!action || !Client::bufferModel())
+ return;
+ int idx = action->property("Index").toInt();
+
+ _jumpKeyMap[idx] = Client::bufferModel()->currentBuffer();
+ CoreAccountSettings().setJumpKeyMap(_jumpKeyMap);
+}
+
void MainWin::on_actionDebugNetworkModel_triggered() {
QTreeView *view = new QTreeView;
view->setAttribute(Qt::WA_DeleteOnClose);