mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
modified buttons a bit
This commit is contained in:
parent
4ac811f2a9
commit
84c23a5d00
15 changed files with 193 additions and 222 deletions
|
@ -96,7 +96,8 @@ SOURCES += \
|
||||||
src/widgets/resizingtextedit.cpp \
|
src/widgets/resizingtextedit.cpp \
|
||||||
src/completionmanager.cpp \
|
src/completionmanager.cpp \
|
||||||
src/widgets/logindialog.cpp \
|
src/widgets/logindialog.cpp \
|
||||||
src/widgets/qualitypopup.cpp
|
src/widgets/qualitypopup.cpp \
|
||||||
|
src/widgets/emotepopup.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/asyncexec.hpp \
|
src/asyncexec.hpp \
|
||||||
|
@ -157,7 +158,8 @@ HEADERS += \
|
||||||
src/util/distancebetweenpoints.hpp \
|
src/util/distancebetweenpoints.hpp \
|
||||||
src/widgets/basewidget.hpp \
|
src/widgets/basewidget.hpp \
|
||||||
src/completionmanager.hpp \
|
src/completionmanager.hpp \
|
||||||
src/widgets/qualitypopup.h
|
src/widgets/qualitypopup.h \
|
||||||
|
src/widgets/emotepopup.h
|
||||||
|
|
||||||
PRECOMPILED_HEADER =
|
PRECOMPILED_HEADER =
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ void ColorScheme::setColors(double hue, double multiplier)
|
||||||
ScrollbarBG = ChatBackground;
|
ScrollbarBG = ChatBackground;
|
||||||
ScrollbarThumb = getColor(0, 0.1, 0.85);
|
ScrollbarThumb = getColor(0, 0.1, 0.85);
|
||||||
ScrollbarThumbSelected = getColor(0, 0.1, 0.7);
|
ScrollbarThumbSelected = getColor(0, 0.1, 0.7);
|
||||||
ScrollbarArrow = getColor(0, 0.1, 0.4);
|
ScrollbarArrow = getColor(0, 0.1, 0.9);
|
||||||
|
|
||||||
// stylesheet
|
// stylesheet
|
||||||
InputStyleSheet = "background:" + ChatInputBackground.name() + ";" +
|
InputStyleSheet = "background:" + ChatInputBackground.name() + ";" +
|
||||||
|
|
|
@ -81,6 +81,18 @@ public:
|
||||||
this->data.insert(name, value);
|
this->data.insert(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void each(std::function<void(const TKey &name, const TValue &value)> &func) const
|
||||||
|
{
|
||||||
|
QMutexLocker lock(this->mutex.get());
|
||||||
|
|
||||||
|
QMapIterator<TKey, TValue> it(this->data);
|
||||||
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
func(it.key(), it.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable std::unique_ptr<QMutex> mutex;
|
mutable std::unique_ptr<QMutex> mutex;
|
||||||
QMap<TKey, TValue> data;
|
QMap<TKey, TValue> data;
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include "notebookpage.hpp"
|
#include "notebookpage.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "settingsmanager.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
#include "widgets/textinputdialog.hpp"
|
|
||||||
#include "widgets/qualitypopup.h"
|
#include "widgets/qualitypopup.h"
|
||||||
|
#include "widgets/textinputdialog.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
@ -100,9 +100,7 @@ std::shared_ptr<Channel> &ChatWidget::getChannelRef()
|
||||||
void ChatWidget::setChannel(std::shared_ptr<Channel> _newChannel)
|
void ChatWidget::setChannel(std::shared_ptr<Channel> _newChannel)
|
||||||
{
|
{
|
||||||
this->channel = _newChannel;
|
this->channel = _newChannel;
|
||||||
this->channel->roomIDchanged.connect([this](){
|
this->channel->roomIDchanged.connect([this]() { this->header.checkLive(); });
|
||||||
this->header.checkLive();
|
|
||||||
});
|
|
||||||
|
|
||||||
this->view.userPopupWidget.setChannel(_newChannel);
|
this->view.userPopupWidget.setChannel(_newChannel);
|
||||||
|
|
||||||
|
@ -131,7 +129,7 @@ void ChatWidget::setChannel(std::shared_ptr<Channel> _newChannel)
|
||||||
|
|
||||||
auto snapshot = this->channel->getMessageSnapshot();
|
auto snapshot = this->channel->getMessageSnapshot();
|
||||||
|
|
||||||
for (int i = 0; i < snapshot.getLength(); i++) {
|
for (size_t i = 0; i < snapshot.getLength(); i++) {
|
||||||
SharedMessageRef deleted;
|
SharedMessageRef deleted;
|
||||||
|
|
||||||
auto messageRef = new MessageRef(snapshot[i]);
|
auto messageRef = new MessageRef(snapshot[i]);
|
||||||
|
@ -261,7 +259,7 @@ void ChatWidget::doCloseSplit()
|
||||||
{
|
{
|
||||||
NotebookPage *page = static_cast<NotebookPage *>(this->parentWidget());
|
NotebookPage *page = static_cast<NotebookPage *>(this->parentWidget());
|
||||||
page->removeFromLayout(this);
|
page->removeFromLayout(this);
|
||||||
QTimer* timer = this->header.findChild<QTimer*>();
|
QTimer *timer = this->header.findChild<QTimer *>();
|
||||||
timer->stop();
|
timer->stop();
|
||||||
timer->deleteLater();
|
timer->deleteLater();
|
||||||
}
|
}
|
||||||
|
@ -269,9 +267,8 @@ void ChatWidget::doCloseSplit()
|
||||||
void ChatWidget::doChangeChannel()
|
void ChatWidget::doChangeChannel()
|
||||||
{
|
{
|
||||||
this->showChangeChannelPopup("Change channel");
|
this->showChangeChannelPopup("Change channel");
|
||||||
auto popup = this->findChildren<QDockWidget*>();
|
auto popup = this->findChildren<QDockWidget *>();
|
||||||
if(popup.at(0)->isVisible() && !popup.at(0)->isFloating())
|
if (popup.at(0)->isVisible() && !popup.at(0)->isFloating()) {
|
||||||
{
|
|
||||||
popup.at(0)->hide();
|
popup.at(0)->hide();
|
||||||
doOpenViewerList();
|
doOpenViewerList();
|
||||||
}
|
}
|
||||||
|
@ -310,7 +307,8 @@ void ChatWidget::doOpenPopupPlayer()
|
||||||
void ChatWidget::doOpenStreamlink()
|
void ChatWidget::doOpenStreamlink()
|
||||||
{
|
{
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
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
|
// TODO(Confuseh): Default streamlink paths
|
||||||
QString path = QString::fromStdString(settings.streamlinkPath.getValue());
|
QString path = QString::fromStdString(settings.streamlinkPath.getValue());
|
||||||
QString channel = QString::fromStdString(this->channelName.getValue());
|
QString channel = QString::fromStdString(this->channelName.getValue());
|
||||||
|
@ -344,29 +342,30 @@ void ChatWidget::doOpenStreamlink()
|
||||||
// my god that signal though
|
// my god that signal though
|
||||||
QObject::connect(p, static_cast<void (QProcess::*)(int)>(&QProcess::finished), this,
|
QObject::connect(p, static_cast<void (QProcess::*)(int)>(&QProcess::finished), this,
|
||||||
[path, channel, p](int exitCode) {
|
[path, channel, p](int exitCode) {
|
||||||
if (exitCode > 0) {
|
if (exitCode > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString lastLine = QString(p->readAllStandardOutput());
|
QString lastLine = QString(p->readAllStandardOutput());
|
||||||
lastLine = lastLine.trimmed().split('\n').last();
|
lastLine = lastLine.trimmed().split('\n').last();
|
||||||
if (lastLine.startsWith("Available streams: ")) {
|
if (lastLine.startsWith("Available streams: ")) {
|
||||||
QStringList options;
|
QStringList options;
|
||||||
QStringList split = lastLine.right(lastLine.length() - 19).split(", ");
|
QStringList split =
|
||||||
|
lastLine.right(lastLine.length() - 19).split(", ");
|
||||||
|
|
||||||
for (int i = split.length() - 1; i >= 0; i--) {
|
for (int i = split.length() - 1; i >= 0; i--) {
|
||||||
QString option = split.at(i);
|
QString option = split.at(i);
|
||||||
if (option.endsWith(" (worst)")) {
|
if (option.endsWith(" (worst)")) {
|
||||||
options << option.left(option.length() - 8);
|
options << option.left(option.length() - 8);
|
||||||
} else if (option.endsWith(" (best)")) {
|
} else if (option.endsWith(" (best)")) {
|
||||||
options << option.left(option.length() - 7);
|
options << option.left(option.length() - 7);
|
||||||
} else {
|
} else {
|
||||||
options << option;
|
options << option;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QualityPopup::showDialog(channel, path, options);
|
QualityPopup::showDialog(channel, path, options);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
p->start(path, {"twitch.tv/" + channel});
|
p->start(path, {"twitch.tv/" + channel});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,13 +373,13 @@ void ChatWidget::doOpenStreamlink()
|
||||||
|
|
||||||
void ChatWidget::doOpenViewerList()
|
void ChatWidget::doOpenViewerList()
|
||||||
{
|
{
|
||||||
auto viewerDock = new QDockWidget("Viewer List",this);
|
auto viewerDock = new QDockWidget("Viewer List", this);
|
||||||
viewerDock->setAllowedAreas(Qt::LeftDockWidgetArea);
|
viewerDock->setAllowedAreas(Qt::LeftDockWidgetArea);
|
||||||
viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar |
|
viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar |
|
||||||
QDockWidget::DockWidgetClosable |
|
QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable);
|
||||||
QDockWidget::DockWidgetFloatable);
|
viewerDock->resize(0.5 * this->width(),
|
||||||
viewerDock->resize(0.5*this->width(),this->height() - this->header.height() - this->input.height());
|
this->height() - this->header.height() - this->input.height());
|
||||||
viewerDock->move(0,this->header.height());
|
viewerDock->move(0, this->header.height());
|
||||||
|
|
||||||
auto accountPopup = new AccountPopupWidget(this->channel);
|
auto accountPopup = new AccountPopupWidget(this->channel);
|
||||||
auto multiWidget = new QWidget(viewerDock);
|
auto multiWidget = new QWidget(viewerDock);
|
||||||
|
@ -392,64 +391,56 @@ void ChatWidget::doOpenViewerList()
|
||||||
|
|
||||||
static QStringList labels = {"Moderators", "Staff", "Admins", "Global Moderators", "Viewers"};
|
static QStringList labels = {"Moderators", "Staff", "Admins", "Global Moderators", "Viewers"};
|
||||||
static QStringList jsonLabels = {"moderators", "staff", "admins", "global_mods", "viewers"};
|
static QStringList jsonLabels = {"moderators", "staff", "admins", "global_mods", "viewers"};
|
||||||
QList<QListWidgetItem*> labelList;
|
QList<QListWidgetItem *> labelList;
|
||||||
for(auto &x : labels)
|
for (auto &x : labels) {
|
||||||
{
|
|
||||||
auto label = new QListWidgetItem(x);
|
auto label = new QListWidgetItem(x);
|
||||||
label->setBackgroundColor(this->colorScheme.ChatHeaderBackground);
|
label->setBackgroundColor(this->colorScheme.ChatHeaderBackground);
|
||||||
labelList.append(label);
|
labelList.append(label);
|
||||||
}
|
}
|
||||||
auto loadingLabel = new QLabel("Loading...");
|
auto loadingLabel = new QLabel("Loading...");
|
||||||
|
|
||||||
util::twitch::get("https://tmi.twitch.tv/group/user/" + channel->name + "/chatters",[=](QJsonObject obj){
|
util::twitch::get(
|
||||||
QJsonObject chattersObj = obj.value("chatters").toObject();
|
"https://tmi.twitch.tv/group/user/" + channel->name + "/chatters", [=](QJsonObject obj) {
|
||||||
|
QJsonObject chattersObj = obj.value("chatters").toObject();
|
||||||
|
|
||||||
loadingLabel->hide();
|
loadingLabel->hide();
|
||||||
for(int i = 0; i < jsonLabels.size(); i++)
|
for (int i = 0; i < jsonLabels.size(); i++) {
|
||||||
{
|
chattersList->addItem(labelList.at(i));
|
||||||
chattersList->addItem(labelList.at(i));
|
foreach (const QJsonValue &v, chattersObj.value(jsonLabels.at(i)).toArray())
|
||||||
foreach (const QJsonValue & v, chattersObj.value(jsonLabels.at(i)).toArray())
|
chattersList->addItem(v.toString());
|
||||||
chattersList->addItem(v.toString());
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
searchBar->setPlaceholderText("Search User...");
|
searchBar->setPlaceholderText("Search User...");
|
||||||
QObject::connect(searchBar,&QLineEdit::textEdited,this,[=](){
|
QObject::connect(searchBar, &QLineEdit::textEdited, this, [=]() {
|
||||||
auto query = searchBar->text();
|
auto query = searchBar->text();
|
||||||
if(!query.isEmpty())
|
if (!query.isEmpty()) {
|
||||||
{
|
auto results = chattersList->findItems(query, Qt::MatchStartsWith);
|
||||||
auto results = chattersList->findItems(query,Qt::MatchStartsWith);
|
|
||||||
chattersList->hide();
|
chattersList->hide();
|
||||||
resultList->clear();
|
resultList->clear();
|
||||||
for (auto & item : results)
|
for (auto &item : results) {
|
||||||
{
|
if (!labels.contains(item->text()))
|
||||||
if(!labels.contains(item->text()))
|
|
||||||
resultList->addItem(item->text());
|
resultList->addItem(item->text());
|
||||||
}
|
}
|
||||||
resultList->show();
|
resultList->show();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
resultList->hide();
|
resultList->hide();
|
||||||
chattersList->show();
|
chattersList->show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(viewerDock,&QDockWidget::topLevelChanged,this,[=](){
|
QObject::connect(viewerDock, &QDockWidget::topLevelChanged, this,
|
||||||
viewerDock->setMinimumWidth(300);
|
[=]() { viewerDock->setMinimumWidth(300); });
|
||||||
});
|
|
||||||
|
|
||||||
QObject::connect(chattersList,&QListWidget::doubleClicked,this,[=](){
|
QObject::connect(chattersList, &QListWidget::doubleClicked, this, [=]() {
|
||||||
if(!labels.contains(chattersList->currentItem()->text()))
|
if (!labels.contains(chattersList->currentItem()->text())) {
|
||||||
{
|
doOpenAccountPopupWidget(accountPopup, chattersList->currentItem()->text());
|
||||||
doOpenAccountPopupWidget(accountPopup,chattersList->currentItem()->text());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(resultList,&QListWidget::doubleClicked,this,[=](){
|
QObject::connect(resultList, &QListWidget::doubleClicked, this, [=]() {
|
||||||
if(!labels.contains(resultList->currentItem()->text()))
|
if (!labels.contains(resultList->currentItem()->text())) {
|
||||||
{
|
doOpenAccountPopupWidget(accountPopup, resultList->currentItem()->text());
|
||||||
doOpenAccountPopupWidget(accountPopup,resultList->currentItem()->text());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "widgets/chatwidgetheader.hpp"
|
#include "widgets/chatwidgetheader.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "colorscheme.hpp"
|
||||||
|
#include "util/urlfetch.hpp"
|
||||||
#include "widgets/chatwidget.hpp"
|
#include "widgets/chatwidget.hpp"
|
||||||
#include "widgets/notebookpage.hpp"
|
#include "widgets/notebookpage.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
|
@ -81,21 +81,17 @@ void ChatWidgetHeader::updateChannelText()
|
||||||
if (channelName.empty()) {
|
if (channelName.empty()) {
|
||||||
this->channelNameLabel.setText("<no channel>");
|
this->channelNameLabel.setText("<no channel>");
|
||||||
} else {
|
} else {
|
||||||
if(this->chatWidget->getChannelRef()->isLive)
|
if (this->chatWidget->getChannelRef()->isLive) {
|
||||||
{
|
|
||||||
auto channel = this->chatWidget->getChannelRef();
|
auto channel = this->chatWidget->getChannelRef();
|
||||||
this->channelNameLabel.setText(QString::fromStdString(channelName) + " (live)");
|
this->channelNameLabel.setText(QString::fromStdString(channelName) + " (live)");
|
||||||
this->setToolTip("<style>.center { text-align: center; }</style>" \
|
this->setToolTip(
|
||||||
"<p class = \"center\">" + \
|
"<style>.center { text-align: center; }</style>"
|
||||||
channel->streamStatus + "<br><br>" + \
|
"<p class = \"center\">" +
|
||||||
channel->streamGame + "<br>" \
|
channel->streamStatus + "<br><br>" + channel->streamGame + "<br>"
|
||||||
"Live for " + channel->streamUptime + \
|
"Live for " +
|
||||||
" with " + channel->streamViewerCount + " viewers" \
|
channel->streamUptime + " with " + channel->streamViewerCount + " viewers"
|
||||||
"</p>"
|
"</p>");
|
||||||
);
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->channelNameLabel.setText(QString::fromStdString(channelName));
|
this->channelNameLabel.setText(QString::fromStdString(channelName));
|
||||||
this->setToolTip("");
|
this->setToolTip("");
|
||||||
}
|
}
|
||||||
|
@ -161,8 +157,10 @@ void ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void ChatWidgetHeader::leftButtonClicked()
|
void ChatWidgetHeader::leftButtonClicked()
|
||||||
{
|
{
|
||||||
this->leftMenu.move(this->leftLabel.mapToGlobal(QPoint(0, this->leftLabel.height())));
|
QTimer::singleShot(100, [&] {
|
||||||
this->leftMenu.show();
|
this->leftMenu.move(this->leftLabel.mapToGlobal(QPoint(0, this->leftLabel.height())));
|
||||||
|
this->leftMenu.show();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidgetHeader::rightButtonClicked()
|
void ChatWidgetHeader::rightButtonClicked()
|
||||||
|
@ -199,24 +197,23 @@ void ChatWidgetHeader::checkLive()
|
||||||
{
|
{
|
||||||
auto channel = this->chatWidget->getChannelRef();
|
auto channel = this->chatWidget->getChannelRef();
|
||||||
auto id = QString::fromStdString(channel->roomID);
|
auto id = QString::fromStdString(channel->roomID);
|
||||||
util::twitch::get("https://api.twitch.tv/kraken/streams/" + id,[=](QJsonObject obj){
|
util::twitch::get("https://api.twitch.tv/kraken/streams/" + id, [=](QJsonObject obj) {
|
||||||
if(obj.value("stream").isNull())
|
if (obj.value("stream").isNull()) {
|
||||||
{
|
channel->isLive = false;
|
||||||
channel->isLive = false;
|
this->updateChannelText();
|
||||||
this->updateChannelText();
|
} else {
|
||||||
}
|
channel->isLive = true;
|
||||||
else
|
auto stream = obj.value("stream").toObject();
|
||||||
{
|
channel->streamViewerCount = QString::number(stream.value("viewers").toDouble());
|
||||||
channel->isLive = true;
|
channel->streamGame = stream.value("game").toString();
|
||||||
auto stream = obj.value("stream").toObject();
|
channel->streamStatus = stream.value("channel").toObject().value("status").toString();
|
||||||
channel->streamViewerCount = QString::number(stream.value("viewers").toDouble());
|
QDateTime since =
|
||||||
channel->streamGame = stream.value("game").toString();
|
QDateTime::fromString(stream.value("created_at").toString(), Qt::ISODate);
|
||||||
channel->streamStatus = stream.value("channel").toObject().value("status").toString();
|
auto diff = since.secsTo(QDateTime::currentDateTime());
|
||||||
QDateTime since = QDateTime::fromString(stream.value("created_at").toString(),Qt::ISODate);
|
channel->streamUptime =
|
||||||
auto diff = since.secsTo(QDateTime::currentDateTime());
|
QString::number(diff / 3600) + "h " + QString::number(diff % 3600 / 60) + "m";
|
||||||
channel->streamUptime = QString::number(diff/3600) + "h " + QString::number(diff % 3600 / 60) + "m";
|
this->updateChannelText();
|
||||||
this->updateChannelText();
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,7 @@ namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
ChatWidgetHeaderButton::ChatWidgetHeaderButton(BaseWidget *parent, int spacing)
|
ChatWidgetHeaderButton::ChatWidgetHeaderButton(BaseWidget *parent, int spacing)
|
||||||
: BaseWidget(parent)
|
: FancyButton(parent)
|
||||||
, mouseOver(false)
|
|
||||||
, mouseDown(false)
|
|
||||||
{
|
{
|
||||||
setLayout(&this->ui.hbox);
|
setLayout(&this->ui.hbox);
|
||||||
|
|
||||||
|
@ -22,76 +20,14 @@ ChatWidgetHeaderButton::ChatWidgetHeaderButton(BaseWidget *parent, int spacing)
|
||||||
this->ui.hbox.addWidget(&this->ui.label);
|
this->ui.hbox.addWidget(&this->ui.label);
|
||||||
this->ui.hbox.addSpacing(spacing);
|
this->ui.hbox.addSpacing(spacing);
|
||||||
|
|
||||||
QObject::connect(&this->ui.label, &SignalLabel::mouseUp, this,
|
this->setMouseEffectColor(QColor(255, 255, 255, 63));
|
||||||
&ChatWidgetHeaderButton::labelMouseUp);
|
|
||||||
QObject::connect(&this->ui.label, &SignalLabel::mouseDown, this,
|
|
||||||
&ChatWidgetHeaderButton::labelMouseDown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidgetHeaderButton::paintEvent(QPaintEvent *)
|
void ChatWidgetHeaderButton::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
QBrush brush(this->colorScheme.isLightTheme() ? QColor(0, 0, 0, 32)
|
this->fancyPaint(painter);
|
||||||
: 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace widgets
|
} // namespace widgets
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "widgets/basewidget.hpp"
|
#include "widgets/basewidget.hpp"
|
||||||
|
#include "widgets/fancybutton.hpp"
|
||||||
#include "widgets/signallabel.hpp"
|
#include "widgets/signallabel.hpp"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -16,10 +17,8 @@ namespace widgets {
|
||||||
|
|
||||||
class ChatWidgetHeader;
|
class ChatWidgetHeader;
|
||||||
|
|
||||||
class ChatWidgetHeaderButton : public BaseWidget
|
class ChatWidgetHeaderButton : public FancyButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ChatWidgetHeaderButton(BaseWidget *parent, int spacing = 6);
|
explicit ChatWidgetHeaderButton(BaseWidget *parent, int spacing = 6);
|
||||||
|
|
||||||
|
@ -28,29 +27,14 @@ public:
|
||||||
return this->ui.label;
|
return this->ui.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
|
||||||
void clicked();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent *) override;
|
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:
|
private:
|
||||||
struct {
|
struct {
|
||||||
QHBoxLayout hbox;
|
QHBoxLayout hbox;
|
||||||
SignalLabel label;
|
SignalLabel label;
|
||||||
} ui;
|
} ui;
|
||||||
|
|
||||||
bool mouseOver = false;
|
|
||||||
bool mouseDown = false;
|
|
||||||
|
|
||||||
void labelMouseUp();
|
|
||||||
void labelMouseDown();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace widgets
|
} // namespace widgets
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <boost/signals2.hpp>
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
@ -23,7 +22,7 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget)
|
||||||
|
|
||||||
this->setLayout(&this->hbox);
|
this->setLayout(&this->hbox);
|
||||||
|
|
||||||
this->hbox.setMargin(4);
|
this->hbox.setMargin(0);
|
||||||
|
|
||||||
this->hbox.addLayout(&this->editContainer);
|
this->hbox.addLayout(&this->editContainer);
|
||||||
this->hbox.addLayout(&this->vbox);
|
this->hbox.addLayout(&this->vbox);
|
||||||
|
@ -31,6 +30,8 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget)
|
||||||
this->editContainer.addWidget(&this->textInput);
|
this->editContainer.addWidget(&this->textInput);
|
||||||
this->editContainer.setMargin(4);
|
this->editContainer.setMargin(4);
|
||||||
|
|
||||||
|
this->emotesLabel.setMinimumHeight(24);
|
||||||
|
|
||||||
this->vbox.addWidget(&this->textLengthLabel);
|
this->vbox.addWidget(&this->textLengthLabel);
|
||||||
this->vbox.addStretch(1);
|
this->vbox.addStretch(1);
|
||||||
this->vbox.addWidget(&this->emotesLabel);
|
this->vbox.addWidget(&this->emotesLabel);
|
||||||
|
@ -43,10 +44,18 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget)
|
||||||
"<img src=':/images/Emoji_Color_1F60A_19.png' width='12' height='12' "
|
"<img src=':/images/Emoji_Color_1F60A_19.png' width='12' height='12' "
|
||||||
"/>");
|
"/>");
|
||||||
|
|
||||||
|
connect(&this->emotesLabel, &ChatWidgetHeaderButton::clicked, [this] {
|
||||||
|
if (this->emotePopup == nullptr) {
|
||||||
|
this->emotePopup = new EmotePopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
this->emotePopup->show(); //
|
||||||
|
});
|
||||||
|
|
||||||
connect(&textInput, &ResizingTextEdit::textChanged, this, &ChatWidgetInput::editTextChanged);
|
connect(&textInput, &ResizingTextEdit::textChanged, this, &ChatWidgetInput::editTextChanged);
|
||||||
|
|
||||||
this->refreshTheme();
|
this->refreshTheme();
|
||||||
this->setMessageLengthVisible(SettingsManager::getInstance().showMessageLength.get());
|
textLengthLabel.setHidden(!SettingsManager::getInstance().showMessageLength.get());
|
||||||
|
|
||||||
auto completer = new QCompleter(
|
auto completer = new QCompleter(
|
||||||
this->chatWidget->completionManager.createModel(this->chatWidget->channelName));
|
this->chatWidget->completionManager.createModel(this->chatWidget->channelName));
|
||||||
|
@ -148,21 +157,14 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* XXX(pajlada): FIX THIS
|
this->textLengthVisibleChangedConnection =
|
||||||
QObject::connect(&Settings::getInstance().showMessageLength,
|
SettingsManager::getInstance().showMessageLength.valueChanged.connect(
|
||||||
&BoolSetting::valueChanged, this,
|
[this](const bool &value) { this->textLengthLabel.setHidden(!value); });
|
||||||
&ChatWidgetInput::setMessageLengthVisible);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatWidgetInput::~ChatWidgetInput()
|
ChatWidgetInput::~ChatWidgetInput()
|
||||||
{
|
{
|
||||||
/* XXX(pajlada): FIX THIS
|
this->textLengthVisibleChangedConnection.disconnect();
|
||||||
QObject::disconnect(
|
|
||||||
&Settings::getInstance().getShowMessageLength(),
|
|
||||||
&BoolSetting::valueChanged, this,
|
|
||||||
&ChatWidgetInput::setMessageLengthVisible);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidgetInput::refreshTheme()
|
void ChatWidgetInput::refreshTheme()
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "resizingtextedit.hpp"
|
#include "resizingtextedit.hpp"
|
||||||
#include "widgets/basewidget.hpp"
|
#include "widgets/basewidget.hpp"
|
||||||
#include "widgets/chatwidgetheaderbutton.hpp"
|
#include "widgets/chatwidgetheaderbutton.hpp"
|
||||||
|
#include "widgets/emotepopup.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -12,6 +13,8 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <boost/signals2.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
@ -33,7 +36,9 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ChatWidget *const chatWidget;
|
ChatWidget *const chatWidget;
|
||||||
|
EmotePopup *emotePopup = nullptr;
|
||||||
|
|
||||||
|
boost::signals2::connection textLengthVisibleChangedConnection;
|
||||||
QHBoxLayout hbox;
|
QHBoxLayout hbox;
|
||||||
QVBoxLayout vbox;
|
QVBoxLayout vbox;
|
||||||
QHBoxLayout editContainer;
|
QHBoxLayout editContainer;
|
||||||
|
@ -45,10 +50,6 @@ private:
|
||||||
virtual void refreshTheme() override;
|
virtual void refreshTheme() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setMessageLengthVisible(bool value)
|
|
||||||
{
|
|
||||||
textLengthLabel.setHidden(!value);
|
|
||||||
}
|
|
||||||
void editTextChanged();
|
void editTextChanged();
|
||||||
// void editKeyPressed(QKeyEvent *event);
|
// void editKeyPressed(QKeyEvent *event);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ ChatWidgetView::ChatWidgetView(ChatWidget *_chatWidget)
|
||||||
, userPopupWidget(_chatWidget->getChannelRef())
|
, userPopupWidget(_chatWidget->getChannelRef())
|
||||||
{
|
{
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
this->setAttribute(Qt::WA_OpaquePaintEvent);
|
// this->setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
#endif
|
#endif
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
|
@ -70,7 +70,8 @@ bool ChatWidgetView::layoutMessages()
|
||||||
this->showingLatestMessages = this->scrollBar.isAtBottom() || !this->scrollBar.isVisible();
|
this->showingLatestMessages = this->scrollBar.isAtBottom() || !this->scrollBar.isVisible();
|
||||||
|
|
||||||
size_t start = this->scrollBar.getCurrentValue();
|
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
|
// layout the visible messages in the view
|
||||||
if (messages.getLength() > start) {
|
if (messages.getLength() > start) {
|
||||||
|
@ -258,17 +259,17 @@ void ChatWidgetView::paintEvent(QPaintEvent * /*event*/)
|
||||||
|
|
||||||
// only update gif emotes
|
// only update gif emotes
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
if (this->onlyUpdateEmotes) {
|
// if (this->onlyUpdateEmotes) {
|
||||||
this->onlyUpdateEmotes = false;
|
// this->onlyUpdateEmotes = false;
|
||||||
|
|
||||||
for (const GifEmoteData &item : this->gifEmotes) {
|
// for (const GifEmoteData &item : this->gifEmotes) {
|
||||||
painter.fillRect(item.rect, this->colorScheme.ChatBackground);
|
// painter.fillRect(item.rect, this->colorScheme.ChatBackground);
|
||||||
|
|
||||||
painter.drawPixmap(item.rect, *item.image->getPixmap());
|
// painter.drawPixmap(item.rect, *item.image->getPixmap());
|
||||||
}
|
// }
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// update all messages
|
// update all messages
|
||||||
|
|
18
src/widgets/emotepopup.cpp
Normal file
18
src/widgets/emotepopup.cpp
Normal file
|
@ -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)
|
||||||
|
{
|
||||||
|
// channel->bttvChannelEmotes.each([](const QString &key, const EmoteData &value) {
|
||||||
|
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
src/widgets/emotepopup.h
Normal file
18
src/widgets/emotepopup.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "channel.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace widgets {
|
||||||
|
|
||||||
|
class EmotePopup : public QWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit EmotePopup(QWidget *parent = 0);
|
||||||
|
|
||||||
|
void loadChannel(std::shared_ptr<Channel> channel);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -86,6 +86,10 @@ void FancyButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
this->mouseDown = false;
|
this->mouseDown = false;
|
||||||
|
|
||||||
|
if (this->rect().contains(event->pos())) {
|
||||||
|
emit clicked();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyButton::mouseMoveEvent(QMouseEvent *event)
|
void FancyButton::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
|
|
@ -13,6 +13,8 @@ namespace widgets {
|
||||||
|
|
||||||
class FancyButton : public BaseWidget
|
class FancyButton : public BaseWidget
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
struct ClickEffect {
|
struct ClickEffect {
|
||||||
double progress = 0.0;
|
double progress = 0.0;
|
||||||
QPoint position;
|
QPoint position;
|
||||||
|
@ -28,6 +30,9 @@ public:
|
||||||
|
|
||||||
void setMouseEffectColor(QColor color);
|
void setMouseEffectColor(QColor color);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void clicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool selected = false;
|
bool selected = false;
|
||||||
bool mouseOver = false;
|
bool mouseOver = false;
|
||||||
|
|
|
@ -212,7 +212,7 @@ void Notebook::resizeEvent(QResizeEvent *)
|
||||||
|
|
||||||
void Notebook::settingsButtonClicked()
|
void Notebook::settingsButtonClicked()
|
||||||
{
|
{
|
||||||
SettingsDialog::showDialog();
|
QTimer::singleShot(100, [this] { SettingsDialog::showDialog(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notebook::usersButtonClicked()
|
void Notebook::usersButtonClicked()
|
||||||
|
@ -221,7 +221,7 @@ void Notebook::usersButtonClicked()
|
||||||
|
|
||||||
void Notebook::addPageButtonClicked()
|
void Notebook::addPageButtonClicked()
|
||||||
{
|
{
|
||||||
addPage(true);
|
QTimer::singleShot(100, [this] { this->addPage(true); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notebook::load(const boost::property_tree::ptree &tree)
|
void Notebook::load(const boost::property_tree::ptree &tree)
|
||||||
|
|
Loading…
Reference in a new issue