ui/core/theme_manager.h¶
Singleton manager for CF UI theme registration and application. More...
Namespaces¶
| Name |
|---|
| cf |
| cf::ui |
| cf::ui::core |
Classes¶
| Name | |
|---|---|
| class | cf::ui::core::ThemeManager Singleton manager for CF UI theme registration and application. |
Detailed Description¶
Singleton manager for CF UI theme registration and application.
Author: N/A
Version: N/A
Since: N/A
Date: N/A
ThemeManager manages theme factory registration, theme creation, and application of themes to widgets. Emits signals when the theme changes.
Source code¶
#pragma once
#include "export.h"
#include "theme.h"
#include "theme_factory.h"
#include <QObject>
#include <QtWidgets/qwidget.h>
#include <functional>
#include <memory>
#include <unordered_map>
#include <unordered_set>
namespace cf::ui::core {
class CF_UI_EXPORT ThemeManager : public QObject {
Q_OBJECT
public:
static ThemeManager& instance();
const ICFTheme& theme(const std::string& name) const;
using InstallerMaker = std::function<std::unique_ptr<ThemeFactory>()>;
bool insert_one(const std::string& name, InstallerMaker make_one);
void remove_one(const std::string& name);
void install_widget(QWidget* w);
void remove_widget(QWidget* w);
void setThemeTo(const std::string& name, bool doBroadcast = true);
const std::string& currentThemeName() const;
signals:
void themeChanged(const ICFTheme& new_theme);
private:
ThemeManager(QObject* parent = nullptr);
~ThemeManager() override = default;
ThemeManager(const ThemeManager&) = delete;
ThemeManager& operator=(const ThemeManager&) = delete;
std::unordered_set<QWidget*> installed_widget;
std::unordered_map<std::string, std::unique_ptr<ThemeFactory>> factories_;
std::unordered_map<std::string, std::unique_ptr<ICFTheme>> theme_cache_;
std::string current_theme_name_;
};
} // namespace cf::ui::core
Updated on 2026-03-09 at 10:14:01 +0000