fixed not being able to select text backwards

This commit is contained in:
fourtf 2018-08-11 17:35:46 +02:00
parent c768bd9bd9
commit 63eaf3b94c
4 changed files with 22 additions and 16 deletions

View file

@ -1,5 +1,6 @@
#pragma once
#include <tuple>
#include <utility>
namespace chatterino {
@ -23,19 +24,13 @@ struct SelectionItem {
bool operator<(const SelectionItem &b) const
{
if (this->messageIndex < b.messageIndex) {
return true;
}
if (this->messageIndex == b.messageIndex &&
this->charIndex < b.charIndex) {
return true;
}
return false;
return std::tie(this->messageIndex, this->charIndex) <
std::tie(b.messageIndex, b.charIndex);
}
bool operator>(const SelectionItem &b) const
{
return this->operator!=(b) && b.operator<(*this);
return b.operator<(*this);
}
bool operator==(const SelectionItem &b) const

View file

@ -78,6 +78,16 @@ const QString &TwitchAccount::getUserId() const
return this->userId_;
}
QColor TwitchAccount::color()
{
return this->color_.get();
}
void TwitchAccount::setColor(QColor color)
{
this->color_.set(color);
}
bool TwitchAccount::setOAuthClient(const QString &newClientID)
{
if (this->oauthClient_.compare(newClientID) == 0) {

View file

@ -1,5 +1,6 @@
#pragma once
#include "common/Atomic.hpp"
#include "common/UniqueAccess.hpp"
#include "controllers/accounts/Account.hpp"
#include "messages/Emote.hpp"
@ -66,9 +67,11 @@ public:
const QString &getUserName() const;
const QString &getOAuthToken() const;
const QString &getOAuthClient() const;
const QString &getUserId() const;
QColor color();
void setColor(QColor color);
// Attempts to update the users OAuth Client ID
// Returns true if the value has changed, otherwise false
bool setOAuthClient(const QString &newClientID);
@ -104,8 +107,6 @@ public:
void loadEmotes();
AccessGuard<const TwitchAccountEmoteData> accessEmotes() const;
QColor color;
private:
void parseEmotes(const rapidjson::Document &document);
void loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet);
@ -115,6 +116,7 @@ private:
QString userName_;
QString userId_;
const bool isAnon_;
Atomic<QColor> color_;
mutable std::mutex ignoresMutex_;
std::set<TwitchUser> ignores_;

View file

@ -457,7 +457,7 @@ void TwitchMessageBuilder::appendUsername()
app->themes->messages.textColors.system,
FontStyle::ChatMedium);
QColor selfColor = currentUser->color;
QColor selfColor = currentUser->color();
if (!selfColor.isValid()) {
selfColor = app->themes->messages.textColors.system;
}
@ -490,7 +490,7 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
QString currentUsername = currentUser->getUserName();
if (this->ircMessage->nick() == currentUsername) {
currentUser->color = this->usernameColor_;
currentUser->setColor(this->usernameColor_);
// Do nothing. Highlights cannot be triggered by yourself
return;
}
@ -645,8 +645,7 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
flags = MessageElementFlag::BttvEmote;
} else if ((emote = getApp()->emotes->ffz.global(name))) {
flags = MessageElementFlag::FfzEmote;
} else if (twitchChannel &&
(emote = this->twitchChannel->ffzEmote(name))) {
} else if (twitchChannel && (emote = this->twitchChannel->ffzEmote(name))) {
flags = MessageElementFlag::FfzEmote;
}