mirror of
https://github.com/uowuo/abaddon.git
synced 2026-08-15 05:19:58 +00:00
fix up a bunch of clang-tidy stuff
mostly changing references, which i hope doesnt break stuff with models (TreeRow, iterators) since they gave me some strange problems in the past
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#include "imgmanager.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include "util.hpp"
|
||||
#include "abaddon.hpp"
|
||||
|
||||
@@ -6,17 +8,13 @@ ImageManager::ImageManager() {
|
||||
m_cb_dispatcher.connect(sigc::mem_fun(*this, &ImageManager::RunCallbacks));
|
||||
}
|
||||
|
||||
Cache &ImageManager::GetCache() {
|
||||
return m_cache;
|
||||
}
|
||||
|
||||
void ImageManager::ClearCache() {
|
||||
m_cache.ClearCache();
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> ImageManager::ReadFileToPixbuf(std::string path) {
|
||||
const auto &data = ReadWholeFile(path);
|
||||
if (data.size() == 0) return Glib::RefPtr<Gdk::Pixbuf>(nullptr);
|
||||
const auto &data = ReadWholeFile(std::move(path));
|
||||
if (data.empty()) return Glib::RefPtr<Gdk::Pixbuf>(nullptr);
|
||||
auto loader = Gdk::PixbufLoader::create();
|
||||
loader->signal_size_prepared().connect([&loader](int w, int h) {
|
||||
int cw, ch;
|
||||
@@ -29,8 +27,8 @@ Glib::RefPtr<Gdk::Pixbuf> ImageManager::ReadFileToPixbuf(std::string path) {
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::PixbufAnimation> ImageManager::ReadFileToPixbufAnimation(std::string path, int w, int h) {
|
||||
const auto &data = ReadWholeFile(path);
|
||||
if (data.size() == 0) return Glib::RefPtr<Gdk::PixbufAnimation>(nullptr);
|
||||
const auto &data = ReadWholeFile(std::move(path));
|
||||
if (data.empty()) return Glib::RefPtr<Gdk::PixbufAnimation>(nullptr);
|
||||
auto loader = Gdk::PixbufLoader::create();
|
||||
loader->signal_size_prepared().connect([&loader, w, h](int, int) {
|
||||
loader->set_size(w, h);
|
||||
@@ -40,10 +38,10 @@ Glib::RefPtr<Gdk::PixbufAnimation> ImageManager::ReadFileToPixbufAnimation(std::
|
||||
return loader->get_animation();
|
||||
}
|
||||
|
||||
void ImageManager::LoadFromURL(std::string url, callback_type cb) {
|
||||
void ImageManager::LoadFromURL(const std::string &url, const callback_type &cb) {
|
||||
sigc::signal<void(Glib::RefPtr<Gdk::Pixbuf>)> signal;
|
||||
signal.connect(cb);
|
||||
m_cache.GetFileFromURL(url, [this, url, signal](std::string path) {
|
||||
m_cache.GetFileFromURL(url, [this, url, signal](const std::string &path) {
|
||||
try {
|
||||
auto buf = ReadFileToPixbuf(path);
|
||||
if (!buf)
|
||||
@@ -60,10 +58,10 @@ void ImageManager::LoadFromURL(std::string url, callback_type cb) {
|
||||
});
|
||||
}
|
||||
|
||||
void ImageManager::LoadAnimationFromURL(std::string url, int w, int h, callback_anim_type cb) {
|
||||
void ImageManager::LoadAnimationFromURL(const std::string &url, int w, int h, const callback_anim_type &cb) {
|
||||
sigc::signal<void(Glib::RefPtr<Gdk::PixbufAnimation>)> signal;
|
||||
signal.connect(cb);
|
||||
m_cache.GetFileFromURL(url, [this, url, signal, w, h](std::string path) {
|
||||
m_cache.GetFileFromURL(url, [this, url, signal, w, h](const std::string &path) {
|
||||
try {
|
||||
auto buf = ReadFileToPixbufAnimation(path, w, h);
|
||||
if (!buf)
|
||||
@@ -80,7 +78,7 @@ void ImageManager::LoadAnimationFromURL(std::string url, int w, int h, callback_
|
||||
});
|
||||
}
|
||||
|
||||
void ImageManager::Prefetch(std::string url) {
|
||||
void ImageManager::Prefetch(const std::string &url) {
|
||||
m_cache.GetFileFromURL(url, [](const auto &) {});
|
||||
}
|
||||
|
||||
@@ -91,22 +89,6 @@ void ImageManager::RunCallbacks() {
|
||||
m_cb_mutex.unlock();
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> ImageManager::GetFromURLIfCached(std::string url) {
|
||||
std::string path = m_cache.GetPathIfCached(url);
|
||||
if (path != "")
|
||||
return ReadFileToPixbuf(path);
|
||||
|
||||
return Glib::RefPtr<Gdk::Pixbuf>(nullptr);
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::PixbufAnimation> ImageManager::GetAnimationFromURLIfCached(std::string url, int w, int h) {
|
||||
std::string path = m_cache.GetPathIfCached(url);
|
||||
if (path != "")
|
||||
return ReadFileToPixbufAnimation(path, w, h);
|
||||
|
||||
return Glib::RefPtr<Gdk::PixbufAnimation>(nullptr);
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> ImageManager::GetPlaceholder(int size) {
|
||||
std::string name = "/placeholder" + std::to_string(size);
|
||||
if (m_pixs.find(name) != m_pixs.end())
|
||||
|
||||
Reference in New Issue
Block a user