From 2e8dc63a9573a19e224bcf4f0a11e131233ac18e Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 18 Jan 2017 21:30:23 +0100 Subject: [PATCH] added namespaces --- account.cpp | 3 + account.h | 3 + appsettings.cpp | 13 -- asyncexec.h | 22 ++- channel.cpp | 5 +- channel.h | 10 +- channels.cpp | 3 + channels.h | 4 +- chatterino.pro | 144 +++++++++--------- colorscheme.cpp | 3 + colorscheme.h | 3 + concurrentmap.cpp | 7 - concurrentmap.h | 3 + dialog.cpp | 14 -- dialog.h | 22 --- dialog.ui | 55 ------- emojis.cpp | 33 ++-- emojis.h | 9 +- emotes.cpp | 28 ++-- emotes.h | 46 +++--- fonts.cpp | 3 + fonts.h | 3 + ircmanager.cpp | 3 + ircmanager.h | 5 +- lambdaqrunnable.cpp | 12 -- lambdaqrunnable.h | 18 --- main.cpp | 5 +- message.cpp.xT5964 | 40 ----- .../lazyloadedimage.cpp | 7 +- .../lazyloadedimage.h | 5 + link.cpp => messages/link.cpp | 7 +- link.h => messages/link.h | 5 + message.cpp => messages/message.cpp | 27 ++-- message.h => messages/message.h | 9 +- word.cpp => messages/word.cpp | 7 +- word.h => messages/word.h | 9 +- wordpart.cpp => messages/wordpart.cpp | 9 +- wordpart.h => messages/wordpart.h | 7 +- resources.cpp | 71 ++++----- resources.h | 65 ++++---- settings/realsetting.h | 32 ++++ settings/setting.h | 30 ++++ settings/settings.cpp | 18 +++ appsettings.h => settings/settings.h | 15 +- twitchemotevalue.h | 3 + chatwidget.cpp => widgets/chatwidget.cpp | 9 +- chatwidget.h => widgets/chatwidget.h | 11 +- .../chatwidgetheader.cpp | 16 +- .../chatwidgetheader.h | 8 +- .../chatwidgetheaderbutton.cpp | 7 +- .../chatwidgetheaderbutton.h | 7 +- .../chatwidgetheaderbuttonlabel.cpp | 7 +- .../chatwidgetheaderbuttonlabel.h | 5 + .../chatwidgetinput.cpp | 7 +- .../chatwidgetinput.h | 5 + .../chatwidgetview.cpp | 15 +- chatwidgetview.h => widgets/chatwidgetview.h | 8 +- mainwindow.cpp => widgets/mainwindow.cpp | 11 +- mainwindow.h => widgets/mainwindow.h | 7 +- notebook.cpp => widgets/notebook.cpp | 16 +- notebook.h => widgets/notebook.h | 11 +- .../notebookbutton.cpp | 7 +- notebookbutton.h => widgets/notebookbutton.h | 5 + notebookpage.cpp => widgets/notebookpage.cpp | 11 +- notebookpage.h => widgets/notebookpage.h | 13 +- .../notebookpagedroppreview.cpp | 7 +- .../notebookpagedroppreview.h | 5 + notebooktab.cpp => widgets/notebooktab.cpp | 9 +- notebooktab.h => widgets/notebooktab.h | 5 + scrollbar.cpp => widgets/scrollbar.cpp | 7 +- scrollbar.h => widgets/scrollbar.h | 7 +- .../scrollbarhighlight.cpp | 7 +- .../scrollbarhighlight.h | 5 + .../settingsdialog.cpp | 9 +- settingsdialog.h => widgets/settingsdialog.h | 7 +- .../settingsdialogtab.cpp | 14 +- .../settingsdialogtab.h | 5 + signallabel.h => widgets/signallabel.h | 0 .../textinputdialog.cpp | 7 +- .../textinputdialog.h | 5 + windows.cpp | 3 + windows.h | 7 +- 82 files changed, 681 insertions(+), 459 deletions(-) delete mode 100644 appsettings.cpp delete mode 100644 concurrentmap.cpp delete mode 100644 dialog.cpp delete mode 100644 dialog.h delete mode 100644 dialog.ui delete mode 100644 lambdaqrunnable.cpp delete mode 100644 lambdaqrunnable.h delete mode 100644 message.cpp.xT5964 rename lazyloadedimage.cpp => messages/lazyloadedimage.cpp (94%) rename lazyloadedimage.h => messages/lazyloadedimage.h (97%) rename link.cpp => messages/link.cpp (65%) rename link.h => messages/link.h (92%) rename message.cpp => messages/message.cpp (96%) rename message.h => messages/message.h (95%) rename word.cpp => messages/word.cpp (90%) rename word.h => messages/word.h (97%) rename wordpart.cpp => messages/wordpart.cpp (87%) rename wordpart.h => messages/wordpart.h (96%) create mode 100644 settings/realsetting.h create mode 100644 settings/setting.h create mode 100644 settings/settings.cpp rename appsettings.h => settings/settings.h (70%) rename chatwidget.cpp => widgets/chatwidget.cpp (92%) rename chatwidget.h => widgets/chatwidget.h (83%) rename chatwidgetheader.cpp => widgets/chatwidgetheader.cpp (96%) rename chatwidgetheader.h => widgets/chatwidgetheader.h (90%) rename chatwidgetheaderbutton.cpp => widgets/chatwidgetheaderbutton.cpp (95%) rename chatwidgetheaderbutton.h => widgets/chatwidgetheaderbutton.h (89%) rename chatwidgetheaderbuttonlabel.cpp => widgets/chatwidgetheaderbuttonlabel.cpp (80%) rename chatwidgetheaderbuttonlabel.h => widgets/chatwidgetheaderbuttonlabel.h (89%) rename chatwidgetinput.cpp => widgets/chatwidgetinput.cpp (81%) rename chatwidgetinput.h => widgets/chatwidgetinput.h (84%) rename chatwidgetview.cpp => widgets/chatwidgetview.cpp (94%) rename chatwidgetview.h => widgets/chatwidgetview.h (75%) rename mainwindow.cpp => widgets/mainwindow.cpp (91%) rename mainwindow.h => widgets/mainwindow.h (82%) rename notebook.cpp => widgets/notebook.cpp (90%) rename notebook.h => widgets/notebook.h (83%) rename notebookbutton.cpp => widgets/notebookbutton.cpp (97%) rename notebookbutton.h => widgets/notebookbutton.h (93%) rename notebookpage.cpp => widgets/notebookpage.cpp (97%) rename notebookpage.h => widgets/notebookpage.h (89%) rename notebookpagedroppreview.cpp => widgets/notebookpagedroppreview.cpp (89%) rename notebookpagedroppreview.h => widgets/notebookpagedroppreview.h (89%) rename notebooktab.cpp => widgets/notebooktab.cpp (94%) rename notebooktab.h => widgets/notebooktab.h (96%) rename scrollbar.cpp => widgets/scrollbar.cpp (96%) rename scrollbar.h => widgets/scrollbar.h (94%) rename scrollbarhighlight.cpp => widgets/scrollbarhighlight.cpp (79%) rename scrollbarhighlight.h => widgets/scrollbarhighlight.h (93%) rename settingsdialog.cpp => widgets/settingsdialog.cpp (97%) rename settingsdialog.h => widgets/settingsdialog.h (90%) rename settingsdialogtab.cpp => widgets/settingsdialogtab.cpp (84%) rename settingsdialogtab.h => widgets/settingsdialogtab.h (95%) rename signallabel.h => widgets/signallabel.h (100%) rename textinputdialog.cpp => widgets/textinputdialog.cpp (92%) rename textinputdialog.h => widgets/textinputdialog.h (93%) diff --git a/account.cpp b/account.cpp index d7b45ae3..d60079fe 100644 --- a/account.cpp +++ b/account.cpp @@ -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; } +} diff --git a/account.h b/account.h index b81a0996..4deb9206 100644 --- a/account.h +++ b/account.h @@ -3,6 +3,8 @@ #include +namespace chatterino { + class Account { public: @@ -45,5 +47,6 @@ private: QString oauthClient; QString oauthToken; }; +} #endif // ACCOUNT_H diff --git a/appsettings.cpp b/appsettings.cpp deleted file mode 100644 index 69178288..00000000 --- a/appsettings.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "appsettings.h" - -Word::Type AppSettings::wordTypeMask = Word::Default; - -AppSettings::AppSettings() -{ -} - -bool -AppSettings::isIgnoredEmote(const QString &emote) -{ - return false; -} diff --git a/asyncexec.h b/asyncexec.h index dabd53df..2b498966 100644 --- a/asyncexec.h +++ b/asyncexec.h @@ -1,13 +1,31 @@ #ifndef ASYNCEXEC_H #define ASYNCEXEC_H -#include "lambdaqrunnable.h" #include "qcoreapplication.h" #include #include +#include #define async_exec(a) \ - QThreadPool::globalInstance()->start(new LambdaQRunnable(a)); + QThreadPool::globalInstance()->start(new LambdaRunnable(a)); + +class LambdaRunnable : public QRunnable +{ +public: + LambdaRunnable(std::function action) + { + this->action = action; + } + + void + run() + { + this->action(); + } + +private: + std::function action; +}; #endif // ASYNCEXEC_H diff --git a/channel.cpp b/channel.cpp index e47ce54a..da6cbebb 100644 --- a/channel.cpp +++ b/channel.cpp @@ -1,9 +1,11 @@ #include "channel.h" -#include "message.h" +#include "messages/message.h" #include "windows.h" #include +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) Windows::repaintVisibleChatWidgets(); } +} diff --git a/channel.h b/channel.h index bdf044dc..47c26a12 100644 --- a/channel.h +++ b/channel.h @@ -2,7 +2,7 @@ #define CHANNEL_H #include "concurrentmap.h" -#include "lazyloadedimage.h" +#include "messages/lazyloadedimage.h" #include #include @@ -10,7 +10,13 @@ #include #include +using namespace chatterino::messages; + +namespace chatterino { + +namespace messages { class Message; +} class Channel { @@ -23,6 +29,7 @@ public: { return bttvChannelEmotes; } + const ConcurrentMap & getFfzChannelEmotes() const { @@ -108,5 +115,6 @@ private: QString streamStatus; QString streamGame; }; +} #endif // CHANNEL_H diff --git a/channels.cpp b/channels.cpp index 385bd1d4..e802f2da 100644 --- a/channels.cpp +++ b/channels.cpp @@ -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()); } } +} diff --git a/channels.h b/channels.h index 186f5aba..67dc128f 100644 --- a/channels.h +++ b/channels.h @@ -3,6 +3,8 @@ #include "channel.h" +namespace chatterino { + class Channels { public: @@ -33,5 +35,5 @@ private: static QMap> channels; }; - +} #endif // CHANNELS_H diff --git a/chatterino.pro b/chatterino.pro index 54164455..80f06c8e 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -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 diff --git a/colorscheme.cpp b/colorscheme.cpp index 82310831..f9d6721a 100644 --- a/colorscheme.cpp +++ b/colorscheme.cpp @@ -4,6 +4,8 @@ #include +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); } +} diff --git a/colorscheme.h b/colorscheme.h index 45460cec..4ac8d71b 100644 --- a/colorscheme.h +++ b/colorscheme.h @@ -4,6 +4,8 @@ #include #include +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 diff --git a/concurrentmap.cpp b/concurrentmap.cpp deleted file mode 100644 index 500c14c6..00000000 --- a/concurrentmap.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "concurrentmap.h" - -// template -// ConcurrentMap::ConcurrentMap() -//{ - -//} diff --git a/concurrentmap.h b/concurrentmap.h index a2e0355a..e1201592 100644 --- a/concurrentmap.h +++ b/concurrentmap.h @@ -5,6 +5,8 @@ #include #include +namespace chatterino { + template class ConcurrentMap { @@ -65,5 +67,6 @@ private: QMutex *mutex; QMap *map; }; +} #endif // CONCURRENTMAP_H diff --git a/dialog.cpp b/dialog.cpp deleted file mode 100644 index 3510a1d0..00000000 --- a/dialog.cpp +++ /dev/null @@ -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; -} diff --git a/dialog.h b/dialog.h deleted file mode 100644 index 1c4973bb..00000000 --- a/dialog.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef DIALOG_H -#define DIALOG_H - -#include - -namespace Ui { -class Dialog; -} - -class Dialog : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog(QWidget *parent = 0); - ~Dialog(); - -private: - Ui::Dialog *ui; -}; - -#endif // DIALOG_H diff --git a/dialog.ui b/dialog.ui deleted file mode 100644 index b9bd1506..00000000 --- a/dialog.ui +++ /dev/null @@ -1,55 +0,0 @@ - - - Dialog - - - - 0 - 0 - 1031 - 625 - - - - Dialog - - - - - - - - - - - 0 - - - true - - - - Tab 1 - - - - - Tab 2 - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - diff --git a/emojis.cpp b/emojis.cpp index ec7c6469..5130c042 100644 --- a/emojis.cpp +++ b/emojis.cpp @@ -5,13 +5,15 @@ #include #include +namespace chatterino { + QRegularExpression Emojis::findShortCodesRegex(":([-+\\w]+):"); QMap Emojis::shortCodeToEmoji; QMap Emojis::emojiToShortCode; QMap> Emojis::firstEmojiChars; -ConcurrentMap Emojis::imageCache; +ConcurrentMap Emojis::imageCache; QString Emojis::replaceShortCodes(const QString &text) @@ -21,8 +23,9 @@ Emojis::replaceShortCodes(const QString &text) } void -Emojis::parseEmojis(std::vector> &vector, - const QString &text) +Emojis::parseEmojis( + std::vector> &vector, + const QString &text) { long lastSlice = 0; @@ -42,17 +45,20 @@ Emojis::parseEmojis(std::vector> &vector, if (i - lastSlice != 0) { vector.push_back( - std::tuple( + std::tuple( NULL, text.mid(lastSlice, i - lastSlice))); } - vector.push_back(std::tuple( - imageCache.getOrAdd(url, - [&url] { - return new LazyLoadedImage( - url, 0.35); - }), - QString())); + vector.push_back( + std::tuple( + imageCache.getOrAdd( + url, + [&url] { + return new messages::LazyLoadedImage( + url, 0.35); + }), + QString())); i += j - 1; @@ -66,8 +72,8 @@ Emojis::parseEmojis(std::vector> &vector, } if (lastSlice < text.length()) { - vector.push_back( - std::tuple(NULL, text.mid(lastSlice))); + vector.push_back(std::tuple( + NULL, text.mid(lastSlice))); } } @@ -121,3 +127,4 @@ Emojis::loadEmojis() QMap{{emoji.second.value, emoji.second.code}}); } } +} diff --git a/emojis.h b/emojis.h index 67a171cd..d5d03f45 100644 --- a/emojis.h +++ b/emojis.h @@ -2,18 +2,20 @@ #define EMOJIS_H #include "concurrentmap.h" -#include "lazyloadedimage.h" +#include "messages/lazyloadedimage.h" #include #include #include #include +namespace chatterino { + class Emojis { public: static void parseEmojis( - std::vector> &vector, + std::vector> &vector, const QString &text); static void loadEmojis(); @@ -32,11 +34,12 @@ private: static QMap emojiToShortCode; static QMap> firstEmojiChars; - static ConcurrentMap imageCache; + static ConcurrentMap imageCache; Emojis() { } }; +} #endif // EMOJIS_H diff --git a/emotes.cpp b/emotes.cpp index 7a891a2f..e93b7bdf 100644 --- a/emotes.cpp +++ b/emotes.cpp @@ -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 Emotes::twitchEmotes; -ConcurrentMap Emotes::bttvEmotes; -ConcurrentMap Emotes::ffzEmotes; -ConcurrentMap Emotes::chatterinoEmotes; -ConcurrentMap Emotes::bttvChannelEmoteFromCaches; -ConcurrentMap Emotes::ffzChannelEmoteFromCaches; -ConcurrentMap Emotes::twitchEmoteFromCache; -ConcurrentMap Emotes::miscImageFromCache; +ConcurrentMap Emotes::bttvEmotes; +ConcurrentMap Emotes::ffzEmotes; +ConcurrentMap Emotes::chatterinoEmotes; +ConcurrentMap + Emotes::bttvChannelEmoteFromCaches; +ConcurrentMap + Emotes::ffzChannelEmoteFromCaches; +ConcurrentMap Emotes::twitchEmoteFromCache; +ConcurrentMap 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(); } } +} diff --git a/emotes.h b/emotes.h index 1194cd3c..e4407a6b 100644 --- a/emotes.h +++ b/emotes.h @@ -2,12 +2,14 @@ #define EMOTES_H #include "concurrentmap.h" -#include "lazyloadedimage.h" +#include "messages/lazyloadedimage.h" #include "twitchemotevalue.h" #include #include +namespace chatterino { + class Emotes { public: @@ -17,43 +19,43 @@ public: return twitchEmotes; } - static ConcurrentMap & + static ConcurrentMap & getBttvEmotes() { return bttvEmotes; } - static ConcurrentMap & + static ConcurrentMap & getFfzEmotes() { return ffzEmotes; } - static ConcurrentMap & + static ConcurrentMap & getChatterinoEmotes() { return chatterinoEmotes; } - static ConcurrentMap & + static ConcurrentMap & getBttvChannelEmoteFromCaches() { return bttvChannelEmoteFromCaches; } - static ConcurrentMap & + static ConcurrentMap & getFfzChannelEmoteFromCaches() { return ffzChannelEmoteFromCaches; } - static ConcurrentMap & + static ConcurrentMap & getTwitchEmoteFromCache() { return twitchEmoteFromCache; } - static ConcurrentMap & + static ConcurrentMap & getMiscImageFromCache() { return miscImageFromCache; @@ -61,11 +63,12 @@ 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, - long int id); + static messages::LazyLoadedImage *getTwitchEmoteById(const QString &name, + long int id); static int getGeneration() @@ -85,17 +88,22 @@ private: static QString twitchEmoteTemplate; static ConcurrentMap twitchEmotes; - static ConcurrentMap bttvEmotes; - static ConcurrentMap ffzEmotes; - static ConcurrentMap chatterinoEmotes; - static ConcurrentMap bttvChannelEmoteFromCaches; - static ConcurrentMap ffzChannelEmoteFromCaches; - static ConcurrentMap twitchEmoteFromCache; - static ConcurrentMap miscImageFromCache; + static ConcurrentMap bttvEmotes; + static ConcurrentMap ffzEmotes; + static ConcurrentMap chatterinoEmotes; + static ConcurrentMap + bttvChannelEmoteFromCaches; + static ConcurrentMap + ffzChannelEmoteFromCaches; + static ConcurrentMap + twitchEmoteFromCache; + static ConcurrentMap + miscImageFromCache; static QString getTwitchEmoteLink(long id, qreal &scale); static int generation; }; +} #endif // EMOTES_H diff --git a/fonts.cpp b/fonts.cpp index 608006d2..4800890a 100644 --- a/fonts.cpp +++ b/fonts.cpp @@ -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; } +} diff --git a/fonts.h b/fonts.h index 7d93a420..3c55c522 100644 --- a/fonts.h +++ b/fonts.h @@ -4,6 +4,8 @@ #include #include +namespace chatterino { + class Fonts { public: @@ -50,5 +52,6 @@ private: static int generation; }; +} #endif // FONTS_H diff --git a/ircmanager.cpp b/ircmanager.cpp index ebe92a27..9cd4ed3d 100644 --- a/ircmanager.cpp +++ b/ircmanager.cpp @@ -12,6 +12,8 @@ #include #include +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 } } +} diff --git a/ircmanager.h b/ircmanager.h index 374c9fc8..b006435f 100644 --- a/ircmanager.h +++ b/ircmanager.h @@ -4,7 +4,7 @@ #define TWITCH_MAX_MESSAGELENGTH 500 #include "account.h" -#include "message.h" +#include "messages/message.h" #include #include @@ -12,6 +12,8 @@ #include #include +namespace chatterino { + class IrcManager { public: @@ -55,5 +57,6 @@ private: static void messageReceived(IrcMessage *message); static void privateMessageReceived(IrcPrivateMessage *message); }; +} #endif // IRCMANAGER_H diff --git a/lambdaqrunnable.cpp b/lambdaqrunnable.cpp deleted file mode 100644 index d3f08354..00000000 --- a/lambdaqrunnable.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "lambdaqrunnable.h" - -LambdaQRunnable::LambdaQRunnable(std::function action) -{ - this->action = action; -} - -void -LambdaQRunnable::run() -{ - this->action(); -} diff --git a/lambdaqrunnable.h b/lambdaqrunnable.h deleted file mode 100644 index 7d2255d3..00000000 --- a/lambdaqrunnable.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef LAMBDAQRUNNABLE_H -#define LAMBDAQRUNNABLE_H - -#include -#include - -class LambdaQRunnable : public QRunnable -{ -public: - LambdaQRunnable(std::function action); - - void run(); - -private: - std::function action; -}; - -#endif // LAMBDAQRUNNABLE_H diff --git a/main.cpp b/main.cpp index 957d30ac..74744f87 100644 --- a/main.cpp +++ b/main.cpp @@ -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 #include +using namespace chatterino; +using namespace chatterino::widgets; + int main(int argc, char *argv[]) { diff --git a/message.cpp.xT5964 b/message.cpp.xT5964 deleted file mode 100644 index 19102c10..00000000 --- a/message.cpp.xT5964 +++ /dev/null @@ -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(); - - // 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()); - } -} diff --git a/lazyloadedimage.cpp b/messages/lazyloadedimage.cpp similarity index 94% rename from lazyloadedimage.cpp rename to messages/lazyloadedimage.cpp index 8a53bd5c..468ec2b6 100644 --- a/lazyloadedimage.cpp +++ b/messages/lazyloadedimage.cpp @@ -1,4 +1,4 @@ -#include "lazyloadedimage.h" +#include "messages/lazyloadedimage.h" #include "asyncexec.h" #include "emotes.h" @@ -10,6 +10,9 @@ #include #include +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() }); //})); } +} +} diff --git a/lazyloadedimage.h b/messages/lazyloadedimage.h similarity index 97% rename from lazyloadedimage.h rename to messages/lazyloadedimage.h index 4740f662..9cde3686 100644 --- a/lazyloadedimage.h +++ b/messages/lazyloadedimage.h @@ -4,6 +4,9 @@ #include #include +namespace chatterino { +namespace messages { + class LazyLoadedImage { public: @@ -104,5 +107,7 @@ private: void loadImage(); }; +} +} #endif // LAZYLOADEDIMAGE_H diff --git a/link.cpp b/messages/link.cpp similarity index 65% rename from link.cpp rename to messages/link.cpp index 130b3c66..c41178cb 100644 --- a/link.cpp +++ b/messages/link.cpp @@ -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) { } +} +} diff --git a/link.h b/messages/link.h similarity index 92% rename from link.h rename to messages/link.h index c2489e1c..022e0e3a 100644 --- a/link.h +++ b/messages/link.h @@ -3,6 +3,9 @@ #include +namespace chatterino { +namespace messages { + class Link { public: @@ -42,5 +45,7 @@ private: Type type; QString value; }; +} +} #endif // LINK_H diff --git a/message.cpp b/messages/message.cpp similarity index 96% rename from message.cpp rename to messages/message.cpp index 654aeddb..2e7dc54f 100644 --- a/message.cpp +++ b/messages/message.cpp @@ -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 #include @@ -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(), - h * image.getScale() * - AppSettings::getEmoteScale()); + word.setSize(w * image.getScale() * + settings::Settings::getEmoteScale(), + h * image.getScale() * + 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(); } +} +} diff --git a/message.h b/messages/message.h similarity index 95% rename from message.h rename to messages/message.h index 6bd3a555..a9f954a1 100644 --- a/message.h +++ b/messages/message.h @@ -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 #include #include +namespace chatterino { +namespace messages { + class Message { public: @@ -129,5 +132,7 @@ private: const std::pair &a, const std::pair &b); }; +} +} #endif // MESSAGE_H diff --git a/word.cpp b/messages/word.cpp similarity index 90% rename from word.cpp rename to messages/word.cpp index 891a4c7d..32ecbd4d 100644 --- a/word.cpp +++ b/messages/word.cpp @@ -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 ©text, @@ -30,3 +33,5 @@ Word::Word(const QString &text, Type type, const QColor &color, , characterWidthCache() { } +} +} diff --git a/word.h b/messages/word.h similarity index 97% rename from word.h rename to messages/word.h index eeab9b76..68312a23 100644 --- a/word.h +++ b/messages/word.h @@ -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 #include #include +namespace chatterino { +namespace messages { + class Word { public: @@ -205,5 +208,7 @@ private: std::vector characterWidthCache; }; +} +} #endif // WORD_H diff --git a/wordpart.cpp b/messages/wordpart.cpp similarity index 87% rename from wordpart.cpp rename to messages/wordpart.cpp index f52f0f52..da8f4174 100644 --- a/wordpart.cpp +++ b/messages/wordpart.cpp @@ -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 ©Text, bool allowTrailingSpace) @@ -27,3 +30,5 @@ WordPart::WordPart(Word &word, int x, int y, int width, int height, , _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace) { } +} +} diff --git a/wordpart.h b/messages/wordpart.h similarity index 96% rename from wordpart.h rename to messages/wordpart.h index da0fa8ab..a0bda61d 100644 --- a/wordpart.h +++ b/messages/wordpart.h @@ -4,6 +4,9 @@ #include #include +namespace chatterino { +namespace messages { + class Word; class WordPart @@ -96,7 +99,7 @@ public: } private: - Word& m_word; + Word &m_word; QString copyText; QString text; @@ -108,5 +111,7 @@ private: bool _trailingSpace; }; +} +} #endif // WORDPART_H diff --git a/resources.cpp b/resources.cpp index e7991423..faaf0f27 100644 --- a/resources.cpp +++ b/resources.cpp @@ -2,23 +2,25 @@ #include -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); +} } diff --git a/resources.h b/resources.h index b861e91f..74bb1609 100644 --- a/resources.h +++ b/resources.h @@ -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 diff --git a/settings/realsetting.h b/settings/realsetting.h new file mode 100644 index 00000000..7750abde --- /dev/null +++ b/settings/realsetting.h @@ -0,0 +1,32 @@ +#ifndef REALSETTING_H +#define REALSETTING_H + +#include + +namespace chatterino { +namespace settings { + +class RealSetting : public Setting +{ +public: + RealSetting(const QString &name, qreal defaultValue, + qreal minValue = std::numeric_limits::min(), + qreal maxValue = std::numeric_limits::max()) + : Setting(name) + , value(defaultValue) + , defaultValue(defaultValue) + , minValue(minValue) + , maxValue(maxValue) + { + } + +private: + qreal value; + qreal defaultValue; + qreal minValue; + qreal maxValue; +}; +} +} + +#endif // REALSETTING_H diff --git a/settings/setting.h b/settings/setting.h new file mode 100644 index 00000000..44e1c84a --- /dev/null +++ b/settings/setting.h @@ -0,0 +1,30 @@ +#ifndef SETTING_H +#define SETTING_H + +#include + +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 diff --git a/settings/settings.cpp b/settings/settings.cpp new file mode 100644 index 00000000..79404e4e --- /dev/null +++ b/settings/settings.cpp @@ -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; +} +} +} diff --git a/appsettings.h b/settings/settings.h similarity index 70% rename from appsettings.h rename to settings/settings.h index e53fbf99..2d9f8da0 100644 --- a/appsettings.h +++ b/settings/settings.h @@ -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 diff --git a/twitchemotevalue.h b/twitchemotevalue.h index ff6b0641..9918b350 100644 --- a/twitchemotevalue.h +++ b/twitchemotevalue.h @@ -3,6 +3,8 @@ #include "QString" +namespace chatterino { + struct TwitchEmoteValue { public: int @@ -28,5 +30,6 @@ private: int id; QString channelName; }; +} #endif // TWITCHEMOTEVALUE_H diff --git a/chatwidget.cpp b/widgets/chatwidget.cpp similarity index 92% rename from chatwidget.cpp rename to widgets/chatwidget.cpp index 6250a7f0..9baa8133 100644 --- a/chatwidget.cpp +++ b/widgets/chatwidget.cpp @@ -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 #include #include #include +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); } +} +} diff --git a/chatwidget.h b/widgets/chatwidget.h similarity index 83% rename from chatwidget.h rename to widgets/chatwidget.h index 5f11d9eb..cf88ea30 100644 --- a/chatwidget.h +++ b/widgets/chatwidget.h @@ -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 #include #include +namespace chatterino { +namespace widgets { + class ChatWidget : public QWidget { Q_OBJECT @@ -53,5 +56,7 @@ private: ChatWidgetView view; ChatWidgetInput input; }; +} +} #endif // CHATWIDGET_H diff --git a/chatwidgetheader.cpp b/widgets/chatwidgetheader.cpp similarity index 96% rename from chatwidgetheader.cpp rename to widgets/chatwidgetheader.cpp index de24152e..29112136 100644 --- a/chatwidgetheader.cpp +++ b/widgets/chatwidgetheader.cpp @@ -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 #include #include #include +namespace chatterino { +namespace widgets { + ChatWidgetHeader::ChatWidgetHeader(ChatWidget *parent) : QWidget() , chatWidget(parent) @@ -65,8 +68,9 @@ 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()); this->rightLabel.getLabel().setTextFormat(Qt::RichText); @@ -208,3 +212,5 @@ void ChatWidgetHeader::menuShowChangelog() { } +} +} diff --git a/chatwidgetheader.h b/widgets/chatwidgetheader.h similarity index 90% rename from chatwidgetheader.h rename to widgets/chatwidgetheader.h index 2e7cd600..82162eb5 100644 --- a/chatwidgetheader.h +++ b/widgets/chatwidgetheader.h @@ -1,8 +1,8 @@ #ifndef CHATWIDGETHEADER_H #define CHATWIDGETHEADER_H -#include "chatwidgetheaderbutton.h" #include "signallabel.h" +#include "widgets/chatwidgetheaderbutton.h" #include #include @@ -13,6 +13,8 @@ #include #include +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 diff --git a/chatwidgetheaderbutton.cpp b/widgets/chatwidgetheaderbutton.cpp similarity index 95% rename from chatwidgetheaderbutton.cpp rename to widgets/chatwidgetheaderbutton.cpp index 651ebce9..14ebf41f 100644 --- a/chatwidgetheaderbutton.cpp +++ b/widgets/chatwidgetheaderbutton.cpp @@ -1,9 +1,12 @@ -#include "chatwidgetheaderbutton.h" +#include "widgets/chatwidgetheaderbutton.h" #include "colorscheme.h" #include #include +namespace chatterino { +namespace widgets { + ChatWidgetHeaderButton::ChatWidgetHeaderButton() : QWidget() , hbox() @@ -97,3 +100,5 @@ ChatWidgetHeaderButton::labelMouseDown() repaint(); } +} +} diff --git a/chatwidgetheaderbutton.h b/widgets/chatwidgetheaderbutton.h similarity index 89% rename from chatwidgetheaderbutton.h rename to widgets/chatwidgetheaderbutton.h index a9e2c75d..f8cd91dd 100644 --- a/chatwidgetheaderbutton.h +++ b/widgets/chatwidgetheaderbutton.h @@ -1,13 +1,16 @@ #ifndef CHATWIDGETHEADERBUTTON_H #define CHATWIDGETHEADERBUTTON_H -#include "chatwidgetheaderbuttonlabel.h" +#include "widgets/chatwidgetheaderbuttonlabel.h" #include #include #include #include +namespace chatterino { +namespace widgets { + class ChatWidgetHeaderButton : public QWidget { Q_OBJECT @@ -43,5 +46,7 @@ private: void labelMouseUp(); void labelMouseDown(); }; +} +} #endif // CHATWIDGETHEADERBUTTON_H diff --git a/chatwidgetheaderbuttonlabel.cpp b/widgets/chatwidgetheaderbuttonlabel.cpp similarity index 80% rename from chatwidgetheaderbuttonlabel.cpp rename to widgets/chatwidgetheaderbuttonlabel.cpp index 58da1688..0ccef371 100644 --- a/chatwidgetheaderbuttonlabel.cpp +++ b/widgets/chatwidgetheaderbuttonlabel.cpp @@ -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(); } } +} +} diff --git a/chatwidgetheaderbuttonlabel.h b/widgets/chatwidgetheaderbuttonlabel.h similarity index 89% rename from chatwidgetheaderbuttonlabel.h rename to widgets/chatwidgetheaderbuttonlabel.h index c053ea44..37f7420a 100644 --- a/chatwidgetheaderbuttonlabel.h +++ b/widgets/chatwidgetheaderbuttonlabel.h @@ -4,6 +4,9 @@ #include #include +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 diff --git a/chatwidgetinput.cpp b/widgets/chatwidgetinput.cpp similarity index 81% rename from chatwidgetinput.cpp rename to widgets/chatwidgetinput.cpp index a2ee5d0b..fcf9f328 100644 --- a/chatwidgetinput.cpp +++ b/widgets/chatwidgetinput.cpp @@ -1,8 +1,11 @@ -#include "chatwidgetinput.h" +#include "widgets/chatwidgetinput.h" #include "colorscheme.h" #include +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); } +} +} diff --git a/chatwidgetinput.h b/widgets/chatwidgetinput.h similarity index 84% rename from chatwidgetinput.h rename to widgets/chatwidgetinput.h index fcc31bf2..2bd744b9 100644 --- a/chatwidgetinput.h +++ b/widgets/chatwidgetinput.h @@ -4,6 +4,9 @@ #include #include +namespace chatterino { +namespace widgets { + class ChatWidgetInput : public QWidget { Q_OBJECT @@ -14,5 +17,7 @@ public: protected: void paintEvent(QPaintEvent *); }; +} +} #endif // CHATWIDGETINPUT_H diff --git a/chatwidgetview.cpp b/widgets/chatwidgetview.cpp similarity index 94% rename from chatwidgetview.cpp rename to widgets/chatwidgetview.cpp index 657d20eb..f462efa7 100644 --- a/chatwidgetview.cpp +++ b/widgets/chatwidgetview.cpp @@ -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 #include #include #include +namespace chatterino { +namespace widgets { + ChatWidgetView::ChatWidgetView(ChatWidget *parent) : QWidget() , chatWidget(parent) @@ -146,3 +149,5 @@ ChatWidgetView::paintEvent(QPaintEvent *) y += message->getHeight(); } } +} +} diff --git a/chatwidgetview.h b/widgets/chatwidgetview.h similarity index 75% rename from chatwidgetview.h rename to widgets/chatwidgetview.h index b597807a..108d6a6f 100644 --- a/chatwidgetview.h +++ b/widgets/chatwidgetview.h @@ -2,11 +2,13 @@ #define CHATVIEW_H #include "channel.h" -#include "scrollbar.h" +#include "widgets/scrollbar.h" #include #include +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 diff --git a/mainwindow.cpp b/widgets/mainwindow.cpp similarity index 91% rename from mainwindow.cpp rename to widgets/mainwindow.cpp index 2524f1fa..8b205fef 100644 --- a/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -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 +namespace chatterino { +namespace widgets { + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , notebook(this) @@ -69,3 +72,5 @@ MainWindow::repaintVisibleChatWidgets(Channel *channel) } } } +} +} diff --git a/mainwindow.h b/widgets/mainwindow.h similarity index 82% rename from mainwindow.h rename to widgets/mainwindow.h index b49d1372..33b12528 100644 --- a/mainwindow.h +++ b/widgets/mainwindow.h @@ -1,10 +1,13 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include "notebook.h" +#include "widgets/notebook.h" #include +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 diff --git a/notebook.cpp b/widgets/notebook.cpp similarity index 90% rename from notebook.cpp rename to widgets/notebook.cpp index 0624f0a3..88a3501f 100644 --- a/notebook.cpp +++ b/widgets/notebook.cpp @@ -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 #include #include #include +namespace chatterino { +namespace widgets { + Notebook::Notebook(QWidget *parent) : QWidget(parent) , addButton(this) @@ -109,3 +111,5 @@ Notebook::resizeEvent(QResizeEvent *) { performLayout(); } +} +} diff --git a/notebook.h b/widgets/notebook.h similarity index 83% rename from notebook.h rename to widgets/notebook.h index 525b8009..bed32a1e 100644 --- a/notebook.h +++ b/widgets/notebook.h @@ -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 #include +namespace chatterino { +namespace widgets { + class Notebook : public QWidget { Q_OBJECT @@ -46,5 +49,7 @@ private: NotebookPage *selectedPage = nullptr; }; +} +} #endif // NOTEBOOK_H diff --git a/notebookbutton.cpp b/widgets/notebookbutton.cpp similarity index 97% rename from notebookbutton.cpp rename to widgets/notebookbutton.cpp index 823496a1..27f5d966 100644 --- a/notebookbutton.cpp +++ b/widgets/notebookbutton.cpp @@ -1,10 +1,13 @@ -#include "notebookbutton.h" +#include "widgets/notebookbutton.h" #include "colorscheme.h" #include #include #include +namespace chatterino { +namespace widgets { + NotebookButton::NotebookButton(QWidget *parent) : QWidget(parent) { @@ -121,3 +124,5 @@ NotebookButton::leaveEvent(QEvent *) this->repaint(); } +} +} diff --git a/notebookbutton.h b/widgets/notebookbutton.h similarity index 93% rename from notebookbutton.h rename to widgets/notebookbutton.h index 2c9435bf..24183b14 100644 --- a/notebookbutton.h +++ b/widgets/notebookbutton.h @@ -3,6 +3,9 @@ #include +namespace chatterino { +namespace widgets { + class NotebookButton : public QWidget { Q_OBJECT @@ -28,5 +31,7 @@ private: bool mouseOver = false; bool mouseDown = false; }; +} +} #endif // NOTEBOOKBUTTON_H diff --git a/notebookpage.cpp b/widgets/notebookpage.cpp similarity index 97% rename from notebookpage.cpp rename to widgets/notebookpage.cpp index 52f0b6cf..4c3199f1 100644 --- a/notebookpage.cpp +++ b/widgets/notebookpage.cpp @@ -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 #include @@ -9,6 +9,9 @@ #include #include +namespace chatterino { +namespace widgets { + bool NotebookPage::isDraggingSplit = false; ChatWidget *NotebookPage::draggingSplit = NULL; std::pair NotebookPage::dropPosition = std::pair(-1, -1); @@ -233,3 +236,5 @@ NotebookPage::paintEvent(QPaintEvent *) ColorScheme::instance().TabSelectedBackground); } } +} +} diff --git a/notebookpage.h b/widgets/notebookpage.h similarity index 89% rename from notebookpage.h rename to widgets/notebookpage.h index 61ae564a..d13b7828 100644 --- a/notebookpage.h +++ b/widgets/notebookpage.h @@ -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 #include @@ -13,6 +13,9 @@ #include #include +namespace chatterino { +namespace widgets { + class NotebookPage : public QWidget { Q_OBJECT @@ -68,5 +71,7 @@ protected: private: void setPreviewRect(QPoint mousePos); }; +} +} #endif // NOTEBOOKPAGE_H diff --git a/notebookpagedroppreview.cpp b/widgets/notebookpagedroppreview.cpp similarity index 89% rename from notebookpagedroppreview.cpp rename to widgets/notebookpagedroppreview.cpp index 30bdd1fb..18143fe1 100644 --- a/notebookpagedroppreview.cpp +++ b/widgets/notebookpagedroppreview.cpp @@ -1,8 +1,11 @@ -#include "notebookpagedroppreview.h" +#include "widgets/notebookpagedroppreview.h" #include "colorscheme.h" #include +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; } +} +} diff --git a/notebookpagedroppreview.h b/widgets/notebookpagedroppreview.h similarity index 89% rename from notebookpagedroppreview.h rename to widgets/notebookpagedroppreview.h index ee1cd8b0..db6d3772 100644 --- a/notebookpagedroppreview.h +++ b/widgets/notebookpagedroppreview.h @@ -4,6 +4,9 @@ #include #include +namespace chatterino { +namespace widgets { + class NotebookPageDropPreview : public QWidget { public: @@ -17,5 +20,7 @@ protected: QPropertyAnimation positionAnimation; QRect desiredGeometry; }; +} +} #endif // NOTEBOOKPAGEDROPPREVIEW_H diff --git a/notebooktab.cpp b/widgets/notebooktab.cpp similarity index 94% rename from notebooktab.cpp rename to widgets/notebooktab.cpp index 11307d19..4bdc0495 100644 --- a/notebooktab.cpp +++ b/widgets/notebooktab.cpp @@ -1,9 +1,12 @@ -#include "notebooktab.h" +#include "widgets/notebooktab.h" #include "colorscheme.h" -#include "notebook.h" +#include "widgets/notebook.h" #include +namespace chatterino { +namespace widgets { + NotebookTab::NotebookTab(Notebook *notebook) : QWidget(notebook) , notebook(notebook) @@ -93,3 +96,5 @@ NotebookTab::dragEnterEvent(QDragEnterEvent *event) { this->notebook->select(page); } +} +} diff --git a/notebooktab.h b/widgets/notebooktab.h similarity index 96% rename from notebooktab.h rename to widgets/notebooktab.h index cbb0bd8f..127f2d4f 100644 --- a/notebooktab.h +++ b/widgets/notebooktab.h @@ -3,6 +3,9 @@ #include +namespace chatterino { +namespace widgets { + class Notebook; class NotebookPage; @@ -81,5 +84,7 @@ private: bool mouseDown; HighlightStyle highlightStyle; }; +} +} #endif // NOTEBOOKTAB_H diff --git a/scrollbar.cpp b/widgets/scrollbar.cpp similarity index 96% rename from scrollbar.cpp rename to widgets/scrollbar.cpp index 6285de1b..70929659 100644 --- a/scrollbar.cpp +++ b/widgets/scrollbar.cpp @@ -1,10 +1,13 @@ -#include "scrollbar.h" +#include "widgets/scrollbar.h" #include "colorscheme.h" #include #define MIN_THUMB_HEIGHT 10 +namespace chatterino { +namespace widgets { + ScrollBar::ScrollBar(QWidget *widget) : QWidget(widget) , mutex() @@ -112,3 +115,5 @@ ScrollBar::updateScroll() repaint(); } +} +} diff --git a/scrollbar.h b/widgets/scrollbar.h similarity index 94% rename from scrollbar.h rename to widgets/scrollbar.h index 7071370a..93f025c0 100644 --- a/scrollbar.h +++ b/widgets/scrollbar.h @@ -1,12 +1,15 @@ #ifndef SCROLLBAR_H #define SCROLLBAR_H -#include "scrollbarhighlight.h" +#include "widgets/scrollbarhighlight.h" #include #include #include +namespace chatterino { +namespace widgets { + class ScrollBar : public QWidget { Q_OBJECT @@ -106,5 +109,7 @@ private: void updateScroll(); }; +} +} #endif // SCROLLBAR_H diff --git a/scrollbarhighlight.cpp b/widgets/scrollbarhighlight.cpp similarity index 79% rename from scrollbarhighlight.cpp rename to widgets/scrollbarhighlight.cpp index 44bcfa1f..aab57566 100644 --- a/scrollbarhighlight.cpp +++ b/widgets/scrollbarhighlight.cpp @@ -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) { } +} +} diff --git a/scrollbarhighlight.h b/widgets/scrollbarhighlight.h similarity index 93% rename from scrollbarhighlight.h rename to widgets/scrollbarhighlight.h index b9136bfb..7d058a2a 100644 --- a/scrollbarhighlight.h +++ b/widgets/scrollbarhighlight.h @@ -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 diff --git a/settingsdialog.cpp b/widgets/settingsdialog.cpp similarity index 97% rename from settingsdialog.cpp rename to widgets/settingsdialog.cpp index 5eeeb94a..2e75fa50 100644 --- a/settingsdialog.cpp +++ b/widgets/settingsdialog.cpp @@ -1,5 +1,5 @@ -#include "settingsdialog.h" -#include "settingsdialogtab.h" +#include "widgets/settingsdialog.h" +#include "widgets/settingsdialogtab.h" #include #include @@ -9,6 +9,9 @@ #include #include +namespace chatterino { +namespace widgets { + SettingsDialog::SettingsDialog() { QFile file(":/qss/settings.qss"); @@ -172,3 +175,5 @@ SettingsDialog::select(SettingsDialogTab *tab) "border-right: none;"); selectedTab = tab; } +} +} diff --git a/settingsdialog.h b/widgets/settingsdialog.h similarity index 90% rename from settingsdialog.h rename to widgets/settingsdialog.h index b9af5db4..79d709b4 100644 --- a/settingsdialog.h +++ b/widgets/settingsdialog.h @@ -1,7 +1,7 @@ #ifndef SETTINGSDIALOG_H #define SETTINGSDIALOG_H -#include "settingsdialogtab.h" +#include "widgets/settingsdialogtab.h" #include #include @@ -14,6 +14,9 @@ #include #include +namespace chatterino { +namespace widgets { + class SettingsDialog : public QWidget { public: @@ -38,5 +41,7 @@ private: QCheckBox *createCheckbox(QString title, QString settingsId); }; +} +} #endif // SETTINGSDIALOG_H diff --git a/settingsdialogtab.cpp b/widgets/settingsdialogtab.cpp similarity index 84% rename from settingsdialogtab.cpp rename to widgets/settingsdialogtab.cpp index 7f0868c1..aaac172a 100644 --- a/settingsdialogtab.cpp +++ b/widgets/settingsdialogtab.cpp @@ -1,7 +1,11 @@ -#include "settingsdialogtab.h" -#include "QPainter" -#include "QStyleOption" -#include "settingsdialog.h" +#include "widgets/settingsdialogtab.h" +#include "widgets/settingsdialog.h" + +#include +#include + +namespace chatterino { +namespace widgets { SettingsDialogTab::SettingsDialogTab(SettingsDialog *dialog, QString label, QString imageRes) @@ -43,3 +47,5 @@ SettingsDialogTab::mouseReleaseEvent(QMouseEvent *event) dialog->select(this); } +} +} diff --git a/settingsdialogtab.h b/widgets/settingsdialogtab.h similarity index 95% rename from settingsdialogtab.h rename to widgets/settingsdialogtab.h index 3e6f46bf..f6a6ad8d 100644 --- a/settingsdialogtab.h +++ b/widgets/settingsdialogtab.h @@ -4,6 +4,9 @@ #include #include +namespace chatterino { +namespace widgets { + class SettingsDialog; class SettingsDialogTab : public QWidget @@ -58,5 +61,7 @@ private: bool selected = false; }; +} +} #endif // SETTINGSNOTEBOOKTAB_H diff --git a/signallabel.h b/widgets/signallabel.h similarity index 100% rename from signallabel.h rename to widgets/signallabel.h diff --git a/textinputdialog.cpp b/widgets/textinputdialog.cpp similarity index 92% rename from textinputdialog.cpp rename to widgets/textinputdialog.cpp index 5bed48e2..68092b7a 100644 --- a/textinputdialog.cpp +++ b/widgets/textinputdialog.cpp @@ -1,6 +1,9 @@ -#include "textinputdialog.h" +#include "widgets/textinputdialog.h" #include +namespace chatterino { +namespace widgets { + TextInputDialog::TextInputDialog(QWidget *parent) : QDialog(parent) , vbox(this) @@ -39,3 +42,5 @@ TextInputDialog::cancelButtonClicked() reject(); close(); } +} +} diff --git a/textinputdialog.h b/widgets/textinputdialog.h similarity index 93% rename from textinputdialog.h rename to widgets/textinputdialog.h index bc0e3b59..6f8f5544 100644 --- a/textinputdialog.h +++ b/widgets/textinputdialog.h @@ -8,6 +8,9 @@ #include #include +namespace chatterino { +namespace widgets { + class TextInputDialog : public QDialog { Q_OBJECT @@ -38,5 +41,7 @@ private slots: void okButtonClicked(); void cancelButtonClicked(); }; +} +} #endif // TEXTINPUTDIALOG_H diff --git a/windows.cpp b/windows.cpp index 2fcbe9f2..4042fbdb 100644 --- a/windows.cpp +++ b/windows.cpp @@ -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); } +} diff --git a/windows.h b/windows.h index 88ba2078..b832a5f5 100644 --- a/windows.h +++ b/windows.h @@ -1,10 +1,14 @@ #ifndef WINDOWS_H #define WINDOWS_H -#include "mainwindow.h" +#include "widgets/mainwindow.h" #include +using namespace chatterino::widgets; + +namespace chatterino { + class Windows { public: @@ -32,5 +36,6 @@ private: static MainWindow *mainWindow; }; +} #endif // WINDOWS_H