#include "resourcemanager.h"

#include <QFontDatabase>
#include <QIcon>
#include <QPainter>

ResourceManager::ResourceManager(QObject *parent) :
    QObject(parent),
    settingsIcon(new QIcon),
    unsavedIcon(new QIcon),
    closeIcon(new QIcon)
{

}

void ResourceManager::painting()
{
    QFontDatabase::addApplicationFont(":/resource/Fonts/Kanit Cyrillic.ttf");
    QFontDatabase::addApplicationFont(":/resource/Fonts/HelveticaNeue-Medium.ttf");

    //settings
    QPixmap settingIcon(":resource/Icons/settingWhite.png");
    QPainter painter;
    QColor color(45,84,130);

    painter.begin(&settingIcon);
    painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
    painter.fillRect(settingIcon.rect(),color);
    painter.end();

    settingsIcon->addPixmap(settingIcon,QIcon::Normal,QIcon::Off);

    //caution
    QPixmap cautionIcon(":resource/Icons/caution.png");

    painter.begin(&cautionIcon);
    painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
    painter.fillRect(cautionIcon.rect(),color);
    painter.end();

    unsavedIcon->addPixmap(cautionIcon,QIcon::Normal,QIcon::Off);

    //exit
    QPixmap crossPixmap(":resource/Icons/close.png");
    QPainter painterCross;

    painter.begin(&crossPixmap);
    painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
    painter.fillRect(crossPixmap.rect(),QColorConstants::White);
    painter.end();

    closeIcon->addPixmap(crossPixmap,QIcon::Normal,QIcon::Off);
    //loading

    movie = new QMovie(":/resource/Icons/762.gif");
}

QMovie *ResourceManager::getMovie() const
{
    return movie;
}

QIcon *ResourceManager::getSettingsIcon() const
{
    return settingsIcon;
}

QIcon *ResourceManager::getUnsavedIcon() const
{
    return unsavedIcon;
}

QIcon *ResourceManager::getCloseIcon() const
{
    return closeIcon;
}
