#include "widgets/aboutwidget.h"
#include "ui_aboutwidget.h"
#include "models/filesystem.h"
#include "models/lotrodatmanager.h"
#include "widgets/mainwindow.h"
#include "constants.h"

#include <QDebug>
#include <QFileDialog>
#include <QMessageBox>
#include <QDesktopServices>

AboutWidget::AboutWidget(QSettings* settings, PatchDownloader* patch_downloader, LotroDatManager* lotro_dat_manager, QWidget *parent) :
    QWidget(parent), app_settings(settings), lotro_manager(lotro_dat_manager),
    ui(new Ui::AboutWidget)
{
    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 *event)
{
    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({50 * coefficient, 50 * coefficient});
    ui->coder_icon->setMinimumSize({50 * coefficient, 50 * coefficient});

    updateFontsSizes();
}

void AboutWidget::on_goto_site_clicked()
{
    QDesktopServices::openUrl(QUrl(app_settings->value("General/site_url", "http://translate.lotros.ru/").toString()));
}



void AboutWidget::on_goto_forum_clicked()
{
    QDesktopServices::openUrl(QUrl(app_settings->value("General/forum_url", "http://lotros.ru/").toString()));
}

void AboutWidget::on_goto_bugs_clicked()
{
    QDesktopServices::openUrl(QUrl(app_settings->value("General/bugs_url", "http://translate.lotros.ru/bugs/add").toString()));
}

void AboutWidget::on_goto_donate_clicked()
{
    QDesktopServices::openUrl(QUrl(app_settings->value("General/donate_url", "http://translate.lotros.ru/donate").toString()));
}
