updated settingsdialog

This commit is contained in:
fourtf
2017-01-22 12:46:35 +01:00
parent 8d85f91c4d
commit be92a82891
21 changed files with 487 additions and 232 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

+6 -5
View File
@@ -337,7 +337,7 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
"introducing-cheering-celebrate-" "introducing-cheering-celebrate-"
"together-da62af41fac6")))); "together-da62af41fac6"))));
words.push_back( words.push_back(
Word(image, Word::Bits, QString("cheer"), Word(image, Word::BitsStatic, QString("cheer"),
QString("Twitch Cheer"), QString("Twitch Cheer"),
Link(Link::Url, Link(Link::Url,
QString("https://blog.twitch.tv/" QString("https://blog.twitch.tv/"
@@ -405,6 +405,8 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
bool bool
Message::layout(int width, bool enableEmoteMargins) Message::layout(int width, bool enableEmoteMargins)
{ {
auto &settings = settings::Settings::getInstance();
width = width - (width % 2); width = width - (width % 2);
int mediumTextLineHeight = Fonts::getFontMetrics(Fonts::Medium).height(); int mediumTextLineHeight = Fonts::getFontMetrics(Fonts::Medium).height();
@@ -415,9 +417,8 @@ Message::layout(int width, bool enableEmoteMargins)
bool recalculateImages = this->emoteGeneration != Emotes::getGeneration(); bool recalculateImages = this->emoteGeneration != Emotes::getGeneration();
bool recalculateText = this->fontGeneration != Fonts::getGeneration(); bool recalculateText = this->fontGeneration != Fonts::getGeneration();
qreal emoteScale = settings::Settings::getEmoteScale().get(); qreal emoteScale = settings.getEmoteScale().get();
bool scaleEmotesByLineHeight = bool scaleEmotesByLineHeight = settings.getScaleEmotesByLineHeight().get();
settings::Settings::getScaleEmotesByLineHeight().get();
if (recalculateImages || recalculateText) { if (recalculateImages || recalculateText) {
this->emoteGeneration = Emotes::getGeneration(); 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) { for (auto it = this->words.begin(); it != this->words.end(); ++it) {
Word &word = *it; Word &word = *it;
+2 -2
View File
@@ -34,7 +34,7 @@ public:
EmoteImages = TwitchEmoteImage | BttvEmoteImage | BttvGifEmoteImage | EmoteImages = TwitchEmoteImage | BttvEmoteImage | BttvGifEmoteImage |
FfzEmoteImage, FfzEmoteImage,
Bits = (1 << 12), BitsStatic = (1 << 12),
BitsAnimated = (1 << 13), BitsAnimated = (1 << 13),
BadgeStaff = (1 << 14), BadgeStaff = (1 << 14),
@@ -59,7 +59,7 @@ public:
EmojiImage = (1 << 27), EmojiImage = (1 << 27),
EmojiText = (1 << 28), EmojiText = (1 << 28),
Default = TimestampNoSeconds | Badges | Username | Bits | Default = TimestampNoSeconds | Badges | Username | BitsStatic |
FfzEmoteImage | BttvEmoteImage | BttvGifEmoteImage | FfzEmoteImage | BttvEmoteImage | BttvGifEmoteImage |
TwitchEmoteImage | BitsAmount | Text | ButtonBan | TwitchEmoteImage | BitsAmount | Text | ButtonBan |
ButtonTimeout ButtonTimeout
+3
View File
@@ -27,5 +27,8 @@
<file>emojidata.txt</file> <file>emojidata.txt</file>
<file>images/button_ban.png</file> <file>images/button_ban.png</file>
<file>images/button_timeout.png</file> <file>images/button_timeout.png</file>
<file>images/StatusAnnotations_Blocked_16xLG_color.png</file>
<file>images/UserProfile_22x.png</file>
<file>images/VSO_Link_blue_16x.png</file>
</qresource> </qresource>
</RCC> </RCC>
+114 -37
View File
@@ -6,44 +6,85 @@
namespace chatterino { namespace chatterino {
namespace settings { namespace settings {
StringSetting Settings::theme("", "dark"); Settings Settings::_;
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);
QSettings Settings::settings( Settings::Settings()
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), : settings(
QSettings::IniFormat); 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<Setting *> Settings::settingsItems; QObject::connect(&showTimestamps, &BoolSetting::valueChanged, this,
&Settings::updateWordTypeMask);
bool Settings::portable(false); QObject::connect(&showTimestampSeconds, &BoolSetting::valueChanged, this,
&Settings::updateWordTypeMask);
messages::Word::Type Settings::wordTypeMask = messages::Word::Default; QObject::connect(&enableBttvEmotes, &BoolSetting::valueChanged, this,
&Settings::updateWordTypeMask);
int Settings::_ = Settings::_init(); 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 void
Settings::save() Settings::save()
@@ -62,9 +103,45 @@ Settings::load()
} }
bool bool
Settings::isIgnoredEmote(const QString &emote) Settings::isIgnoredEmote(const QString &)
{ {
return false; 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();
// }
}
} }
} }
+120 -132
View File
@@ -12,243 +12,231 @@
namespace chatterino { namespace chatterino {
namespace settings { namespace settings {
class Settings class Settings : public QObject
{ {
Q_OBJECT
public: public:
static messages::Word::Type static Settings &
getInstance()
{
return _;
}
void load();
void save();
messages::Word::Type
getWordTypeMask() getWordTypeMask()
{ {
return wordTypeMask; return wordTypeMask;
} }
static bool isIgnoredEmote(const QString &emote); bool isIgnoredEmote(const QString &emote);
static void load(); bool
static void save();
static bool
getPortable() getPortable()
{ {
return portable; return portable;
} }
static void void
setPortable(bool value) setPortable(bool value)
{ {
portable = value; portable = value;
} }
signals:
void wordTypeMaskChanged();
private: private:
Settings(); Settings();
static int _; static Settings _;
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 QSettings settings; void updateWordTypeMask(bool);
static std::vector<Setting *> settingsItems;
template <class T> QSettings settings;
static T std::vector<Setting *> settingsItems;
addSetting(T setting)
{
settingsItems.push_back(setting);
return setting;
}
static bool portable; // template <class T>
// 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 // settings
public: public:
static StringSetting & StringSetting &
getTheme() getTheme()
{ {
return Settings::theme; return this->theme;
} }
static StringSetting & StringSetting &
getUser() getUser()
{ {
return Settings::user; return this->user;
} }
static FloatSetting & FloatSetting &
getEmoteScale() getEmoteScale()
{ {
return Settings::emoteScale; return this->emoteScale;
} }
static BoolSetting & BoolSetting &
getScaleEmotesByLineHeight() getScaleEmotesByLineHeight()
{ {
return Settings::scaleEmotesByLineHeight; return this->scaleEmotesByLineHeight;
} }
static BoolSetting & BoolSetting &
getShowTimestamps() getShowTimestamps()
{ {
return Settings::showTimestamps; return this->showTimestamps;
} }
static BoolSetting & BoolSetting &
getShowTimestampSeconds() getShowTimestampSeconds()
{ {
return Settings::showTimestampSeconds; return this->showTimestampSeconds;
} }
static BoolSetting & BoolSetting &
getShowLastMessageIndicator()
{
return this->showLastMessageIndicator;
}
BoolSetting &
getAllowDouplicateMessages() getAllowDouplicateMessages()
{ {
return Settings::allowDouplicateMessages; return this->allowDouplicateMessages;
} }
static BoolSetting & BoolSetting &
getLinksDoubleClickOnly() getLinksDoubleClickOnly()
{ {
return Settings::linksDoubleClickOnly; return this->linksDoubleClickOnly;
} }
static BoolSetting & BoolSetting &
getHideEmptyInput() getHideEmptyInput()
{ {
return Settings::hideEmptyInput; return this->hideEmptyInput;
} }
static BoolSetting & BoolSetting &
getShowMessageLength() getShowMessageLength()
{ {
return Settings::showMessageLength; return this->showMessageLength;
} }
static BoolSetting & BoolSetting &
getSeperateMessages() getSeperateMessages()
{ {
return Settings::seperateMessages; return this->seperateMessages;
} }
static BoolSetting & BoolSetting &
getMentionUsersWithAt() getMentionUsersWithAt()
{ {
return Settings::mentionUsersWithAt; return this->mentionUsersWithAt;
} }
static BoolSetting & BoolSetting &
getAllowCommandsAtEnd() getAllowCommandsAtEnd()
{ {
return Settings::allowCommandsAtEnd; return this->allowCommandsAtEnd;
} }
static BoolSetting & BoolSetting &
getEnableHighlights() getEnableHighlights()
{ {
return Settings::enableHighlights; return this->enableHighlights;
} }
static BoolSetting & BoolSetting &
getEnableHighlightSound() getEnableHighlightSound()
{ {
return Settings::enableHighlightSound; return this->enableHighlightSound;
} }
static BoolSetting & BoolSetting &
getEnableHighlightTaskbar() getEnableHighlightTaskbar()
{ {
return Settings::enableHighlightTaskbar; return this->enableHighlightTaskbar;
} }
static BoolSetting & BoolSetting &
getCustomHighlightSound() getCustomHighlightSound()
{ {
return Settings::customHighlightSound; return this->customHighlightSound;
} }
static BoolSetting & BoolSetting &
getEnableTwitchEmotes() getEnableTwitchEmotes()
{ {
return Settings::enableTwitchEmotes; return this->enableTwitchEmotes;
} }
static BoolSetting & BoolSetting &
getEnableBttvEmotes() getEnableBttvEmotes()
{ {
return Settings::enableBttvEmotes; return this->enableBttvEmotes;
} }
static BoolSetting & BoolSetting &
getEnableFFzEmotes() getEnableFfzEmotes()
{ {
return Settings::enableFFzEmotes; return this->enableFfzEmotes;
} }
static BoolSetting & BoolSetting &
getEnableEmojis() getEnableEmojis()
{ {
return Settings::enableEmojis; return this->enableEmojis;
} }
static BoolSetting & BoolSetting &
getEnableGifAnimations() getEnableGifAnimations()
{ {
return Settings::enableGifAnimations; return this->enableGifAnimations;
} }
static BoolSetting & BoolSetting &
getEnableGifs() getEnableGifs()
{ {
return Settings::enableGifs; return this->enableGifs;
} }
static BoolSetting & BoolSetting &
getInlineWhispers() getInlineWhispers()
{ {
return Settings::inlineWhispers; return this->inlineWhispers;
} }
static BoolSetting & BoolSetting &
getWindowTopMost() getWindowTopMost()
{ {
return Settings::windowTopMost; return this->windowTopMost;
} }
static BoolSetting & BoolSetting &
getHideTabX() 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;
}; };
} }
} }
+1 -4
View File
@@ -1,6 +1,7 @@
#include "widgets/chatwidget.h" #include "widgets/chatwidget.h"
#include "channels.h" #include "channels.h"
#include "colorscheme.h" #include "colorscheme.h"
#include "settings/settings.h"
#include "widgets/textinputdialog.h" #include "widgets/textinputdialog.h"
#include <QFont> #include <QFont>
@@ -23,10 +24,6 @@ ChatWidget::ChatWidget(QWidget *parent)
this->vbox.setSpacing(0); this->vbox.setSpacing(0);
this->vbox.setMargin(1); 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(&header);
this->vbox.addWidget(&view, 1); this->vbox.addWidget(&view, 1);
this->vbox.addWidget(&input); this->vbox.addWidget(&input);
+1
View File
@@ -2,6 +2,7 @@
#define CHATWIDGET_H #define CHATWIDGET_H
#include "channel.h" #include "channel.h"
#include "messages/word.h"
#include "widgets/chatwidgetheader.h" #include "widgets/chatwidgetheader.h"
#include "widgets/chatwidgetinput.h" #include "widgets/chatwidgetinput.h"
#include "widgets/chatwidgetview.h" #include "widgets/chatwidgetview.h"
+15
View File
@@ -1,5 +1,6 @@
#include "widgets/chatwidgetinput.h" #include "widgets/chatwidgetinput.h"
#include "colorscheme.h" #include "colorscheme.h"
#include "settings/settings.h"
#include <QPainter> #include <QPainter>
@@ -38,6 +39,20 @@ ChatWidgetInput::ChatWidgetInput()
// this->emotesLabel.setMaximumSize(12, 12); // this->emotesLabel.setMaximumSize(12, 12);
this->refreshTheme(); 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 void
+6
View File
@@ -21,6 +21,7 @@ class ChatWidgetInput : public QWidget
public: public:
ChatWidgetInput(); ChatWidgetInput();
~ChatWidgetInput();
protected: protected:
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
@@ -37,6 +38,11 @@ private:
private slots: private slots:
void refreshTheme(); void refreshTheme();
void
setMessageLengthVisisble(bool value)
{
this->textLengthLabel.setHidden(!value);
}
}; };
} }
} }
+12 -1
View File
@@ -2,8 +2,8 @@
#include "channels.h" #include "channels.h"
#include "colorscheme.h" #include "colorscheme.h"
#include "messages/message.h" #include "messages/message.h"
#include "messages/word.h"
#include "messages/wordpart.h" #include "messages/wordpart.h"
#include "settings/settings.h"
#include "widgets/chatwidget.h" #include "widgets/chatwidget.h"
#include <math.h> #include <math.h>
@@ -22,6 +22,17 @@ ChatWidgetView::ChatWidgetView(ChatWidget *parent)
auto scroll = QScroller::scroller(this); auto scroll = QScroller::scroller(this);
scroll->scrollTo(QPointF(0, 100)); 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 bool
+11
View File
@@ -2,6 +2,7 @@
#define CHATVIEW_H #define CHATVIEW_H
#include "channel.h" #include "channel.h"
#include "messages/word.h"
#include "widgets/scrollbar.h" #include "widgets/scrollbar.h"
#include <QPaintEvent> #include <QPaintEvent>
@@ -17,6 +18,7 @@ class ChatWidgetView : public QWidget
public: public:
explicit ChatWidgetView(ChatWidget *parent); explicit ChatWidgetView(ChatWidget *parent);
~ChatWidgetView();
bool layoutMessages(); bool layoutMessages();
@@ -29,6 +31,15 @@ private:
ChatWidget *chatWidget; ChatWidget *chatWidget;
ScrollBar scrollbar; ScrollBar scrollbar;
private slots:
void
wordTypeMaskChanged()
{
if (layoutMessages()) {
repaint();
}
}
}; };
} }
} }
-4
View File
@@ -14,10 +14,6 @@ MainWindow::MainWindow(QWidget *parent)
{ {
setCentralWidget(&this->notebook); setCentralWidget(&this->notebook);
this->notebook.addPage();
this->notebook.addPage();
this->notebook.addPage();
QPalette palette; QPalette palette;
palette.setColor(QPalette::Background, palette.setColor(QPalette::Background,
ColorScheme::instance().TabPanelBackground); ColorScheme::instance().TabPanelBackground);
+47 -8
View File
@@ -18,6 +18,7 @@ Notebook::Notebook(QWidget *parent)
, addButton(this) , addButton(this)
, settingsButton(this) , settingsButton(this)
, userButton(this) , userButton(this)
, selectedPage(nullptr)
{ {
connect(&this->settingsButton, SIGNAL(clicked()), this, connect(&this->settingsButton, SIGNAL(clicked()), this,
SLOT(settingsButtonClicked())); SLOT(settingsButtonClicked()));
@@ -34,6 +35,8 @@ Notebook::Notebook(QWidget *parent)
this->userButton.icon = NotebookButton::IconUser; this->userButton.icon = NotebookButton::IconUser;
this->addButton.resize(24, 24); this->addButton.resize(24, 24);
this->addPage();
} }
NotebookPage * NotebookPage *
@@ -42,13 +45,15 @@ Notebook::addPage(bool select)
auto tab = new NotebookTab(this); auto tab = new NotebookTab(this);
auto page = new NotebookPage(this, tab); auto page = new NotebookPage(this, tab);
tab->show();
if (select || this->pages.count() == 0) { if (select || this->pages.count() == 0) {
this->select(page); this->select(page);
} }
this->pages.append(page); this->pages.append(page);
performLayout(); this->performLayout();
return page; return page;
} }
@@ -56,20 +61,24 @@ Notebook::addPage(bool select)
void void
Notebook::removePage(NotebookPage *page) Notebook::removePage(NotebookPage *page)
{ {
int index = pages.indexOf(page); int index = this->pages.indexOf(page);
if (pages.size() == 1) { if (pages.size() == 1) {
select(NULL); this->select(NULL);
} else if (index == pages.count() - 1) { } else if (index == pages.count() - 1) {
select(pages[index - 1]); this->select(pages[index - 1]);
} else { } else {
select(pages[index + 1]); this->select(pages[index + 1]);
} }
delete page->tab; delete page->tab;
delete page; delete page;
pages.removeOne(page); this->pages.removeOne(page);
if (this->pages.size() == 0) {
addPage();
}
performLayout(); performLayout();
} }
@@ -95,6 +104,36 @@ Notebook::select(NotebookPage *page)
performLayout(); 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 void
Notebook::performLayout() Notebook::performLayout()
{ {
@@ -109,10 +148,10 @@ Notebook::performLayout()
(i == this->pages.last() ? tabHeight : 0) + x + i->tab->width() > (i == this->pages.last() ? tabHeight : 0) + x + i->tab->width() >
width()) { width()) {
y += i->tab->height(); y += i->tab->height();
i->tab->move(0, y); i->tab->moveAnimated(QPoint(0, y));
x = i->tab->width(); x = i->tab->width();
} else { } else {
i->tab->move(x, y); i->tab->moveAnimated(QPoint(x, y));
x += i->tab->width(); x += i->tab->width();
} }
+4 -1
View File
@@ -33,6 +33,9 @@ public:
void performLayout(); void performLayout();
NotebookPage *tabAt(QPoint point, int &index);
void rearrangePage(NotebookPage *page, int index);
protected: protected:
void resizeEvent(QResizeEvent *); void resizeEvent(QResizeEvent *);
@@ -50,7 +53,7 @@ private:
NotebookButton settingsButton; NotebookButton settingsButton;
NotebookButton userButton; NotebookButton userButton;
NotebookPage *selectedPage = nullptr; NotebookPage *selectedPage;
}; };
} }
} }
+60 -24
View File
@@ -10,6 +10,8 @@ namespace widgets {
NotebookTab::NotebookTab(Notebook *notebook) NotebookTab::NotebookTab(Notebook *notebook)
: QWidget(notebook) : QWidget(notebook)
// , posAnimation(this, "pos")
// , posAnimated(false)
, notebook(notebook) , notebook(notebook)
, text("<no title>") , text("<no title>")
, selected(false) , selected(false)
@@ -19,36 +21,56 @@ NotebookTab::NotebookTab(Notebook *notebook)
, mouseDownX(false) , mouseDownX(false)
, highlightStyle(HighlightNone) , highlightStyle(HighlightNone)
{ {
calcSize(); this->calcSize();
this->setAcceptDrops(true);
setAcceptDrops(true); QObject::connect(&settings::Settings::getInstance().getHideTabX(),
&settings::BoolSetting::valueChanged, this,
QObject::connect(&settings::Settings::getHideTabX(), &NotebookTab::hideTabXChanged);
SIGNAL(settings::BoolSetting::valueChanged(bool)), this,
SLOT(NotebookTab::hideTabXChanged(bool)));
this->installEventFilter(this);
this->setMouseTracking(true); this->setMouseTracking(true);
} }
NotebookTab::~NotebookTab() NotebookTab::~NotebookTab()
{ {
QObject::disconnect(&settings::Settings::getHideTabX(), QObject::disconnect(&settings::Settings::getInstance().getHideTabX(),
SIGNAL(settings::BoolSetting::valueChanged(bool)), this, &settings::BoolSetting::valueChanged, this,
SLOT(NotebookTab::hideTabXChanged(bool))); &NotebookTab::hideTabXChanged);
} }
void void
NotebookTab::calcSize() NotebookTab::calcSize()
{ {
if (settings::Settings::getHideTabX().get()) { if (settings::Settings::getInstance().getHideTabX().get()) {
this->resize(this->fontMetrics().width(this->text) + 8, 24); this->resize(this->fontMetrics().width(this->text) + 8, 24);
} else { } else {
this->resize(this->fontMetrics().width(this->text) + 8 + 24, 24); 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 void
NotebookTab::paintEvent(QPaintEvent *) NotebookTab::paintEvent(QPaintEvent *)
{ {
@@ -77,25 +99,28 @@ NotebookTab::paintEvent(QPaintEvent *)
painter.setPen(fg); painter.setPen(fg);
QRect rect(0, 0, QRect rect(
width() - (settings::Settings::getHideTabX().get() ? 0 : 16), 0, 0,
height()); width() -
(settings::Settings::getInstance().getHideTabX().get() ? 0 : 16),
height());
painter.drawText(rect, this->text, QTextOption(Qt::AlignCenter)); painter.drawText(rect, this->text, QTextOption(Qt::AlignCenter));
if (!settings::Settings::getHideTabX().get() && (mouseOver || selected)) { if (!settings::Settings::getInstance().getHideTabX().get() &&
if (mouseOverX) { (this->mouseOver || this->selected)) {
painter.fillRect(getXRect(), QColor(0, 0, 0, 64)); if (this->mouseOverX) {
painter.fillRect(this->getXRect(), QColor(0, 0, 0, 64));
if (mouseDownX) { if (this->mouseDownX) {
painter.fillRect(getXRect(), QColor(0, 0, 0, 64)); painter.fillRect(this->getXRect(), QColor(0, 0, 0, 64));
} }
} }
painter.drawLine(getXRect().topLeft() + QPoint(4, 4), painter.drawLine(this->getXRect().topLeft() + QPoint(4, 4),
getXRect().bottomRight() + QPoint(-4, -4)); this->getXRect().bottomRight() + QPoint(-4, -4));
painter.drawLine(getXRect().topRight() + QPoint(-4, 4), painter.drawLine(this->getXRect().topRight() + QPoint(-4, 4),
getXRect().bottomLeft() + QPoint(4, -4)); this->getXRect().bottomLeft() + QPoint(4, -4));
} }
} }
@@ -156,6 +181,17 @@ NotebookTab::mouseMoveEvent(QMouseEvent *event)
this->repaint(); 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);
}
}
} }
} }
} }
+8 -2
View File
@@ -1,6 +1,7 @@
#ifndef NOTEBOOKTAB_H #ifndef NOTEBOOKTAB_H
#define NOTEBOOKTAB_H #define NOTEBOOKTAB_H
#include <QPropertyAnimation>
#include <QWidget> #include <QWidget>
namespace chatterino { namespace chatterino {
@@ -20,7 +21,7 @@ public:
HighlightNewMessage HighlightNewMessage
}; };
NotebookTab(Notebook *notebook); explicit NotebookTab(Notebook *notebook);
~NotebookTab(); ~NotebookTab();
void calcSize(); void calcSize();
@@ -65,6 +66,8 @@ public:
repaint(); repaint();
} }
void moveAnimated(QPoint pos);
protected: protected:
void paintEvent(QPaintEvent *) override; void paintEvent(QPaintEvent *) override;
@@ -78,6 +81,9 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;
private: private:
// QPropertyAnimation posAnimation;
// bool posAnimated;
Notebook *notebook; Notebook *notebook;
QString text; QString text;
@@ -98,7 +104,7 @@ private:
private slots: private slots:
void void
hideTabXChanged(bool value) hideTabXChanged(bool)
{ {
calcSize(); calcSize();
repaint(); repaint();
+74 -11
View File
@@ -54,6 +54,8 @@ SettingsDialog::SettingsDialog()
void void
SettingsDialog::addTabs() SettingsDialog::addTabs()
{ {
settings::Settings &settings = settings::Settings::getInstance();
QVBoxLayout *vbox; QVBoxLayout *vbox;
// Appearance // Appearance
@@ -80,12 +82,17 @@ SettingsDialog::addTabs()
auto group = new QGroupBox("Messages"); auto group = new QGroupBox("Messages");
auto v = new QVBoxLayout(); auto v = new QVBoxLayout();
v->addWidget(createCheckbox("Show timestamp", "")); v->addWidget(
v->addWidget(createCheckbox("Show seconds in timestamp", "")); createCheckbox("Show timestamp", settings.getShowTimestamps()));
v->addWidget(createCheckbox("Show seconds in timestamp",
settings.getShowTimestampSeconds()));
v->addWidget(createCheckbox( v->addWidget(createCheckbox(
"Allow sending duplicate messages (add a space at the end)", "")); "Allow sending duplicate messages (add a space at the end)",
v->addWidget(createCheckbox("Seperate messages", "")); settings.getAllowDouplicateMessages()));
v->addWidget(createCheckbox("Show message length", "")); v->addWidget(createCheckbox("Seperate messages",
settings.getSeperateMessages()));
v->addWidget(createCheckbox("Show message length",
settings.getShowMessageLength()));
group->setLayout(v); group->setLayout(v);
@@ -99,11 +106,15 @@ SettingsDialog::addTabs()
// Behaviour // Behaviour
vbox = new QVBoxLayout(); vbox = new QVBoxLayout();
vbox->addWidget(createCheckbox("Hide input box if empty", "")); vbox->addWidget(createCheckbox("Hide input box if empty",
settings.getHideEmptyInput()));
vbox->addWidget( vbox->addWidget(
createCheckbox("Mention users with a @ (except in commands)", "")); createCheckbox("Mention users with a @ (except in commands)",
vbox->addWidget(createCheckbox("Window always on top", "")); settings.getMentionUsersWithAt()));
vbox->addWidget(createCheckbox("Show last read message indicator", "")); vbox->addWidget(
createCheckbox("Window always on top", settings.getWindowTopMost()));
vbox->addWidget(createCheckbox("Show last read message indicator",
settings.getShowLastMessageIndicator()));
{ {
auto v = new QVBoxLayout(); auto v = new QVBoxLayout();
@@ -128,14 +139,66 @@ SettingsDialog::addTabs()
addTab(vbox, "Commands", ":/images/CustomActionEditor_16x.png"); 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 // Add stretch
tabs.addStretch(1); tabs.addStretch(1);
} }
QCheckBox * 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 void
+3 -1
View File
@@ -1,6 +1,7 @@
#ifndef SETTINGSDIALOG_H #ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H #define SETTINGSDIALOG_H
#include "settings/settings.h"
#include "widgets/settingsdialogtab.h" #include "widgets/settingsdialogtab.h"
#include <QButtonGroup> #include <QButtonGroup>
@@ -39,7 +40,8 @@ private:
SettingsDialogTab *selectedTab = NULL; SettingsDialogTab *selectedTab = NULL;
QCheckBox *createCheckbox(QString title, QString settingsId); QCheckBox *createCheckbox(const QString &title,
settings::BoolSetting &setting);
}; };
} }
} }