Add opening tab in popup (#3082)

Co-authored-by: zneix <zneix@zneix.eu>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Tal Neoran
2021-08-21 15:16:00 +03:00
committed by GitHub
parent 773c4bb9e7
commit ad4a0c28d1
11 changed files with 167 additions and 102 deletions
+8
View File
@@ -338,6 +338,14 @@ void Window::addShortcuts()
}
});
createWindowShortcut(this, "CTRL+SHIFT+N", [this] {
if (auto page = dynamic_cast<SplitContainer *>(
this->notebook_->getSelectedPage()))
{
page->popup();
}
});
// Zoom in
{
auto s = new QShortcut(QKeySequence::ZoomIn, this);
+10
View File
@@ -64,6 +64,16 @@ NotebookTab::NotebookTab(Notebook *notebook)
this->notebook_->removePage(this->page);
});
this->menu_.addAction(
"Popup Tab",
[=]() {
if (auto container = dynamic_cast<SplitContainer *>(this->page))
{
container->popup();
}
},
QKeySequence("Ctrl+Shift+N"));
highlightNewMessagesAction_ =
new QAction("Mark Tab as Unread on New Messages", &this->menu_);
highlightNewMessagesAction_->setCheckable(true);
@@ -44,6 +44,8 @@ KeyboardSettingsPage::KeyboardSettingsPage()
form->addRow(new QLabel("Ctrl + Shift + T"), new QLabel("Create new tab"));
form->addRow(new QLabel("Ctrl + Shift + W"),
new QLabel("Close current tab"));
form->addRow(new QLabel("Ctrl + Shift + N"),
new QLabel("Open current tab as a popup"));
form->addRow(new QLabel("Ctrl + H"),
new QLabel("Hide/Show similar messages (See General->R9K)"));
+28
View File
@@ -9,6 +9,7 @@
#include "util/Helpers.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/Window.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include "widgets/splits/ClosedSplits.hpp"
@@ -761,6 +762,33 @@ void SplitContainer::applyFromDescriptor(const NodeDescriptor &rootNode)
this->layout();
}
void SplitContainer::popup()
{
Window &window = getApp()->windows->createWindow(WindowType::Popup);
auto popupContainer = window.getNotebook().getOrAddSelectedPage();
QJsonObject encodedTab;
WindowManager::encodeTab(this, true, encodedTab);
TabDescriptor tab = TabDescriptor::loadFromJSON(encodedTab);
// custom title
if (!tab.customTitle_.isEmpty())
{
popupContainer->getTab()->setCustomTitle(tab.customTitle_);
}
// highlighting on new messages
popupContainer->getTab()->setHighlightsEnabled(tab.highlightsEnabled_);
// splits
if (tab.rootNode_)
{
popupContainer->applyFromDescriptor(*tab.rootNode_);
}
window.show();
}
void SplitContainer::applyFromDescriptorRecursively(
const NodeDescriptor &rootNode, Node *node)
{
+2
View File
@@ -202,6 +202,8 @@ public:
void applyFromDescriptor(const NodeDescriptor &rootNode);
void popup();
protected:
void paintEvent(QPaintEvent *event) override;