Split.cpp
// Initialize chat widget-wide hotkeys
// CTRL+W: Close Split
createShortcut(this, "CTRL+W", &Split::deleteFromContainer);
// CTRL+R: Change Channel
createShortcut(this, "CTRL+R", &Split::changeChannel);
// CTRL+F: Search
createShortcut(this, "CTRL+F", &Split::showSearch);
// F5: reload emotes
createShortcut(this, "F5", &Split::reloadChannelAndSubscriberEmotes);
// F10
createShortcut(this, "F10", [] {
auto *popup = new DebugPopup;
popup->setAttribute(Qt::WA_DeleteOnClose);
popup->show();
});
Window.cpp
// Window::addDebugStuff
createWindowShortcut(this, "F6", [=] {
const auto &messages = miscMessages;
static int index = 0;
auto app = getApp();
const auto &msg = messages[index++ % messages.size()];
app->twitch.server->addFakeMessage(msg);
});
createWindowShortcut(this, "F7", [=] {
const auto &messages = cheerMessages;
static int index = 0;
const auto &msg = messages[index++ % messages.size()];
getApp()->twitch.server->addFakeMessage(msg);
});
createWindowShortcut(this, "F8", [=] {
const auto &messages = linkMessages;
static int index = 0;
auto app = getApp();
const auto &msg = messages[index++ % messages.size()];
app->twitch.server->addFakeMessage(msg);
});
createWindowShortcut(this, "F9", [=] {
auto *dialog = new WelcomeDialog();
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
});
// window::addshortcuts
// Open settings
createWindowShortcut(this, "CTRL+P", [] { SettingsDialog::showDialog(); });
// Switch tab
createWindowShortcut(this, "CTRL+T", [this] {
this->notebook_->getOrAddSelectedPage()->appendNewSplit(true);
});
// CTRL + 1-8 to open corresponding tab.
for (auto i = 0; i < 8; i++)
{
char hotkey[7];
std::sprintf(hotkey, "CTRL+%d", i + 1);
const auto openTab = [this, i] { this->notebook_->selectIndex(i); };
createWindowShortcut(this, hotkey, openTab);
}
createWindowShortcut(this, "CTRL+9",
[this] { this->notebook_->selectLastTab(); });
createWindowShortcut(this, "CTRL+TAB",
[this] { this->notebook_->selectNextTab(); });
createWindowShortcut(this, "CTRL+SHIFT+TAB",
[this] { this->notebook_->selectPreviousTab(); });
// Zoom in
{
auto s = new QShortcut(QKeySequence::ZoomIn, this);
s->setContext(Qt::WindowShortcut);
QObject::connect(s, &QShortcut::activated, this, [] {
getSettings()->setClampedUiScale(
getSettings()->getClampedUiScale() + 0.1f);
});
}
// Zoom out
{
auto s = new QShortcut(QKeySequence::ZoomOut, this);
s->setContext(Qt::WindowShortcut);
QObject::connect(s, &QShortcut::activated, this, [] {
getSettings()->setClampedUiScale(
getSettings()->getClampedUiScale() - 0.1f);
});
}
// New tab
createWindowShortcut(this, "CTRL+SHIFT+T",
[this] { this->notebook_->addPage(true); });
// Close tab
createWindowShortcut(this, "CTRL+SHIFT+W",
[this] { this->notebook_->removeCurrentPage(); });
// Reopen last closed split
createWindowShortcut(this, "CTRL+G", [this] {
if (ClosedSplits::empty())
{
return;
}
ClosedSplits::SplitInfo si = ClosedSplits::pop();
SplitContainer *splitContainer{nullptr};
if (si.tab)
{
splitContainer = dynamic_cast<SplitContainer *>(si.tab->page);
}
if (!splitContainer)
{
splitContainer = this->notebook_->getOrAddSelectedPage();
}
this->notebook_->select(splitContainer);
Split *split = new Split(splitContainer);
split->setChannel(
getApp()->twitch.server->getOrAddChannel(si.channelName));
splitContainer->appendSplit(split);
});
createWindowShortcut(this, "CTRL+H", [this] {
getSettings()->hideSimilar.setValue(!getSettings()->hideSimilar);
getApp()->windows->forceLayoutChannelViews();
});
// Window::addMenuBar
// Window menu.
QMenu *windowMenu = mainMenu->addMenu(QString("Window"));
QAction *nextTab = windowMenu->addAction(QString("Select next tab"));
nextTab->setShortcuts({QKeySequence("Meta+Tab")});
connect(nextTab, &QAction::triggered, this,
[=] { this->notebook_->selectNextTab(); });
QAction *prevTab = windowMenu->addAction(QString("Select previous tab"));
prevTab->setShortcuts({QKeySequence("Meta+Shift+Tab")});
connect(prevTab, &QAction::triggered, this,
[=] { this->notebook_->selectPreviousTab(); });
EmotePopup.cpp
// constructor
createWindowShortcut(this, "CTRL+Tab", [=] { notebook->selectNextTab(); });
createWindowShortcut(this, "CTRL+Shift+Tab",
[=] { notebook->selectPreviousTab(); });
Created
May 3, 2020 13:27
-
-
Save Mm2PL/bffc294068248c94001e69b9c538e48e to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment