added namespaces

This commit is contained in:
fourtf 2017-01-18 21:30:23 +01:00
parent 82338baaa3
commit 2e8dc63a95
82 changed files with 681 additions and 459 deletions

View file

@ -1,5 +1,7 @@
#include "account.h"
namespace chatterino {
Account Account::anon("justinfan123", "", "");
Account::Account(QString username, QString oauthToken, QString oauthClient)
@ -8,3 +10,4 @@ Account::Account(QString username, QString oauthToken, QString oauthClient)
this->oauthToken = oauthToken;
this->username = username;
}
}

View file

@ -3,6 +3,8 @@
#include <QString>
namespace chatterino {
class Account
{
public:
@ -45,5 +47,6 @@ private:
QString oauthClient;
QString oauthToken;
};
}
#endif // ACCOUNT_H

View file

@ -1,13 +0,0 @@
#include "appsettings.h"
Word::Type AppSettings::wordTypeMask = Word::Default;
AppSettings::AppSettings()
{
}
bool
AppSettings::isIgnoredEmote(const QString &emote)
{
return false;
}

View file

@ -1,13 +1,31 @@
#ifndef ASYNCEXEC_H
#define ASYNCEXEC_H
#include "lambdaqrunnable.h"
#include "qcoreapplication.h"
#include <QRunnable>
#include <QThreadPool>
#include <functional>
#define async_exec(a) \
QThreadPool::globalInstance()->start(new LambdaQRunnable(a));
QThreadPool::globalInstance()->start(new LambdaRunnable(a));
class LambdaRunnable : public QRunnable
{
public:
LambdaRunnable(std::function<void()> action)
{
this->action = action;
}
void
run()
{
this->action();
}
private:
std::function<void()> action;
};
#endif // ASYNCEXEC_H

View file

@ -1,9 +1,11 @@
#include "channel.h"
#include "message.h"
#include "messages/message.h"
#include "windows.h"
#include <memory>
namespace chatterino {
Channel::Channel(const QString &channel)
: messages()
, name((channel.length() > 0 && channel[0] == '#') ? channel.mid(1)
@ -37,3 +39,4 @@ Channel::addMessage(std::shared_ptr<Message> message)
Windows::repaintVisibleChatWidgets();
}
}

View file

@ -2,7 +2,7 @@
#define CHANNEL_H
#include "concurrentmap.h"
#include "lazyloadedimage.h"
#include "messages/lazyloadedimage.h"
#include <QMap>
#include <QMutex>
@ -10,7 +10,13 @@
#include <QVector>
#include <memory>
using namespace chatterino::messages;
namespace chatterino {
namespace messages {
class Message;
}
class Channel
{
@ -23,6 +29,7 @@ public:
{
return bttvChannelEmotes;
}
const ConcurrentMap<QString, LazyLoadedImage *> &
getFfzChannelEmotes() const
{
@ -108,5 +115,6 @@ private:
QString streamStatus;
QString streamGame;
};
}
#endif // CHANNEL_H

View file

@ -1,6 +1,8 @@
#include "channels.h"
#include "ircmanager.h"
namespace chatterino {
Channel Channels::whispers(QString("/whispers"));
Channel Channels::mentions(QString("/mentions"));
Channel Channels::empty(QString(""));
@ -77,3 +79,4 @@ Channels::removeChannel(const QString &channel)
delete std::get<0>(a.value());
}
}
}

View file

@ -3,6 +3,8 @@
#include "channel.h"
namespace chatterino {
class Channels
{
public:
@ -33,5 +35,5 @@ private:
static QMap<QString, std::tuple<Channel *, int>> channels;
};
}
#endif // CHANNELS_H

View file

@ -37,89 +37,83 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += main.cpp\
mainwindow.cpp \
chatwidget.cpp \
notebook.cpp \
notebooktab.cpp \
notebookpage.cpp \
notebookbutton.cpp \
colorscheme.cpp \
chatwidgetheader.cpp \
chatwidgetinput.cpp \
chatwidgetview.cpp \
notebookpagedroppreview.cpp \
channel.cpp \
dialog.cpp \
settingsdialog.cpp \
settingsdialogtab.cpp \
scrollbar.cpp \
scrollbarhighlight.cpp \
ircmanager.cpp \
lambdaqrunnable.cpp \
account.cpp \
emotes.cpp \
lazyloadedimage.cpp \
concurrentmap.cpp \
message.cpp \
word.cpp \
link.cpp \
fonts.cpp \
appsettings.cpp \
emojis.cpp \
wordpart.cpp \
resources.cpp \
windows.cpp \
chatwidgetheaderbutton.cpp \
chatwidgetheaderbuttonlabel.cpp \
channel.cpp \
channels.cpp \
textinputdialog.cpp
colorscheme.cpp \
emojis.cpp \
emotes.cpp \
fonts.cpp \
ircmanager.cpp \
messages/lazyloadedimage.cpp \
messages/link.cpp \
messages/message.cpp \
messages/word.cpp \
messages/wordpart.cpp \
resources.cpp \
settings/settings.cpp \
widgets/chatwidget.cpp \
widgets/chatwidgetheader.cpp \
widgets/chatwidgetheaderbutton.cpp \
widgets/chatwidgetheaderbuttonlabel.cpp \
widgets/chatwidgetinput.cpp \
widgets/chatwidgetview.cpp \
widgets/mainwindow.cpp \
widgets/notebook.cpp \
widgets/notebookbutton.cpp \
widgets/notebookpage.cpp \
widgets/notebookpagedroppreview.cpp \
widgets/notebooktab.cpp \
widgets/scrollbar.cpp \
widgets/scrollbarhighlight.cpp \
widgets/settingsdialog.cpp \
widgets/settingsdialogtab.cpp \
widgets/textinputdialog.cpp \
windows.cpp
HEADERS += mainwindow.h \
chatwidget.h \
notebook.h \
notebooktab.h \
notebookpage.h \
notebookbutton.h \
colorscheme.h \
chatwidgetheader.h \
chatwidgetinput.h \
chatwidgetview.h \
notebookpagedroppreview.h \
channel.h \
dialog.h \
settingsdialog.h \
settingsdialogtab.h \
scrollbar.h \
scrollbarhighlight.h \
ircmanager.h \
lambdaqrunnable.h \
HEADERS += account.h \
asyncexec.h \
account.h \
emotes.h \
lazyloadedimage.h \
twitchemotevalue.h \
concurrentmap.h \
message.h \
word.h \
link.h \
fonts.h \
appsettings.h \
emojis.h \
wordpart.h \
common.h \
resources.h \
windows.h \
chatwidgetheaderbutton.h \
chatwidgetheaderbuttonlabel.h \
channel.h \
channels.h \
textinputdialog.h \
signallabel.h
colorscheme.h \
common.h \
concurrentmap.h \
emojis.h \
emotes.h \
fonts.h \
ircmanager.h \
messages/lazyloadedimage.h \
messages/link.h \
messages/message.h \
messages/word.h \
messages/wordpart.h \
resources.h \
settings/realsetting.h \
settings/setting.h \
settings/settings.h \
twitchemotevalue.h \
widgets/chatwidget.h \
widgets/chatwidgetheader.h \
widgets/chatwidgetheaderbutton.h \
widgets/chatwidgetheaderbuttonlabel.h \
widgets/chatwidgetinput.h \
widgets/chatwidgetview.h \
widgets/mainwindow.h \
widgets/notebook.h \
widgets/notebookbutton.h \
widgets/notebookpage.h \
widgets/notebookpagedroppreview.h \
widgets/notebooktab.h \
widgets/scrollbar.h \
widgets/scrollbarhighlight.h \
widgets/settingsdialog.h \
widgets/settingsdialogtab.h \
widgets/signallabel.h \
widgets/textinputdialog.h \
windows.h
PRECOMPILED_HEADER =
FORMS += \
dialog.ui
RESOURCES += \
resources.qrc

View file

@ -4,6 +4,8 @@
#include <QColor>
namespace chatterino {
// hue: theme color (0 - 1)
// multiplyer: 1 = white, 0.8 = light, -0.8 dark, -1 black
void
@ -129,3 +131,4 @@ ColorScheme::normalizeColor(QColor &color)
// color.setHslF(color.hueF(), s, newL);
}
}

View file

@ -4,6 +4,8 @@
#include <QBrush>
#include <QColor>
namespace chatterino {
class ColorScheme
{
public:
@ -79,5 +81,6 @@ private:
void fillLookupTableValues(qreal (&array)[360], qreal from, qreal to,
qreal fromValue, qreal toValue);
};
}
#endif // COLORSCHEME_H

View file

@ -1,7 +0,0 @@
#include "concurrentmap.h"
// template<typename TKey, typename TValue>
// ConcurrentMap<TKey, TValue>::ConcurrentMap()
//{
//}

View file

@ -5,6 +5,8 @@
#include <QMutex>
#include <functional>
namespace chatterino {
template <typename TKey, typename TValue>
class ConcurrentMap
{
@ -65,5 +67,6 @@ private:
QMutex *mutex;
QMap<TKey, TValue> *map;
};
}
#endif // CONCURRENTMAP_H

View file

@ -1,14 +0,0 @@
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}

View file

@ -1,22 +0,0 @@
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private:
Ui::Dialog *ui;
};
#endif // DIALOG_H

View file

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1031</width>
<height>625</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="documentMode">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -5,13 +5,15 @@
#include <QStringBuilder>
#include <QTextStream>
namespace chatterino {
QRegularExpression Emojis::findShortCodesRegex(":([-+\\w]+):");
QMap<QString, Emojis::EmojiData> Emojis::shortCodeToEmoji;
QMap<QString, QString> Emojis::emojiToShortCode;
QMap<QChar, QMap<QString, QString>> Emojis::firstEmojiChars;
ConcurrentMap<QString, LazyLoadedImage *> Emojis::imageCache;
ConcurrentMap<QString, messages::LazyLoadedImage *> Emojis::imageCache;
QString
Emojis::replaceShortCodes(const QString &text)
@ -21,7 +23,8 @@ Emojis::replaceShortCodes(const QString &text)
}
void
Emojis::parseEmojis(std::vector<std::tuple<LazyLoadedImage *, QString>> &vector,
Emojis::parseEmojis(
std::vector<std::tuple<messages::LazyLoadedImage *, QString>> &vector,
const QString &text)
{
long lastSlice = 0;
@ -42,14 +45,17 @@ Emojis::parseEmojis(std::vector<std::tuple<LazyLoadedImage *, QString>> &vector,
if (i - lastSlice != 0) {
vector.push_back(
std::tuple<LazyLoadedImage *, QString>(
std::tuple<messages::LazyLoadedImage *,
QString>(
NULL, text.mid(lastSlice, i - lastSlice)));
}
vector.push_back(std::tuple<LazyLoadedImage *, QString>(
imageCache.getOrAdd(url,
vector.push_back(
std::tuple<messages::LazyLoadedImage *, QString>(
imageCache.getOrAdd(
url,
[&url] {
return new LazyLoadedImage(
return new messages::LazyLoadedImage(
url, 0.35);
}),
QString()));
@ -66,8 +72,8 @@ Emojis::parseEmojis(std::vector<std::tuple<LazyLoadedImage *, QString>> &vector,
}
if (lastSlice < text.length()) {
vector.push_back(
std::tuple<LazyLoadedImage *, QString>(NULL, text.mid(lastSlice)));
vector.push_back(std::tuple<messages::LazyLoadedImage *, QString>(
NULL, text.mid(lastSlice)));
}
}
@ -121,3 +127,4 @@ Emojis::loadEmojis()
QMap<QString, QString>{{emoji.second.value, emoji.second.code}});
}
}
}

View file

@ -2,18 +2,20 @@
#define EMOJIS_H
#include "concurrentmap.h"
#include "lazyloadedimage.h"
#include "messages/lazyloadedimage.h"
#include <QObject>
#include <QRegularExpression>
#include <QString>
#include <unordered_map>
namespace chatterino {
class Emojis
{
public:
static void parseEmojis(
std::vector<std::tuple<LazyLoadedImage *, QString>> &vector,
std::vector<std::tuple<messages::LazyLoadedImage *, QString>> &vector,
const QString &text);
static void loadEmojis();
@ -32,11 +34,12 @@ private:
static QMap<QString, QString> emojiToShortCode;
static QMap<QChar, QMap<QString, QString>> firstEmojiChars;
static ConcurrentMap<QString, LazyLoadedImage *> imageCache;
static ConcurrentMap<QString, messages::LazyLoadedImage *> imageCache;
Emojis()
{
}
};
}
#endif // EMOJIS_H

View file

@ -1,17 +1,21 @@
#include "emotes.h"
#include "resources.h"
namespace chatterino {
QString Emotes::twitchEmoteTemplate(
"https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}.0");
ConcurrentMap<QString, TwitchEmoteValue *> Emotes::twitchEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::bttvEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::ffzEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::chatterinoEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::bttvChannelEmoteFromCaches;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::ffzChannelEmoteFromCaches;
ConcurrentMap<long, LazyLoadedImage *> Emotes::twitchEmoteFromCache;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::miscImageFromCache;
ConcurrentMap<QString, messages::LazyLoadedImage *> Emotes::bttvEmotes;
ConcurrentMap<QString, messages::LazyLoadedImage *> Emotes::ffzEmotes;
ConcurrentMap<QString, messages::LazyLoadedImage *> Emotes::chatterinoEmotes;
ConcurrentMap<QString, messages::LazyLoadedImage *>
Emotes::bttvChannelEmoteFromCaches;
ConcurrentMap<QString, messages::LazyLoadedImage *>
Emotes::ffzChannelEmoteFromCaches;
ConcurrentMap<long, messages::LazyLoadedImage *> Emotes::twitchEmoteFromCache;
ConcurrentMap<QString, messages::LazyLoadedImage *> Emotes::miscImageFromCache;
int Emotes::generation = 0;
@ -19,13 +23,14 @@ Emotes::Emotes()
{
}
LazyLoadedImage *
messages::LazyLoadedImage *
Emotes::getTwitchEmoteById(const QString &name, long id)
{
return Emotes::twitchEmoteFromCache.getOrAdd(id, [&name, id] {
qreal scale;
QString url = getTwitchEmoteLink(id, scale);
return new LazyLoadedImage(url, scale, name, name + "\nTwitch Emote");
return new messages::LazyLoadedImage(url, scale, name,
name + "\nTwitch Emote");
});
}
@ -38,14 +43,14 @@ Emotes::getTwitchEmoteLink(long id, qreal &scale)
.replace("{scale}", "2");
}
LazyLoadedImage *
messages::LazyLoadedImage *
Emotes::getCheerImage(long long amount, bool animated)
{
// TODO: fix this xD
return getCheerBadge(amount);
}
LazyLoadedImage *
messages::LazyLoadedImage *
Emotes::getCheerBadge(long long amount)
{
if (amount >= 100000) {
@ -62,3 +67,4 @@ Emotes::getCheerBadge(long long amount)
return Resources::getCheerBadge1();
}
}
}

View file

@ -2,12 +2,14 @@
#define EMOTES_H
#include "concurrentmap.h"
#include "lazyloadedimage.h"
#include "messages/lazyloadedimage.h"
#include "twitchemotevalue.h"
#include <QMap>
#include <QMutex>
namespace chatterino {
class Emotes
{
public:
@ -17,43 +19,43 @@ public:
return twitchEmotes;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getBttvEmotes()
{
return bttvEmotes;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getFfzEmotes()
{
return ffzEmotes;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getChatterinoEmotes()
{
return chatterinoEmotes;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getBttvChannelEmoteFromCaches()
{
return bttvChannelEmoteFromCaches;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getFfzChannelEmoteFromCaches()
{
return ffzChannelEmoteFromCaches;
}
static ConcurrentMap<long, LazyLoadedImage *> &
static ConcurrentMap<long, messages::LazyLoadedImage *> &
getTwitchEmoteFromCache()
{
return twitchEmoteFromCache;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getMiscImageFromCache()
{
return miscImageFromCache;
@ -61,10 +63,11 @@ public:
static void loadGlobalEmotes();
static LazyLoadedImage *getCheerImage(long long int amount, bool animated);
static LazyLoadedImage *getCheerBadge(long long int amount);
static messages::LazyLoadedImage *getCheerImage(long long int amount,
bool animated);
static messages::LazyLoadedImage *getCheerBadge(long long int amount);
static LazyLoadedImage *getTwitchEmoteById(const QString &name,
static messages::LazyLoadedImage *getTwitchEmoteById(const QString &name,
long int id);
static int
@ -85,17 +88,22 @@ private:
static QString twitchEmoteTemplate;
static ConcurrentMap<QString, TwitchEmoteValue *> twitchEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> bttvEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> ffzEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> chatterinoEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> bttvChannelEmoteFromCaches;
static ConcurrentMap<QString, LazyLoadedImage *> ffzChannelEmoteFromCaches;
static ConcurrentMap<long, LazyLoadedImage *> twitchEmoteFromCache;
static ConcurrentMap<QString, LazyLoadedImage *> miscImageFromCache;
static ConcurrentMap<QString, messages::LazyLoadedImage *> bttvEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *> ffzEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *> chatterinoEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *>
bttvChannelEmoteFromCaches;
static ConcurrentMap<QString, messages::LazyLoadedImage *>
ffzChannelEmoteFromCaches;
static ConcurrentMap<long, messages::LazyLoadedImage *>
twitchEmoteFromCache;
static ConcurrentMap<QString, messages::LazyLoadedImage *>
miscImageFromCache;
static QString getTwitchEmoteLink(long id, qreal &scale);
static int generation;
};
}
#endif // EMOTES_H

View file

@ -2,6 +2,8 @@
#define DEFAULT_FONT "Arial"
namespace chatterino {
QFont *Fonts::medium = new QFont(DEFAULT_FONT, 14);
QFont *Fonts::mediumBold = new QFont(DEFAULT_FONT, 14);
QFont *Fonts::mediumItalic = new QFont(DEFAULT_FONT, 14);
@ -59,3 +61,4 @@ Fonts::getFontMetrics(Type type)
return *metricsMedium;
}
}

View file

@ -4,6 +4,8 @@
#include <QFont>
#include <QFontMetrics>
namespace chatterino {
class Fonts
{
public:
@ -50,5 +52,6 @@ private:
static int generation;
};
}
#endif // FONTS_H

View file

@ -12,6 +12,8 @@
#include <QNetworkRequest>
#include <future>
namespace chatterino {
Account *IrcManager::account = nullptr;
IrcConnection *IrcManager::connection = NULL;
QMutex IrcManager::connectionMutex;
@ -286,3 +288,4 @@ IrcManager::removeIgnoredUser(QString const &username)
// TODO: Implement IrcManager::removeIgnoredUser
}
}
}

View file

@ -4,7 +4,7 @@
#define TWITCH_MAX_MESSAGELENGTH 500
#include "account.h"
#include "message.h"
#include "messages/message.h"
#include <IrcMessage>
#include <QMap>
@ -12,6 +12,8 @@
#include <QNetworkAccessManager>
#include <QString>
namespace chatterino {
class IrcManager
{
public:
@ -55,5 +57,6 @@ private:
static void messageReceived(IrcMessage *message);
static void privateMessageReceived(IrcPrivateMessage *message);
};
}
#endif // IRCMANAGER_H

View file

@ -1,12 +0,0 @@
#include "lambdaqrunnable.h"
LambdaQRunnable::LambdaQRunnable(std::function<void()> action)
{
this->action = action;
}
void
LambdaQRunnable::run()
{
this->action();
}

View file

@ -1,18 +0,0 @@
#ifndef LAMBDAQRUNNABLE_H
#define LAMBDAQRUNNABLE_H
#include <QRunnable>
#include <functional>
class LambdaQRunnable : public QRunnable
{
public:
LambdaQRunnable(std::function<void()> action);
void run();
private:
std::function<void()> action;
};
#endif // LAMBDAQRUNNABLE_H

View file

@ -2,13 +2,16 @@
#include "colorscheme.h"
#include "emojis.h"
#include "ircmanager.h"
#include "mainwindow.h"
#include "resources.h"
#include "widgets/mainwindow.h"
#include "windows.h"
#include <QApplication>
#include <QClipboard>
using namespace chatterino;
using namespace chatterino::widgets;
int
main(int argc, char *argv[])
{

View file

@ -1,40 +0,0 @@
#include "message.h"
#include "qcolor.h"
#include "colorscheme.h"
Message::Message(const QString &text)
{
}
Message::Message(const IrcPrivateMessage& ircMessage, const Channel& Channel)
{
m_parseTime = std::chrono::system_clock::now();
auto words = new QList<Word>();
// username
m_userName = ircMessage.account();
if (m_userName.isEmpty())
{
auto iterator = ircMessage.tags().find("login");
if (iterator != ircMessage.tags().end())
{
m_userName = iterator.value().toString();
}
}
// highlights
#warning "xD"
// color
QColor usernameColor = ColorScheme::SystemMessageColor;
auto iterator = ircMessage.tags().find("color");
if (iterator != ircMessage.tags().end())
{
usernameColor = QColor(iterator.value().toString());
}
}

View file

@ -1,4 +1,4 @@
#include "lazyloadedimage.h"
#include "messages/lazyloadedimage.h"
#include "asyncexec.h"
#include "emotes.h"
@ -10,6 +10,9 @@
#include <QNetworkRequest>
#include <functional>
namespace chatterino {
namespace messages {
LazyLoadedImage::LazyLoadedImage(const QString &url, qreal scale,
const QString &name, const QString &tooltip,
const QMargins &margin, bool isHat)
@ -63,3 +66,5 @@ LazyLoadedImage::loadImage()
});
//}));
}
}
}

View file

@ -4,6 +4,9 @@
#include <QPixmap>
#include <QString>
namespace chatterino {
namespace messages {
class LazyLoadedImage
{
public:
@ -104,5 +107,7 @@ private:
void loadImage();
};
}
}
#endif // LAZYLOADEDIMAGE_H

View file

@ -1,4 +1,7 @@
#include "link.h"
#include "messages/link.h"
namespace chatterino {
namespace messages {
Link::Link()
: type(None)
@ -11,3 +14,5 @@ Link::Link(Type type, const QString &value)
, value(value)
{
}
}
}

View file

@ -3,6 +3,9 @@
#include <QString>
namespace chatterino {
namespace messages {
class Link
{
public:
@ -42,5 +45,7 @@ private:
Type type;
QString value;
};
}
}
#endif // LINK_H

View file

@ -1,13 +1,13 @@
#include "message.h"
#include "appsettings.h"
#include "messages/message.h"
#include "colorscheme.h"
#include "emojis.h"
#include "emotes.h"
#include "fonts.h"
#include "ircmanager.h"
#include "link.h"
#include "messages/link.h"
#include "qcolor.h"
#include "resources.h"
#include "settings/settings.h"
#include <QStringList>
#include <ctime>
@ -19,6 +19,9 @@
#define MARGIN_TOP 8
#define MARGIN_BOTTOM 8
namespace chatterino {
namespace messages {
QRegularExpression *Message::cheerRegex =
new QRegularExpression("cheer[1-9][0-9]*");
@ -426,16 +429,16 @@ Message::layout(int width, bool enableEmoteMargins)
qreal w = image.getWidth();
qreal h = image.getHeight();
if (AppSettings::getScaleEmotesByLineHeight()) {
if (settings::Settings::getScaleEmotesByLineHeight()) {
word.setSize(w * mediumTextLineHeight / h *
AppSettings::getEmoteScale(),
settings::Settings::getEmoteScale(),
mediumTextLineHeight *
AppSettings::getEmoteScale());
settings::Settings::getEmoteScale());
} else {
word.setSize(
w * image.getScale() * AppSettings::getEmoteScale(),
word.setSize(w * image.getScale() *
settings::Settings::getEmoteScale(),
h * image.getScale() *
AppSettings::getEmoteScale());
settings::Settings::getEmoteScale());
}
}
} else {
@ -471,7 +474,7 @@ Message::layout(int width, bool enableEmoteMargins)
}
};
int flags = AppSettings::getWordTypeMask();
int flags = settings::Settings::getWordTypeMask();
for (auto it = this->words.begin(); it != this->words.end(); ++it) {
Word &word = *it;
@ -598,3 +601,5 @@ Message::matchLink(const QString &string)
// TODO: Implement this xD
return QString();
}
}
}

View file

@ -2,13 +2,16 @@
#define MESSAGE_H
#include "channel.h"
#include "word.h"
#include "wordpart.h"
#include "messages/word.h"
#include "messages/wordpart.h"
#include <IrcMessage>
#include <QVector>
#include <chrono>
namespace chatterino {
namespace messages {
class Message
{
public:
@ -129,5 +132,7 @@ private:
const std::pair<long int, LazyLoadedImage *> &a,
const std::pair<long int, LazyLoadedImage *> &b);
};
}
}
#endif // MESSAGE_H

View file

@ -1,4 +1,7 @@
#include "word.h"
#include "messages/word.h"
namespace chatterino {
namespace messages {
// Image word
Word::Word(LazyLoadedImage *image, Type type, const QString &copytext,
@ -30,3 +33,5 @@ Word::Word(const QString &text, Type type, const QColor &color,
, characterWidthCache()
{
}
}
}

View file

@ -2,13 +2,16 @@
#define WORD_H
#include "fonts.h"
#include "lazyloadedimage.h"
#include "link.h"
#include "messages/lazyloadedimage.h"
#include "messages/link.h"
#include <stdint.h>
#include <QRect>
#include <QString>
namespace chatterino {
namespace messages {
class Word
{
public:
@ -205,5 +208,7 @@ private:
std::vector<short> characterWidthCache;
};
}
}
#endif // WORD_H

View file

@ -1,5 +1,8 @@
#include "wordpart.h"
#include "word.h"
#include "messages/wordpart.h"
#include "messages/word.h"
namespace chatterino {
namespace messages {
WordPart::WordPart(Word &word, int x, int y, const QString &copyText,
bool allowTrailingSpace)
@ -27,3 +30,5 @@ WordPart::WordPart(Word &word, int x, int y, int width, int height,
, _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
{
}
}
}

View file

@ -4,6 +4,9 @@
#include <QRect>
#include <QString>
namespace chatterino {
namespace messages {
class Word;
class WordPart
@ -108,5 +111,7 @@ private:
bool _trailingSpace;
};
}
}
#endif // WORDPART_H

View file

@ -2,23 +2,25 @@
#include <QPixmap>
LazyLoadedImage *Resources::badgeStaff(NULL);
LazyLoadedImage *Resources::badgeAdmin(NULL);
LazyLoadedImage *Resources::badgeModerator(NULL);
LazyLoadedImage *Resources::badgeGlobalmod(NULL);
LazyLoadedImage *Resources::badgeTurbo(NULL);
LazyLoadedImage *Resources::badgeBroadcaster(NULL);
LazyLoadedImage *Resources::badgePremium(NULL);
namespace chatterino {
LazyLoadedImage *Resources::cheerBadge100000(NULL);
LazyLoadedImage *Resources::cheerBadge10000(NULL);
LazyLoadedImage *Resources::cheerBadge5000(NULL);
LazyLoadedImage *Resources::cheerBadge1000(NULL);
LazyLoadedImage *Resources::cheerBadge100(NULL);
LazyLoadedImage *Resources::cheerBadge1(NULL);
messages::LazyLoadedImage *Resources::badgeStaff(NULL);
messages::LazyLoadedImage *Resources::badgeAdmin(NULL);
messages::LazyLoadedImage *Resources::badgeModerator(NULL);
messages::LazyLoadedImage *Resources::badgeGlobalmod(NULL);
messages::LazyLoadedImage *Resources::badgeTurbo(NULL);
messages::LazyLoadedImage *Resources::badgeBroadcaster(NULL);
messages::LazyLoadedImage *Resources::badgePremium(NULL);
LazyLoadedImage *Resources::buttonBan(NULL);
LazyLoadedImage *Resources::buttonTimeout(NULL);
messages::LazyLoadedImage *Resources::cheerBadge100000(NULL);
messages::LazyLoadedImage *Resources::cheerBadge10000(NULL);
messages::LazyLoadedImage *Resources::cheerBadge5000(NULL);
messages::LazyLoadedImage *Resources::cheerBadge1000(NULL);
messages::LazyLoadedImage *Resources::cheerBadge100(NULL);
messages::LazyLoadedImage *Resources::cheerBadge1(NULL);
messages::LazyLoadedImage *Resources::buttonBan(NULL);
messages::LazyLoadedImage *Resources::buttonTimeout(NULL);
Resources::Resources()
{
@ -29,37 +31,38 @@ Resources::load()
{
// badges
Resources::badgeStaff =
new LazyLoadedImage(new QPixmap(":/images/staff_bg.png"));
new messages::LazyLoadedImage(new QPixmap(":/images/staff_bg.png"));
Resources::badgeAdmin =
new LazyLoadedImage(new QPixmap(":/images/admin_bg.png"));
new messages::LazyLoadedImage(new QPixmap(":/images/admin_bg.png"));
Resources::badgeModerator =
new LazyLoadedImage(new QPixmap(":/images/moderator_bg.png"));
new messages::LazyLoadedImage(new QPixmap(":/images/moderator_bg.png"));
Resources::badgeGlobalmod =
new LazyLoadedImage(new QPixmap(":/images/globalmod_bg.png"));
new messages::LazyLoadedImage(new QPixmap(":/images/globalmod_bg.png"));
Resources::badgeTurbo =
new LazyLoadedImage(new QPixmap(":/images/turbo_bg.png"));
Resources::badgeBroadcaster =
new LazyLoadedImage(new QPixmap(":/images/broadcaster_bg.png"));
Resources::badgePremium =
new LazyLoadedImage(new QPixmap(":/images/twitchprime_bg.png"));
new messages::LazyLoadedImage(new QPixmap(":/images/turbo_bg.png"));
Resources::badgeBroadcaster = new messages::LazyLoadedImage(
new QPixmap(":/images/broadcaster_bg.png"));
Resources::badgePremium = new messages::LazyLoadedImage(
new QPixmap(":/images/twitchprime_bg.png"));
// cheer badges
Resources::cheerBadge100000 =
new LazyLoadedImage(new QPixmap(":/images/cheer100000"));
new messages::LazyLoadedImage(new QPixmap(":/images/cheer100000"));
Resources::cheerBadge10000 =
new LazyLoadedImage(new QPixmap(":/images/cheer10000"));
new messages::LazyLoadedImage(new QPixmap(":/images/cheer10000"));
Resources::cheerBadge5000 =
new LazyLoadedImage(new QPixmap(":/images/cheer5000"));
new messages::LazyLoadedImage(new QPixmap(":/images/cheer5000"));
Resources::cheerBadge1000 =
new LazyLoadedImage(new QPixmap(":/images/cheer1000"));
new messages::LazyLoadedImage(new QPixmap(":/images/cheer1000"));
Resources::cheerBadge100 =
new LazyLoadedImage(new QPixmap(":/images/cheer100"));
new messages::LazyLoadedImage(new QPixmap(":/images/cheer100"));
Resources::cheerBadge1 =
new LazyLoadedImage(new QPixmap(":/images/cheer1"));
new messages::LazyLoadedImage(new QPixmap(":/images/cheer1"));
// button
Resources::buttonBan =
new LazyLoadedImage(new QPixmap(":/images/button_ban.png"), 0.25);
Resources::buttonTimeout =
new LazyLoadedImage(new QPixmap(":/images/button_timeout.png"), 0.25);
Resources::buttonBan = new messages::LazyLoadedImage(
new QPixmap(":/images/button_ban.png"), 0.25);
Resources::buttonTimeout = new messages::LazyLoadedImage(
new QPixmap(":/images/button_timeout.png"), 0.25);
}
}

View file

@ -1,7 +1,9 @@
#ifndef RESOURCES_H
#define RESOURCES_H
#include "lazyloadedimage.h"
#include "messages/lazyloadedimage.h"
namespace chatterino {
class Resources
{
@ -9,92 +11,92 @@ public:
static void load();
// badges
static LazyLoadedImage *
static messages::LazyLoadedImage *
getBadgeStaff()
{
return badgeStaff;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getBadgeAdmin()
{
return badgeAdmin;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getBadgeGlobalmod()
{
return badgeGlobalmod;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getBadgeModerator()
{
return badgeModerator;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getBadgeTurbo()
{
return badgeTurbo;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getBadgeBroadcaster()
{
return badgeBroadcaster;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getBadgePremium()
{
return badgePremium;
}
// cheer badges
static LazyLoadedImage *
static messages::LazyLoadedImage *
getCheerBadge100000()
{
return cheerBadge100000;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getCheerBadge10000()
{
return cheerBadge10000;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getCheerBadge5000()
{
return cheerBadge5000;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getCheerBadge1000()
{
return cheerBadge1000;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getCheerBadge100()
{
return cheerBadge100;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getCheerBadge1()
{
return cheerBadge1;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getButtonBan()
{
return buttonBan;
}
static LazyLoadedImage *
static messages::LazyLoadedImage *
getButtonTimeout()
{
return buttonTimeout;
@ -103,23 +105,24 @@ public:
private:
Resources();
static LazyLoadedImage *badgeStaff;
static LazyLoadedImage *badgeAdmin;
static LazyLoadedImage *badgeGlobalmod;
static LazyLoadedImage *badgeModerator;
static LazyLoadedImage *badgeTurbo;
static LazyLoadedImage *badgeBroadcaster;
static LazyLoadedImage *badgePremium;
static messages::LazyLoadedImage *badgeStaff;
static messages::LazyLoadedImage *badgeAdmin;
static messages::LazyLoadedImage *badgeGlobalmod;
static messages::LazyLoadedImage *badgeModerator;
static messages::LazyLoadedImage *badgeTurbo;
static messages::LazyLoadedImage *badgeBroadcaster;
static messages::LazyLoadedImage *badgePremium;
static LazyLoadedImage *cheerBadge100000;
static LazyLoadedImage *cheerBadge10000;
static LazyLoadedImage *cheerBadge5000;
static LazyLoadedImage *cheerBadge1000;
static LazyLoadedImage *cheerBadge100;
static LazyLoadedImage *cheerBadge1;
static messages::LazyLoadedImage *cheerBadge100000;
static messages::LazyLoadedImage *cheerBadge10000;
static messages::LazyLoadedImage *cheerBadge5000;
static messages::LazyLoadedImage *cheerBadge1000;
static messages::LazyLoadedImage *cheerBadge100;
static messages::LazyLoadedImage *cheerBadge1;
static LazyLoadedImage *buttonBan;
static LazyLoadedImage *buttonTimeout;
static messages::LazyLoadedImage *buttonBan;
static messages::LazyLoadedImage *buttonTimeout;
};
}
#endif // RESOURCES_H

32
settings/realsetting.h Normal file
View file

@ -0,0 +1,32 @@
#ifndef REALSETTING_H
#define REALSETTING_H
#include <QString>
namespace chatterino {
namespace settings {
class RealSetting : public Setting
{
public:
RealSetting(const QString &name, qreal defaultValue,
qreal minValue = std::numeric_limits<qreal>::min(),
qreal maxValue = std::numeric_limits<qreal>::max())
: Setting(name)
, value(defaultValue)
, defaultValue(defaultValue)
, minValue(minValue)
, maxValue(maxValue)
{
}
private:
qreal value;
qreal defaultValue;
qreal minValue;
qreal maxValue;
};
}
}
#endif // REALSETTING_H

30
settings/setting.h Normal file
View file

@ -0,0 +1,30 @@
#ifndef SETTING_H
#define SETTING_H
#include <QString>
namespace chatterino {
namespace settings {
class Setting
{
public:
explicit Setting(const QString &name)
: name(name)
{
}
const QString &
getName() const
{
return name;
}
virtual QString toString() = 0;
private:
QString name;
};
}
#endif // SETTING_H

18
settings/settings.cpp Normal file
View file

@ -0,0 +1,18 @@
#include "settings/settings.h"
namespace chatterino {
namespace settings {
messages::Word::Type Settings::wordTypeMask = messages::Word::Default;
Settings::Settings()
{
}
bool
Settings::isIgnoredEmote(const QString &emote)
{
return false;
}
}
}

View file

@ -1,12 +1,15 @@
#ifndef APPSETTINGS_H
#define APPSETTINGS_H
#include "word.h"
#include "messages/word.h"
class AppSettings
namespace chatterino {
namespace settings {
class Settings
{
public:
static Word::Type
static messages::Word::Type
getWordTypeMask()
{
return wordTypeMask;
@ -33,8 +36,10 @@ public:
}
private:
AppSettings();
static Word::Type wordTypeMask;
Settings();
static messages::Word::Type wordTypeMask;
};
}
}
#endif // APPSETTINGS_H

View file

@ -3,6 +3,8 @@
#include "QString"
namespace chatterino {
struct TwitchEmoteValue {
public:
int
@ -28,5 +30,6 @@ private:
int id;
QString channelName;
};
}
#endif // TWITCHEMOTEVALUE_H

View file

@ -1,13 +1,16 @@
#include "chatwidget.h"
#include "widgets/chatwidget.h"
#include "channels.h"
#include "colorscheme.h"
#include "textinputdialog.h"
#include "widgets/textinputdialog.h"
#include <QFont>
#include <QFontDatabase>
#include <QPainter>
#include <QVBoxLayout>
namespace chatterino {
namespace widgets {
ChatWidget::ChatWidget(QWidget *parent)
: QWidget(parent)
, channel(NULL)
@ -76,3 +79,5 @@ ChatWidget::paintEvent(QPaintEvent *)
painter.fillRect(this->rect(), ColorScheme::instance().ChatBackground);
}
}
}

View file

@ -2,14 +2,17 @@
#define CHATWIDGET_H
#include "channel.h"
#include "chatwidgetheader.h"
#include "chatwidgetinput.h"
#include "chatwidgetview.h"
#include "widgets/chatwidgetheader.h"
#include "widgets/chatwidgetinput.h"
#include "widgets/chatwidgetview.h"
#include <QFont>
#include <QVBoxLayout>
#include <QWidget>
namespace chatterino {
namespace widgets {
class ChatWidget : public QWidget
{
Q_OBJECT
@ -53,5 +56,7 @@ private:
ChatWidgetView view;
ChatWidgetInput input;
};
}
}
#endif // CHATWIDGET_H

View file

@ -1,13 +1,16 @@
#include "chatwidgetheader.h"
#include "chatwidget.h"
#include "widgets/chatwidgetheader.h"
#include "colorscheme.h"
#include "notebookpage.h"
#include "widgets/chatwidget.h"
#include "widgets/notebookpage.h"
#include <QByteArray>
#include <QDrag>
#include <QMimeData>
#include <QPainter>
namespace chatterino {
namespace widgets {
ChatWidgetHeader::ChatWidgetHeader(ChatWidget *parent)
: QWidget()
, chatWidget(parent)
@ -65,7 +68,8 @@ ChatWidgetHeader::ChatWidgetHeader(ChatWidget *parent)
* SLOT(mouseDoubleClickEvent));
* mouseDoubleClickEvent is not a signal, its an event handler
*/
connect(&this->middleLabel, &SignalLabel::mouseDoubleClick, this, &ChatWidgetHeader::mouseDoubleClickEvent);
connect(&this->middleLabel, &SignalLabel::mouseDoubleClick, this,
&ChatWidgetHeader::mouseDoubleClickEvent);
// right
this->rightLabel.setMinimumWidth(height());
@ -208,3 +212,5 @@ void
ChatWidgetHeader::menuShowChangelog()
{
}
}
}

View file

@ -1,8 +1,8 @@
#ifndef CHATWIDGETHEADER_H
#define CHATWIDGETHEADER_H
#include "chatwidgetheaderbutton.h"
#include "signallabel.h"
#include "widgets/chatwidgetheaderbutton.h"
#include <QAction>
#include <QHBoxLayout>
@ -13,6 +13,8 @@
#include <QPoint>
#include <QWidget>
namespace chatterino {
namespace widgets {
class ChatWidget;
class ChatWidgetHeader : public QWidget
@ -20,7 +22,7 @@ class ChatWidgetHeader : public QWidget
Q_OBJECT
public:
ChatWidgetHeader(ChatWidget *parent);
explicit ChatWidgetHeader(ChatWidget *parent);
ChatWidget *
getChatWidget()
@ -67,5 +69,7 @@ private slots:
void menuManualReconnect();
void menuShowChangelog();
};
}
}
#endif // CHATWIDGETHEADER_H

View file

@ -1,9 +1,12 @@
#include "chatwidgetheaderbutton.h"
#include "widgets/chatwidgetheaderbutton.h"
#include "colorscheme.h"
#include <QBrush>
#include <QPainter>
namespace chatterino {
namespace widgets {
ChatWidgetHeaderButton::ChatWidgetHeaderButton()
: QWidget()
, hbox()
@ -97,3 +100,5 @@ ChatWidgetHeaderButton::labelMouseDown()
repaint();
}
}
}

View file

@ -1,13 +1,16 @@
#ifndef CHATWIDGETHEADERBUTTON_H
#define CHATWIDGETHEADERBUTTON_H
#include "chatwidgetheaderbuttonlabel.h"
#include "widgets/chatwidgetheaderbuttonlabel.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QPaintEvent>
#include <QWidget>
namespace chatterino {
namespace widgets {
class ChatWidgetHeaderButton : public QWidget
{
Q_OBJECT
@ -43,5 +46,7 @@ private:
void labelMouseUp();
void labelMouseDown();
};
}
}
#endif // CHATWIDGETHEADERBUTTON_H

View file

@ -1,4 +1,7 @@
#include "chatwidgetheaderbuttonlabel.h"
#include "widgets/chatwidgetheaderbuttonlabel.h"
namespace chatterino {
namespace widgets {
ChatWidgetHeaderButtonLabel::ChatWidgetHeaderButtonLabel()
{
@ -20,3 +23,5 @@ ChatWidgetHeaderButtonLabel::mouseReleaseEvent(QMouseEvent *event)
emit mouseUp();
}
}
}
}

View file

@ -4,6 +4,9 @@
#include <QLabel>
#include <QMouseEvent>
namespace chatterino {
namespace widgets {
class ChatWidgetHeaderButtonLabel : public QLabel
{
Q_OBJECT
@ -19,5 +22,7 @@ protected:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
};
}
}
#endif // CHATWIDGETHEADERBUTTONLABEL_H

View file

@ -1,8 +1,11 @@
#include "chatwidgetinput.h"
#include "widgets/chatwidgetinput.h"
#include "colorscheme.h"
#include <QPainter>
namespace chatterino {
namespace widgets {
ChatWidgetInput::ChatWidgetInput()
{
setFixedHeight(38);
@ -17,3 +20,5 @@ ChatWidgetInput::paintEvent(QPaintEvent *)
painter.setPen(ColorScheme::instance().ChatInputBorder);
painter.drawRect(0, 0, width() - 1, height() - 1);
}
}
}

View file

@ -4,6 +4,9 @@
#include <QPaintEvent>
#include <QWidget>
namespace chatterino {
namespace widgets {
class ChatWidgetInput : public QWidget
{
Q_OBJECT
@ -14,5 +17,7 @@ public:
protected:
void paintEvent(QPaintEvent *);
};
}
}
#endif // CHATWIDGETINPUT_H

View file

@ -1,16 +1,19 @@
#include "chatwidgetview.h"
#include "widgets/chatwidgetview.h"
#include "channels.h"
#include "chatwidget.h"
#include "colorscheme.h"
#include "message.h"
#include "word.h"
#include "wordpart.h"
#include "messages/message.h"
#include "messages/word.h"
#include "messages/wordpart.h"
#include "widgets/chatwidget.h"
#include <math.h>
#include <QPainter>
#include <QScroller>
#include <functional>
namespace chatterino {
namespace widgets {
ChatWidgetView::ChatWidgetView(ChatWidget *parent)
: QWidget()
, chatWidget(parent)
@ -146,3 +149,5 @@ ChatWidgetView::paintEvent(QPaintEvent *)
y += message->getHeight();
}
}
}
}

View file

@ -2,11 +2,13 @@
#define CHATVIEW_H
#include "channel.h"
#include "scrollbar.h"
#include "widgets/scrollbar.h"
#include <QPaintEvent>
#include <QWidget>
namespace chatterino {
namespace widgets {
class ChatWidget;
class ChatWidgetView : public QWidget
@ -14,7 +16,7 @@ class ChatWidgetView : public QWidget
Q_OBJECT
public:
ChatWidgetView(ChatWidget *parent);
explicit ChatWidgetView(ChatWidget *parent);
bool layoutMessages();
@ -28,5 +30,7 @@ private:
ScrollBar scrollbar;
};
}
}
#endif // CHATVIEW_H

View file

@ -1,10 +1,13 @@
#include "mainwindow.h"
#include "chatwidget.h"
#include "widgets/mainwindow.h"
#include "colorscheme.h"
#include "notebook.h"
#include "widgets/chatwidget.h"
#include "widgets/notebook.h"
#include <QPalette>
namespace chatterino {
namespace widgets {
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, notebook(this)
@ -69,3 +72,5 @@ MainWindow::repaintVisibleChatWidgets(Channel *channel)
}
}
}
}
}

View file

@ -1,10 +1,13 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "notebook.h"
#include "widgets/notebook.h"
#include <QMainWindow>
namespace chatterino {
namespace widgets {
class MainWindow : public QMainWindow
{
Q_OBJECT
@ -17,5 +20,7 @@ public:
void layoutVisibleChatWidgets(Channel *channel = NULL);
void repaintVisibleChatWidgets(Channel *channel = NULL);
};
}
}
#endif // MAINWINDOW_H

View file

@ -1,16 +1,18 @@
#include "notebook.h"
#include "widgets/notebook.h"
#include "colorscheme.h"
#include "dialog.h"
#include "notebookbutton.h"
#include "notebookpage.h"
#include "notebooktab.h"
#include "settingsdialog.h"
#include "widgets/notebookbutton.h"
#include "widgets/notebookpage.h"
#include "widgets/notebooktab.h"
#include "widgets/settingsdialog.h"
#include <QFormLayout>
#include <QLayout>
#include <QList>
#include <QWidget>
namespace chatterino {
namespace widgets {
Notebook::Notebook(QWidget *parent)
: QWidget(parent)
, addButton(this)
@ -109,3 +111,5 @@ Notebook::resizeEvent(QResizeEvent *)
{
performLayout();
}
}
}

View file

@ -1,13 +1,16 @@
#ifndef NOTEBOOK_H
#define NOTEBOOK_H
#include "notebookbutton.h"
#include "notebookpage.h"
#include "notebooktab.h"
#include "widgets/notebookbutton.h"
#include "widgets/notebookpage.h"
#include "widgets/notebooktab.h"
#include <QList>
#include <QWidget>
namespace chatterino {
namespace widgets {
class Notebook : public QWidget
{
Q_OBJECT
@ -46,5 +49,7 @@ private:
NotebookPage *selectedPage = nullptr;
};
}
}
#endif // NOTEBOOK_H

View file

@ -1,10 +1,13 @@
#include "notebookbutton.h"
#include "widgets/notebookbutton.h"
#include "colorscheme.h"
#include <QMouseEvent>
#include <QPainter>
#include <QPainterPath>
namespace chatterino {
namespace widgets {
NotebookButton::NotebookButton(QWidget *parent)
: QWidget(parent)
{
@ -121,3 +124,5 @@ NotebookButton::leaveEvent(QEvent *)
this->repaint();
}
}
}

View file

@ -3,6 +3,9 @@
#include <QWidget>
namespace chatterino {
namespace widgets {
class NotebookButton : public QWidget
{
Q_OBJECT
@ -28,5 +31,7 @@ private:
bool mouseOver = false;
bool mouseDown = false;
};
}
}
#endif // NOTEBOOKBUTTON_H

View file

@ -1,7 +1,7 @@
#include "notebookpage.h"
#include "chatwidget.h"
#include "widgets/notebookpage.h"
#include "colorscheme.h"
#include "notebooktab.h"
#include "widgets/chatwidget.h"
#include "widgets/notebooktab.h"
#include <QHBoxLayout>
#include <QMimeData>
@ -9,6 +9,9 @@
#include <QVBoxLayout>
#include <QWidget>
namespace chatterino {
namespace widgets {
bool NotebookPage::isDraggingSplit = false;
ChatWidget *NotebookPage::draggingSplit = NULL;
std::pair<int, int> NotebookPage::dropPosition = std::pair<int, int>(-1, -1);
@ -233,3 +236,5 @@ NotebookPage::paintEvent(QPaintEvent *)
ColorScheme::instance().TabSelectedBackground);
}
}
}
}

View file

@ -1,10 +1,10 @@
#ifndef NOTEBOOKPAGE_H
#define NOTEBOOKPAGE_H
#include "chatwidget.h"
#include "notebookpage.h"
#include "notebookpagedroppreview.h"
#include "notebooktab.h"
#include "widgets/chatwidget.h"
#include "widgets/notebookpage.h"
#include "widgets/notebookpagedroppreview.h"
#include "widgets/notebooktab.h"
#include <QDragEnterEvent>
#include <QHBoxLayout>
@ -13,6 +13,9 @@
#include <QVector>
#include <QWidget>
namespace chatterino {
namespace widgets {
class NotebookPage : public QWidget
{
Q_OBJECT
@ -68,5 +71,7 @@ protected:
private:
void setPreviewRect(QPoint mousePos);
};
}
}
#endif // NOTEBOOKPAGE_H

View file

@ -1,8 +1,11 @@
#include "notebookpagedroppreview.h"
#include "widgets/notebookpagedroppreview.h"
#include "colorscheme.h"
#include <QPainter>
namespace chatterino {
namespace widgets {
NotebookPageDropPreview::NotebookPageDropPreview(QWidget *parent)
: QWidget(parent)
, positionAnimation(this, "geometry")
@ -35,3 +38,5 @@ NotebookPageDropPreview::setBounds(const QRect &rect)
this->desiredGeometry = rect;
}
}
}

View file

@ -4,6 +4,9 @@
#include <QPropertyAnimation>
#include <QWidget>
namespace chatterino {
namespace widgets {
class NotebookPageDropPreview : public QWidget
{
public:
@ -17,5 +20,7 @@ protected:
QPropertyAnimation positionAnimation;
QRect desiredGeometry;
};
}
}
#endif // NOTEBOOKPAGEDROPPREVIEW_H

View file

@ -1,9 +1,12 @@
#include "notebooktab.h"
#include "widgets/notebooktab.h"
#include "colorscheme.h"
#include "notebook.h"
#include "widgets/notebook.h"
#include <QPainter>
namespace chatterino {
namespace widgets {
NotebookTab::NotebookTab(Notebook *notebook)
: QWidget(notebook)
, notebook(notebook)
@ -93,3 +96,5 @@ NotebookTab::dragEnterEvent(QDragEnterEvent *event)
{
this->notebook->select(page);
}
}
}

View file

@ -3,6 +3,9 @@
#include <QWidget>
namespace chatterino {
namespace widgets {
class Notebook;
class NotebookPage;
@ -81,5 +84,7 @@ private:
bool mouseDown;
HighlightStyle highlightStyle;
};
}
}
#endif // NOTEBOOKTAB_H

View file

@ -1,10 +1,13 @@
#include "scrollbar.h"
#include "widgets/scrollbar.h"
#include "colorscheme.h"
#include <QPainter>
#define MIN_THUMB_HEIGHT 10
namespace chatterino {
namespace widgets {
ScrollBar::ScrollBar(QWidget *widget)
: QWidget(widget)
, mutex()
@ -112,3 +115,5 @@ ScrollBar::updateScroll()
repaint();
}
}
}

View file

@ -1,12 +1,15 @@
#ifndef SCROLLBAR_H
#define SCROLLBAR_H
#include "scrollbarhighlight.h"
#include "widgets/scrollbarhighlight.h"
#include <QMutex>
#include <QWidget>
#include <functional>
namespace chatterino {
namespace widgets {
class ScrollBar : public QWidget
{
Q_OBJECT
@ -106,5 +109,7 @@ private:
void updateScroll();
};
}
}
#endif // SCROLLBAR_H

View file

@ -1,6 +1,9 @@
#include "scrollbarhighlight.h"
#include "widgets/scrollbarhighlight.h"
#include "colorscheme.h"
namespace chatterino {
namespace widgets {
ScrollBarHighlight::ScrollBarHighlight(float position, int colorIndex,
Style style, QString tag)
: position(position)
@ -11,3 +14,5 @@ ScrollBarHighlight::ScrollBarHighlight(float position, int colorIndex,
, next(NULL)
{
}
}
}

View file

@ -3,6 +3,9 @@
#include "QString"
namespace chatterino {
namespace widgets {
class ScrollBarHighlight
{
public:
@ -43,5 +46,7 @@ private:
int colorIndex;
QString tag;
};
}
}
#endif // SCROLLBARHIGHLIGHT_H

View file

@ -1,5 +1,5 @@
#include "settingsdialog.h"
#include "settingsdialogtab.h"
#include "widgets/settingsdialog.h"
#include "widgets/settingsdialogtab.h"
#include <QComboBox>
#include <QFile>
@ -9,6 +9,9 @@
#include <QPalette>
#include <QResource>
namespace chatterino {
namespace widgets {
SettingsDialog::SettingsDialog()
{
QFile file(":/qss/settings.qss");
@ -172,3 +175,5 @@ SettingsDialog::select(SettingsDialogTab *tab)
"border-right: none;");
selectedTab = tab;
}
}
}

View file

@ -1,7 +1,7 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include "settingsdialogtab.h"
#include "widgets/settingsdialogtab.h"
#include <QButtonGroup>
#include <QCheckBox>
@ -14,6 +14,9 @@
#include <QVBoxLayout>
#include <QWidget>
namespace chatterino {
namespace widgets {
class SettingsDialog : public QWidget
{
public:
@ -38,5 +41,7 @@ private:
QCheckBox *createCheckbox(QString title, QString settingsId);
};
}
}
#endif // SETTINGSDIALOG_H

View file

@ -1,7 +1,11 @@
#include "settingsdialogtab.h"
#include "QPainter"
#include "QStyleOption"
#include "settingsdialog.h"
#include "widgets/settingsdialogtab.h"
#include "widgets/settingsdialog.h"
#include <QPainter>
#include <QStyleOption>
namespace chatterino {
namespace widgets {
SettingsDialogTab::SettingsDialogTab(SettingsDialog *dialog, QString label,
QString imageRes)
@ -43,3 +47,5 @@ SettingsDialogTab::mouseReleaseEvent(QMouseEvent *event)
dialog->select(this);
}
}
}

View file

@ -4,6 +4,9 @@
#include <QPaintEvent>
#include <QWidget>
namespace chatterino {
namespace widgets {
class SettingsDialog;
class SettingsDialogTab : public QWidget
@ -58,5 +61,7 @@ private:
bool selected = false;
};
}
}
#endif // SETTINGSNOTEBOOKTAB_H

View file

@ -1,6 +1,9 @@
#include "textinputdialog.h"
#include "widgets/textinputdialog.h"
#include <QSizePolicy>
namespace chatterino {
namespace widgets {
TextInputDialog::TextInputDialog(QWidget *parent)
: QDialog(parent)
, vbox(this)
@ -39,3 +42,5 @@ TextInputDialog::cancelButtonClicked()
reject();
close();
}
}
}

View file

@ -8,6 +8,9 @@
#include <QString>
#include <QVBoxLayout>
namespace chatterino {
namespace widgets {
class TextInputDialog : public QDialog
{
Q_OBJECT
@ -38,5 +41,7 @@ private slots:
void okButtonClicked();
void cancelButtonClicked();
};
}
}
#endif // TEXTINPUTDIALOG_H

View file

@ -1,5 +1,7 @@
#include "windows.h"
namespace chatterino {
QMutex Windows::windowMutex;
MainWindow *Windows::mainWindow(NULL);
@ -15,3 +17,4 @@ Windows::repaintVisibleChatWidgets(Channel *channel)
{
Windows::mainWindow->repaintVisibleChatWidgets(channel);
}
}

View file

@ -1,10 +1,14 @@
#ifndef WINDOWS_H
#define WINDOWS_H
#include "mainwindow.h"
#include "widgets/mainwindow.h"
#include <QMutex>
using namespace chatterino::widgets;
namespace chatterino {
class Windows
{
public:
@ -32,5 +36,6 @@ private:
static MainWindow *mainWindow;
};
}
#endif // WINDOWS_H