changed to 80 max column

This commit is contained in:
fourtf
2018-08-06 21:17:03 +02:00
parent defa7e41fa
commit f71ff08e68
203 changed files with 3792 additions and 2405 deletions
+158 -104
View File
@@ -33,7 +33,8 @@
namespace chatterino {
namespace {
void addEmoteContextMenuItems(const Emote &emote, MessageElement::Flags creatorFlags, QMenu &menu)
void addEmoteContextMenuItems(const Emote &emote,
MessageElement::Flags creatorFlags, QMenu &menu)
{
auto openAction = menu.addAction("Open");
auto openMenu = new QMenu;
@@ -45,18 +46,21 @@ void addEmoteContextMenuItems(const Emote &emote, MessageElement::Flags creatorF
// see if the QMenu actually gets destroyed
QObject::connect(openMenu, &QMenu::destroyed, [] {
QMessageBox(QMessageBox::Information, "xD", "the menu got deleted").exec();
QMessageBox(QMessageBox::Information, "xD", "the menu got deleted")
.exec();
});
// Add copy and open links for 1x, 2x, 3x
auto addImageLink = [&](const ImagePtr &image, char scale) {
if (!image->empty()) {
copyMenu->addAction(QString(scale) + "x link", [url = image->url()] {
QApplication::clipboard()->setText(url.string);
});
openMenu->addAction(QString(scale) + "x link", [url = image->url()] {
QDesktopServices::openUrl(QUrl(url.string));
});
copyMenu->addAction(
QString(scale) + "x link", [url = image->url()] {
QApplication::clipboard()->setText(url.string);
});
openMenu->addAction(QString(scale) + "x link",
[url = image->url()] {
QDesktopServices::openUrl(QUrl(url.string));
});
}
};
@@ -69,12 +73,14 @@ void addEmoteContextMenuItems(const Emote &emote, MessageElement::Flags creatorF
copyMenu->addSeparator();
openMenu->addSeparator();
copyMenu->addAction("Copy " + name + " emote link", [url = emote.homePage] {
QApplication::clipboard()->setText(url.string); //
});
openMenu->addAction("Open " + name + " emote link", [url = emote.homePage] {
QDesktopServices::openUrl(QUrl(url.string)); //
});
copyMenu->addAction(
"Copy " + name + " emote link", [url = emote.homePage] {
QApplication::clipboard()->setText(url.string); //
});
openMenu->addAction("Open " + name + " emote link",
[url = emote.homePage] {
QDesktopServices::openUrl(QUrl(url.string)); //
});
};
if (creatorFlags & MessageElement::Flags::BttvEmote) {
@@ -99,7 +105,8 @@ ChannelView::ChannelView(BaseWidget *parent)
}));
this->scrollBar_.getCurrentValueChanged().connect([this] {
// Whenever the scrollbar value has been changed, re-render the ChatWidgetView
// Whenever the scrollbar value has been changed, re-render the
// ChatWidgetView
this->actuallyLayoutMessages(true);
// if (!this->isPaused()) {
@@ -111,21 +118,24 @@ ChannelView::ChannelView(BaseWidget *parent)
this->queueUpdate();
});
this->scrollBar_.getDesiredValueChanged().connect(
[this] { this->pausedByScrollingUp_ = !this->scrollBar_.isAtBottom(); });
this->scrollBar_.getDesiredValueChanged().connect([this] {
this->pausedByScrollingUp_ = !this->scrollBar_.isAtBottom();
});
this->connections_.push_back(app->windows->repaintGifs.connect([&] {
this->queueUpdate(); //
}));
this->connections_.push_back(app->windows->layout.connect([&](Channel *channel) {
if (channel == nullptr || this->channel_.get() == channel) {
this->layoutMessages();
}
}));
this->connections_.push_back(
app->windows->layout.connect([&](Channel *channel) {
if (channel == nullptr || this->channel_.get() == channel) {
this->layoutMessages();
}
}));
this->goToBottom_ = new RippleEffectLabel(this, 0);
this->goToBottom_->setStyleSheet("background-color: rgba(0,0,0,0.66); color: #FFF;");
this->goToBottom_->setStyleSheet(
"background-color: rgba(0,0,0,0.66); color: #FFF;");
this->goToBottom_->getLabel().setText("More messages below");
this->goToBottom_->setVisible(false);
@@ -175,8 +185,9 @@ ChannelView::ChannelView(BaseWidget *parent)
});
QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+C"), this);
QObject::connect(shortcut, &QShortcut::activated,
[this] { QGuiApplication::clipboard()->setText(this->getSelectedText()); });
QObject::connect(shortcut, &QShortcut::activated, [this] {
QGuiApplication::clipboard()->setText(this->getSelectedText());
});
}
ChannelView::~ChannelView()
@@ -235,7 +246,8 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
// True if one of the following statements are true:
// The scrollbar was not visible
// The scrollbar was visible and at the bottom
this->showingLatestMessages_ = this->scrollBar_.isAtBottom() || !this->scrollBar_.isVisible();
this->showingLatestMessages_ =
this->scrollBar_.isAtBottom() || !this->scrollBar_.isVisible();
size_t start = size_t(this->scrollBar_.getCurrentValue());
int layoutWidth = this->getLayoutWidth();
@@ -250,7 +262,8 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
auto message = messagesSnapshot[i];
redrawRequired |= message->layout(layoutWidth, this->getScale(), flags);
redrawRequired |=
message->layout(layoutWidth, this->getScale(), flags);
y += message->getHeight();
@@ -288,9 +301,10 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
this->scrollBar_.setMaximum(messagesSnapshot.getLength());
// If we were showing the latest messages and the scrollbar now wants to be rendered, scroll
// to bottom
if (this->enableScrollingToBottom_ && this->showingLatestMessages_ && showScrollbar) {
// If we were showing the latest messages and the scrollbar now wants to be
// rendered, scroll to bottom
if (this->enableScrollingToBottom_ && this->showingLatestMessages_ &&
showScrollbar) {
if (!this->isPaused()) {
this->scrollBar_.scrollToBottom(
// this->messageWasAdded &&
@@ -309,7 +323,8 @@ void ChannelView::clearMessages()
// Clear all stored messages in this chat widget
this->messages.clear();
// Layout chat widget messages, and force an update regardless if there are no messages
// Layout chat widget messages, and force an update regardless if there are
// no messages
this->layoutMessages();
this->queueUpdate();
}
@@ -323,7 +338,8 @@ QString ChannelView::getSelectedText()
{
QString result = "";
LimitedQueueSnapshot<MessageLayoutPtr> messagesSnapshot = this->getMessagesSnapshot();
LimitedQueueSnapshot<MessageLayoutPtr> messagesSnapshot =
this->getMessagesSnapshot();
Selection _selection = this->selection_;
@@ -334,10 +350,12 @@ QString ChannelView::getSelectedText()
for (int msg = _selection.selectionMin.messageIndex;
msg <= _selection.selectionMax.messageIndex; msg++) {
MessageLayoutPtr layout = messagesSnapshot[msg];
int from =
msg == _selection.selectionMin.messageIndex ? _selection.selectionMin.charIndex : 0;
int to = msg == _selection.selectionMax.messageIndex ? _selection.selectionMax.charIndex
: layout->getLastCharacterIndex() + 1;
int from = msg == _selection.selectionMin.messageIndex
? _selection.selectionMin.charIndex
: 0;
int to = msg == _selection.selectionMax.messageIndex
? _selection.selectionMax.charIndex
: layout->getLastCharacterIndex() + 1;
qDebug() << "from:" << from << ", to:" << to;
@@ -374,7 +392,8 @@ void ChannelView::setOverrideFlags(boost::optional<MessageElement::Flags> value)
this->overrideFlags_ = value;
}
const boost::optional<MessageElement::Flags> &ChannelView::getOverrideFlags() const
const boost::optional<MessageElement::Flags> &ChannelView::getOverrideFlags()
const
{
return this->overrideFlags_;
}
@@ -406,13 +425,15 @@ void ChannelView::setChannel(ChannelPtr newChannel)
if (this->lastMessageHasAlternateBackground_) {
messageRef->flags |= MessageLayout::AlternateBackground;
}
this->lastMessageHasAlternateBackground_ = !this->lastMessageHasAlternateBackground_;
this->lastMessageHasAlternateBackground_ =
!this->lastMessageHasAlternateBackground_;
if (this->isPaused()) {
this->messagesAddedSinceSelectionPause_++;
}
if (this->messages.pushBack(MessageLayoutPtr(messageRef), deleted)) {
if (this->messages.pushBack(MessageLayoutPtr(messageRef),
deleted)) {
// if (!this->isPaused()) {
if (this->scrollBar_.isAtBottom()) {
this->scrollBar_.scrollToBottom();
@@ -424,9 +445,11 @@ void ChannelView::setChannel(ChannelPtr newChannel)
if (!(message->flags & Message::DoNotTriggerNotification)) {
if (message->flags & Message::Highlighted) {
this->tabHighlightRequested.invoke(HighlightState::Highlighted);
this->tabHighlightRequested.invoke(
HighlightState::Highlighted);
} else {
this->tabHighlightRequested.invoke(HighlightState::NewMessage);
this->tabHighlightRequested.invoke(
HighlightState::NewMessage);
}
}
@@ -437,34 +460,37 @@ void ChannelView::setChannel(ChannelPtr newChannel)
}));
this->channelConnections_.push_back(
newChannel->messagesAddedAtStart.connect([this](std::vector<MessagePtr> &messages) {
std::vector<MessageLayoutPtr> messageRefs;
messageRefs.resize(messages.size());
for (size_t i = 0; i < messages.size(); i++) {
messageRefs.at(i) = MessageLayoutPtr(new MessageLayout(messages.at(i)));
}
newChannel->messagesAddedAtStart.connect(
[this](std::vector<MessagePtr> &messages) {
std::vector<MessageLayoutPtr> messageRefs;
messageRefs.resize(messages.size());
for (size_t i = 0; i < messages.size(); i++) {
messageRefs.at(i) =
MessageLayoutPtr(new MessageLayout(messages.at(i)));
}
if (!this->isPaused()) {
if (this->messages.pushFront(messageRefs).size() > 0) {
if (this->scrollBar_.isAtBottom()) {
this->scrollBar_.scrollToBottom();
} else {
this->scrollBar_.offset(qreal(messages.size()));
if (!this->isPaused()) {
if (this->messages.pushFront(messageRefs).size() > 0) {
if (this->scrollBar_.isAtBottom()) {
this->scrollBar_.scrollToBottom();
} else {
this->scrollBar_.offset(qreal(messages.size()));
}
}
}
}
std::vector<ScrollbarHighlight> highlights;
highlights.reserve(messages.size());
for (size_t i = 0; i < messages.size(); i++) {
highlights.push_back(messages.at(i)->getScrollBarHighlight());
}
std::vector<ScrollbarHighlight> highlights;
highlights.reserve(messages.size());
for (size_t i = 0; i < messages.size(); i++) {
highlights.push_back(
messages.at(i)->getScrollBarHighlight());
}
this->scrollBar_.addHighlightsAtStart(highlights);
this->scrollBar_.addHighlightsAtStart(highlights);
this->messageWasAdded_ = true;
this->layoutMessages();
}));
this->messageWasAdded_ = true;
this->layoutMessages();
}));
// on message removed
this->channelConnections_.push_back(
@@ -478,17 +504,19 @@ void ChannelView::setChannel(ChannelPtr newChannel)
}));
// on message replaced
this->channelConnections_.push_back(
newChannel->messageReplaced.connect([this](size_t index, MessagePtr replacement) {
if (index >= this->messages.getSnapshot().getLength() || index < 0) {
this->channelConnections_.push_back(newChannel->messageReplaced.connect(
[this](size_t index, MessagePtr replacement) {
if (index >= this->messages.getSnapshot().getLength() ||
index < 0) {
return;
}
MessageLayoutPtr newItem(new MessageLayout(replacement));
auto snapshot = this->messages.getSnapshot();
if (index >= snapshot.getLength()) {
Log("Tried to replace out of bounds message. Index: {}. Length: {}", index,
snapshot.getLength());
Log("Tried to replace out of bounds message. Index: {}. "
"Length: {}",
index, snapshot.getLength());
return;
}
@@ -497,7 +525,8 @@ void ChannelView::setChannel(ChannelPtr newChannel)
newItem->flags |= MessageLayout::AlternateBackground;
}
this->scrollBar_.replaceHighlight(index, replacement->getScrollBarHighlight());
this->scrollBar_.replaceHighlight(
index, replacement->getScrollBarHighlight());
this->messages.replaceItem(message, newItem);
this->layoutMessages();
@@ -513,7 +542,8 @@ void ChannelView::setChannel(ChannelPtr newChannel)
if (this->lastMessageHasAlternateBackground_) {
messageRef->flags |= MessageLayout::AlternateBackground;
}
this->lastMessageHasAlternateBackground_ = !this->lastMessageHasAlternateBackground_;
this->lastMessageHasAlternateBackground_ =
!this->lastMessageHasAlternateBackground_;
this->messages.pushBack(MessageLayoutPtr(messageRef), deleted);
}
@@ -567,7 +597,8 @@ void ChannelView::resizeEvent(QResizeEvent *)
this->update();
}
void ChannelView::setSelection(const SelectionItem &start, const SelectionItem &end)
void ChannelView::setSelection(const SelectionItem &start,
const SelectionItem &end)
{
// selections
if (!this->selecting_ && start != end) {
@@ -596,7 +627,8 @@ MessageElement::Flags ChannelView::getFlags() const
if (split != nullptr) {
if (split->getModerationMode()) {
flags = MessageElement::Flags(flags | MessageElement::ModeratorTools);
flags =
MessageElement::Flags(flags | MessageElement::ModeratorTools);
}
if (this->channel_ == app->twitch.server->mentionsChannel) {
flags = MessageElement::Flags(flags | MessageElement::ChannelName);
@@ -609,7 +641,8 @@ MessageElement::Flags ChannelView::getFlags() const
bool ChannelView::isPaused()
{
return false;
// return this->pausedTemporarily_ || this->pausedBySelection_ || this->pausedByScrollingUp_;
// return this->pausedTemporarily_ || this->pausedBySelection_ ||
// this->pausedByScrollingUp_;
}
void ChannelView::updatePauseStatus()
@@ -633,8 +666,8 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
this->drawMessages(painter);
}
// if overlays is false then it draws the message, if true then it draws things such as the grey
// overlay when a message is disabled
// if overlays is false then it draws the message, if true then it draws things
// such as the grey overlay when a message is disabled
void ChannelView::drawMessages(QPainter &painter)
{
auto app = getApp();
@@ -661,7 +694,8 @@ void ChannelView::drawMessages(QPainter &painter)
isLastMessage = this->lastReadMessage_.get() == layout;
}
layout->paint(painter, DRAW_WIDTH, y, i, this->selection_, isLastMessage, windowFocused);
layout->paint(painter, DRAW_WIDTH, y, i, this->selection_,
isLastMessage, windowFocused);
y += layout->getHeight();
@@ -732,7 +766,8 @@ void ChannelView::wheelEvent(QWheelEvent *event)
if (delta > 0) {
qreal scrollFactor = fmod(desired, 1);
qreal currentScrollLeft = int(scrollFactor * snapshot[i]->getHeight());
qreal currentScrollLeft =
int(scrollFactor * snapshot[i]->getHeight());
for (; i >= 0; i--) {
if (delta < currentScrollLeft) {
@@ -746,8 +781,8 @@ void ChannelView::wheelEvent(QWheelEvent *event)
if (i == 0) {
desired = 0;
} else {
snapshot[i - 1]->layout(this->getLayoutWidth(), this->getScale(),
this->getFlags());
snapshot[i - 1]->layout(this->getLayoutWidth(),
this->getScale(), this->getFlags());
scrollFactor = 1;
currentScrollLeft = snapshot[i - 1]->getHeight();
}
@@ -755,11 +790,13 @@ void ChannelView::wheelEvent(QWheelEvent *event)
} else {
delta = -delta;
qreal scrollFactor = 1 - fmod(desired, 1);
qreal currentScrollLeft = int(scrollFactor * snapshot[i]->getHeight());
qreal currentScrollLeft =
int(scrollFactor * snapshot[i]->getHeight());
for (; i < snapshotLength; i++) {
if (delta < currentScrollLeft) {
desired += scrollFactor * (qreal(delta) / currentScrollLeft);
desired +=
scrollFactor * (qreal(delta) / currentScrollLeft);
break;
} else {
delta -= currentScrollLeft;
@@ -769,8 +806,8 @@ void ChannelView::wheelEvent(QWheelEvent *event)
if (i == snapshotLength - 1) {
desired = snapshot.getLength();
} else {
snapshot[i + 1]->layout(this->getLayoutWidth(), this->getScale(),
this->getFlags());
snapshot[i + 1]->layout(this->getLayoutWidth(),
this->getScale(), this->getFlags());
scrollFactor = 1;
currentScrollLeft = snapshot[i + 1]->getHeight();
@@ -826,7 +863,8 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
this->pause(300);
int index = layout->getSelectionIndex(relativePos);
this->setSelection(this->selection_.start, SelectionItem(messageIndex, index));
this->setSelection(this->selection_.start,
SelectionItem(messageIndex, index));
this->queueUpdate();
}
@@ -839,7 +877,8 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
}
// check if word underneath cursor
const MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos);
const MessageLayoutElement *hoverLayoutElement =
layout->getElementAt(relativePos);
if (hoverLayoutElement == nullptr) {
this->setCursor(Qt::ArrowCursor);
@@ -934,7 +973,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
if (this->isMouseDown_) {
this->isMouseDown_ = false;
if (fabsf(distanceBetweenPoints(this->lastPressPosition_, event->screenPos())) > 15.f) {
if (fabsf(distanceBetweenPoints(this->lastPressPosition_,
event->screenPos())) > 15.f) {
return;
}
} else {
@@ -944,8 +984,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
if (this->isRightMouseDown_) {
this->isRightMouseDown_ = false;
if (fabsf(distanceBetweenPoints(this->lastRightPressPosition_, event->screenPos())) >
15.f) {
if (fabsf(distanceBetweenPoints(this->lastRightPressPosition_,
event->screenPos())) > 15.f) {
return;
}
} else {
@@ -978,7 +1018,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
return;
}
const MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos);
const MessageLayoutElement *hoverLayoutElement =
layout->getElementAt(relativePos);
if (hoverLayoutElement == nullptr) {
return;
@@ -988,7 +1029,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
this->handleMouseClick(event, hoverLayoutElement, layout.get());
}
void ChannelView::handleMouseClick(QMouseEvent *event, const MessageLayoutElement *hoveredElement,
void ChannelView::handleMouseClick(QMouseEvent *event,
const MessageLayoutElement *hoveredElement,
MessageLayout *layout)
{
switch (event->button()) {
@@ -1029,8 +1071,8 @@ void ChannelView::handleMouseClick(QMouseEvent *event, const MessageLayoutElemen
}
}
void ChannelView::addContextMenuItems(const MessageLayoutElement *hoveredElement,
MessageLayout *layout)
void ChannelView::addContextMenuItems(
const MessageLayoutElement *hoveredElement, MessageLayout *layout)
{
const auto &creator = hoveredElement->getCreator();
auto creatorFlags = creator.getFlags();
@@ -1039,9 +1081,12 @@ void ChannelView::addContextMenuItems(const MessageLayoutElement *hoveredElement
menu->clear();
// Emote actions
if (creatorFlags & (MessageElement::Flags::EmoteImages | MessageElement::Flags::EmojiImage)) {
if (creatorFlags & (MessageElement::Flags::EmoteImages |
MessageElement::Flags::EmojiImage)) {
const auto emoteElement = dynamic_cast<const EmoteElement *>(&creator);
if (emoteElement) addEmoteContextMenuItems(*emoteElement->getEmote(), creatorFlags, *menu);
if (emoteElement)
addEmoteContextMenuItems(*emoteElement->getEmote(), creatorFlags,
*menu);
}
// add seperator
@@ -1053,16 +1098,19 @@ void ChannelView::addContextMenuItems(const MessageLayoutElement *hoveredElement
if (hoveredElement->getLink().type == Link::Url) {
QString url = hoveredElement->getLink().value;
menu->addAction("Open link", [url] { QDesktopServices::openUrl(QUrl(url)); });
menu->addAction("Copy link", [url] { QApplication::clipboard()->setText(url); });
menu->addAction("Open link",
[url] { QDesktopServices::openUrl(QUrl(url)); });
menu->addAction("Copy link",
[url] { QApplication::clipboard()->setText(url); });
menu->addSeparator();
}
// Copy actions
if (!this->selection_.isEmpty()) {
menu->addAction("Copy selection",
[this] { QGuiApplication::clipboard()->setText(this->getSelectedText()); });
menu->addAction("Copy selection", [this] {
QGuiApplication::clipboard()->setText(this->getSelectedText());
});
}
menu->addAction("Copy message", [layout] {
@@ -1103,7 +1151,8 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
return;
}
const MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos);
const MessageLayoutElement *hoverLayoutElement =
layout->getElementAt(relativePos);
if (hoverLayoutElement == nullptr) {
return;
@@ -1123,7 +1172,8 @@ void ChannelView::hideEvent(QHideEvent *)
this->messagesOnScreen_.clear();
}
void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, MessageLayout *layout)
void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
MessageLayout *layout)
{
if (event->button() != Qt::LeftButton) {
return;
@@ -1136,7 +1186,8 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, MessageL
auto *userPopup = new UserInfoPopup;
userPopup->setData(user, this->channel_);
userPopup->setActionOnFocusLoss(BaseWindow::Delete);
QPoint offset(int(150 * this->getScale()), int(70 * this->getScale()));
QPoint offset(int(150 * this->getScale()),
int(70 * this->getScale()));
userPopup->move(QCursor::pos() - offset);
userPopup->show();
@@ -1159,7 +1210,8 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, MessageL
}
}
bool ChannelView::tryGetMessageAt(QPoint p, std::shared_ptr<MessageLayout> &_message,
bool ChannelView::tryGetMessageAt(QPoint p,
std::shared_ptr<MessageLayout> &_message,
QPoint &relativePos, int &index)
{
auto messagesSnapshot = this->getMessagesSnapshot();
@@ -1170,7 +1222,8 @@ bool ChannelView::tryGetMessageAt(QPoint p, std::shared_ptr<MessageLayout> &_mes
return false;
}
int y = -(messagesSnapshot[start]->getHeight() * (fmod(this->scrollBar_.getCurrentValue(), 1)));
int y = -(messagesSnapshot[start]->getHeight() *
(fmod(this->scrollBar_.getCurrentValue(), 1)));
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
auto message = messagesSnapshot[i];
@@ -1190,7 +1243,8 @@ bool ChannelView::tryGetMessageAt(QPoint p, std::shared_ptr<MessageLayout> &_mes
int ChannelView::getLayoutWidth() const
{
if (this->scrollBar_.isVisible()) return int(this->width() - 8 * this->getScale());
if (this->scrollBar_.isVisible())
return int(this->width() - 8 * this->getScale());
return this->width();
}
+10 -7
View File
@@ -70,10 +70,11 @@ protected:
void hideEvent(QHideEvent *) override;
void handleLinkClick(QMouseEvent *event, const Link &link, MessageLayout *layout);
void handleLinkClick(QMouseEvent *event, const Link &link,
MessageLayout *layout);
bool tryGetMessageAt(QPoint p, std::shared_ptr<MessageLayout> &message, QPoint &relativePos,
int &index);
bool tryGetMessageAt(QPoint p, std::shared_ptr<MessageLayout> &message,
QPoint &relativePos, int &index);
private:
void updatePauseStatus();
@@ -85,9 +86,11 @@ private:
MessageElement::Flags getFlags() const;
bool isPaused();
void handleMouseClick(QMouseEvent *event, const MessageLayoutElement *hoverLayoutElement,
void handleMouseClick(QMouseEvent *event,
const MessageLayoutElement *hoverLayoutElement,
MessageLayout *layout);
void addContextMenuItems(const MessageLayoutElement *hoveredElement, MessageLayout *layout);
void addContextMenuItems(const MessageLayoutElement *hoveredElement,
MessageLayout *layout);
int getLayoutWidth() const;
QTimer *layoutCooldown_;
@@ -114,8 +117,8 @@ private:
Scrollbar scrollBar_;
RippleEffectLabel *goToBottom_;
// This variable can be used to decide whether or not we should render the "Show latest
// messages" button
// This variable can be used to decide whether or not we should render the
// "Show latest messages" button
bool showingLatestMessages_ = true;
bool enableScrollingToBottom_ = true;
+10 -5
View File
@@ -13,7 +13,8 @@ ComboBoxItemDelegate::~ComboBoxItemDelegate()
{
}
QWidget *ComboBoxItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
QWidget *ComboBoxItemDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QVariant data = index.data(Qt::UserRole + 1);
@@ -27,10 +28,12 @@ QWidget *ComboBoxItemDelegate::createEditor(QWidget *parent, const QStyleOptionV
return combo;
}
void ComboBoxItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
void ComboBoxItemDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
if (QComboBox *cb = qobject_cast<QComboBox *>(editor)) {
// get the index of the text in the combobox that matches the current value of the itenm
// get the index of the text in the combobox that matches the current
// value of the itenm
QString currentText = index.data(Qt::EditRole).toString();
int cbIndex = cb->findText(currentText);
@@ -43,11 +46,13 @@ void ComboBoxItemDelegate::setEditorData(QWidget *editor, const QModelIndex &ind
}
}
void ComboBoxItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
void ComboBoxItemDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
if (QComboBox *cb = qobject_cast<QComboBox *>(editor))
// save the current text of the combo box as the current value of the item
// save the current text of the combo box as the current value of the
// item
model->setData(index, cb->currentText(), Qt::EditRole);
else
QStyledItemDelegate::setModelData(editor, model, index);
+2 -1
View File
@@ -14,7 +14,8 @@ public:
ComboBoxItemDelegate(QObject *parent = nullptr);
~ComboBoxItemDelegate();
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
virtual QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
virtual void setModelData(QWidget *editor, QAbstractItemModel *model,
+6 -3
View File
@@ -31,14 +31,16 @@ EditableModelView::EditableModelView(QAbstractTableModel *model)
// add
QPushButton *add = new QPushButton("Add");
buttons->addWidget(add);
QObject::connect(add, &QPushButton::clicked, [this] { this->addButtonPressed.invoke(); });
QObject::connect(add, &QPushButton::clicked,
[this] { this->addButtonPressed.invoke(); });
// remove
QPushButton *remove = new QPushButton("Remove");
buttons->addWidget(remove);
QObject::connect(remove, &QPushButton::clicked, [this] {
QModelIndexList list;
while ((list = this->getTableView()->selectionModel()->selectedRows(0)).length() > 0) {
while ((list = this->getTableView()->selectionModel()->selectedRows(0))
.length() > 0) {
model_->removeRow(list[0].row());
}
});
@@ -55,7 +57,8 @@ void EditableModelView::setTitles(std::initializer_list<QString> titles)
break;
}
this->model_->setHeaderData(i++, Qt::Horizontal, title, Qt::DisplayRole);
this->model_->setHeaderData(i++, Qt::Horizontal, title,
Qt::DisplayRole);
}
}
+4 -2
View File
@@ -27,9 +27,11 @@ public:
painter.setPen(QColor("#999"));
if (this->vertical_) {
painter.drawLine(this->width() / 2, 0, this->width() / 2, this->height());
painter.drawLine(this->width() / 2, 0, this->width() / 2,
this->height());
} else {
painter.drawLine(0, this->height() / 2, this->width(), this->height() / 2);
painter.drawLine(0, this->height() / 2, this->width(),
this->height() / 2);
}
}
+15 -12
View File
@@ -68,12 +68,14 @@ void NotebookButton::paintEvent(QPaintEvent *event)
QRect rect = this->rect();
int s = h * 4 / 9;
painter.drawLine(
rect.left() + rect.width() / 2 - (s / 2), rect.top() + rect.height() / 2,
rect.left() + rect.width() / 2 + (s / 2), rect.top() + rect.height() / 2);
painter.drawLine(
rect.left() + rect.width() / 2, rect.top() + rect.height() / 2 - (s / 2),
rect.left() + rect.width() / 2, rect.top() + rect.height() / 2 + (s / 2));
painter.drawLine(rect.left() + rect.width() / 2 - (s / 2),
rect.top() + rect.height() / 2,
rect.left() + rect.width() / 2 + (s / 2),
rect.top() + rect.height() / 2);
painter.drawLine(rect.left() + rect.width() / 2,
rect.top() + rect.height() / 2 - (s / 2),
rect.left() + rect.width() / 2,
rect.top() + rect.height() / 2 + (s / 2));
} break;
case User: {
@@ -105,9 +107,10 @@ void NotebookButton::paintEvent(QPaintEvent *event)
path.arcMoveTo(a, a, 6 * a, 6 * a, 0 - (360 / 32.0));
for (int i = 0; i < 8; i++) {
path.arcTo(a, a, 6 * a, 6 * a, i * (360 / 8.0) - (360 / 32.0), (360 / 32.0));
path.arcTo(2 * a, 2 * a, 4 * a, 4 * a, i * (360 / 8.0) + (360 / 32.0),
path.arcTo(a, a, 6 * a, 6 * a, i * (360 / 8.0) - (360 / 32.0),
(360 / 32.0));
path.arcTo(2 * a, 2 * a, 4 * a, 4 * a,
i * (360 / 8.0) + (360 / 32.0), (360 / 32.0));
}
painter.fillPath(path, foreground);
@@ -144,8 +147,8 @@ void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
event->acceptProposedAction();
auto e = new QMouseEvent(QMouseEvent::MouseButtonPress,
QPointF(this->width() / 2, this->height() / 2), Qt::LeftButton,
Qt::LeftButton, 0);
QPointF(this->width() / 2, this->height() / 2),
Qt::LeftButton, Qt::LeftButton, 0);
RippleEffectButton::mousePressEvent(e);
delete e;
}
@@ -156,8 +159,8 @@ void NotebookButton::dragLeaveEvent(QDragLeaveEvent *)
this->update();
auto e = new QMouseEvent(QMouseEvent::MouseButtonRelease,
QPointF(this->width() / 2, this->height() / 2), Qt::LeftButton,
Qt::LeftButton, 0);
QPointF(this->width() / 2, this->height() / 2),
Qt::LeftButton, Qt::LeftButton, 0);
RippleEffectButton::mouseReleaseEvent(e);
delete e;
}
+59 -38
View File
@@ -30,17 +30,20 @@ NotebookTab::NotebookTab(Notebook *notebook)
this->setAcceptDrops(true);
this->positionChangedAnimation_.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
this->positionChangedAnimation_.setEasingCurve(
QEasingCurve(QEasingCurve::InCubic));
app->settings->showTabCloseButton.connect(boost::bind(&NotebookTab::hideTabXChanged, this, _1),
this->managedConnections_);
app->settings->showTabCloseButton.connect(
boost::bind(&NotebookTab::hideTabXChanged, this, _1),
this->managedConnections_);
this->setMouseTracking(true);
this->menu_.addAction("Rename", [this]() {
TextInputDialog d(this);
d.setWindowTitle("Change tab title (Leave empty for default behaviour)");
d.setWindowTitle(
"Change tab title (Leave empty for default behaviour)");
d.setText(this->getCustomTitle());
d.highlightText();
@@ -54,12 +57,13 @@ NotebookTab::NotebookTab(Notebook *notebook)
// new QAction("Enable highlights on new message", &this->menu);
// enableHighlightsOnNewMessageAction->setCheckable(true);
this->menu_.addAction("Close", [=]() { this->notebook_->removePage(this->page); });
this->menu_.addAction("Close",
[=]() { this->notebook_->removePage(this->page); });
// this->menu.addAction(enableHighlightsOnNewMessageAction);
// QObject::connect(enableHighlightsOnNewMessageAction, &QAction::toggled, [this](bool
// newValue) {
// QObject::connect(enableHighlightsOnNewMessageAction,
// &QAction::toggled, [this](bool newValue) {
// Log("New value is {}", newValue); //
// });
}
@@ -78,7 +82,8 @@ void NotebookTab::updateSize()
int width;
QFontMetrics metrics = getApp()->fonts->getFontMetrics(
FontStyle::UiTabs, float(qreal(this->getScale()) * this->devicePixelRatioF()));
FontStyle::UiTabs,
float(qreal(this->getScale()) * this->devicePixelRatioF()));
if (this->hasXButton()) {
width = (metrics.width(this->getTitle()) + int(32 * scale));
@@ -135,7 +140,8 @@ const QString &NotebookTab::getDefaultTitle() const
const QString &NotebookTab::getTitle() const
{
return this->customTitle_.isEmpty() ? this->defaultTitle_ : this->customTitle_;
return this->customTitle_.isEmpty() ? this->defaultTitle_
: this->customTitle_;
}
void NotebookTab::titleUpdated()
@@ -188,7 +194,8 @@ void NotebookTab::moveAnimated(QPoint pos, bool animated)
QWidget *w = this->window();
if ((w != nullptr && !w->isVisible()) || !animated || !this->positionChangedAnimationRunning_) {
if ((w != nullptr && !w->isVisible()) || !animated ||
!this->positionChangedAnimationRunning_) {
this->move(pos);
this->positionChangedAnimationRunning_ = true;
@@ -213,9 +220,11 @@ void NotebookTab::paintEvent(QPaintEvent *)
float scale = this->getScale();
painter.setFont(getApp()->fonts->getFont(
FontStyle::UiTabs, scale * 96.f / this->logicalDpiX() * this->devicePixelRatioF()));
FontStyle::UiTabs,
scale * 96.f / this->logicalDpiX() * this->devicePixelRatioF()));
QFontMetrics metrics = app->fonts->getFontMetrics(
FontStyle::UiTabs, scale * 96.f / this->logicalDpiX() * this->devicePixelRatioF());
FontStyle::UiTabs,
scale * 96.f / this->logicalDpiX() * this->devicePixelRatioF());
int height = int(scale * NOTEBOOK_TAB_HEIGHT);
// int fullHeight = (int)(scale * 48);
@@ -239,10 +248,12 @@ void NotebookTab::paintEvent(QPaintEvent *)
QBrush tabBackground = /*this->mouseOver_ ? colors.backgrounds.hover
:*/
(windowFocused ? colors.backgrounds.regular : colors.backgrounds.unfocused);
(windowFocused ? colors.backgrounds.regular
: colors.backgrounds.unfocused);
// painter.fillRect(rect(), this->mouseOver_ ? regular.backgrounds.hover
// : (windowFocused ? regular.backgrounds.regular
// : (windowFocused ?
// regular.backgrounds.regular
// :
// regular.backgrounds.unfocused));
@@ -262,11 +273,12 @@ void NotebookTab::paintEvent(QPaintEvent *)
// painter.drawPath(path);
// top line
painter.fillRect(QRectF(0, (this->selected_ ? 0.f : 1.f) * scale, this->width(),
(this->selected_ ? 2.f : 1.f) * scale),
this->mouseOver_
? colors.line.hover
: (windowFocused ? colors.line.regular : colors.line.unfocused));
painter.fillRect(
QRectF(0, (this->selected_ ? 0.f : 1.f) * scale, this->width(),
(this->selected_ ? 2.f : 1.f) * scale),
this->mouseOver_
? colors.line.hover
: (windowFocused ? colors.line.regular : colors.line.unfocused));
// set the pen color
painter.setPen(colors.text);
@@ -277,15 +289,17 @@ void NotebookTab::paintEvent(QPaintEvent *)
// draw text
int offset = int(scale * 8);
QRect textRect(offset, this->selected_ ? 1 : 2, this->width() - offset - offset, height);
QRect textRect(offset, this->selected_ ? 1 : 2,
this->width() - offset - offset, height);
if (this->shouldDrawXButton()) {
textRect.setRight(textRect.right() - this->height() / 2);
}
int width = metrics.width(this->getTitle());
Qt::Alignment alignment = width > textRect.width() ? Qt::AlignLeft | Qt::AlignVCenter
: Qt::AlignHCenter | Qt::AlignVCenter;
Qt::Alignment alignment = width > textRect.width()
? Qt::AlignLeft | Qt::AlignVCenter
: Qt::AlignHCenter | Qt::AlignVCenter;
QTextOption option(alignment);
option.setWrapMode(QTextOption::NoWrap);
@@ -307,14 +321,17 @@ void NotebookTab::paintEvent(QPaintEvent *)
int a = static_cast<int>(scale * 4);
painter.drawLine(xRect.topLeft() + QPoint(a, a), xRect.bottomRight() + QPoint(-a, -a));
painter.drawLine(xRect.topRight() + QPoint(-a, a), xRect.bottomLeft() + QPoint(a, -a));
painter.drawLine(xRect.topLeft() + QPoint(a, a),
xRect.bottomRight() + QPoint(-a, -a));
painter.drawLine(xRect.topRight() + QPoint(-a, a),
xRect.bottomLeft() + QPoint(a, -a));
}
}
// draw line at bottom
if (!this->selected_) {
painter.fillRect(0, this->height() - 1, this->width(), 1, app->themes->window.background);
painter.fillRect(0, this->height() - 1, this->width(), 1,
app->themes->window.background);
this->fancyPaint(painter);
}
@@ -322,7 +339,8 @@ void NotebookTab::paintEvent(QPaintEvent *)
bool NotebookTab::hasXButton()
{
return getApp()->settings->showTabCloseButton && this->notebook_->getAllowUserTabManagement();
return getApp()->settings->showTabCloseButton &&
this->notebook_->getAllowUserTabManagement();
}
bool NotebookTab::shouldDrawXButton()
@@ -354,9 +372,10 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
this->mouseDown_ = false;
auto removeThisPage = [this] {
auto reply = QMessageBox::question(this, "Remove this tab",
"Are you sure that you want to remove this tab?",
QMessageBox::Yes | QMessageBox::Cancel);
auto reply = QMessageBox::question(
this, "Remove this tab",
"Are you sure that you want to remove this tab?",
QMessageBox::Yes | QMessageBox::Cancel);
if (reply == QMessageBox::Yes) {
this->notebook_->removePage(this->page);
@@ -368,7 +387,8 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
removeThisPage();
}
} else {
if (this->hasXButton() && this->mouseDownX_ && this->getXRect().contains(event->pos())) {
if (this->hasXButton() && this->mouseDownX_ &&
this->getXRect().contains(event->pos())) {
this->mouseDownX_ = false;
removeThisPage();
@@ -399,11 +419,9 @@ void NotebookTab::leaveEvent(QEvent *event)
void NotebookTab::dragEnterEvent(QDragEnterEvent *event)
{
if (!event->mimeData()->hasFormat("chatterino/split"))
return;
if (!event->mimeData()->hasFormat("chatterino/split")) return;
if (!SplitContainer::isDraggingSplit)
return;
if (!SplitContainer::isDraggingSplit) return;
if (this->notebook_->getAllowUserTabManagement()) {
this->notebook_->select(this->page);
@@ -414,7 +432,8 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
{
auto app = getApp();
if (app->settings->showTabCloseButton && this->notebook_->getAllowUserTabManagement()) //
if (app->settings->showTabCloseButton &&
this->notebook_->getAllowUserTabManagement()) //
{
bool overX = this->getXRect().contains(event->pos());
@@ -432,7 +451,8 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
this->notebook_->getAllowUserTabManagement()) //
{
int index;
QWidget *clickedPage = this->notebook_->tabAt(relPoint, index, this->width());
QWidget *clickedPage =
this->notebook_->tabAt(relPoint, index, this->width());
if (clickedPage != nullptr && clickedPage != this->page) {
this->notebook_->rearrangePage(this->page, index);
@@ -449,8 +469,9 @@ QRect NotebookTab::getXRect()
// }
float s = this->getScale();
return QRect(this->width() - static_cast<int>(20 * s), static_cast<int>(6 * s),
static_cast<int>(16 * s), static_cast<int>(16 * s));
return QRect(this->width() - static_cast<int>(20 * s),
static_cast<int>(6 * s), static_cast<int>(16 * s),
static_cast<int>(16 * s));
}
} // namespace chatterino
+23 -14
View File
@@ -12,7 +12,8 @@ ResizingTextEdit::ResizingTextEdit()
this->setSizePolicy(sizePolicy);
this->setAcceptRichText(false);
QObject::connect(this, &QTextEdit::textChanged, this, &QWidget::updateGeometry);
QObject::connect(this, &QTextEdit::textChanged, this,
&QWidget::updateGeometry);
this->setFocusPolicy(Qt::ClickFocus);
}
@@ -77,8 +78,9 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
this->keyPressed.invoke(event);
bool doComplete = (event->key() == Qt::Key_Tab || event->key() == Qt::Key_Backtab) &&
(event->modifiers() & Qt::ControlModifier) == Qt::NoModifier;
bool doComplete =
(event->key() == Qt::Key_Tab || event->key() == Qt::Key_Backtab) &&
(event->modifiers() & Qt::ControlModifier) == Qt::NoModifier;
if (doComplete) {
// check if there is a completer
@@ -93,10 +95,12 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
return;
}
auto *completionModel = static_cast<CompletionModel *>(this->completer_->model());
auto *completionModel =
static_cast<CompletionModel *>(this->completer_->model());
if (!this->completionInProgress_) {
// First type pressing tab after modifying a message, we refresh our completion model
// First type pressing tab after modifying a message, we refresh our
// completion model
this->completer_->setModel(completionModel);
completionModel->refresh();
this->completionInProgress_ = true;
@@ -107,14 +111,17 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
// scrolling through selections
if (event->key() == Qt::Key_Tab) {
if (!this->completer_->setCurrentRow(this->completer_->currentRow() + 1)) {
if (!this->completer_->setCurrentRow(
this->completer_->currentRow() + 1)) {
// wrap over and start again
this->completer_->setCurrentRow(0);
}
} else {
if (!this->completer_->setCurrentRow(this->completer_->currentRow() - 1)) {
if (!this->completer_->setCurrentRow(
this->completer_->currentRow() - 1)) {
// wrap over and start again
this->completer_->setCurrentRow(this->completer_->completionCount() - 1);
this->completer_->setCurrentRow(
this->completer_->completionCount() - 1);
}
}
@@ -123,10 +130,10 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
}
// (hemirt)
// this resets the selection in the completion list, it should probably only trigger on actual
// chat input (space, character) and not on every key input (pressing alt for example)
// (fourtf)
// fixed for shift+tab, there might be a better solution but nobody is gonna bother anyways
// this resets the selection in the completion list, it should probably only
// trigger on actual chat input (space, character) and not on every key
// input (pressing alt for example) (fourtf) fixed for shift+tab, there
// might be a better solution but nobody is gonna bother anyways
if (event->key() != Qt::Key_Shift && event->key() != Qt::Key_Control &&
event->key() != Qt::Key_Alt && event->key() != Qt::Key_Super_L &&
event->key() != Qt::Key_Super_R) {
@@ -172,7 +179,8 @@ void ResizingTextEdit::setCompleter(QCompleter *c)
this->completer_->setCompletionMode(QCompleter::InlineCompletion);
this->completer_->setCaseSensitivity(Qt::CaseInsensitive);
QObject::connect(completer_,
static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::highlighted),
static_cast<void (QCompleter::*)(const QString &)>(
&QCompleter::highlighted),
this, &ResizingTextEdit::insertCompletion);
}
@@ -192,7 +200,8 @@ void ResizingTextEdit::insertCompletion(const QString &completion)
}
QTextCursor tc = this->textCursor();
tc.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, prefixSize);
tc.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor,
prefixSize);
tc.insertText(completion);
this->setTextCursor(tc);
}
+2 -1
View File
@@ -31,7 +31,8 @@ protected:
void focusOutEvent(QFocusEvent *event) override;
private:
// hadSpace is set to true in case the "textUnderCursor" word was after a space
// hadSpace is set to true in case the "textUnderCursor" word was after a
// space
QString textUnderCursor(bool *hadSpace = nullptr) const;
QCompleter *completer_ = nullptr;
+22 -16
View File
@@ -10,7 +10,8 @@ namespace chatterino {
RippleEffectButton::RippleEffectButton(BaseWidget *parent)
: BaseWidget(parent)
{
connect(&effectTimer_, &QTimer::timeout, this, &RippleEffectButton::onMouseEffectTimeout);
connect(&effectTimer_, &QTimer::timeout, this,
&RippleEffectButton::onMouseEffectTimeout);
this->effectTimer_.setInterval(20);
this->effectTimer_.start();
@@ -121,29 +122,30 @@ void RippleEffectButton::fancyPaint(QPainter &painter)
if (this->mouseEffectColor_) {
c = this->mouseEffectColor_.get();
} else {
c = this->theme->isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255);
c = this->theme->isLightTheme() ? QColor(0, 0, 0)
: QColor(255, 255, 255);
}
if (this->hoverMultiplier_ > 0) {
QRadialGradient gradient(QPointF(mousePos_), this->width() / 2);
gradient.setColorAt(0,
QColor(c.red(), c.green(), c.blue(), int(50 * this->hoverMultiplier_)));
gradient.setColorAt(1,
QColor(c.red(), c.green(), c.blue(), int(40 * this->hoverMultiplier_)));
gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(),
int(50 * this->hoverMultiplier_)));
gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(),
int(40 * this->hoverMultiplier_)));
painter.fillRect(this->rect(), gradient);
}
for (auto effect : this->clickEffects_) {
QRadialGradient gradient(effect.position.x(), effect.position.y(),
effect.progress * qreal(width()) * 2, effect.position.x(),
effect.position.y());
effect.progress * qreal(width()) * 2,
effect.position.x(), effect.position.y());
gradient.setColorAt(0,
QColor(c.red(), c.green(), c.blue(), int((1 - effect.progress) * 95)));
gradient.setColorAt(0.9999,
QColor(c.red(), c.green(), c.blue(), int((1 - effect.progress) * 95)));
gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(),
int((1 - effect.progress) * 95)));
gradient.setColorAt(0.9999, QColor(c.red(), c.green(), c.blue(),
int((1 - effect.progress) * 95)));
gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), int(0)));
painter.fillRect(this->rect(), gradient);
@@ -211,17 +213,20 @@ void RippleEffectButton::onMouseEffectTimeout()
if (selected_) {
if (this->hoverMultiplier_ != 0) {
this->hoverMultiplier_ = std::max(0.0, this->hoverMultiplier_ - 0.1);
this->hoverMultiplier_ =
std::max(0.0, this->hoverMultiplier_ - 0.1);
performUpdate = true;
}
} else if (mouseOver_) {
if (this->hoverMultiplier_ != 1) {
this->hoverMultiplier_ = std::min(1.0, this->hoverMultiplier_ + 0.5);
this->hoverMultiplier_ =
std::min(1.0, this->hoverMultiplier_ + 0.5);
performUpdate = true;
}
} else {
if (this->hoverMultiplier_ != 0) {
this->hoverMultiplier_ = std::max(0.0, this->hoverMultiplier_ - 0.3);
this->hoverMultiplier_ =
std::max(0.0, this->hoverMultiplier_ - 0.3);
performUpdate = true;
}
}
@@ -229,7 +234,8 @@ void RippleEffectButton::onMouseEffectTimeout()
if (this->clickEffects_.size() != 0) {
performUpdate = true;
for (auto it = this->clickEffects_.begin(); it != this->clickEffects_.end();) {
for (auto it = this->clickEffects_.begin();
it != this->clickEffects_.end();) {
it->progress += mouseDown_ ? 0.02 : 0.07;
if (it->progress >= 1.0) {
+2 -1
View File
@@ -77,7 +77,8 @@ void SearchPopup::performSearch()
MessagePtr message = this->snapshot_[i];
if (text.isEmpty() ||
message->searchText.indexOf(this->searchInput_->text(), 0, Qt::CaseInsensitive) != -1) {
message->searchText.indexOf(this->searchInput_->text(), 0,
Qt::CaseInsensitive) != -1) {
channel->addMessage(message);
}
}
+4 -3
View File
@@ -7,8 +7,8 @@
namespace chatterino {
SettingsDialogTab::SettingsDialogTab(SettingsDialog *_dialog, SettingsPage *_page,
QString imageFileName)
SettingsDialogTab::SettingsDialogTab(SettingsDialog *_dialog,
SettingsPage *_page, QString imageFileName)
: BaseWidget(_dialog)
, dialog_(_dialog)
, page_(_page)
@@ -48,7 +48,8 @@ void SettingsDialogTab::paintEvent(QPaintEvent *)
this->style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
int a = (this->height() - (20 * this->getScale())) / 2;
QPixmap pixmap = this->ui_.icon.pixmap(QSize(this->height() - a * 2, this->height() - a * 2));
QPixmap pixmap = this->ui_.icon.pixmap(
QSize(this->height() - a * 2, this->height() - a * 2));
painter.drawPixmap(a, a, pixmap);
+2 -1
View File
@@ -16,7 +16,8 @@ class SettingsDialogTab : public BaseWidget
Q_OBJECT
public:
SettingsDialogTab(SettingsDialog *dialog_, SettingsPage *page_, QString imageFileName);
SettingsDialogTab(SettingsDialog *dialog_, SettingsPage *page_,
QString imageFileName);
void setSelected(bool selected_);
SettingsPage *getSettingsPage();
+3 -2
View File
@@ -102,9 +102,10 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
path.arcMoveTo(a, a, 6 * a, 6 * a, 0 - (360 / 32.0));
for (int i = 0; i < 8; i++) {
path.arcTo(a, a, 6 * a, 6 * a, i * (360 / 8.0) - (360 / 32.0), (360 / 32.0));
path.arcTo(2 * a, 2 * a, 4 * a, 4 * a, i * (360 / 8.0) + (360 / 32.0),
path.arcTo(a, a, 6 * a, 6 * a, i * (360 / 8.0) - (360 / 32.0),
(360 / 32.0));
path.arcTo(2 * a, 2 * a, 4 * a, 4 * a,
i * (360 / 8.0) + (360 / 32.0), (360 / 32.0));
}
painter.strokePath(path, color);