From 3b9a9e8373e49491fd3e520c4fb028e936079333 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Mon, 29 May 2017 21:26:55 +0200 Subject: [PATCH] CTRL+T opens new split in current page --- widgets/chatwidgetheader.cpp | 2 ++ widgets/notebook.cpp | 15 +++++++++++++++ widgets/notebookpage.cpp | 12 ++++++++++++ widgets/notebookpage.h | 2 ++ 4 files changed, 31 insertions(+) diff --git a/widgets/chatwidgetheader.cpp b/widgets/chatwidgetheader.cpp index 213ee1e4a..7a4c762ad 100644 --- a/widgets/chatwidgetheader.cpp +++ b/widgets/chatwidgetheader.cpp @@ -157,9 +157,11 @@ void ChatWidgetHeader::rightButtonClicked() void ChatWidgetHeader::menuAddSplit() { + printf("Add split for menu (NOT IMPLEMENTED KKarrot)\n"); } void ChatWidgetHeader::menuCloseSplit() { + printf("Close split\n"); } void ChatWidgetHeader::menuMoveSplit() { diff --git a/widgets/notebook.cpp b/widgets/notebook.cpp index 93b9930f1..493c192a7 100644 --- a/widgets/notebook.cpp +++ b/widgets/notebook.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,20 @@ Notebook::Notebook(QWidget *parent) [this](const bool &) { performLayout(); }); SettingsManager::getInstance().hideUserButton.valueChanged.connect( [this](const bool &) { performLayout(); }); + + // Initialize notebook hotkeys + { + // CTRL+T: Create new split (Add page) + auto shortcut = new QShortcut(QKeySequence("CTRL+T"), this); + connect(shortcut, &QShortcut::activated, [this]() { + printf("ctrL+t pressed\n"); // + if (this->_selectedPage == nullptr) { + return; + } + + this->_selectedPage->addChat(); + }); + } } NotebookPage *Notebook::addPage(bool select) diff --git a/widgets/notebookpage.cpp b/widgets/notebookpage.cpp index 0e7d9472a..94f891234 100644 --- a/widgets/notebookpage.cpp +++ b/widgets/notebookpage.cpp @@ -49,6 +49,18 @@ NotebookTab *NotebookPage::getTab() const return _tab; } +void +NotebookPage::addChat(bool openChannelNameDialog) +{ + ChatWidget *w = new ChatWidget(); + + if (openChannelNameDialog) { + w->showChangeChannelPopup(); + } + + addToLayout(w, std::pair(-1, -1)); +} + std::pair NotebookPage::removeFromLayout(ChatWidget *widget) { // remove from chatWidgets vector diff --git a/widgets/notebookpage.h b/widgets/notebookpage.h index 713c6a05f..b03b0c191 100644 --- a/widgets/notebookpage.h +++ b/widgets/notebookpage.h @@ -31,6 +31,8 @@ public: const std::vector &getChatWidgets() const; NotebookTab *getTab() const; + void addChat(bool openChannelNameDialog = false); + static bool isDraggingSplit; static ChatWidget *draggingSplit; static std::pair dropPosition;