mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
parent
29046b3aa1
commit
26170e4fdb
|
@ -14,5 +14,13 @@ inline void CreateShortcut(WidgetType *w, const char *key, Func func)
|
|||
QObject::connect(s, &QShortcut::activated, w, func);
|
||||
}
|
||||
|
||||
template <typename WidgetType, typename Func>
|
||||
inline void CreateWindowShortcut(WidgetType *w, const char *key, Func func)
|
||||
{
|
||||
auto s = new QShortcut(QKeySequence(key), w);
|
||||
s->setContext(Qt::WindowShortcut);
|
||||
QObject::connect(s, &QShortcut::activated, w, func);
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -95,6 +95,15 @@ void Notebook::removePage(SplitContainer *page)
|
|||
this->performLayout();
|
||||
}
|
||||
|
||||
void Notebook::removeCurrentPage()
|
||||
{
|
||||
if (this->selectedPage == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->removePage(this->selectedPage);
|
||||
}
|
||||
|
||||
void Notebook::select(SplitContainer *page)
|
||||
{
|
||||
if (page == this->selectedPage) {
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
SplitContainer *addPage(const std::string &uuid, bool select = false);
|
||||
|
||||
void removePage(SplitContainer *page);
|
||||
void removeCurrentPage();
|
||||
void select(SplitContainer *page);
|
||||
void selectIndex(unsigned index);
|
||||
|
||||
|
|
|
@ -58,20 +58,26 @@ Window::Window(const QString &windowName, singletons::ThemeManager &_themeManage
|
|||
|
||||
/// Initialize program-wide hotkeys
|
||||
// CTRL+P: Open Settings Dialog
|
||||
CreateShortcut(this, "CTRL+P", [] {
|
||||
CreateWindowShortcut(this, "CTRL+P", [] {
|
||||
SettingsDialog::showDialog(); //
|
||||
});
|
||||
|
||||
// CTRL+Number: Switch to n'th tab
|
||||
CreateShortcut(this, "CTRL+1", [this] { this->notebook.selectIndex(0); });
|
||||
CreateShortcut(this, "CTRL+2", [this] { this->notebook.selectIndex(1); });
|
||||
CreateShortcut(this, "CTRL+3", [this] { this->notebook.selectIndex(2); });
|
||||
CreateShortcut(this, "CTRL+4", [this] { this->notebook.selectIndex(3); });
|
||||
CreateShortcut(this, "CTRL+5", [this] { this->notebook.selectIndex(4); });
|
||||
CreateShortcut(this, "CTRL+6", [this] { this->notebook.selectIndex(5); });
|
||||
CreateShortcut(this, "CTRL+7", [this] { this->notebook.selectIndex(6); });
|
||||
CreateShortcut(this, "CTRL+8", [this] { this->notebook.selectIndex(7); });
|
||||
CreateShortcut(this, "CTRL+9", [this] { this->notebook.selectIndex(8); });
|
||||
CreateWindowShortcut(this, "CTRL+1", [this] { this->notebook.selectIndex(0); });
|
||||
CreateWindowShortcut(this, "CTRL+2", [this] { this->notebook.selectIndex(1); });
|
||||
CreateWindowShortcut(this, "CTRL+3", [this] { this->notebook.selectIndex(2); });
|
||||
CreateWindowShortcut(this, "CTRL+4", [this] { this->notebook.selectIndex(3); });
|
||||
CreateWindowShortcut(this, "CTRL+5", [this] { this->notebook.selectIndex(4); });
|
||||
CreateWindowShortcut(this, "CTRL+6", [this] { this->notebook.selectIndex(5); });
|
||||
CreateWindowShortcut(this, "CTRL+7", [this] { this->notebook.selectIndex(6); });
|
||||
CreateWindowShortcut(this, "CTRL+8", [this] { this->notebook.selectIndex(7); });
|
||||
CreateWindowShortcut(this, "CTRL+9", [this] { this->notebook.selectIndex(8); });
|
||||
|
||||
// CTRL+SHIFT+T: New tab
|
||||
CreateWindowShortcut(this, "CTRL+SHIFT+T", [this] { this->notebook.addNewPage(); });
|
||||
|
||||
// CTRL+SHIFT+W: Close current tab
|
||||
CreateWindowShortcut(this, "CTRL+SHIFT+W", [this] { this->notebook.removeCurrentPage(); });
|
||||
}
|
||||
|
||||
void Window::repaintVisibleChatWidgets(Channel *channel)
|
||||
|
|
Loading…
Reference in a new issue