From 73e7be1617217396c5f1eead52af87bc7fef2357 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 6 Aug 2013 14:02:19 +0300 Subject: add colors tab into chat emotes window. --- src/gui/emotewindow.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'src/gui/emotewindow.cpp') diff --git a/src/gui/emotewindow.cpp b/src/gui/emotewindow.cpp index a66cecf87..fc76f474b 100644 --- a/src/gui/emotewindow.cpp +++ b/src/gui/emotewindow.cpp @@ -23,6 +23,8 @@ #include "gui/chatwindow.h" #include "gui/gui.h" +#include "gui/widgets/colormodel.h" +#include "gui/widgets/colorpage.h" #include "gui/widgets/emotepage.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" @@ -41,7 +43,9 @@ EmoteWindow::EmoteWindow() : Window(_("Emotes"), false, nullptr, "emotes.xml"), mTabs(new TabbedArea(this)), mEmotePage(new EmotePage(this)), - mScrollEmotePage(new ScrollArea(mEmotePage, false, "emotepage.xml")) + mColorModel(ColorModel::createDefault(this)), + mColorPage(new ColorPage(this, mColorModel, "colorpage.xml")), + mScrollColorPage(new ScrollArea(mColorPage, false, "emotepage.xml")) { setShowTitle(false); @@ -57,17 +61,28 @@ EmoteWindow::EmoteWindow() : center(); setTitleBarHeight(getPadding() + getTitlePadding()); + mScrollColorPage->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS); // TRANSLATORS: emotes tab name mTabs->addTab(_("Emotes"), mEmotePage); + // TRANSLATORS: emotes tab name + mTabs->addTab(_("Colors"), mScrollColorPage); mEmotePage->setActionEventId("emote"); + mColorPage->setActionEventId("color"); } EmoteWindow::~EmoteWindow() { + mTabs->removeAll(false); mTabs->removeTab(mTabs->getTabByIndex(0)); - delete mScrollEmotePage; - mScrollEmotePage = nullptr; + delete mEmotePage; + mEmotePage = nullptr; + delete mColorPage; + mColorPage = nullptr; + delete mColorModel; + mColorModel = nullptr; + delete mScrollColorPage; + mScrollColorPage = nullptr; } void EmoteWindow::show() @@ -100,7 +115,26 @@ void EmoteWindow::clearEmote() setVisible(false); } +std::string EmoteWindow::getSelectedColor() const +{ + const int index = mColorPage->getSelected(); + if (index < 0) + return std::string(); + + char chr[2]; + chr[0] = '0' + index; + chr[1] = 0; + return std::string("##").append(&chr[0]); +} + +void EmoteWindow::clearColor() +{ + mColorPage->resetAction(); + setVisible(false); +} + void EmoteWindow::addListeners(gcn::ActionListener *const listener) { mEmotePage->addActionListener(listener); + mColorPage->addActionListener(listener); } -- cgit v1.2.3-60-g2f50