From 84c23a5d009f82d5318c4b9aedaa22de3c7c6381 Mon Sep 17 00:00:00 2001 From: fourtf Date: Fri, 15 Sep 2017 17:23:49 +0200 Subject: [PATCH] modified buttons a bit --- chatterino.pro | 6 +- src/colorscheme.cpp | 2 +- src/concurrentmap.hpp | 12 +++ src/widgets/chatwidget.cpp | 131 ++++++++++++------------- src/widgets/chatwidgetheader.cpp | 65 ++++++------ src/widgets/chatwidgetheaderbutton.cpp | 70 +------------ src/widgets/chatwidgetheaderbutton.hpp | 20 +--- src/widgets/chatwidgetinput.cpp | 30 +++--- src/widgets/chatwidgetinput.hpp | 9 +- src/widgets/chatwidgetview.cpp | 21 ++-- src/widgets/emotepopup.cpp | 18 ++++ src/widgets/emotepopup.h | 18 ++++ src/widgets/fancybutton.cpp | 4 + src/widgets/fancybutton.hpp | 5 + src/widgets/notebook.cpp | 4 +- 15 files changed, 193 insertions(+), 222 deletions(-) create mode 100644 src/widgets/emotepopup.cpp create mode 100644 src/widgets/emotepopup.h diff --git a/chatterino.pro b/chatterino.pro index b08abaccc..9135bcb5f 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -96,7 +96,8 @@ SOURCES += \ src/widgets/resizingtextedit.cpp \ src/completionmanager.cpp \ src/widgets/logindialog.cpp \ - src/widgets/qualitypopup.cpp + src/widgets/qualitypopup.cpp \ + src/widgets/emotepopup.cpp HEADERS += \ src/asyncexec.hpp \ @@ -157,7 +158,8 @@ HEADERS += \ src/util/distancebetweenpoints.hpp \ src/widgets/basewidget.hpp \ src/completionmanager.hpp \ - src/widgets/qualitypopup.h + src/widgets/qualitypopup.h \ + src/widgets/emotepopup.h PRECOMPILED_HEADER = diff --git a/src/colorscheme.cpp b/src/colorscheme.cpp index 98b5d7813..338f544f4 100644 --- a/src/colorscheme.cpp +++ b/src/colorscheme.cpp @@ -111,7 +111,7 @@ void ColorScheme::setColors(double hue, double multiplier) ScrollbarBG = ChatBackground; ScrollbarThumb = getColor(0, 0.1, 0.85); ScrollbarThumbSelected = getColor(0, 0.1, 0.7); - ScrollbarArrow = getColor(0, 0.1, 0.4); + ScrollbarArrow = getColor(0, 0.1, 0.9); // stylesheet InputStyleSheet = "background:" + ChatInputBackground.name() + ";" + diff --git a/src/concurrentmap.hpp b/src/concurrentmap.hpp index fe87a773a..0a60204fd 100644 --- a/src/concurrentmap.hpp +++ b/src/concurrentmap.hpp @@ -81,6 +81,18 @@ public: this->data.insert(name, value); } + void each(std::function &func) const + { + QMutexLocker lock(this->mutex.get()); + + QMapIterator it(this->data); + + while (it.hasNext()) { + it.next(); + func(it.key(), it.value()); + } + } + private: mutable std::unique_ptr mutex; QMap data; diff --git a/src/widgets/chatwidget.cpp b/src/widgets/chatwidget.cpp index e31904490..059cafb98 100644 --- a/src/widgets/chatwidget.cpp +++ b/src/widgets/chatwidget.cpp @@ -4,8 +4,8 @@ #include "notebookpage.hpp" #include "settingsmanager.hpp" #include "util/urlfetch.hpp" -#include "widgets/textinputdialog.hpp" #include "widgets/qualitypopup.h" +#include "widgets/textinputdialog.hpp" #include #include @@ -100,9 +100,7 @@ std::shared_ptr &ChatWidget::getChannelRef() void ChatWidget::setChannel(std::shared_ptr _newChannel) { this->channel = _newChannel; - this->channel->roomIDchanged.connect([this](){ - this->header.checkLive(); - }); + this->channel->roomIDchanged.connect([this]() { this->header.checkLive(); }); this->view.userPopupWidget.setChannel(_newChannel); @@ -131,7 +129,7 @@ void ChatWidget::setChannel(std::shared_ptr _newChannel) auto snapshot = this->channel->getMessageSnapshot(); - for (int i = 0; i < snapshot.getLength(); i++) { + for (size_t i = 0; i < snapshot.getLength(); i++) { SharedMessageRef deleted; auto messageRef = new MessageRef(snapshot[i]); @@ -261,7 +259,7 @@ void ChatWidget::doCloseSplit() { NotebookPage *page = static_cast(this->parentWidget()); page->removeFromLayout(this); - QTimer* timer = this->header.findChild(); + QTimer *timer = this->header.findChild(); timer->stop(); timer->deleteLater(); } @@ -269,9 +267,8 @@ void ChatWidget::doCloseSplit() void ChatWidget::doChangeChannel() { this->showChangeChannelPopup("Change channel"); - auto popup = this->findChildren(); - if(popup.at(0)->isVisible() && !popup.at(0)->isFloating()) - { + auto popup = this->findChildren(); + if (popup.at(0)->isVisible() && !popup.at(0)->isFloating()) { popup.at(0)->hide(); doOpenViewerList(); } @@ -310,7 +307,8 @@ void ChatWidget::doOpenPopupPlayer() void ChatWidget::doOpenStreamlink() { SettingsManager &settings = SettingsManager::getInstance(); - QString preferredQuality = QString::fromStdString(settings.preferredQuality.getValue()).toLower(); + QString preferredQuality = + QString::fromStdString(settings.preferredQuality.getValue()).toLower(); // TODO(Confuseh): Default streamlink paths QString path = QString::fromStdString(settings.streamlinkPath.getValue()); QString channel = QString::fromStdString(this->channelName.getValue()); @@ -344,29 +342,30 @@ void ChatWidget::doOpenStreamlink() // my god that signal though QObject::connect(p, static_cast(&QProcess::finished), this, [path, channel, p](int exitCode) { - if (exitCode > 0) { - return; - } - QString lastLine = QString(p->readAllStandardOutput()); - lastLine = lastLine.trimmed().split('\n').last(); - if (lastLine.startsWith("Available streams: ")) { - QStringList options; - QStringList split = lastLine.right(lastLine.length() - 19).split(", "); + if (exitCode > 0) { + return; + } + QString lastLine = QString(p->readAllStandardOutput()); + lastLine = lastLine.trimmed().split('\n').last(); + if (lastLine.startsWith("Available streams: ")) { + QStringList options; + QStringList split = + lastLine.right(lastLine.length() - 19).split(", "); - for (int i = split.length() - 1; i >= 0; i--) { - QString option = split.at(i); - if (option.endsWith(" (worst)")) { - options << option.left(option.length() - 8); - } else if (option.endsWith(" (best)")) { - options << option.left(option.length() - 7); - } else { - options << option; - } - } + for (int i = split.length() - 1; i >= 0; i--) { + QString option = split.at(i); + if (option.endsWith(" (worst)")) { + options << option.left(option.length() - 8); + } else if (option.endsWith(" (best)")) { + options << option.left(option.length() - 7); + } else { + options << option; + } + } - QualityPopup::showDialog(channel, path, options); - } - }); + QualityPopup::showDialog(channel, path, options); + } + }); p->start(path, {"twitch.tv/" + channel}); } } @@ -374,13 +373,13 @@ void ChatWidget::doOpenStreamlink() void ChatWidget::doOpenViewerList() { - auto viewerDock = new QDockWidget("Viewer List",this); + auto viewerDock = new QDockWidget("Viewer List", this); viewerDock->setAllowedAreas(Qt::LeftDockWidgetArea); viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar | - QDockWidget::DockWidgetClosable | - QDockWidget::DockWidgetFloatable); - viewerDock->resize(0.5*this->width(),this->height() - this->header.height() - this->input.height()); - viewerDock->move(0,this->header.height()); + QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); + viewerDock->resize(0.5 * this->width(), + this->height() - this->header.height() - this->input.height()); + viewerDock->move(0, this->header.height()); auto accountPopup = new AccountPopupWidget(this->channel); auto multiWidget = new QWidget(viewerDock); @@ -392,64 +391,56 @@ void ChatWidget::doOpenViewerList() static QStringList labels = {"Moderators", "Staff", "Admins", "Global Moderators", "Viewers"}; static QStringList jsonLabels = {"moderators", "staff", "admins", "global_mods", "viewers"}; - QList labelList; - for(auto &x : labels) - { + QList labelList; + for (auto &x : labels) { auto label = new QListWidgetItem(x); label->setBackgroundColor(this->colorScheme.ChatHeaderBackground); labelList.append(label); } auto loadingLabel = new QLabel("Loading..."); - util::twitch::get("https://tmi.twitch.tv/group/user/" + channel->name + "/chatters",[=](QJsonObject obj){ - QJsonObject chattersObj = obj.value("chatters").toObject(); + util::twitch::get( + "https://tmi.twitch.tv/group/user/" + channel->name + "/chatters", [=](QJsonObject obj) { + QJsonObject chattersObj = obj.value("chatters").toObject(); - loadingLabel->hide(); - for(int i = 0; i < jsonLabels.size(); i++) - { - chattersList->addItem(labelList.at(i)); - foreach (const QJsonValue & v, chattersObj.value(jsonLabels.at(i)).toArray()) - chattersList->addItem(v.toString()); - } - }); + loadingLabel->hide(); + for (int i = 0; i < jsonLabels.size(); i++) { + chattersList->addItem(labelList.at(i)); + foreach (const QJsonValue &v, chattersObj.value(jsonLabels.at(i)).toArray()) + chattersList->addItem(v.toString()); + } + }); searchBar->setPlaceholderText("Search User..."); - QObject::connect(searchBar,&QLineEdit::textEdited,this,[=](){ + QObject::connect(searchBar, &QLineEdit::textEdited, this, [=]() { auto query = searchBar->text(); - if(!query.isEmpty()) - { - auto results = chattersList->findItems(query,Qt::MatchStartsWith); + if (!query.isEmpty()) { + auto results = chattersList->findItems(query, Qt::MatchStartsWith); chattersList->hide(); resultList->clear(); - for (auto & item : results) - { - if(!labels.contains(item->text())) + for (auto &item : results) { + if (!labels.contains(item->text())) resultList->addItem(item->text()); } resultList->show(); - } - else - { + } else { resultList->hide(); chattersList->show(); } }); - QObject::connect(viewerDock,&QDockWidget::topLevelChanged,this,[=](){ - viewerDock->setMinimumWidth(300); - }); + QObject::connect(viewerDock, &QDockWidget::topLevelChanged, this, + [=]() { viewerDock->setMinimumWidth(300); }); - QObject::connect(chattersList,&QListWidget::doubleClicked,this,[=](){ - if(!labels.contains(chattersList->currentItem()->text())) - { - doOpenAccountPopupWidget(accountPopup,chattersList->currentItem()->text()); + QObject::connect(chattersList, &QListWidget::doubleClicked, this, [=]() { + if (!labels.contains(chattersList->currentItem()->text())) { + doOpenAccountPopupWidget(accountPopup, chattersList->currentItem()->text()); } }); - QObject::connect(resultList,&QListWidget::doubleClicked,this,[=](){ - if(!labels.contains(resultList->currentItem()->text())) - { - doOpenAccountPopupWidget(accountPopup,resultList->currentItem()->text()); + QObject::connect(resultList, &QListWidget::doubleClicked, this, [=]() { + if (!labels.contains(resultList->currentItem()->text())) { + doOpenAccountPopupWidget(accountPopup, resultList->currentItem()->text()); } }); diff --git a/src/widgets/chatwidgetheader.cpp b/src/widgets/chatwidgetheader.cpp index 2f0ae8d91..45a26f73d 100644 --- a/src/widgets/chatwidgetheader.cpp +++ b/src/widgets/chatwidgetheader.cpp @@ -1,8 +1,8 @@ #include "widgets/chatwidgetheader.hpp" #include "colorscheme.hpp" +#include "util/urlfetch.hpp" #include "widgets/chatwidget.hpp" #include "widgets/notebookpage.hpp" -#include "util/urlfetch.hpp" #include #include @@ -81,21 +81,17 @@ void ChatWidgetHeader::updateChannelText() if (channelName.empty()) { this->channelNameLabel.setText(""); } else { - if(this->chatWidget->getChannelRef()->isLive) - { + if (this->chatWidget->getChannelRef()->isLive) { auto channel = this->chatWidget->getChannelRef(); this->channelNameLabel.setText(QString::fromStdString(channelName) + " (live)"); - this->setToolTip("" \ - "

" + \ - channel->streamStatus + "

" + \ - channel->streamGame + "
" \ - "Live for " + channel->streamUptime + \ - " with " + channel->streamViewerCount + " viewers" \ - "

" - ); - } - else - { + this->setToolTip( + "" + "

" + + channel->streamStatus + "

" + channel->streamGame + "
" + "Live for " + + channel->streamUptime + " with " + channel->streamViewerCount + " viewers" + "

"); + } else { this->channelNameLabel.setText(QString::fromStdString(channelName)); this->setToolTip(""); } @@ -161,8 +157,10 @@ void ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event) void ChatWidgetHeader::leftButtonClicked() { - this->leftMenu.move(this->leftLabel.mapToGlobal(QPoint(0, this->leftLabel.height()))); - this->leftMenu.show(); + QTimer::singleShot(100, [&] { + this->leftMenu.move(this->leftLabel.mapToGlobal(QPoint(0, this->leftLabel.height()))); + this->leftMenu.show(); + }); } void ChatWidgetHeader::rightButtonClicked() @@ -199,24 +197,23 @@ void ChatWidgetHeader::checkLive() { auto channel = this->chatWidget->getChannelRef(); auto id = QString::fromStdString(channel->roomID); - util::twitch::get("https://api.twitch.tv/kraken/streams/" + id,[=](QJsonObject obj){ - if(obj.value("stream").isNull()) - { - channel->isLive = false; - this->updateChannelText(); - } - else - { - channel->isLive = true; - auto stream = obj.value("stream").toObject(); - channel->streamViewerCount = QString::number(stream.value("viewers").toDouble()); - channel->streamGame = stream.value("game").toString(); - channel->streamStatus = stream.value("channel").toObject().value("status").toString(); - QDateTime since = QDateTime::fromString(stream.value("created_at").toString(),Qt::ISODate); - auto diff = since.secsTo(QDateTime::currentDateTime()); - channel->streamUptime = QString::number(diff/3600) + "h " + QString::number(diff % 3600 / 60) + "m"; - this->updateChannelText(); - } + util::twitch::get("https://api.twitch.tv/kraken/streams/" + id, [=](QJsonObject obj) { + if (obj.value("stream").isNull()) { + channel->isLive = false; + this->updateChannelText(); + } else { + channel->isLive = true; + auto stream = obj.value("stream").toObject(); + channel->streamViewerCount = QString::number(stream.value("viewers").toDouble()); + channel->streamGame = stream.value("game").toString(); + channel->streamStatus = stream.value("channel").toObject().value("status").toString(); + QDateTime since = + QDateTime::fromString(stream.value("created_at").toString(), Qt::ISODate); + auto diff = since.secsTo(QDateTime::currentDateTime()); + channel->streamUptime = + QString::number(diff / 3600) + "h " + QString::number(diff % 3600 / 60) + "m"; + this->updateChannelText(); + } }); } diff --git a/src/widgets/chatwidgetheaderbutton.cpp b/src/widgets/chatwidgetheaderbutton.cpp index a8a79208f..82df8f1da 100644 --- a/src/widgets/chatwidgetheaderbutton.cpp +++ b/src/widgets/chatwidgetheaderbutton.cpp @@ -9,9 +9,7 @@ namespace chatterino { namespace widgets { ChatWidgetHeaderButton::ChatWidgetHeaderButton(BaseWidget *parent, int spacing) - : BaseWidget(parent) - , mouseOver(false) - , mouseDown(false) + : FancyButton(parent) { setLayout(&this->ui.hbox); @@ -22,76 +20,14 @@ ChatWidgetHeaderButton::ChatWidgetHeaderButton(BaseWidget *parent, int spacing) this->ui.hbox.addWidget(&this->ui.label); this->ui.hbox.addSpacing(spacing); - QObject::connect(&this->ui.label, &SignalLabel::mouseUp, this, - &ChatWidgetHeaderButton::labelMouseUp); - QObject::connect(&this->ui.label, &SignalLabel::mouseDown, this, - &ChatWidgetHeaderButton::labelMouseDown); + this->setMouseEffectColor(QColor(255, 255, 255, 63)); } void ChatWidgetHeaderButton::paintEvent(QPaintEvent *) { QPainter painter(this); - QBrush brush(this->colorScheme.isLightTheme() ? QColor(0, 0, 0, 32) - : QColor(255, 255, 255, 32)); - - if (mouseDown) { - painter.fillRect(rect(), brush); - } - - if (mouseOver) { - painter.fillRect(rect(), brush); - } -} - -void ChatWidgetHeaderButton::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - mouseDown = true; - - update(); - } -} - -void ChatWidgetHeaderButton::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - mouseDown = false; - - update(); - - emit clicked(); - } -} - -void ChatWidgetHeaderButton::enterEvent(QEvent *) -{ - mouseOver = true; - - update(); -} - -void ChatWidgetHeaderButton::leaveEvent(QEvent *) -{ - mouseOver = false; - - update(); -} - -void ChatWidgetHeaderButton::labelMouseUp() -{ - mouseDown = false; - - update(); - - emit clicked(); -} - -void ChatWidgetHeaderButton::labelMouseDown() -{ - mouseDown = true; - - update(); + this->fancyPaint(painter); } } // namespace widgets diff --git a/src/widgets/chatwidgetheaderbutton.hpp b/src/widgets/chatwidgetheaderbutton.hpp index 47c6d3b29..427aa0c79 100644 --- a/src/widgets/chatwidgetheaderbutton.hpp +++ b/src/widgets/chatwidgetheaderbutton.hpp @@ -1,6 +1,7 @@ #pragma once #include "widgets/basewidget.hpp" +#include "widgets/fancybutton.hpp" #include "widgets/signallabel.hpp" #include @@ -16,10 +17,8 @@ namespace widgets { class ChatWidgetHeader; -class ChatWidgetHeaderButton : public BaseWidget +class ChatWidgetHeaderButton : public FancyButton { - Q_OBJECT - public: explicit ChatWidgetHeaderButton(BaseWidget *parent, int spacing = 6); @@ -28,29 +27,14 @@ public: return this->ui.label; } -signals: - void clicked(); - protected: virtual void paintEvent(QPaintEvent *) override; - virtual void enterEvent(QEvent *) override; - virtual void leaveEvent(QEvent *) override; - - virtual void mousePressEvent(QMouseEvent *event) override; - virtual void mouseReleaseEvent(QMouseEvent *event) override; - private: struct { QHBoxLayout hbox; SignalLabel label; } ui; - - bool mouseOver = false; - bool mouseDown = false; - - void labelMouseUp(); - void labelMouseDown(); }; } // namespace widgets diff --git a/src/widgets/chatwidgetinput.cpp b/src/widgets/chatwidgetinput.cpp index 075e7f3d3..35e43ec47 100644 --- a/src/widgets/chatwidgetinput.cpp +++ b/src/widgets/chatwidgetinput.cpp @@ -9,7 +9,6 @@ #include #include -#include namespace chatterino { namespace widgets { @@ -23,7 +22,7 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget) this->setLayout(&this->hbox); - this->hbox.setMargin(4); + this->hbox.setMargin(0); this->hbox.addLayout(&this->editContainer); this->hbox.addLayout(&this->vbox); @@ -31,6 +30,8 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget) this->editContainer.addWidget(&this->textInput); this->editContainer.setMargin(4); + this->emotesLabel.setMinimumHeight(24); + this->vbox.addWidget(&this->textLengthLabel); this->vbox.addStretch(1); this->vbox.addWidget(&this->emotesLabel); @@ -43,10 +44,18 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget) ""); + connect(&this->emotesLabel, &ChatWidgetHeaderButton::clicked, [this] { + if (this->emotePopup == nullptr) { + this->emotePopup = new EmotePopup(); + } + + this->emotePopup->show(); // + }); + connect(&textInput, &ResizingTextEdit::textChanged, this, &ChatWidgetInput::editTextChanged); this->refreshTheme(); - this->setMessageLengthVisible(SettingsManager::getInstance().showMessageLength.get()); + textLengthLabel.setHidden(!SettingsManager::getInstance().showMessageLength.get()); auto completer = new QCompleter( this->chatWidget->completionManager.createModel(this->chatWidget->channelName)); @@ -148,21 +157,14 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget) } }); - /* XXX(pajlada): FIX THIS - QObject::connect(&Settings::getInstance().showMessageLength, - &BoolSetting::valueChanged, this, - &ChatWidgetInput::setMessageLengthVisible); - */ + this->textLengthVisibleChangedConnection = + SettingsManager::getInstance().showMessageLength.valueChanged.connect( + [this](const bool &value) { this->textLengthLabel.setHidden(!value); }); } ChatWidgetInput::~ChatWidgetInput() { - /* XXX(pajlada): FIX THIS - QObject::disconnect( - &Settings::getInstance().getShowMessageLength(), - &BoolSetting::valueChanged, this, - &ChatWidgetInput::setMessageLengthVisible); - */ + this->textLengthVisibleChangedConnection.disconnect(); } void ChatWidgetInput::refreshTheme() diff --git a/src/widgets/chatwidgetinput.hpp b/src/widgets/chatwidgetinput.hpp index a0fdc09bf..92888e8ba 100644 --- a/src/widgets/chatwidgetinput.hpp +++ b/src/widgets/chatwidgetinput.hpp @@ -3,6 +3,7 @@ #include "resizingtextedit.hpp" #include "widgets/basewidget.hpp" #include "widgets/chatwidgetheaderbutton.hpp" +#include "widgets/emotepopup.h" #include #include @@ -12,6 +13,8 @@ #include #include +#include + namespace chatterino { namespace widgets { @@ -33,7 +36,9 @@ protected: private: ChatWidget *const chatWidget; + EmotePopup *emotePopup = nullptr; + boost::signals2::connection textLengthVisibleChangedConnection; QHBoxLayout hbox; QVBoxLayout vbox; QHBoxLayout editContainer; @@ -45,10 +50,6 @@ private: virtual void refreshTheme() override; private slots: - void setMessageLengthVisible(bool value) - { - textLengthLabel.setHidden(!value); - } void editTextChanged(); // void editKeyPressed(QKeyEvent *event); diff --git a/src/widgets/chatwidgetview.cpp b/src/widgets/chatwidgetview.cpp index 2286dbb3a..79a25c139 100644 --- a/src/widgets/chatwidgetview.cpp +++ b/src/widgets/chatwidgetview.cpp @@ -30,7 +30,7 @@ ChatWidgetView::ChatWidgetView(ChatWidget *_chatWidget) , userPopupWidget(_chatWidget->getChannelRef()) { #ifndef Q_OS_MAC - this->setAttribute(Qt::WA_OpaquePaintEvent); +// this->setAttribute(Qt::WA_OpaquePaintEvent); #endif this->setMouseTracking(true); @@ -70,7 +70,8 @@ bool ChatWidgetView::layoutMessages() this->showingLatestMessages = this->scrollBar.isAtBottom() || !this->scrollBar.isVisible(); size_t start = this->scrollBar.getCurrentValue(); - int layoutWidth = this->scrollBar.isVisible() ? width() - this->scrollBar.width() : width(); + int layoutWidth = + (this->scrollBar.isVisible() ? width() - this->scrollBar.width() : width()) - 4; // layout the visible messages in the view if (messages.getLength() > start) { @@ -258,17 +259,17 @@ void ChatWidgetView::paintEvent(QPaintEvent * /*event*/) // only update gif emotes #ifndef Q_OS_MAC - if (this->onlyUpdateEmotes) { - this->onlyUpdateEmotes = false; +// if (this->onlyUpdateEmotes) { +// this->onlyUpdateEmotes = false; - for (const GifEmoteData &item : this->gifEmotes) { - painter.fillRect(item.rect, this->colorScheme.ChatBackground); +// for (const GifEmoteData &item : this->gifEmotes) { +// painter.fillRect(item.rect, this->colorScheme.ChatBackground); - painter.drawPixmap(item.rect, *item.image->getPixmap()); - } +// painter.drawPixmap(item.rect, *item.image->getPixmap()); +// } - return; - } +// return; +// } #endif // update all messages diff --git a/src/widgets/emotepopup.cpp b/src/widgets/emotepopup.cpp new file mode 100644 index 000000000..731ff54db --- /dev/null +++ b/src/widgets/emotepopup.cpp @@ -0,0 +1,18 @@ +#include "emotepopup.h" +namespace chatterino { +namespace widgets { + +EmotePopup::EmotePopup(QWidget *parent) + : QWidget(parent) +{ +} + +void EmotePopup::loadChannel(std::shared_ptr channel) +{ + // channel->bttvChannelEmotes.each([](const QString &key, const EmoteData &value) { + + // // + // }); +} +} +} diff --git a/src/widgets/emotepopup.h b/src/widgets/emotepopup.h new file mode 100644 index 000000000..779b23d64 --- /dev/null +++ b/src/widgets/emotepopup.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +#include "channel.hpp" + +namespace chatterino { +namespace widgets { + +class EmotePopup : public QWidget +{ +public: + explicit EmotePopup(QWidget *parent = 0); + + void loadChannel(std::shared_ptr channel); +}; +} +} diff --git a/src/widgets/fancybutton.cpp b/src/widgets/fancybutton.cpp index d821ef239..fb177266a 100644 --- a/src/widgets/fancybutton.cpp +++ b/src/widgets/fancybutton.cpp @@ -86,6 +86,10 @@ void FancyButton::mouseReleaseEvent(QMouseEvent *event) } this->mouseDown = false; + + if (this->rect().contains(event->pos())) { + emit clicked(); + } } void FancyButton::mouseMoveEvent(QMouseEvent *event) diff --git a/src/widgets/fancybutton.hpp b/src/widgets/fancybutton.hpp index 172c13b1c..c61a9cac7 100644 --- a/src/widgets/fancybutton.hpp +++ b/src/widgets/fancybutton.hpp @@ -13,6 +13,8 @@ namespace widgets { class FancyButton : public BaseWidget { + Q_OBJECT + struct ClickEffect { double progress = 0.0; QPoint position; @@ -28,6 +30,9 @@ public: void setMouseEffectColor(QColor color); +signals: + void clicked(); + protected: bool selected = false; bool mouseOver = false; diff --git a/src/widgets/notebook.cpp b/src/widgets/notebook.cpp index 5c3ee785f..3803df89f 100644 --- a/src/widgets/notebook.cpp +++ b/src/widgets/notebook.cpp @@ -212,7 +212,7 @@ void Notebook::resizeEvent(QResizeEvent *) void Notebook::settingsButtonClicked() { - SettingsDialog::showDialog(); + QTimer::singleShot(100, [this] { SettingsDialog::showDialog(); }); } void Notebook::usersButtonClicked() @@ -221,7 +221,7 @@ void Notebook::usersButtonClicked() void Notebook::addPageButtonClicked() { - addPage(true); + QTimer::singleShot(100, [this] { this->addPage(true); }); } void Notebook::load(const boost::property_tree::ptree &tree)