improved handling of relayouting messages
This commit is contained in:
@@ -46,16 +46,6 @@ public:
|
||||
|
||||
util::EmoteData getTwitchEmoteById(long int id, const QString &emoteName);
|
||||
|
||||
int getGeneration()
|
||||
{
|
||||
return _generation;
|
||||
}
|
||||
|
||||
void incGeneration()
|
||||
{
|
||||
_generation++;
|
||||
}
|
||||
|
||||
pajlada::Signals::NoArgSignal &getGifUpdateSignal();
|
||||
|
||||
// Bit badge/emotes?
|
||||
@@ -145,8 +135,6 @@ private:
|
||||
pajlada::Signals::NoArgSignal gifUpdateTimerSignal;
|
||||
QTimer gifUpdateTimer;
|
||||
bool gifUpdateTimerInitiated = false;
|
||||
|
||||
int _generation = 0;
|
||||
};
|
||||
|
||||
} // namespace singletons
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include <QDebug>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "application.hpp"
|
||||
#include "util/assertinguithread.hpp"
|
||||
#include "windowmanager.hpp"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#define DEFAULT_FONT_FAMILY "Segoe UI"
|
||||
@@ -27,27 +29,33 @@ FontManager::FontManager()
|
||||
{
|
||||
qDebug() << "init FontManager";
|
||||
|
||||
this->chatFontFamily.connect([this](const std::string &newValue, auto) {
|
||||
this->chatFontFamily.connect([this](const std::string &, auto) {
|
||||
util::assertInGuiThread();
|
||||
|
||||
this->incGeneration();
|
||||
if (getApp()->windows) {
|
||||
getApp()->windows->incGeneration();
|
||||
}
|
||||
|
||||
for (auto &map : this->fontsByType) {
|
||||
map.clear();
|
||||
}
|
||||
this->fontChanged.invoke();
|
||||
});
|
||||
|
||||
this->chatFontSize.connect([this](const int &newValue, auto) {
|
||||
this->chatFontSize.connect([this](const int &, auto) {
|
||||
util::assertInGuiThread();
|
||||
|
||||
this->incGeneration();
|
||||
if (getApp()->windows) {
|
||||
getApp()->windows->incGeneration();
|
||||
}
|
||||
|
||||
for (auto &map : this->fontsByType) {
|
||||
map.clear();
|
||||
}
|
||||
this->fontChanged.invoke();
|
||||
});
|
||||
|
||||
this->fontsByType.resize((size_t)EndType);
|
||||
this->fontsByType.resize(size_t(EndType));
|
||||
}
|
||||
|
||||
QFont FontManager::getFont(FontManager::Type type, float scale)
|
||||
@@ -60,23 +68,13 @@ QFontMetrics FontManager::getFontMetrics(FontManager::Type type, float scale)
|
||||
return this->getOrCreateFontData(type, scale).metrics;
|
||||
}
|
||||
|
||||
int FontManager::getGeneration() const
|
||||
{
|
||||
return this->generation;
|
||||
}
|
||||
|
||||
void FontManager::incGeneration()
|
||||
{
|
||||
this->generation++;
|
||||
}
|
||||
|
||||
FontManager::FontData &FontManager::getOrCreateFontData(Type type, float scale)
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
assert(type >= 0 && type < EndType);
|
||||
|
||||
auto &map = this->fontsByType[(size_t)type];
|
||||
auto &map = this->fontsByType[size_t(type)];
|
||||
|
||||
// find element
|
||||
auto it = map.find(scale);
|
||||
@@ -109,7 +107,7 @@ FontManager::FontData FontManager::createFontData(Type type, float scale)
|
||||
|
||||
auto data = sizeScale[type];
|
||||
return FontData(QFont(QString::fromStdString(this->chatFontFamily.getValue()),
|
||||
this->chatFontSize.getValue() * data.scale * scale, data.weight,
|
||||
int(this->chatFontSize.getValue() * data.scale * scale), data.weight,
|
||||
data.italic));
|
||||
}
|
||||
|
||||
@@ -128,7 +126,7 @@ FontManager::FontData FontManager::createFontData(Type type, float scale)
|
||||
};
|
||||
|
||||
UiFontData &data = defaultSize[type];
|
||||
QFont font(data.name, data.size * scale, data.weight, data.italic);
|
||||
QFont font(data.name, int(data.size * scale), data.weight, data.italic);
|
||||
return FontData(font);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,6 @@ public:
|
||||
QFont getFont(Type type, float scale);
|
||||
QFontMetrics getFontMetrics(Type type, float scale);
|
||||
|
||||
int getGeneration() const;
|
||||
void incGeneration();
|
||||
|
||||
pajlada::Settings::Setting<std::string> chatFontFamily;
|
||||
pajlada::Settings::Setting<int> chatFontSize;
|
||||
|
||||
@@ -79,8 +76,6 @@ private:
|
||||
FontData createFontData(Type type, float scale);
|
||||
|
||||
std::vector<std::unordered_map<float, FontData>> fontsByType;
|
||||
|
||||
int generation = 0;
|
||||
};
|
||||
|
||||
} // namespace singletons
|
||||
|
||||
@@ -39,13 +39,18 @@ void SettingManager::initialize()
|
||||
|
||||
this->timestampFormat.connect([](auto, auto) {
|
||||
auto app = getApp();
|
||||
app->windows->layoutVisibleChatWidgets();
|
||||
app->windows->layoutChannelViews();
|
||||
});
|
||||
|
||||
this->emoteScale.connect([](auto, auto) {
|
||||
getApp()->fonts->incGeneration();
|
||||
getApp()->windows->layoutVisibleChatWidgets();
|
||||
});
|
||||
this->emoteScale.connect([](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
|
||||
|
||||
this->timestampFormat.connect([](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
|
||||
this->alternateMessageBackground.connect(
|
||||
[](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
|
||||
this->seperateMessages.connect(
|
||||
[](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
|
||||
this->collapseLongMessages.connect(
|
||||
[](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
|
||||
}
|
||||
|
||||
MessageElement::Flags SettingManager::getWordFlags()
|
||||
|
||||
@@ -58,11 +58,17 @@ WindowManager::WindowManager()
|
||||
qDebug() << "init WindowManager";
|
||||
}
|
||||
|
||||
void WindowManager::layoutVisibleChatWidgets(Channel *channel)
|
||||
void WindowManager::layoutChannelViews(Channel *channel)
|
||||
{
|
||||
this->layout.invoke(channel);
|
||||
}
|
||||
|
||||
void WindowManager::forceLayoutChannelViews()
|
||||
{
|
||||
this->incGeneration();
|
||||
this->layoutChannelViews(nullptr);
|
||||
}
|
||||
|
||||
void WindowManager::repaintVisibleChatWidgets(Channel *channel)
|
||||
{
|
||||
if (this->mainWindow != nullptr) {
|
||||
@@ -394,5 +400,15 @@ void WindowManager::closeAll()
|
||||
}
|
||||
}
|
||||
|
||||
int WindowManager::getGeneration() const
|
||||
{
|
||||
return this->generation;
|
||||
}
|
||||
|
||||
void WindowManager::incGeneration()
|
||||
{
|
||||
this->generation++;
|
||||
}
|
||||
|
||||
} // namespace singletons
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "widgets/window.hpp"
|
||||
#include "widgets/splitcontainer.hpp"
|
||||
#include "widgets/window.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
//namespace widgets {
|
||||
//struct SplitContainer::Node;
|
||||
// namespace widgets {
|
||||
// struct SplitContainer::Node;
|
||||
//}
|
||||
namespace singletons {
|
||||
|
||||
@@ -19,7 +19,8 @@ public:
|
||||
void showSettingsDialog();
|
||||
void showAccountSelectPopup(QPoint point);
|
||||
|
||||
void layoutVisibleChatWidgets(Channel *channel = nullptr);
|
||||
void layoutChannelViews(Channel *channel = nullptr);
|
||||
void forceLayoutChannelViews();
|
||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||
void repaintGifEmotes();
|
||||
// void updateAll();
|
||||
@@ -35,12 +36,17 @@ public:
|
||||
void initialize();
|
||||
void closeAll();
|
||||
|
||||
int getGeneration() const;
|
||||
void incGeneration();
|
||||
|
||||
pajlada::Signals::NoArgSignal repaintGifs;
|
||||
pajlada::Signals::Signal<Channel *> layout;
|
||||
|
||||
private:
|
||||
bool initialized = false;
|
||||
|
||||
std::atomic<int> generation{0};
|
||||
|
||||
std::vector<widgets::Window *> windows;
|
||||
|
||||
widgets::Window *mainWindow = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user