ui/widget/application_support/application.h¶
CF Desktop Application class with integrated theme and animation support. More...
Namespaces¶
| Name |
|---|
| cf |
| cf::ui |
| cf::ui::widget |
| cf::ui::widget::application_support |
Classes¶
| Name | |
|---|---|
| class | cf::ui::widget::application_support::Application Application class with integrated theme and animation management. |
Detailed Description¶
CF Desktop Application class with integrated theme and animation support.
Author: N/A
Version: 0.1
Date: 2026-02-28
Copyright: Copyright © 2026
Application extends QApplication to provide unified access to ThemeManager and CFMaterialAnimationFactory. It replaces the standard QApplication in main() and provides token-based APIs for theme and animation access.
Source code¶
#pragma once
#include "components/animation_factory_manager.h"
#include "core/theme_manager.h"
#include "export.h"
#include <QApplication>
#include <functional>
#include <memory>
#include <string>
#include <unordered_map>
namespace cf::ui::widget::application_support {
class CF_UI_EXPORT Application : public QApplication {
Q_OBJECT
public:
Application(int& argc, char** argv);
~Application() override;
// Non-copyable, non-movable
Application(const Application&) = delete;
Application& operator=(const Application&) = delete;
Application(Application&&) = delete;
Application& operator=(Application&&) = delete;
// ========================================================================
// Global Access (Static Methods - Convenience API)
// ========================================================================
static Application* instance();
static core::ThemeManager* themeManager();
static cf::WeakPtr<components::ICFAnimationManagerFactory> animationFactory();
// ========================================================================
// Theme Access (Token-based)
// ========================================================================
const core::ICFTheme& theme(const std::string& themeToken) const;
void setTheme(const std::string& themeToken);
const core::ICFTheme& currentTheme() const;
// ========================================================================
// Animation Access (Token-based)
// ========================================================================
cf::WeakPtr<components::ICFAbstractAnimation> animation(const std::string& animationToken);
void setAnimationsEnabled(bool enabled);
bool animationsEnabled() const;
// ========================================================================
// Animation Factory Registration
// ========================================================================
using AnimationFactoryMaker =
std::function<std::unique_ptr<components::ICFAnimationManagerFactory>(const core::ICFTheme&,
QObject*)>;
static bool registerAnimationFactoryType(const std::string& themePrefix,
AnimationFactoryMaker maker);
static void unregisterAnimationFactoryType(const std::string& themePrefix);
signals:
void themeChanged(const core::ICFTheme& newTheme);
void animationsEnabledChanged(bool enabled);
protected:
virtual void init();
private:
void initializeAnimationFactory();
bool registerAnimationFactory(const std::string& themePrefix, AnimationFactoryMaker maker);
void unregisterAnimationFactory(const std::string& themePrefix);
std::unique_ptr<components::ICFAnimationManagerFactory>
createAnimationFactory(const std::string& themeName, const core::ICFTheme& theme,
QObject* parent);
void onThemeManagerChanged(const core::ICFTheme& newTheme);
std::unique_ptr<components::ICFAnimationManagerFactory> animationFactory_;
bool initialized_;
static std::unordered_map<std::string, AnimationFactoryMaker>& animationFactoryRegistry();
};
} // namespace cf::ui::widget::application_support
Updated on 2026-03-09 at 10:14:01 +0000