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

View file

@ -78,6 +78,16 @@ const QString &TwitchAccount::getUserId() const
return this->userId_; 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) bool TwitchAccount::setOAuthClient(const QString &newClientID)
{ {
if (this->oauthClient_.compare(newClientID) == 0) { if (this->oauthClient_.compare(newClientID) == 0) {

View file

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

View file

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