From e8a948cffc566d105c331dbde7170b76bb7064ab Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 18 Apr 2018 17:51:53 +0200 Subject: [PATCH] added custom window frame to the emote popup --- src/widgets/emotepopup.cpp | 17 ++++++++++------- src/widgets/notebook.cpp | 7 ++++++- src/widgets/notebook.hpp | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/widgets/emotepopup.cpp b/src/widgets/emotepopup.cpp index 7b6fe215b..09fb1d533 100644 --- a/src/widgets/emotepopup.cpp +++ b/src/widgets/emotepopup.cpp @@ -6,6 +6,7 @@ #include "messages/messagebuilder.hpp" #include "providers/twitch/twitchchannel.hpp" #include "singletons/accountmanager.hpp" +#include "widgets/notebook.hpp" using namespace chatterino::providers::twitch; using namespace chatterino::messages; @@ -14,7 +15,7 @@ namespace chatterino { namespace widgets { EmotePopup::EmotePopup(singletons::ThemeManager &themeManager) - : BaseWindow(themeManager, 0) + : BaseWindow(themeManager, nullptr, true) { this->viewEmotes = new ChannelView(); this->viewEmojis = new ChannelView(); @@ -27,13 +28,15 @@ EmotePopup::EmotePopup(singletons::ThemeManager &themeManager) this->viewEmotes->setEnableScrollingToBottom(false); this->viewEmojis->setEnableScrollingToBottom(false); - this->setLayout(new QVBoxLayout(this)); + auto *layout = new QVBoxLayout(this); + this->getLayoutContainer()->setLayout(layout); - QTabWidget *tabs = new QTabWidget(this); - this->layout()->addWidget(tabs); - this->layout()->setMargin(0); - tabs->addTab(this->viewEmotes, "Emotes"); - tabs->addTab(this->viewEmojis, "Emojis"); + Notebook2 *notebook = new Notebook2(this); + layout->addWidget(notebook); + layout->setMargin(0); + + notebook->addPage(this->viewEmotes, "Emotes"); + notebook->addPage(this->viewEmojis, "Emojis"); this->loadEmojis(); diff --git a/src/widgets/notebook.cpp b/src/widgets/notebook.cpp index 7a548ce50..ed4f59cbf 100644 --- a/src/widgets/notebook.cpp +++ b/src/widgets/notebook.cpp @@ -36,11 +36,16 @@ Notebook2::Notebook2(QWidget *parent) QObject::connect(shortcut_prev, &QShortcut::activated, [this] { this->selectPreviousTab(); }); } -NotebookTab2 *Notebook2::addPage(QWidget *page, bool select) +NotebookTab2 *Notebook2::addPage(QWidget *page, QString title, bool select) { auto *tab = new NotebookTab2(this); tab->page = page; + if (!title.isEmpty()) { + tab->setTitle(title); + tab->useDefaultTitle = false; + } + Item item; item.page = page; item.tab = tab; diff --git a/src/widgets/notebook.hpp b/src/widgets/notebook.hpp index 220b2ed22..d82f26a58 100644 --- a/src/widgets/notebook.hpp +++ b/src/widgets/notebook.hpp @@ -21,7 +21,7 @@ class Notebook2 : public BaseWidget public: explicit Notebook2(QWidget *parent); - NotebookTab2 *addPage(QWidget *page, bool select = false); + NotebookTab2 *addPage(QWidget *page, QString title = QString(), bool select = false); void removePage(QWidget *page); void removeCurrentPage();