#include "ui_aboutwidget.h"

#include "models/patchlist.h"
#include "models/settings.h"
#include "constants.h"

#include "widgets/aboutwidget.h"

#include <QDesktopServices>

AboutWidget::AboutWidget(PatchList *legacy_patches, QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::AboutWidget)
    , legacy_patches_(legacy_patches)
{
    ui->setupUi(this);
}

AboutWidget::~AboutWidget()
{
    delete ui;
}

void AboutWidget::updateFontsSizes()
{
    ui->widget_name_label->setFont(trajan_9pt);

    ui->goto_bugs->setFont(trajan_8pt);
    ui->goto_donate->setFont(trajan_8pt);
    ui->goto_forum->setFont(trajan_8pt);
    ui->goto_site->setFont(trajan_8pt);

    ui->powered_by->setFont(trajan_10pt);
    ui->server_size->setFont(trajan_8pt);
    ui->client_side->setFont(trajan_8pt);
}

void AboutWidget::resizeEvent(QResizeEvent *)
{
    double coefficient = window_width / default_window_width;

    ui->left_panel->move(QPoint(40, 75) * coefficient);
    ui->left_panel->resize(QSize(240, 440) * coefficient);

    ui->widget_name_label->move(QPoint(45, 33)* coefficient);
    ui->widget_name_label->resize(QSize(180, 21) * coefficient);

    ui->endevir_icon->setMinimumSize({int(50.0 * coefficient), int(50.0 * coefficient)});
    ui->coder_icon->setMinimumSize({int(50.0 * coefficient), int(50.0 * coefficient)});

    updateFontsSizes();
}

void AboutWidget::on_goto_site_clicked()
{
    QDesktopServices::openUrl(Settings::getValue("Network/site_url").toUrl());
}

void AboutWidget::on_goto_forum_clicked()
{
    QDesktopServices::openUrl(Settings::getValue("Network/forum_url").toUrl());
}

void AboutWidget::on_goto_bugs_clicked()
{
    QDesktopServices::openUrl(Settings::getValue("Network/add_report_url").toUrl());
}

void AboutWidget::on_goto_donate_clicked()
{
    QDesktopServices::openUrl(Settings::getValue("Network/donate_url").toUrl());
}
