X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=1362e850845e128f6efc99b3b6d897f8baabffd5;hp=cdfa65bca490698e5fe6cd616c830e2425ef4256;hb=017602cf14ad2fbfffed4a71a613d5eaa87e43c9;hpb=1cf8bbe1e5805e28fa5ea6e6083a5b459247f8f0 diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index cdfa65bc..1362e850 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -69,7 +69,6 @@ #include "inputwidget.h" #include "irclistmodel.h" #include "ircconnectionwizard.h" -#include "jumpkeyhandler.h" #include "legacysystemtray.h" #include "msgprocessorstatuswidget.h" #include "nicklistwidget.h" @@ -150,8 +149,6 @@ MainWin::MainWin(QWidget *parent) setWindowTitle("Quassel IRC"); setWindowIconText("Quassel IRC"); updateIcon(); - - installEventFilter(new JumpKeyHandler(this)); } void MainWin::init() { @@ -371,6 +368,57 @@ void MainWin::setupActions() { 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() { @@ -1152,6 +1200,34 @@ void MainWin::on_jumpHotBuffer_triggered() { Client::bufferModel()->switchToBuffer(bufferId); } +void MainWin::onJumpKey() { + QAction *action = qobject_cast(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(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);