Subversion Repositories tpanel

Rev

Blame | Last modification | View Log | RSS feed

/*
 * Copyright (C) 2021 by Andreas Theofilu <andreas@theosys.at>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

#include <iostream>
#include <fstream>

#include <QFile>

#include "ttpinit.h"
#include "terror.h"

using std::string;
using std::ostream;

TTPInit::TTPInit(const string& path)
    : mPath(path)
{
    DECL_TRACER("TTPInit::TTPInit(const string& path)")

    createPanelConfigs();
}

bool TTPInit::createPanelConfigs()
{
    DECL_TRACER("TTPInit::createPanelConfigs()");

    bool err = false;
    QFile external(":ressources/external.xma");

    if (external.exists())
    {
        QString path = mPath.c_str();
        path += "/external.xma";

        if (!external.copy(path))
        {
            MSG_ERROR("Could not copy \"external.xma\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << external.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile fnt(":ressources/fnt.xma");

    if (fnt.exists())
    {
        QString path = mPath.c_str();
        path += "/fnt.xma";

        if (!fnt.copy(path))
        {
            MSG_ERROR("Could not copy \"fnt.xma\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << fnt.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile icon(":ressources/icon.xma");

    if (icon.exists())
    {
        QString path = mPath.c_str();
        path += "/icon.xma";

        if (!icon.copy(path))
        {
            MSG_ERROR("Could not copy \"icon.xma\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << icon.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile _main(":ressources/_main.xml");

    if (_main.exists())
    {
        QString path = mPath.c_str();
        path += "/_main.xml";

        if (!_main.copy(path))
        {
            MSG_ERROR("Could not copy \"_main.xml\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << _main.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile manifest(":ressources/manifest.xma");

    if (manifest.exists())
    {
        QString path = mPath.c_str();
        path += "/manifest.xma";

        if (!manifest.copy(path))
        {
            MSG_ERROR("Could not copy \"manifest.xma\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << manifest.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile map(":ressources/map.xma");

    if (map.exists())
    {
        QString path = mPath.c_str();
        path += "/map.xma";

        if (!map.copy(path))
        {
            MSG_ERROR("Could not copy \"map.xma\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << map.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile pal(":ressources/pal_001.xma");

    if (pal.exists())
    {
        QString path = mPath.c_str();
        path += "/pal_001.xma";

        if (!pal.copy(path))
        {
            MSG_ERROR("Could not copy \"pal_001.xma\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << pal.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile prj(":ressources/prj.xma");

    if (prj.exists())
    {
        QString path = mPath.c_str();
        path += "/prj.xma";

        if (!prj.copy(path))
        {
            MSG_ERROR("Could not copy \"prj.xma\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << prj.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile _setup(":ressources/_setup.xml");

    if (_setup.exists())
    {
        QString path = mPath.c_str();
        path += "/_setup.xml";

        if (!_setup.copy(path))
        {
            MSG_ERROR("Could not copy \"_setup.xml\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << _setup.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile table(":ressources/table.xma");

    if (table.exists())
    {
        QString path = mPath.c_str();
        path += "/table.xma";

        if (!table.copy(path))
        {
            MSG_ERROR("Could not copy \"table.xma\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << table.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile fonts(":ressources/fonts/arial.ttf");

    if (fonts.exists())
    {
        QString path = mPath.c_str();
        path += "/fonts/arial.ttf";

        if (!fonts.copy(path))
        {
            MSG_ERROR("Could not copy \"arial.ttf\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << fonts.fileName().data() << " doesn't exist!");
        err = true;
    }

    QFile images(":ressources/images/theosys_logo.png");

    if (images.exists())
    {
        QString path = mPath.c_str();
        path += "/images/theosys_logo.png";

        if (!images.copy(path))
        {
            MSG_ERROR("Could not copy \"theosys_logo.png\" to " << path.data());
            err = true;
        }
    }
    else
    {
        MSG_ERROR("File " << images.fileName().data() << " doesn't exist!");
        err = true;
    }

    return err;
}