From 2c74e980237d6bdbaf2186730ed263bec3649395 Mon Sep 17 00:00:00 2001 From: fourtf Date: Thu, 13 Aug 2020 18:02:23 +0200 Subject: [PATCH] edited split dropdown --- src/widgets/Window.cpp | 11 +++++++ .../settingspages/KeyboardSettingsPage.cpp | 2 ++ src/widgets/splits/SplitContainer.cpp | 12 ++++++++ src/widgets/splits/SplitContainer.hpp | 3 +- src/widgets/splits/SplitHeader.cpp | 30 +++++++++++-------- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 2cf06b444..115902a1a 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -327,6 +327,17 @@ void Window::addShortcuts() createWindowShortcut(this, "CTRL+SHIFT+TAB", [this] { this->notebook_->selectPreviousTab(); }); + createWindowShortcut(this, "CTRL+N", [this] { + if (auto page = dynamic_cast( + this->notebook_->getSelectedPage())) + { + if (auto split = page->getSelectedSplit()) + { + split->popup(); + } + } + }); + // Zoom in { auto s = new QShortcut(QKeySequence::ZoomIn, this); diff --git a/src/widgets/settingspages/KeyboardSettingsPage.cpp b/src/widgets/settingspages/KeyboardSettingsPage.cpp index c2181e9b1..b35abdd3f 100644 --- a/src/widgets/settingspages/KeyboardSettingsPage.cpp +++ b/src/widgets/settingspages/KeyboardSettingsPage.cpp @@ -26,6 +26,8 @@ KeyboardSettingsPage::KeyboardSettingsPage() form->addItem(new QSpacerItem(16, 16)); form->addRow(new QLabel("Ctrl + T"), new QLabel("Create new split")); form->addRow(new QLabel("Ctrl + W"), new QLabel("Close current split")); + form->addRow(new QLabel("Ctrl + N"), + new QLabel("Open current split as a popup")); form->addRow(new QLabel("Ctrl + G"), new QLabel("Reopen last closed split")); diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index feb59a1e5..ae2f12eb9 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -187,6 +187,18 @@ void SplitContainer::insertSplit(Split *split, Direction direction, this->addSplit(split); } +Split *SplitContainer::getSelectedSplit() const +{ + // safety check + if (std::find(this->splits_.begin(), this->splits_.end(), + this->selected_) == this->splits_.end()) + { + return nullptr; + } + + return this->selected_; +} + void SplitContainer::addSplit(Split *split) { assertInGuiThread(); diff --git a/src/widgets/splits/SplitContainer.hpp b/src/widgets/splits/SplitContainer.hpp index a29930038..59c3e4cbb 100644 --- a/src/widgets/splits/SplitContainer.hpp +++ b/src/widgets/splits/SplitContainer.hpp @@ -177,6 +177,7 @@ public: void insertSplit(Split *split, Direction direction, Split *relativeTo); void insertSplit(Split *split, Direction direction, Node *relativeTo = nullptr); + Split *getSelectedSplit() const; Position releaseSplit(Split *split); Position deleteSplit(Split *split); @@ -244,7 +245,7 @@ private: QPoint mouseOverPoint_; Node baseNode_; - Split *selected_; + Split *selected_{}; Split *topRight_{}; NotebookTab *tab_; diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index d41ec53be..d5b1db73d 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -277,7 +277,8 @@ std::unique_ptr SplitHeader::createMainMenu() menu->addAction("Close", this->split_, &Split::deleteFromContainer, QKeySequence("Ctrl+W")); menu->addSeparator(); - menu->addAction("Popup", this->split_, &Split::popup); + menu->addAction("Popup", this->split_, &Split::popup, + QKeySequence("Ctrl+N")); menu->addAction("Search", this->split_, &Split::showSearch, QKeySequence("Ctrl+F")); menu->addSeparator(); @@ -323,6 +324,20 @@ std::unique_ptr SplitHeader::createMainMenu() menu->addSeparator(); } + // reload / reconnect + if (this->split_->getChannel()->canReconnect()) + menu->addAction("Reconnect", this, SLOT(reconnect())); + + if (dynamic_cast(this->split_->getChannel().get())) + { + menu->addAction("Reload channel emotes", this, + SLOT(reloadChannelEmotes()), QKeySequence("F5")); + menu->addAction("Reload subscriber emotes", this, + SLOT(reloadSubscriberEmotes())); + } + + menu->addSeparator(); + { // "How to..." sub menu auto subMenu = new QMenu("How to...", this); @@ -331,6 +346,8 @@ std::unique_ptr SplitHeader::createMainMenu() menu->addMenu(subMenu); } + menu->addSeparator(); + // sub menu auto moreMenu = new QMenu("More", this); @@ -379,17 +396,6 @@ std::unique_ptr SplitHeader::createMainMenu() moreMenu->addAction(action); } - moreMenu->addSeparator(); - if (this->split_->getChannel()->canReconnect()) - moreMenu->addAction("Reconnect", this, SLOT(reconnect())); - - if (dynamic_cast(this->split_->getChannel().get())) - { - moreMenu->addAction("Reload channel emotes", this, - SLOT(reloadChannelEmotes())); - moreMenu->addAction("Reload subscriber emotes", this, - SLOT(reloadSubscriberEmotes())); - } moreMenu->addSeparator(); moreMenu->addAction("Clear messages", this->split_, &Split::clear); // moreMenu->addSeparator();