added brace wrapping after if and for

This commit is contained in:
fourtf
2018-10-21 13:43:02 +02:00
parent c6e1ec3c71
commit e259b9e39f
138 changed files with 4738 additions and 2237 deletions
+10 -5
View File
@@ -35,7 +35,8 @@ void Fonts::initialize(Settings &, Paths &)
this->chatFontFamily.connect([this](const std::string &, auto) {
assertInGuiThread();
for (auto &map : this->fontsByType_) {
for (auto &map : this->fontsByType_)
{
map.clear();
}
this->fontChanged.invoke();
@@ -44,7 +45,8 @@ void Fonts::initialize(Settings &, Paths &)
this->chatFontSize.connect([this](const int &, auto) {
assertInGuiThread();
for (auto &map : this->fontsByType_) {
for (auto &map : this->fontsByType_)
{
map.clear();
}
this->fontChanged.invoke();
@@ -55,7 +57,8 @@ void Fonts::initialize(Settings &, Paths &)
getApp()->windows->incGeneration();
for (auto &map : this->fontsByType_) {
for (auto &map : this->fontsByType_)
{
map.clear();
}
this->fontChanged.invoke();
@@ -82,7 +85,8 @@ Fonts::FontData &Fonts::getOrCreateFontData(FontStyle type, float scale)
// find element
auto it = map.find(scale);
if (it != map.end()) {
if (it != map.end())
{
// return if found
return it->second;
@@ -98,7 +102,8 @@ Fonts::FontData &Fonts::getOrCreateFontData(FontStyle type, float scale)
Fonts::FontData Fonts::createFontData(FontStyle type, float scale)
{
// check if it's a chat (scale the setting)
if (type >= FontStyle::ChatStart && type <= FontStyle::ChatEnd) {
if (type >= FontStyle::ChatStart && type <= FontStyle::ChatEnd)
{
static std::unordered_map<FontStyle, ChatFontData> sizeScale{
{FontStyle::ChatSmall, {0.6f, false, QFont::Normal}},
{FontStyle::ChatMediumSmall, {0.8f, false, QFont::Normal}},
+7 -3
View File
@@ -18,17 +18,21 @@ void Logging::initialize(Settings &settings, Paths &paths)
void Logging::addMessage(const QString &channelName, MessagePtr message)
{
if (!getSettings()->enableLogging) {
if (!getSettings()->enableLogging)
{
return;
}
auto it = this->loggingChannels_.find(channelName);
if (it == this->loggingChannels_.end()) {
if (it == this->loggingChannels_.end())
{
auto channel = new LoggingChannel(channelName);
channel->addMessage(message);
this->loggingChannels_.emplace(
channelName, std::unique_ptr<LoggingChannel>(std::move(channel)));
} else {
}
else
{
it->second->addMessage(message);
}
}
+39 -18
View File
@@ -37,7 +37,8 @@ void registerNmManifest(Paths &paths, const QString &manifestFilename,
void registerNmHost(Paths &paths)
{
if (paths.isPortable()) return;
if (paths.isPortable())
return;
auto getBaseDocument = [&] {
QJsonObject obj;
@@ -112,11 +113,14 @@ std::string &getNmQueueName(Paths &paths)
void NativeMessagingClient::sendMessage(const QByteArray &array)
{
try {
try
{
ipc::message_queue messageQueue(ipc::open_only, "chatterino_gui");
messageQueue.try_send(array.data(), array.size(), 1);
} catch (ipc::interprocess_exception &ex) {
}
catch (ipc::interprocess_exception &ex)
{
qDebug() << "send to gui process:" << ex.what();
}
}
@@ -144,8 +148,10 @@ void NativeMessagingServer::ReceiverThread::run()
ipc::message_queue messageQueue(ipc::open_or_create, "chatterino_gui", 100,
MESSAGE_SIZE);
while (true) {
try {
while (true)
{
try
{
auto buf = std::make_unique<char[]>(MESSAGE_SIZE);
auto retSize = ipc::message_queue::size_type();
auto priority = static_cast<unsigned int>(0);
@@ -156,7 +162,9 @@ void NativeMessagingServer::ReceiverThread::run()
QByteArray::fromRawData(buf.get(), retSize));
this->handleMessage(document.object());
} catch (ipc::interprocess_exception &ex) {
}
catch (ipc::interprocess_exception &ex)
{
qDebug() << "received from gui process:" << ex.what();
}
}
@@ -169,12 +177,14 @@ void NativeMessagingServer::ReceiverThread::handleMessage(
QString action = root.value("action").toString();
if (action.isNull()) {
if (action.isNull())
{
qDebug() << "NM action was null";
return;
}
if (action == "select") {
if (action == "select")
{
QString _type = root.value("type").toString();
bool attach = root.value("attach").toBool();
QString name = root.value("name").toString();
@@ -188,26 +198,31 @@ void NativeMessagingServer::ReceiverThread::handleMessage(
args.width = root.value("size").toObject().value("width").toInt(-1);
args.height = root.value("size").toObject().value("height").toInt(-1);
if (_type.isNull() || args.winId.isNull()) {
if (_type.isNull() || args.winId.isNull())
{
qDebug() << "NM type, name or winId missing";
attach = false;
return;
}
#endif
if (_type == "twitch") {
if (_type == "twitch")
{
postToThread([=] {
if (!name.isEmpty()) {
if (!name.isEmpty())
{
app->twitch.server->watchingChannel.reset(
app->twitch.server->getOrAddChannel(name));
}
if (attach) {
if (attach)
{
#ifdef USEWINSDK
// if (args.height != -1) {
auto *window =
AttachedWindow::get(::GetForegroundWindow(), args);
if (!name.isEmpty()) {
if (!name.isEmpty())
{
window->setChannel(
app->twitch.server->getOrAddChannel(name));
}
@@ -216,14 +231,18 @@ void NativeMessagingServer::ReceiverThread::handleMessage(
#endif
}
});
} else {
}
else
{
qDebug() << "NM unknown channel type";
}
} else if (action == "detach") {
}
else if (action == "detach")
{
QString winId = root.value("winId").toString();
if (winId.isNull()) {
if (winId.isNull())
{
qDebug() << "NM winId missing";
return;
}
@@ -234,7 +253,9 @@ void NativeMessagingServer::ReceiverThread::handleMessage(
AttachedWindow::detach(winId);
});
#endif
} else {
}
else
{
qDebug() << "NM unknown action " + action;
}
}
+8 -4
View File
@@ -49,7 +49,8 @@ QString Paths::cacheDirectory()
auto path = cachePathSetting.getValue();
if (path == "") {
if (path == "")
{
return this->cacheDirectory_;
}
@@ -83,14 +84,16 @@ void Paths::initAppDataDirectory()
this->rootAppDataDirectory = [&]() -> QString {
// portable
if (this->isPortable()) {
if (this->isPortable())
{
return QCoreApplication::applicationDirPath();
}
// permanent installation
QString path =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
if (path.isEmpty()) {
if (path.isEmpty())
{
throw std::runtime_error(
"Error finding writable location for settings");
}
@@ -117,7 +120,8 @@ void Paths::initSubDirectories()
auto path = combinePath(this->rootAppDataDirectory,
QString::fromStdString(name));
if (!QDir().mkpath(path)) {
if (!QDir().mkpath(path))
{
throw std::runtime_error(
"Error creating appdata path %appdata%/chatterino/" + name);
}
+12 -6
View File
@@ -37,9 +37,11 @@ void Settings::saveSnapshot()
rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType);
rapidjson::Document::AllocatorType &a = d->GetAllocator();
for (const auto &weakSetting : _settings) {
for (const auto &weakSetting : _settings)
{
auto setting = weakSetting.lock();
if (!setting) {
if (!setting)
{
continue;
}
@@ -55,22 +57,26 @@ void Settings::saveSnapshot()
void Settings::restoreSnapshot()
{
if (!this->snapshot_) {
if (!this->snapshot_)
{
return;
}
const auto &snapshotObject = this->snapshot_->GetObject();
for (const auto &weakSetting : _settings) {
for (const auto &weakSetting : _settings)
{
auto setting = weakSetting.lock();
if (!setting) {
if (!setting)
{
log("Error stage 1 of loading");
continue;
}
const char *path = setting->getPath().c_str();
if (!snapshotObject.HasMember(path)) {
if (!snapshotObject.HasMember(path))
{
log("Error stage 2 of loading");
continue;
}
+39 -16
View File
@@ -12,13 +12,20 @@ namespace detail {
double getMultiplierByTheme(const QString &themeName)
{
if (themeName == "Light") {
if (themeName == "Light")
{
return 0.8;
} else if (themeName == "White") {
}
else if (themeName == "White")
{
return 1.0;
} else if (themeName == "Black") {
}
else if (themeName == "Black")
{
return -1.0;
} else if (themeName == "Dark") {
}
else if (themeName == "Dark")
{
return -0.8;
}
@@ -88,7 +95,8 @@ void Theme::actuallyUpdate(double hue, double multiplier)
QColor highlighted = lightWin ? QColor("#ff0000") : QColor("#ee6166");
/// TABS
if (lightWin) {
if (lightWin)
{
this->tabs.regular = {
QColor("#444"),
{QColor("#fff"), QColor("#eee"), QColor("#fff")},
@@ -105,7 +113,9 @@ void Theme::actuallyUpdate(double hue, double multiplier)
QColor("#000"),
{QColor("#b4d7ff"), QColor("#b4d7ff"), QColor("#b4d7ff")},
{QColor("#00aeef"), QColor("#00aeef"), QColor("#00aeef")}};
} else {
}
else
{
this->tabs.regular = {
QColor("#aaa"),
{QColor("#252525"), QColor("#252525"), QColor("#252525")},
@@ -161,13 +171,16 @@ void Theme::actuallyUpdate(double hue, double multiplier)
this->splits.dropPreview = QColor(0, 148, 255, 0x30);
this->splits.dropPreviewBorder = QColor(0, 148, 255, 0xff);
if (isLight_) {
if (isLight_)
{
this->splits.dropTargetRect = QColor(255, 255, 255, 0x00);
this->splits.dropTargetRectBorder = QColor(0, 148, 255, 0x00);
this->splits.resizeHandle = QColor(0, 148, 255, 0xff);
this->splits.resizeHandleBackground = QColor(0, 148, 255, 0x50);
} else {
}
else
{
this->splits.dropTargetRect = QColor(0, 148, 255, 0x00);
this->splits.dropTargetRectBorder = QColor(0, 148, 255, 0x00);
@@ -200,10 +213,13 @@ void Theme::actuallyUpdate(double hue, double multiplier)
this->messages.backgrounds.regular = splits.background;
this->messages.backgrounds.alternate = getColor(0, sat, 0.93);
if (isLight_) {
if (isLight_)
{
this->messages.backgrounds.highlighted =
blendColors(themeColor, this->messages.backgrounds.regular, 0.8);
} else {
}
else
{
this->messages.backgrounds.highlighted =
QColor(getSettings()->highlightColor);
}
@@ -247,25 +263,32 @@ QColor Theme::blendColors(const QColor &color1, const QColor &color2,
void Theme::normalizeColor(QColor &color)
{
if (this->isLight_) {
if (color.lightnessF() > 0.5) {
if (this->isLight_)
{
if (color.lightnessF() > 0.5)
{
color.setHslF(color.hueF(), color.saturationF(), 0.5);
}
if (color.lightnessF() > 0.4 && color.hueF() > 0.1 &&
color.hueF() < 0.33333) {
color.hueF() < 0.33333)
{
color.setHslF(color.hueF(), color.saturationF(),
color.lightnessF() - sin((color.hueF() - 0.1) /
(0.3333 - 0.1) * 3.14159) *
color.saturationF() * 0.4);
}
} else {
if (color.lightnessF() < 0.5) {
}
else
{
if (color.lightnessF() < 0.5)
{
color.setHslF(color.hueF(), color.saturationF(), 0.5);
}
if (color.lightnessF() < 0.6 && color.hueF() > 0.54444 &&
color.hueF() < 0.83333) {
color.hueF() < 0.83333)
{
color.setHslF(
color.hueF(), color.saturationF(),
color.lightnessF() + sin((color.hueF() - 0.54444) /
+21 -10
View File
@@ -45,12 +45,16 @@ void Toasts::sendChannelNotification(const QString &channelName, Platform p)
};
#endif
// Fetch user profile avatar
if (p == Platform::Twitch) {
if (p == Platform::Twitch)
{
QFileInfo check_file(getPaths()->twitchProfileAvatars + "/twitch/" +
channelName + ".png");
if (check_file.exists() && check_file.isFile()) {
if (check_file.exists() && check_file.isFile())
{
sendChannelNotification();
} else {
}
else
{
this->fetchChannelAvatar(
channelName,
[channelName, sendChannelNotification](QString avatarLink) {
@@ -81,7 +85,8 @@ public:
void toastActivated() const
{
QString link;
if (platform_ == Platform::Twitch) {
if (platform_ == Platform::Twitch)
{
link = "http://www.twitch.tv/" + channelName_;
}
QDesktopServices::openUrl(QUrl(link));
@@ -112,14 +117,16 @@ void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
templ.setTextField(L"Click here to open in browser",
WinToastLib::WinToastTemplate::SecondLine);
QString Path;
if (p == Platform::Twitch) {
if (p == Platform::Twitch)
{
Path = getPaths()->twitchProfileAvatars + "/twitch/" + channelName +
".png";
}
std::string temp_Utf8 = Path.toUtf8().constData();
std::wstring imagePath = std::wstring(temp_Utf8.begin(), temp_Utf8.end());
templ.setImagePath(imagePath);
if (getSettings()->notificationPlaySound) {
if (getSettings()->notificationPlaySound)
{
templ.setAudioOption(
WinToastLib::WinToastTemplate::AudioOption::Silent);
}
@@ -151,19 +158,22 @@ void Toasts::fetchChannelAvatar(const QString channelName,
request.setTimeout(30000);
request.onSuccess([successCallback](auto result) mutable -> Outcome {
auto root = result.parseJson();
if (!root.value("users").isArray()) {
if (!root.value("users").isArray())
{
// log("API Error while getting user id, users is not an array");
successCallback("");
return Failure;
}
auto users = root.value("users").toArray();
if (users.size() != 1) {
if (users.size() != 1)
{
// log("API Error while getting user id, users array size is not
// 1");
successCallback("");
return Failure;
}
if (!users[0].isObject()) {
if (!users[0].isObject())
{
// log("API Error while getting user id, first user is not an
// object");
successCallback("");
@@ -171,7 +181,8 @@ void Toasts::fetchChannelAvatar(const QString channelName,
}
auto firstUser = users[0].toObject();
auto avatar = firstUser.value("logo");
if (!avatar.isString()) {
if (!avatar.isString())
{
// log("API Error: while getting user avatar, first user object "
// "`avatar` key "
// "is not a "
+19 -9
View File
@@ -39,7 +39,8 @@ const QString &Updates::getOnlineVersion() const
void Updates::installUpdates()
{
if (this->status_ != UpdateAvailable) {
if (this->status_ != UpdateAvailable)
{
assert(false);
return;
}
@@ -77,7 +78,8 @@ void Updates::installUpdates()
QFile file(filename);
file.open(QIODevice::Truncate | QIODevice::WriteOnly);
if (file.write(object) == -1) {
if (file.write(object) == -1)
{
this->setStatus_(WriteFileFailed);
return Failure;
}
@@ -109,7 +111,8 @@ void Updates::checkForUpdates()
QJsonValue version_val = object.value("version");
QJsonValue update_val = object.value("update");
if (!version_val.isString() || !update_val.isString()) {
if (!version_val.isString() || !update_val.isString())
{
this->setStatus_(SearchFailed);
qDebug() << "error updating";
@@ -129,7 +132,8 @@ void Updates::checkForUpdates()
this->onlineVersion_ = version_val.toString();
this->updateUrl_ = update_val.toString();
if (this->currentVersion_ != this->onlineVersion_) {
if (this->currentVersion_ != this->onlineVersion_)
{
this->setStatus_(UpdateAvailable);
postToThread([this] {
QMessageBox *box = new QMessageBox(
@@ -140,11 +144,14 @@ void Updates::checkForUpdates()
box->setAttribute(Qt::WA_DeleteOnClose);
box->show();
box->raise();
if (box->exec() == QMessageBox::Yes) {
if (box->exec() == QMessageBox::Yes)
{
this->installUpdates();
}
});
} else {
}
else
{
this->setStatus_(NoUpdateAvailable);
}
return Failure;
@@ -161,7 +168,8 @@ Updates::Status Updates::getStatus() const
bool Updates::shouldShowUpdateButton() const
{
switch (this->getStatus()) {
switch (this->getStatus())
{
case UpdateAvailable:
case SearchFailed:
case Downloading:
@@ -176,7 +184,8 @@ bool Updates::shouldShowUpdateButton() const
bool Updates::isError() const
{
switch (this->getStatus()) {
switch (this->getStatus())
{
case SearchFailed:
case DownloadFailed:
case WriteFileFailed:
@@ -189,7 +198,8 @@ bool Updates::isError() const
void Updates::setStatus_(Status status)
{
if (this->status_ != status) {
if (this->status_ != status)
{
this->status_ = status;
postToThread([this, status] { this->statusUpdated.invoke(status); });
}
+95 -46
View File
@@ -45,7 +45,8 @@ void WindowManager::showAccountSelectPopup(QPoint point)
// static QWidget *lastFocusedWidget = nullptr;
static AccountSwitchPopupWidget *w = new AccountSwitchPopupWidget();
if (w->hasFocus()) {
if (w->hasFocus())
{
w->hide();
// if (lastFocusedWidget) {
// lastFocusedWidget->setFocus();
@@ -109,7 +110,8 @@ void WindowManager::updateWordTypeMask()
auto flags = MessageElementFlags(MEF::Text);
// timestamp
if (settings->showTimestamps) {
if (settings->showTimestamps)
{
flags.set(MEF::Timestamp);
}
@@ -152,7 +154,8 @@ void WindowManager::updateWordTypeMask()
// update flags
MessageElementFlags newFlags = static_cast<MessageElementFlags>(flags);
if (newFlags != this->wordFlags_) {
if (newFlags != this->wordFlags_)
{
this->wordFlags_ = newFlags;
this->wordFlagsChanged.invoke();
@@ -172,7 +175,8 @@ void WindowManager::forceLayoutChannelViews()
void WindowManager::repaintVisibleChatWidgets(Channel *channel)
{
if (this->mainWindow_ != nullptr) {
if (this->mainWindow_ != nullptr)
{
this->mainWindow_->repaintVisibleChatWidgets(channel);
}
}
@@ -211,13 +215,16 @@ Window &WindowManager::createWindow(WindowType type)
this->windows_.push_back(window);
window->show();
if (type != WindowType::Main) {
if (type != WindowType::Main)
{
window->setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(window, &QWidget::destroyed, [this, window] {
for (auto it = this->windows_.begin(); it != this->windows_.end();
it++) {
if (*it == window) {
it++)
{
if (*it == window)
{
this->windows_.erase(it);
break;
}
@@ -237,7 +244,8 @@ Window *WindowManager::windowAt(int index)
{
assertInGuiThread();
if (index < 0 || (size_t)index >= this->windows_.size()) {
if (index < 0 || (size_t)index >= this->windows_.size())
{
return nullptr;
}
log("getting window at bad index {}", index);
@@ -263,7 +271,8 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
QJsonArray windows_arr = document.object().value("windows").toArray();
// "deserialize"
for (QJsonValue window_val : windows_arr) {
for (QJsonValue window_val : windows_arr)
{
QJsonObject window_obj = window_val.toObject();
// get type
@@ -271,13 +280,15 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
WindowType type =
type_val == "main" ? WindowType::Main : WindowType::Popup;
if (type == WindowType::Main && mainWindow_ != nullptr) {
if (type == WindowType::Main && mainWindow_ != nullptr)
{
type = WindowType::Popup;
}
Window &window = createWindow(type);
if (type == WindowType::Main) {
if (type == WindowType::Main)
{
mainWindow_ = &window;
}
@@ -288,7 +299,8 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
int width = window_obj.value("width").toInt(-1);
int height = window_obj.value("height").toInt(-1);
if (x != -1 && y != -1 && width != -1 && height != -1) {
if (x != -1 && y != -1 && width != -1 && height != -1)
{
// Have to offset x by one because qt moves the window 1px too
// far to the left
window.setGeometry(x + 1, y, width, height);
@@ -297,19 +309,22 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
// load tabs
QJsonArray tabs = window_obj.value("tabs").toArray();
for (QJsonValue tab_val : tabs) {
for (QJsonValue tab_val : tabs)
{
SplitContainer *page = window.getNotebook().addPage(false);
QJsonObject tab_obj = tab_val.toObject();
// set custom title
QJsonValue title_val = tab_obj.value("title");
if (title_val.isString()) {
if (title_val.isString())
{
page->getTab()->setCustomTitle(title_val.toString());
}
// selected
if (tab_obj.value("selected").toBool(false)) {
if (tab_obj.value("selected").toBool(false))
{
window.getNotebook().select(page);
}
@@ -320,7 +335,8 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
// load splits
QJsonObject splitRoot = tab_obj.value("splits2").toObject();
if (!splitRoot.isEmpty()) {
if (!splitRoot.isEmpty())
{
page->decodeFromJson(splitRoot);
continue;
@@ -328,8 +344,10 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
// fallback load splits (old)
int colNr = 0;
for (QJsonValue column_val : tab_obj.value("splits").toArray()) {
for (QJsonValue split_val : column_val.toArray()) {
for (QJsonValue column_val : tab_obj.value("splits").toArray())
{
for (QJsonValue split_val : column_val.toArray())
{
Split *split = new Split(page);
QJsonObject split_obj = split_val.toObject();
@@ -342,7 +360,8 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
}
}
if (mainWindow_ == nullptr) {
if (mainWindow_ == nullptr)
{
mainWindow_ = &createWindow(WindowType::Main);
mainWindow_->getNotebook().addPage(true);
}
@@ -376,11 +395,13 @@ void WindowManager::save()
// "serialize"
QJsonArray window_arr;
for (Window *window : this->windows_) {
for (Window *window : this->windows_)
{
QJsonObject window_obj;
// window type
switch (window->getType()) {
switch (window->getType())
{
case WindowType::Main:
window_obj.insert("type", "main");
break;
@@ -402,19 +423,22 @@ void WindowManager::save()
QJsonArray tabs_arr;
for (int tab_i = 0; tab_i < window->getNotebook().getPageCount();
tab_i++) {
tab_i++)
{
QJsonObject tab_obj;
SplitContainer *tab = dynamic_cast<SplitContainer *>(
window->getNotebook().getPageAt(tab_i));
assert(tab != nullptr);
// custom tab title
if (tab->getTab()->hasCustomTitle()) {
if (tab->getTab()->hasCustomTitle())
{
tab_obj.insert("title", tab->getTab()->getCustomTitle());
}
// selected
if (window->getNotebook().getSelectedPage() == tab) {
if (window->getNotebook().getSelectedPage() == tab)
{
tab_obj.insert("selected", true);
}
@@ -459,7 +483,8 @@ void WindowManager::save()
void WindowManager::sendAlert()
{
int flashDuration = 2500;
if (getSettings()->longAlerts) {
if (getSettings()->longAlerts)
{
flashDuration = 0;
}
QApplication::alert(this->getMainWindow().window(), flashDuration);
@@ -474,29 +499,35 @@ void WindowManager::queueSave()
void WindowManager::encodeNodeRecusively(SplitNode *node, QJsonObject &obj)
{
switch (node->getType()) {
case SplitNode::_Split: {
switch (node->getType())
{
case SplitNode::_Split:
{
obj.insert("type", "split");
QJsonObject split;
encodeChannel(node->getSplit()->getIndirectChannel(), split);
obj.insert("data", split);
obj.insert("flexh", node->getHorizontalFlex());
obj.insert("flexv", node->getVerticalFlex());
} break;
}
break;
case SplitNode::HorizontalContainer:
case SplitNode::VerticalContainer: {
case SplitNode::VerticalContainer:
{
obj.insert("type", node->getType() == SplitNode::HorizontalContainer
? "horizontal"
: "vertical");
QJsonArray items_arr;
for (const std::unique_ptr<SplitNode> &n : node->getChildren()) {
for (const std::unique_ptr<SplitNode> &n : node->getChildren())
{
QJsonObject subObj;
this->encodeNodeRecusively(n.get(), subObj);
items_arr.append(subObj);
}
obj.insert("items", items_arr);
} break;
}
break;
}
}
@@ -504,20 +535,29 @@ void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
{
assertInGuiThread();
switch (channel.getType()) {
case Channel::Type::Twitch: {
switch (channel.getType())
{
case Channel::Type::Twitch:
{
obj.insert("type", "twitch");
obj.insert("name", channel.get()->getName());
} break;
case Channel::Type::TwitchMentions: {
}
break;
case Channel::Type::TwitchMentions:
{
obj.insert("type", "mentions");
} break;
case Channel::Type::TwitchWatching: {
}
break;
case Channel::Type::TwitchWatching:
{
obj.insert("type", "watching");
} break;
case Channel::Type::TwitchWhispers: {
}
break;
case Channel::Type::TwitchWhispers:
{
obj.insert("type", "whispers");
} break;
}
break;
}
}
@@ -528,14 +568,21 @@ IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj)
auto app = getApp();
QString type = obj.value("type").toString();
if (type == "twitch") {
if (type == "twitch")
{
return app->twitch.server->getOrAddChannel(
obj.value("name").toString());
} else if (type == "mentions") {
}
else if (type == "mentions")
{
return app->twitch.server->mentionsChannel;
} else if (type == "watching") {
}
else if (type == "watching")
{
return app->twitch.server->watchingChannel;
} else if (type == "whispers") {
}
else if (type == "whispers")
{
return app->twitch.server->whispersChannel;
}
@@ -546,7 +593,8 @@ void WindowManager::closeAll()
{
assertInGuiThread();
for (Window *window : windows_) {
for (Window *window : windows_)
{
window->close();
}
}
@@ -573,7 +621,8 @@ float WindowManager::getUiScaleValue()
float WindowManager::getUiScaleValue(int scale)
{
switch (clampUiScale(scale)) {
switch (clampUiScale(scale))
{
case -5:
return 0.5f;
case -4:
+19 -8
View File
@@ -16,11 +16,16 @@ QByteArray endline("\n");
LoggingChannel::LoggingChannel(const QString &_channelName)
: channelName(_channelName)
{
if (this->channelName.startsWith("/whispers")) {
if (this->channelName.startsWith("/whispers"))
{
this->subDirectory = "Whispers";
} else if (channelName.startsWith("/mentions")) {
}
else if (channelName.startsWith("/mentions"))
{
this->subDirectory = "Mentions";
} else {
}
else
{
this->subDirectory =
QStringLiteral("Channels") + QDir::separator() + channelName;
}
@@ -33,9 +38,12 @@ LoggingChannel::LoggingChannel(const QString &_channelName)
getSettings()->logPath.connect([this](const QString &logPath, auto) {
auto app = getApp();
if (logPath.isEmpty()) {
if (logPath.isEmpty())
{
this->baseDirectory = getPaths()->messageLogDirectory;
} else {
}
else
{
this->baseDirectory = logPath;
}
@@ -54,7 +62,8 @@ void LoggingChannel::openLogFile()
QDateTime now = QDateTime::currentDateTime();
this->dateString = this->generateDateString(now);
if (this->fileHandle.isOpen()) {
if (this->fileHandle.isOpen())
{
this->fileHandle.flush();
this->fileHandle.close();
}
@@ -64,7 +73,8 @@ void LoggingChannel::openLogFile()
QString directory =
this->baseDirectory + QDir::separator() + this->subDirectory;
if (!QDir().mkpath(directory)) {
if (!QDir().mkpath(directory))
{
log("Unable to create logging path");
return;
}
@@ -84,7 +94,8 @@ void LoggingChannel::addMessage(MessagePtr message)
QDateTime now = QDateTime::currentDateTime();
QString messageDateString = this->generateDateString(now);
if (messageDateString != this->dateString) {
if (messageDateString != this->dateString)
{
this->dateString = messageDateString;
this->openLogFile();
}