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:
@@ -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);
|
||||
|
||||
@@ -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)"));
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -202,6 +202,8 @@ public:
|
||||
|
||||
void applyFromDescriptor(const NodeDescriptor &rootNode);
|
||||
|
||||
void popup();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user