Refactor the whole structure, no more separation for C++ and Slint files

This commit is contained in:
Vyn 2024-11-04 14:45:27 +01:00
parent d6c781faa2
commit 893fcc11e3
35 changed files with 920 additions and 518 deletions

View file

@ -4,6 +4,8 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
#pragma once
#include <functional>
#include <vector>
@ -11,7 +13,7 @@ template <typename T> class EventEmitter
{
public:
void registerCallback(std::function<T> func)
void registerCallback(std::function<void(T)> func)
{
callbacks.push_back(func);
}
@ -24,5 +26,5 @@ template <typename T> class EventEmitter
}
private:
std::vector<std::function<T>> callbacks;
std::vector<std::function<void(T)>> callbacks;
};

View file

@ -6,6 +6,7 @@
#pragma once
#include "EventEmitter.h"
#include "Source.h"
#include <functional>
#include <memory>
@ -35,10 +36,18 @@ class Mirai
// Returns a non owning pointer to the requested resource or nullptr if not found.
Source *getSourceById(int id);
void onSourceAdded(std::function<void(Source *)> f);
void onSourceEdited(std::function<void(Source *)> f);
void onSourceDeleted(std::function<void(int)> f);
private:
void loadConfig(const std::string &path);
void saveConfig();
std::vector<std::unique_ptr<Source>> sources_;
std::string configPath_;
EventEmitter<Source *> sourceAdded;
EventEmitter<Source *> sourceEdited;
EventEmitter<int> sourceDeleted;
};
} // namespace mirai