#include "information.h"

information::information(QWidget *parent) : QWidget(parent)
{
    m_informationLayout = new QVBoxLayout(this);
    m_perhour = new perhour(this);
    m_weekweather = new weekweather(this);
    m_lifestyle = new lifestyle(this);

    m_hoursTipLabel = new QLabel(this);
    m_dayTipLabel = new QLabel(this);
    m_lifeTipLabel = new QLabel(this);
    
    QPalette hoursTipPalette = m_hoursTipLabel->palette();
    hoursTipPalette.setColor(QPalette::WindowText, Qt::white);
    m_hoursTipLabel->setPalette(hoursTipPalette);

    QPalette dayTipPalette = m_dayTipLabel->palette();
    dayTipPalette.setColor(QPalette::WindowText, Qt::white);
    m_dayTipLabel->setPalette(dayTipPalette);

    QPalette lifeTipPalette = m_lifeTipLabel->palette();
    lifeTipPalette.setColor(QPalette::WindowText, Qt::white);
    m_lifeTipLabel->setPalette(lifeTipPalette);

    m_hoursTipLabel->setText(tr("Hourly Weather")); //  时刻天气
    m_dayTipLabel->setText(tr("Daily Wather")); // 逐日天气
    m_lifeTipLabel->setText(tr("Life Index")); // 生活指数

    initLayout();
    initQss();
    initConnect();
}

void information::initLayout()
{
    m_informationLayout->addWidget(m_hoursTipLabel);
    m_informationLayout->addWidget(m_perhour);
    m_informationLayout->addSpacing(20);
    m_informationLayout->addWidget(m_dayTipLabel);
    m_informationLayout->addWidget(m_weekweather);
    m_informationLayout->addSpacing(20);
    m_informationLayout->addWidget(m_lifeTipLabel);
    m_informationLayout->addWidget(m_lifestyle);
    m_informationLayout->addSpacing(15);
    // m_informationLayout->addStretch();
    m_informationLayout->setMargin(0);
    m_informationLayout->setSpacing(0);
    m_informationLayout->setContentsMargins(0, 0, 0, 0);
    this->setLayout(m_informationLayout);
}

void information::initQss()
{
    //    this->setStyleSheet("QWidget{background:blue;}");
    //        m_perhour->setStyleSheet("QWidget{background:red;}");
}

void information::initConnect()
{
    connect(this, &information::getLifeStyleInfor, m_lifestyle, &lifestyle::getLifeStyleInfor);
    connect(this, &information::sendIsFullScreen, m_perhour, &perhour::sendIsFullScreen);
    connect(this, &information::sendHourlyInfor, m_perhour, &perhour::setHourlyInfor);
    connect(this, &information::sendIsFullScreen, m_perhour, &perhour::setHourlyIcon);
    connect(this, &information::sendIsFullScreen, m_weekweather, &weekweather::sendIsFullScreen);
    // 判断使用普通大小界面图标还是全屏大小图标
    connect(this, &information::sendIsFullScreen, m_weekweather, &weekweather::setWeatherIcon);
    connect(this, &information::sendIsFullScreen, m_lifestyle, &lifestyle::sendIsFullScreen);
    connect(this, &information::sendForcastInfor, m_weekweather, &weekweather::getForcastInfor);
    connect(this, &information::sendIsFullScreen, m_lifestyle, &lifestyle::sendIsFullScreen);
    connect(this, &information::getLifeStyleInfor, m_lifestyle, &lifestyle::getLifeStyleInfor);
}

void information::resizeEvent(QResizeEvent *event) {}
