diff --git a/images/StatusAnnotations_Blocked_16xLG_color.png b/images/StatusAnnotations_Blocked_16xLG_color.png
new file mode 100644
index 00000000..b58166e3
Binary files /dev/null and b/images/StatusAnnotations_Blocked_16xLG_color.png differ
diff --git a/images/UserProfile_22x.png b/images/UserProfile_22x.png
new file mode 100644
index 00000000..c47f6124
Binary files /dev/null and b/images/UserProfile_22x.png differ
diff --git a/images/VSO_Link_blue_16x.png b/images/VSO_Link_blue_16x.png
new file mode 100644
index 00000000..eb388292
Binary files /dev/null and b/images/VSO_Link_blue_16x.png differ
diff --git a/messages/message.cpp b/messages/message.cpp
index 76bfd8ba..48e93a13 100644
--- a/messages/message.cpp
+++ b/messages/message.cpp
@@ -337,7 +337,7 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
"introducing-cheering-celebrate-"
"together-da62af41fac6"))));
words.push_back(
- Word(image, Word::Bits, QString("cheer"),
+ Word(image, Word::BitsStatic, QString("cheer"),
QString("Twitch Cheer"),
Link(Link::Url,
QString("https://blog.twitch.tv/"
@@ -405,6 +405,8 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
bool
Message::layout(int width, bool enableEmoteMargins)
{
+ auto &settings = settings::Settings::getInstance();
+
width = width - (width % 2);
int mediumTextLineHeight = Fonts::getFontMetrics(Fonts::Medium).height();
@@ -415,9 +417,8 @@ Message::layout(int width, bool enableEmoteMargins)
bool recalculateImages = this->emoteGeneration != Emotes::getGeneration();
bool recalculateText = this->fontGeneration != Fonts::getGeneration();
- qreal emoteScale = settings::Settings::getEmoteScale().get();
- bool scaleEmotesByLineHeight =
- settings::Settings::getScaleEmotesByLineHeight().get();
+ qreal emoteScale = settings.getEmoteScale().get();
+ bool scaleEmotesByLineHeight = settings.getScaleEmotesByLineHeight().get();
if (recalculateImages || recalculateText) {
this->emoteGeneration = Emotes::getGeneration();
@@ -474,7 +475,7 @@ Message::layout(int width, bool enableEmoteMargins)
}
};
- int flags = settings::Settings::getWordTypeMask();
+ uint32_t flags = settings::Settings::getInstance().getWordTypeMask();
for (auto it = this->words.begin(); it != this->words.end(); ++it) {
Word &word = *it;
diff --git a/messages/word.h b/messages/word.h
index 68312a23..1e3d3808 100644
--- a/messages/word.h
+++ b/messages/word.h
@@ -34,7 +34,7 @@ public:
EmoteImages = TwitchEmoteImage | BttvEmoteImage | BttvGifEmoteImage |
FfzEmoteImage,
- Bits = (1 << 12),
+ BitsStatic = (1 << 12),
BitsAnimated = (1 << 13),
BadgeStaff = (1 << 14),
@@ -59,7 +59,7 @@ public:
EmojiImage = (1 << 27),
EmojiText = (1 << 28),
- Default = TimestampNoSeconds | Badges | Username | Bits |
+ Default = TimestampNoSeconds | Badges | Username | BitsStatic |
FfzEmoteImage | BttvEmoteImage | BttvGifEmoteImage |
TwitchEmoteImage | BitsAmount | Text | ButtonBan |
ButtonTimeout
diff --git a/resources.qrc b/resources.qrc
index 489d0d6d..0c300cab 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -27,5 +27,8 @@
emojidata.txt
images/button_ban.png
images/button_timeout.png
+ images/StatusAnnotations_Blocked_16xLG_color.png
+ images/UserProfile_22x.png
+ images/VSO_Link_blue_16x.png
diff --git a/settings/settings.cpp b/settings/settings.cpp
index 5262a897..9aaba2af 100644
--- a/settings/settings.cpp
+++ b/settings/settings.cpp
@@ -6,44 +6,85 @@
namespace chatterino {
namespace settings {
-StringSetting Settings::theme("", "dark");
-StringSetting Settings::user("", "");
-FloatSetting Settings::emoteScale("", 1.0);
-BoolSetting Settings::scaleEmotesByLineHeight("", false);
-BoolSetting Settings::showTimestamps("", true);
-BoolSetting Settings::showTimestampSeconds("", false);
-BoolSetting Settings::allowDouplicateMessages("", true);
-BoolSetting Settings::linksDoubleClickOnly("", false);
-BoolSetting Settings::hideEmptyInput("", false);
-BoolSetting Settings::showMessageLength("", false);
-BoolSetting Settings::seperateMessages("", false);
-BoolSetting Settings::mentionUsersWithAt("", false);
-BoolSetting Settings::allowCommandsAtEnd("", false);
-BoolSetting Settings::enableHighlights("", true);
-BoolSetting Settings::enableHighlightSound("", true);
-BoolSetting Settings::enableHighlightTaskbar("", true);
-BoolSetting Settings::customHighlightSound("", false);
-BoolSetting Settings::enableTwitchEmotes("", true);
-BoolSetting Settings::enableBttvEmotes("", true);
-BoolSetting Settings::enableFFzEmotes("", true);
-BoolSetting Settings::enableEmojis("", true);
-BoolSetting Settings::enableGifAnimations("", true);
-BoolSetting Settings::enableGifs("", true);
-BoolSetting Settings::inlineWhispers("", true);
-BoolSetting Settings::windowTopMost("", true);
-BoolSetting Settings::hideTabX("", false);
+Settings Settings::_;
-QSettings Settings::settings(
- QStandardPaths::writableLocation(QStandardPaths::AppDataLocation),
- QSettings::IniFormat);
+Settings::Settings()
+ : settings(
+ QStandardPaths::writableLocation(QStandardPaths::AppDataLocation),
+ QSettings::IniFormat)
+ , settingsItems()
+ , portable(false)
+ , wordTypeMask(messages::Word::Default)
+ , theme("", "dark")
+ , user("", "")
+ , emoteScale("", 1.0)
+ , scaleEmotesByLineHeight("", false)
+ , showTimestamps("", true)
+ , showTimestampSeconds("", false)
+ , showLastMessageIndicator("", false)
+ , allowDouplicateMessages("", true)
+ , linksDoubleClickOnly("", false)
+ , hideEmptyInput("", false)
+ , showMessageLength("", false)
+ , seperateMessages("", false)
+ , mentionUsersWithAt("", false)
+ , allowCommandsAtEnd("", false)
+ , enableHighlights("", true)
+ , enableHighlightSound("", true)
+ , enableHighlightTaskbar("", true)
+ , customHighlightSound("", false)
+ , enableTwitchEmotes("", true)
+ , enableBttvEmotes("", true)
+ , enableFfzEmotes("", true)
+ , enableEmojis("", true)
+ , enableGifAnimations("", true)
+ , enableGifs("", true)
+ , inlineWhispers("", true)
+ , windowTopMost("", true)
+ , hideTabX("", false)
+{
+ settingsItems.reserve(25);
+ settingsItems.push_back(&theme);
+ settingsItems.push_back(&user);
+ settingsItems.push_back(&emoteScale);
+ settingsItems.push_back(&scaleEmotesByLineHeight);
+ settingsItems.push_back(&showTimestamps);
+ settingsItems.push_back(&showTimestampSeconds);
+ settingsItems.push_back(&showLastMessageIndicator);
+ settingsItems.push_back(&allowDouplicateMessages);
+ settingsItems.push_back(&linksDoubleClickOnly);
+ settingsItems.push_back(&hideEmptyInput);
+ settingsItems.push_back(&showMessageLength);
+ settingsItems.push_back(&seperateMessages);
+ settingsItems.push_back(&mentionUsersWithAt);
+ settingsItems.push_back(&allowCommandsAtEnd);
+ settingsItems.push_back(&enableHighlights);
+ settingsItems.push_back(&enableHighlightSound);
+ settingsItems.push_back(&enableHighlightTaskbar);
+ settingsItems.push_back(&customHighlightSound);
+ settingsItems.push_back(&enableTwitchEmotes);
+ settingsItems.push_back(&enableBttvEmotes);
+ settingsItems.push_back(&enableFfzEmotes);
+ settingsItems.push_back(&enableEmojis);
+ settingsItems.push_back(&enableGifAnimations);
+ settingsItems.push_back(&enableGifs);
+ settingsItems.push_back(&inlineWhispers);
+ settingsItems.push_back(&windowTopMost);
+ settingsItems.push_back(&hideTabX);
-std::vector Settings::settingsItems;
-
-bool Settings::portable(false);
-
-messages::Word::Type Settings::wordTypeMask = messages::Word::Default;
-
-int Settings::_ = Settings::_init();
+ QObject::connect(&showTimestamps, &BoolSetting::valueChanged, this,
+ &Settings::updateWordTypeMask);
+ QObject::connect(&showTimestampSeconds, &BoolSetting::valueChanged, this,
+ &Settings::updateWordTypeMask);
+ QObject::connect(&enableBttvEmotes, &BoolSetting::valueChanged, this,
+ &Settings::updateWordTypeMask);
+ QObject::connect(&enableEmojis, &BoolSetting::valueChanged, this,
+ &Settings::updateWordTypeMask);
+ QObject::connect(&enableFfzEmotes, &BoolSetting::valueChanged, this,
+ &Settings::updateWordTypeMask);
+ QObject::connect(&enableTwitchEmotes, &BoolSetting::valueChanged, this,
+ &Settings::updateWordTypeMask);
+}
void
Settings::save()
@@ -62,9 +103,45 @@ Settings::load()
}
bool
-Settings::isIgnoredEmote(const QString &emote)
+Settings::isIgnoredEmote(const QString &)
{
return false;
}
+
+void
+Settings::updateWordTypeMask(bool)
+
+{
+ using namespace messages;
+
+ uint32_t mask = Word::Text;
+
+ if (showTimestamps.get()) {
+ mask |= showTimestampSeconds.get() ? Word::TimestampWithSeconds
+ : Word::TimestampNoSeconds;
+ }
+
+ mask |= enableTwitchEmotes.get() ? Word::TwitchEmoteImage
+ : Word::TwitchEmoteText;
+ mask |= enableFfzEmotes.get() ? Word::FfzEmoteImage : Word::FfzEmoteText;
+ mask |= enableBttvEmotes.get() ? Word::BttvEmoteImage : Word::BttvEmoteText;
+ mask |= (enableBttvEmotes.get() && enableGifs.get()) ? Word::BttvEmoteImage
+ : Word::BttvEmoteText;
+ mask |= enableEmojis.get() ? Word::EmojiImage : Word::EmojiText;
+
+ mask |= Word::BitsAmount;
+ mask |= enableGifs.get() ? Word::BitsAnimated : Word::BitsStatic;
+
+ mask |= Word::Badges;
+ mask |= Word::Username;
+
+ Word::Type _mask = (Word::Type)mask;
+
+ // if (mask != _mask) {
+ wordTypeMask = _mask;
+
+ emit wordTypeMaskChanged();
+ // }
+}
}
}
diff --git a/settings/settings.h b/settings/settings.h
index 74184127..97f72f05 100644
--- a/settings/settings.h
+++ b/settings/settings.h
@@ -12,243 +12,231 @@
namespace chatterino {
namespace settings {
-class Settings
+class Settings : public QObject
{
+ Q_OBJECT
+
public:
- static messages::Word::Type
+ static Settings &
+ getInstance()
+ {
+ return _;
+ }
+
+ void load();
+ void save();
+
+ messages::Word::Type
getWordTypeMask()
{
return wordTypeMask;
}
- static bool isIgnoredEmote(const QString &emote);
+ bool isIgnoredEmote(const QString &emote);
- static void load();
- static void save();
-
- static bool
+ bool
getPortable()
{
return portable;
}
- static void
+ void
setPortable(bool value)
{
portable = value;
}
+signals:
+ void wordTypeMaskChanged();
+
private:
Settings();
- static int _;
- static int
- _init()
- {
- settingsItems.reserve(25);
- settingsItems.push_back(&theme);
- settingsItems.push_back(&user);
- settingsItems.push_back(&emoteScale);
- settingsItems.push_back(&scaleEmotesByLineHeight);
- settingsItems.push_back(&showTimestamps);
- settingsItems.push_back(&showTimestampSeconds);
- settingsItems.push_back(&allowDouplicateMessages);
- settingsItems.push_back(&linksDoubleClickOnly);
- settingsItems.push_back(&hideEmptyInput);
- settingsItems.push_back(&showMessageLength);
- settingsItems.push_back(&seperateMessages);
- settingsItems.push_back(&mentionUsersWithAt);
- settingsItems.push_back(&allowCommandsAtEnd);
- settingsItems.push_back(&enableHighlights);
- settingsItems.push_back(&enableHighlightSound);
- settingsItems.push_back(&enableHighlightTaskbar);
- settingsItems.push_back(&customHighlightSound);
- settingsItems.push_back(&enableTwitchEmotes);
- settingsItems.push_back(&enableBttvEmotes);
- settingsItems.push_back(&enableFFzEmotes);
- settingsItems.push_back(&enableEmojis);
- settingsItems.push_back(&enableGifAnimations);
- settingsItems.push_back(&enableGifs);
- settingsItems.push_back(&inlineWhispers);
- settingsItems.push_back(&windowTopMost);
- settingsItems.push_back(&hideTabX);
- }
+ static Settings _;
- static QSettings settings;
- static std::vector settingsItems;
+ void updateWordTypeMask(bool);
- template
- static T
- addSetting(T setting)
- {
- settingsItems.push_back(setting);
- return setting;
- }
+ QSettings settings;
+ std::vector settingsItems;
- static bool portable;
+ // template
+ // T
+ // addSetting(T setting)
+ // {
+ // settingsItems.push_back(setting);
+ // return setting;
+ // }
- static messages::Word::Type wordTypeMask;
+ bool portable;
+
+ messages::Word::Type wordTypeMask;
+
+private:
+ StringSetting theme;
+ StringSetting user;
+ FloatSetting emoteScale;
+ BoolSetting scaleEmotesByLineHeight;
+ BoolSetting showTimestamps;
+ BoolSetting showTimestampSeconds;
+ BoolSetting showLastMessageIndicator;
+ BoolSetting allowDouplicateMessages;
+ BoolSetting linksDoubleClickOnly;
+ BoolSetting hideEmptyInput;
+ BoolSetting showMessageLength;
+ BoolSetting seperateMessages;
+ BoolSetting mentionUsersWithAt;
+ BoolSetting allowCommandsAtEnd;
+ BoolSetting enableHighlights;
+ BoolSetting enableHighlightSound;
+ BoolSetting enableHighlightTaskbar;
+ BoolSetting customHighlightSound;
+ BoolSetting enableTwitchEmotes;
+ BoolSetting enableBttvEmotes;
+ BoolSetting enableFfzEmotes;
+ BoolSetting enableEmojis;
+ BoolSetting enableGifAnimations;
+ BoolSetting enableGifs;
+ BoolSetting inlineWhispers;
+ BoolSetting windowTopMost;
+ BoolSetting hideTabX;
// settings
public:
- static StringSetting &
+ StringSetting &
getTheme()
{
- return Settings::theme;
+ return this->theme;
}
- static StringSetting &
+ StringSetting &
getUser()
{
- return Settings::user;
+ return this->user;
}
- static FloatSetting &
+ FloatSetting &
getEmoteScale()
{
- return Settings::emoteScale;
+ return this->emoteScale;
}
- static BoolSetting &
+ BoolSetting &
getScaleEmotesByLineHeight()
{
- return Settings::scaleEmotesByLineHeight;
+ return this->scaleEmotesByLineHeight;
}
- static BoolSetting &
+ BoolSetting &
getShowTimestamps()
{
- return Settings::showTimestamps;
+ return this->showTimestamps;
}
- static BoolSetting &
+ BoolSetting &
getShowTimestampSeconds()
{
- return Settings::showTimestampSeconds;
+ return this->showTimestampSeconds;
}
- static BoolSetting &
+ BoolSetting &
+ getShowLastMessageIndicator()
+ {
+ return this->showLastMessageIndicator;
+ }
+ BoolSetting &
getAllowDouplicateMessages()
{
- return Settings::allowDouplicateMessages;
+ return this->allowDouplicateMessages;
}
- static BoolSetting &
+ BoolSetting &
getLinksDoubleClickOnly()
{
- return Settings::linksDoubleClickOnly;
+ return this->linksDoubleClickOnly;
}
- static BoolSetting &
+ BoolSetting &
getHideEmptyInput()
{
- return Settings::hideEmptyInput;
+ return this->hideEmptyInput;
}
- static BoolSetting &
+ BoolSetting &
getShowMessageLength()
{
- return Settings::showMessageLength;
+ return this->showMessageLength;
}
- static BoolSetting &
+ BoolSetting &
getSeperateMessages()
{
- return Settings::seperateMessages;
+ return this->seperateMessages;
}
- static BoolSetting &
+ BoolSetting &
getMentionUsersWithAt()
{
- return Settings::mentionUsersWithAt;
+ return this->mentionUsersWithAt;
}
- static BoolSetting &
+ BoolSetting &
getAllowCommandsAtEnd()
{
- return Settings::allowCommandsAtEnd;
+ return this->allowCommandsAtEnd;
}
- static BoolSetting &
+ BoolSetting &
getEnableHighlights()
{
- return Settings::enableHighlights;
+ return this->enableHighlights;
}
- static BoolSetting &
+ BoolSetting &
getEnableHighlightSound()
{
- return Settings::enableHighlightSound;
+ return this->enableHighlightSound;
}
- static BoolSetting &
+ BoolSetting &
getEnableHighlightTaskbar()
{
- return Settings::enableHighlightTaskbar;
+ return this->enableHighlightTaskbar;
}
- static BoolSetting &
+ BoolSetting &
getCustomHighlightSound()
{
- return Settings::customHighlightSound;
+ return this->customHighlightSound;
}
- static BoolSetting &
+ BoolSetting &
getEnableTwitchEmotes()
{
- return Settings::enableTwitchEmotes;
+ return this->enableTwitchEmotes;
}
- static BoolSetting &
+ BoolSetting &
getEnableBttvEmotes()
{
- return Settings::enableBttvEmotes;
+ return this->enableBttvEmotes;
}
- static BoolSetting &
- getEnableFFzEmotes()
+ BoolSetting &
+ getEnableFfzEmotes()
{
- return Settings::enableFFzEmotes;
+ return this->enableFfzEmotes;
}
- static BoolSetting &
+ BoolSetting &
getEnableEmojis()
{
- return Settings::enableEmojis;
+ return this->enableEmojis;
}
- static BoolSetting &
+ BoolSetting &
getEnableGifAnimations()
{
- return Settings::enableGifAnimations;
+ return this->enableGifAnimations;
}
- static BoolSetting &
+ BoolSetting &
getEnableGifs()
{
- return Settings::enableGifs;
+ return this->enableGifs;
}
- static BoolSetting &
+ BoolSetting &
getInlineWhispers()
{
- return Settings::inlineWhispers;
+ return this->inlineWhispers;
}
- static BoolSetting &
+ BoolSetting &
getWindowTopMost()
{
- return Settings::windowTopMost;
+ return this->windowTopMost;
}
- static BoolSetting &
+ BoolSetting &
getHideTabX()
{
- return Settings::hideTabX;
+ return this->hideTabX;
}
-
-private:
- static StringSetting theme;
- static StringSetting user;
- static FloatSetting emoteScale;
- static BoolSetting scaleEmotesByLineHeight;
- static BoolSetting showTimestamps;
- static BoolSetting showTimestampSeconds;
- static BoolSetting allowDouplicateMessages;
- static BoolSetting linksDoubleClickOnly;
- static BoolSetting hideEmptyInput;
- static BoolSetting showMessageLength;
- static BoolSetting seperateMessages;
- static BoolSetting mentionUsersWithAt;
- static BoolSetting allowCommandsAtEnd;
- static BoolSetting enableHighlights;
- static BoolSetting enableHighlightSound;
- static BoolSetting enableHighlightTaskbar;
- static BoolSetting customHighlightSound;
- static BoolSetting enableTwitchEmotes;
- static BoolSetting enableBttvEmotes;
- static BoolSetting enableFFzEmotes;
- static BoolSetting enableEmojis;
- static BoolSetting enableGifAnimations;
- static BoolSetting enableGifs;
- static BoolSetting inlineWhispers;
- static BoolSetting windowTopMost;
- static BoolSetting hideTabX;
};
}
}
diff --git a/widgets/chatwidget.cpp b/widgets/chatwidget.cpp
index 695d99a8..493b41d2 100644
--- a/widgets/chatwidget.cpp
+++ b/widgets/chatwidget.cpp
@@ -1,6 +1,7 @@
#include "widgets/chatwidget.h"
#include "channels.h"
#include "colorscheme.h"
+#include "settings/settings.h"
#include "widgets/textinputdialog.h"
#include
@@ -23,10 +24,6 @@ ChatWidget::ChatWidget(QWidget *parent)
this->vbox.setSpacing(0);
this->vbox.setMargin(1);
- // header.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- // view.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- // input.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
-
this->vbox.addWidget(&header);
this->vbox.addWidget(&view, 1);
this->vbox.addWidget(&input);
diff --git a/widgets/chatwidget.h b/widgets/chatwidget.h
index cf88ea30..cff83f8c 100644
--- a/widgets/chatwidget.h
+++ b/widgets/chatwidget.h
@@ -2,6 +2,7 @@
#define CHATWIDGET_H
#include "channel.h"
+#include "messages/word.h"
#include "widgets/chatwidgetheader.h"
#include "widgets/chatwidgetinput.h"
#include "widgets/chatwidgetview.h"
diff --git a/widgets/chatwidgetinput.cpp b/widgets/chatwidgetinput.cpp
index 489db3ab..8d292c25 100644
--- a/widgets/chatwidgetinput.cpp
+++ b/widgets/chatwidgetinput.cpp
@@ -1,5 +1,6 @@
#include "widgets/chatwidgetinput.h"
#include "colorscheme.h"
+#include "settings/settings.h"
#include
@@ -38,6 +39,20 @@ ChatWidgetInput::ChatWidgetInput()
// this->emotesLabel.setMaximumSize(12, 12);
this->refreshTheme();
+
+ this->setMessageLengthVisisble(
+ settings::Settings::getInstance().getShowMessageLength().get());
+
+ QObject::connect(&settings::Settings::getInstance().getShowMessageLength(),
+ &settings::BoolSetting::valueChanged, this,
+ &setMessageLengthVisisble);
+}
+
+ChatWidgetInput::~ChatWidgetInput()
+{
+ QObject::disconnect(
+ &settings::Settings::getInstance().getShowMessageLength(),
+ &settings::BoolSetting::valueChanged, this, &setMessageLengthVisisble);
}
void
diff --git a/widgets/chatwidgetinput.h b/widgets/chatwidgetinput.h
index 9ce7ca5c..b8608752 100644
--- a/widgets/chatwidgetinput.h
+++ b/widgets/chatwidgetinput.h
@@ -21,6 +21,7 @@ class ChatWidgetInput : public QWidget
public:
ChatWidgetInput();
+ ~ChatWidgetInput();
protected:
void paintEvent(QPaintEvent *);
@@ -37,6 +38,11 @@ private:
private slots:
void refreshTheme();
+ void
+ setMessageLengthVisisble(bool value)
+ {
+ this->textLengthLabel.setHidden(!value);
+ }
};
}
}
diff --git a/widgets/chatwidgetview.cpp b/widgets/chatwidgetview.cpp
index 0d49708f..fb7d2127 100644
--- a/widgets/chatwidgetview.cpp
+++ b/widgets/chatwidgetview.cpp
@@ -2,8 +2,8 @@
#include "channels.h"
#include "colorscheme.h"
#include "messages/message.h"
-#include "messages/word.h"
#include "messages/wordpart.h"
+#include "settings/settings.h"
#include "widgets/chatwidget.h"
#include
@@ -22,6 +22,17 @@ ChatWidgetView::ChatWidgetView(ChatWidget *parent)
auto scroll = QScroller::scroller(this);
scroll->scrollTo(QPointF(0, 100));
+
+ QObject::connect(&settings::Settings::getInstance(),
+ &settings::Settings::wordTypeMaskChanged, this,
+ &wordTypeMaskChanged);
+}
+
+ChatWidgetView::~ChatWidgetView()
+{
+ QObject::disconnect(&settings::Settings::getInstance(),
+ &settings::Settings::wordTypeMaskChanged, this,
+ &wordTypeMaskChanged);
}
bool
diff --git a/widgets/chatwidgetview.h b/widgets/chatwidgetview.h
index 108d6a6f..1585436c 100644
--- a/widgets/chatwidgetview.h
+++ b/widgets/chatwidgetview.h
@@ -2,6 +2,7 @@
#define CHATVIEW_H
#include "channel.h"
+#include "messages/word.h"
#include "widgets/scrollbar.h"
#include
@@ -17,6 +18,7 @@ class ChatWidgetView : public QWidget
public:
explicit ChatWidgetView(ChatWidget *parent);
+ ~ChatWidgetView();
bool layoutMessages();
@@ -29,6 +31,15 @@ private:
ChatWidget *chatWidget;
ScrollBar scrollbar;
+
+private slots:
+ void
+ wordTypeMaskChanged()
+ {
+ if (layoutMessages()) {
+ repaint();
+ }
+ }
};
}
}
diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp
index 8b205fef..937c869e 100644
--- a/widgets/mainwindow.cpp
+++ b/widgets/mainwindow.cpp
@@ -14,10 +14,6 @@ MainWindow::MainWindow(QWidget *parent)
{
setCentralWidget(&this->notebook);
- this->notebook.addPage();
- this->notebook.addPage();
- this->notebook.addPage();
-
QPalette palette;
palette.setColor(QPalette::Background,
ColorScheme::instance().TabPanelBackground);
diff --git a/widgets/notebook.cpp b/widgets/notebook.cpp
index 26a1d10c..83e70718 100644
--- a/widgets/notebook.cpp
+++ b/widgets/notebook.cpp
@@ -18,6 +18,7 @@ Notebook::Notebook(QWidget *parent)
, addButton(this)
, settingsButton(this)
, userButton(this)
+ , selectedPage(nullptr)
{
connect(&this->settingsButton, SIGNAL(clicked()), this,
SLOT(settingsButtonClicked()));
@@ -34,6 +35,8 @@ Notebook::Notebook(QWidget *parent)
this->userButton.icon = NotebookButton::IconUser;
this->addButton.resize(24, 24);
+
+ this->addPage();
}
NotebookPage *
@@ -42,13 +45,15 @@ Notebook::addPage(bool select)
auto tab = new NotebookTab(this);
auto page = new NotebookPage(this, tab);
+ tab->show();
+
if (select || this->pages.count() == 0) {
this->select(page);
}
this->pages.append(page);
- performLayout();
+ this->performLayout();
return page;
}
@@ -56,20 +61,24 @@ Notebook::addPage(bool select)
void
Notebook::removePage(NotebookPage *page)
{
- int index = pages.indexOf(page);
+ int index = this->pages.indexOf(page);
if (pages.size() == 1) {
- select(NULL);
+ this->select(NULL);
} else if (index == pages.count() - 1) {
- select(pages[index - 1]);
+ this->select(pages[index - 1]);
} else {
- select(pages[index + 1]);
+ this->select(pages[index + 1]);
}
delete page->tab;
delete page;
- pages.removeOne(page);
+ this->pages.removeOne(page);
+
+ if (this->pages.size() == 0) {
+ addPage();
+ }
performLayout();
}
@@ -95,6 +104,36 @@ Notebook::select(NotebookPage *page)
performLayout();
}
+NotebookPage *
+Notebook::tabAt(QPoint point, int &index)
+{
+ int i = 0;
+
+ for (auto *page : pages) {
+ if (page->tab->geometry().contains(point)) {
+ index = i;
+ return page;
+ }
+
+ i++;
+ }
+
+ index = -1;
+ return nullptr;
+}
+
+void
+Notebook::rearrangePage(NotebookPage *page, int index)
+{
+ int i1 = pages.indexOf(page);
+
+ pages.move(pages.indexOf(page), index);
+
+ int i2 = pages.indexOf(page);
+
+ performLayout();
+}
+
void
Notebook::performLayout()
{
@@ -109,10 +148,10 @@ Notebook::performLayout()
(i == this->pages.last() ? tabHeight : 0) + x + i->tab->width() >
width()) {
y += i->tab->height();
- i->tab->move(0, y);
+ i->tab->moveAnimated(QPoint(0, y));
x = i->tab->width();
} else {
- i->tab->move(x, y);
+ i->tab->moveAnimated(QPoint(x, y));
x += i->tab->width();
}
diff --git a/widgets/notebook.h b/widgets/notebook.h
index 3c33687e..0fce894a 100644
--- a/widgets/notebook.h
+++ b/widgets/notebook.h
@@ -33,6 +33,9 @@ public:
void performLayout();
+ NotebookPage *tabAt(QPoint point, int &index);
+ void rearrangePage(NotebookPage *page, int index);
+
protected:
void resizeEvent(QResizeEvent *);
@@ -50,7 +53,7 @@ private:
NotebookButton settingsButton;
NotebookButton userButton;
- NotebookPage *selectedPage = nullptr;
+ NotebookPage *selectedPage;
};
}
}
diff --git a/widgets/notebooktab.cpp b/widgets/notebooktab.cpp
index 131801af..a2072929 100644
--- a/widgets/notebooktab.cpp
+++ b/widgets/notebooktab.cpp
@@ -10,6 +10,8 @@ namespace widgets {
NotebookTab::NotebookTab(Notebook *notebook)
: QWidget(notebook)
+ // , posAnimation(this, "pos")
+ // , posAnimated(false)
, notebook(notebook)
, text("")
, selected(false)
@@ -19,36 +21,56 @@ NotebookTab::NotebookTab(Notebook *notebook)
, mouseDownX(false)
, highlightStyle(HighlightNone)
{
- calcSize();
+ this->calcSize();
+ this->setAcceptDrops(true);
- setAcceptDrops(true);
-
- QObject::connect(&settings::Settings::getHideTabX(),
- SIGNAL(settings::BoolSetting::valueChanged(bool)), this,
- SLOT(NotebookTab::hideTabXChanged(bool)));
-
- this->installEventFilter(this);
+ QObject::connect(&settings::Settings::getInstance().getHideTabX(),
+ &settings::BoolSetting::valueChanged, this,
+ &NotebookTab::hideTabXChanged);
this->setMouseTracking(true);
}
NotebookTab::~NotebookTab()
{
- QObject::disconnect(&settings::Settings::getHideTabX(),
- SIGNAL(settings::BoolSetting::valueChanged(bool)), this,
- SLOT(NotebookTab::hideTabXChanged(bool)));
+ QObject::disconnect(&settings::Settings::getInstance().getHideTabX(),
+ &settings::BoolSetting::valueChanged, this,
+ &NotebookTab::hideTabXChanged);
}
void
NotebookTab::calcSize()
{
- if (settings::Settings::getHideTabX().get()) {
+ if (settings::Settings::getInstance().getHideTabX().get()) {
this->resize(this->fontMetrics().width(this->text) + 8, 24);
} else {
this->resize(this->fontMetrics().width(this->text) + 8 + 24, 24);
}
}
+void
+NotebookTab::moveAnimated(QPoint pos)
+{
+ move(pos);
+
+ // if (posAnimated == false) {
+ // move(pos);
+
+ // posAnimated = true;
+ // return;
+ // }
+
+ // if (this->posAnimation.endValue() == pos) {
+ // return;
+ // }
+
+ // this->posAnimation.stop();
+ // this->posAnimation.setDuration(50);
+ // this->posAnimation.setStartValue(this->pos());
+ // this->posAnimation.setEndValue(pos);
+ // this->posAnimation.start();
+}
+
void
NotebookTab::paintEvent(QPaintEvent *)
{
@@ -77,25 +99,28 @@ NotebookTab::paintEvent(QPaintEvent *)
painter.setPen(fg);
- QRect rect(0, 0,
- width() - (settings::Settings::getHideTabX().get() ? 0 : 16),
- height());
+ QRect rect(
+ 0, 0,
+ width() -
+ (settings::Settings::getInstance().getHideTabX().get() ? 0 : 16),
+ height());
painter.drawText(rect, this->text, QTextOption(Qt::AlignCenter));
- if (!settings::Settings::getHideTabX().get() && (mouseOver || selected)) {
- if (mouseOverX) {
- painter.fillRect(getXRect(), QColor(0, 0, 0, 64));
+ if (!settings::Settings::getInstance().getHideTabX().get() &&
+ (this->mouseOver || this->selected)) {
+ if (this->mouseOverX) {
+ painter.fillRect(this->getXRect(), QColor(0, 0, 0, 64));
- if (mouseDownX) {
- painter.fillRect(getXRect(), QColor(0, 0, 0, 64));
+ if (this->mouseDownX) {
+ painter.fillRect(this->getXRect(), QColor(0, 0, 0, 64));
}
}
- painter.drawLine(getXRect().topLeft() + QPoint(4, 4),
- getXRect().bottomRight() + QPoint(-4, -4));
- painter.drawLine(getXRect().topRight() + QPoint(-4, 4),
- getXRect().bottomLeft() + QPoint(4, -4));
+ painter.drawLine(this->getXRect().topLeft() + QPoint(4, 4),
+ this->getXRect().bottomRight() + QPoint(-4, -4));
+ painter.drawLine(this->getXRect().topRight() + QPoint(-4, 4),
+ this->getXRect().bottomLeft() + QPoint(4, -4));
}
}
@@ -156,6 +181,17 @@ NotebookTab::mouseMoveEvent(QMouseEvent *event)
this->repaint();
}
+
+ if (this->mouseDown && !this->rect().contains(event->pos())) {
+ QPoint relPoint = this->mapToParent(event->pos());
+
+ int index;
+ NotebookPage *page = notebook->tabAt(relPoint, index);
+
+ if (page != nullptr && page != this->page) {
+ notebook->rearrangePage(this->page, index);
+ }
+ }
}
}
}
diff --git a/widgets/notebooktab.h b/widgets/notebooktab.h
index 147c9350..c008e0d9 100644
--- a/widgets/notebooktab.h
+++ b/widgets/notebooktab.h
@@ -1,6 +1,7 @@
#ifndef NOTEBOOKTAB_H
#define NOTEBOOKTAB_H
+#include
#include
namespace chatterino {
@@ -20,7 +21,7 @@ public:
HighlightNewMessage
};
- NotebookTab(Notebook *notebook);
+ explicit NotebookTab(Notebook *notebook);
~NotebookTab();
void calcSize();
@@ -65,6 +66,8 @@ public:
repaint();
}
+ void moveAnimated(QPoint pos);
+
protected:
void paintEvent(QPaintEvent *) override;
@@ -78,6 +81,9 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override;
private:
+ // QPropertyAnimation posAnimation;
+ // bool posAnimated;
+
Notebook *notebook;
QString text;
@@ -98,7 +104,7 @@ private:
private slots:
void
- hideTabXChanged(bool value)
+ hideTabXChanged(bool)
{
calcSize();
repaint();
diff --git a/widgets/settingsdialog.cpp b/widgets/settingsdialog.cpp
index 2e75fa50..d1358043 100644
--- a/widgets/settingsdialog.cpp
+++ b/widgets/settingsdialog.cpp
@@ -54,6 +54,8 @@ SettingsDialog::SettingsDialog()
void
SettingsDialog::addTabs()
{
+ settings::Settings &settings = settings::Settings::getInstance();
+
QVBoxLayout *vbox;
// Appearance
@@ -80,12 +82,17 @@ SettingsDialog::addTabs()
auto group = new QGroupBox("Messages");
auto v = new QVBoxLayout();
- v->addWidget(createCheckbox("Show timestamp", ""));
- v->addWidget(createCheckbox("Show seconds in timestamp", ""));
+ v->addWidget(
+ createCheckbox("Show timestamp", settings.getShowTimestamps()));
+ v->addWidget(createCheckbox("Show seconds in timestamp",
+ settings.getShowTimestampSeconds()));
v->addWidget(createCheckbox(
- "Allow sending duplicate messages (add a space at the end)", ""));
- v->addWidget(createCheckbox("Seperate messages", ""));
- v->addWidget(createCheckbox("Show message length", ""));
+ "Allow sending duplicate messages (add a space at the end)",
+ settings.getAllowDouplicateMessages()));
+ v->addWidget(createCheckbox("Seperate messages",
+ settings.getSeperateMessages()));
+ v->addWidget(createCheckbox("Show message length",
+ settings.getShowMessageLength()));
group->setLayout(v);
@@ -99,11 +106,15 @@ SettingsDialog::addTabs()
// Behaviour
vbox = new QVBoxLayout();
- vbox->addWidget(createCheckbox("Hide input box if empty", ""));
+ vbox->addWidget(createCheckbox("Hide input box if empty",
+ settings.getHideEmptyInput()));
vbox->addWidget(
- createCheckbox("Mention users with a @ (except in commands)", ""));
- vbox->addWidget(createCheckbox("Window always on top", ""));
- vbox->addWidget(createCheckbox("Show last read message indicator", ""));
+ createCheckbox("Mention users with a @ (except in commands)",
+ settings.getMentionUsersWithAt()));
+ vbox->addWidget(
+ createCheckbox("Window always on top", settings.getWindowTopMost()));
+ vbox->addWidget(createCheckbox("Show last read message indicator",
+ settings.getShowLastMessageIndicator()));
{
auto v = new QVBoxLayout();
@@ -128,14 +139,66 @@ SettingsDialog::addTabs()
addTab(vbox, "Commands", ":/images/CustomActionEditor_16x.png");
+ // Emotes
+ vbox = new QVBoxLayout();
+
+ vbox->addWidget(createCheckbox("Enable Twitch Emotes",
+ settings.getEnableTwitchEmotes()));
+ vbox->addWidget(createCheckbox("Enable BetterTTV Emotes",
+ settings.getEnableBttvEmotes()));
+ vbox->addWidget(createCheckbox("Enable FrankerFaceZ Emotes",
+ settings.getEnableFfzEmotes()));
+ vbox->addWidget(
+ createCheckbox("Enable Gif Emotes", settings.getEnableGifs()));
+ vbox->addWidget(
+ createCheckbox("Enable Emojis", settings.getEnableEmojis()));
+
+ vbox->addWidget(createCheckbox("Enable Twitch Emotes",
+ settings.getEnableTwitchEmotes()));
+
+ vbox->addStretch(1);
+ addTab(vbox, "Emotes", ":/images/Emoji_Color_1F60A_19.png");
+
+ // Ignored Users
+ vbox = new QVBoxLayout();
+ vbox->addStretch(1);
+ addTab(vbox, "Ignored Users",
+ ":/images/StatusAnnotations_Blocked_16xLG_color.png");
+
+ // Ignored Messages
+ vbox = new QVBoxLayout();
+ vbox->addStretch(1);
+ addTab(vbox, "Ignored Messages", ":/images/Filter_16x.png");
+
+ // Links
+ vbox = new QVBoxLayout();
+ vbox->addStretch(1);
+ addTab(vbox, "Links", ":/images/VSO_Link_blue_16x.png");
+
+ // Highlighting
+ vbox = new QVBoxLayout();
+ vbox->addStretch(1);
+ addTab(vbox, "Highlighting", ":/images/format_Bold_16xLG.png");
+
+ // Whispers
+ vbox = new QVBoxLayout();
+ vbox->addStretch(1);
+ addTab(vbox, "Whispers", ":/images/Message_16xLG.png");
+
// Add stretch
tabs.addStretch(1);
}
QCheckBox *
-SettingsDialog::createCheckbox(QString title, QString settingsId)
+SettingsDialog::createCheckbox(const QString &title,
+ settings::BoolSetting &setting)
{
- return new QCheckBox(title);
+ auto checkbox = new QCheckBox(title);
+
+ QObject::connect(checkbox, &QCheckBox::toggled, this,
+ [&setting, this](bool state) { setting.set(state); });
+
+ return checkbox;
}
void
diff --git a/widgets/settingsdialog.h b/widgets/settingsdialog.h
index 79d709b4..e63bcd32 100644
--- a/widgets/settingsdialog.h
+++ b/widgets/settingsdialog.h
@@ -1,6 +1,7 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
+#include "settings/settings.h"
#include "widgets/settingsdialogtab.h"
#include
@@ -39,7 +40,8 @@ private:
SettingsDialogTab *selectedTab = NULL;
- QCheckBox *createCheckbox(QString title, QString settingsId);
+ QCheckBox *createCheckbox(const QString &title,
+ settings::BoolSetting &setting);
};
}
}