/*
 * Copyright (C) 2023, KylinSoft Co., Ltd.
 *
 * 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, see <https://www.gnu.org/licenses/>.
 */
#include "perhour.h"
#include "onehourweather.h"
#include <QLabel>
#include <QPushButton>
#include <QGraphicsOpacityEffect>
#include <QDebug>
#include <QPainter>
#include <QStyleOption>

const QSize ICON_SIZE = QSize(72, 66);
const QString ICON_PATH = ":/res/weather-icon/PNG48/1x/";
const QString ICON_FILE = ":/res/weather-icon/PNG48/1x/100.png";

perhour::perhour(QWidget *parent) : QWidget(parent)
{
    this->initWidget();
    this->initConnect();
}

void perhour::initWidget()
{
    m_onehourWeatherFirstFirst = new onehourweather(this);
    m_onehourWeatherFirstSecond = new onehourweather(this);
    m_onehourWeatherFirstThird = new onehourweather(this);
    m_onehourWeatherFirstFourth = new onehourweather(this);
    m_onehourWeatherFirstFifth = new onehourweather(this);
    m_onehourWeatherFirstSixth = new onehourweather(this);
    m_onehourWeatherFirstSeventh = new onehourweather(this);
    m_onehourWeatherFirstEighth = new onehourweather(this);

    m_onehourWeatherSecondFirst = new onehourweather(this);
    m_onehourWeatherSecondSecond = new onehourweather(this);
    m_onehourWeatherSecondThird = new onehourweather(this);
    m_onehourWeatherSecondFourth = new onehourweather(this);
    m_onehourWeatherSecondFifth = new onehourweather(this);
    m_onehourWeatherSecondSixth = new onehourweather(this);
    m_onehourWeatherSecondSeventh = new onehourweather(this);
    m_onehourWeatherSecondEighth = new onehourweather(this);

    m_onehourWeatherThirdFirst = new onehourweather(this);
    m_onehourWeatherThirdSecond = new onehourweather(this);
    m_onehourWeatherThirdThird = new onehourweather(this);
    m_onehourWeatherThirdFourth = new onehourweather(this);
    m_onehourWeatherThirdFifth = new onehourweather(this);
    m_onehourWeatherThirdSixth = new onehourweather(this);
    m_onehourWeatherThirdSeventh = new onehourweather(this);
    m_onehourWeatherThirdEighth = new onehourweather(this);

    m_perhourLayout = new QHBoxLayout();
    m_perhourWid = new QWidget();
    m_scrollArea = new QScrollArea(this);
    m_Layout = new QHBoxLayout();
    this->initStyle();

    return;
}

void perhour::initStyle()
{
    m_perhourLayout->addWidget(m_onehourWeatherFirstFirst);
    m_perhourLayout->addWidget(m_onehourWeatherFirstSecond);
    m_perhourLayout->addWidget(m_onehourWeatherFirstThird);
    m_perhourLayout->addWidget(m_onehourWeatherFirstFourth);
    m_perhourLayout->addWidget(m_onehourWeatherFirstFifth);
    m_perhourLayout->addWidget(m_onehourWeatherFirstSixth);
    m_perhourLayout->addWidget(m_onehourWeatherFirstSeventh);
    m_perhourLayout->addWidget(m_onehourWeatherFirstEighth);
    m_perhourLayout->addWidget(m_onehourWeatherSecondFirst);
    m_perhourLayout->addWidget(m_onehourWeatherSecondSecond);
    m_perhourLayout->addWidget(m_onehourWeatherSecondThird);
    m_perhourLayout->addWidget(m_onehourWeatherSecondFourth);
    m_perhourLayout->addWidget(m_onehourWeatherSecondFifth);
    m_perhourLayout->addWidget(m_onehourWeatherSecondSixth);
    m_perhourLayout->addWidget(m_onehourWeatherSecondSeventh);
    m_perhourLayout->addWidget(m_onehourWeatherSecondEighth);
    m_perhourLayout->addWidget(m_onehourWeatherThirdFirst);
    m_perhourLayout->addWidget(m_onehourWeatherThirdSecond);
    m_perhourLayout->addWidget(m_onehourWeatherThirdThird);
    m_perhourLayout->addWidget(m_onehourWeatherThirdFourth);
    m_perhourLayout->addWidget(m_onehourWeatherThirdFifth);
    m_perhourLayout->addWidget(m_onehourWeatherThirdSixth);
    m_perhourLayout->addWidget(m_onehourWeatherThirdSeventh);
    m_perhourLayout->addWidget(m_onehourWeatherThirdEighth);

    m_perhourWid->setLayout(m_perhourLayout);
    this->setLayout(m_Layout);
    m_Layout->addWidget(m_scrollArea);
    m_Layout->setMargin(0);

    m_scrollArea->setWidget(m_perhourWid);
    m_scrollArea->setFocusPolicy(Qt::NoFocus); //设置焦点类型
    m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    m_scrollArea->horizontalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
    m_scrollArea->horizontalScrollBar()->setProperty("drawScrollBarGroove", false);

    // 设置scrollarea背景透明
    QPalette scrollarea = m_scrollArea->palette();
    scrollarea.setColor(QPalette::Background, QColor(Qt::transparent));
    m_scrollArea->setPalette(scrollarea);
    m_scrollArea->setFrameShape(QFrame::NoFrame); // 设置滑动区无边框
    
    switch (ViewVar::getInstance()->m_currentMode)
    {
        case CurrentMode::PCMode:
            slotChangePCMode();
            break;
        case CurrentMode::PadHMode:
            slotChangePadHMode();
            break;    
        case CurrentMode::PadVMode:
            slotChangePadVMode();
            break;
        default:
            slotChangePCMode();
            break;
    }
    return;
}

// 逐小时信息
void perhour::setHourlyInfor(QList<Hourly> tmp_list, int m_isFullScreen)
{
    tmpList = tmp_list;

    if (tmpList.isEmpty()) {

        return;
    }

    m_firstFirstIconPath = ICON_PATH + tmp_list.at(0).cond_code + ".png";
    m_firstSecondIconPath = ICON_PATH + tmp_list.at(1).cond_code + ".png";
    m_firstThirdIconPath = ICON_PATH + tmp_list.at(2).cond_code + ".png";
    m_firstFourthIconPath = ICON_PATH + tmp_list.at(3).cond_code + ".png";
    m_firstFifthIconPath = ICON_PATH + tmp_list.at(4).cond_code + ".png";
    m_firstSixthIconPath = ICON_PATH + tmp_list.at(5).cond_code + ".png";
    m_firstSeventhIconPath = ICON_PATH + tmp_list.at(6).cond_code + ".png";
    m_firstEighthIconPath = ICON_PATH + tmp_list.at(7).cond_code + ".png";

    m_secondFirstIconPath = ICON_PATH + tmp_list.at(8).cond_code + ".png";
    m_secondSecondIconPath = ICON_PATH + tmp_list.at(9).cond_code + ".png";
    m_secondThirdIconPath = ICON_PATH + tmp_list.at(10).cond_code + ".png";
    m_secondFourthIconPath = ICON_PATH + tmp_list.at(11).cond_code + ".png";
    m_secondFifthIconPath = ICON_PATH + tmp_list.at(12).cond_code + ".png";
    m_secondSixthIconPath = ICON_PATH + tmp_list.at(13).cond_code + ".png";
    m_secondSeventhIconPath = ICON_PATH + tmp_list.at(14).cond_code + ".png";
    m_secondEighthIconPath = ICON_PATH + tmp_list.at(15).cond_code + ".png";

    m_thirdFirstIconPath = ICON_PATH + tmp_list.at(16).cond_code + ".png";
    m_thirdSecondIconPath = ICON_PATH + tmp_list.at(17).cond_code + ".png";
    m_thirdThirdIconPath = ICON_PATH + tmp_list.at(18).cond_code + ".png";
    m_thirdFourthIconPath = ICON_PATH + tmp_list.at(19).cond_code + ".png";
    m_thirdFifthIconPath = ICON_PATH + tmp_list.at(20).cond_code + ".png";
    m_thirdSixthIconPath = ICON_PATH + tmp_list.at(21).cond_code + ".png";
    m_thirdSeventhIconPath = ICON_PATH + tmp_list.at(22).cond_code + ".png";
    m_thirdEighthIconPath = ICON_PATH + tmp_list.at(23).cond_code + ".png";

    QFileInfo m_firstFirstIconPathFile(m_firstFirstIconPath);
    if (m_firstFirstIconPathFile.exists() == false) {
        m_firstFirstIconPath = ICON_FILE;
    }
    QFileInfo m_firstSecondIconPathFile(m_firstSecondIconPath);
    if (m_firstSecondIconPathFile.exists() == false) {
        m_firstSecondIconPath = ICON_FILE;
    }
    QFileInfo m_firstThirdIconPathFile(m_firstThirdIconPath);
    if (m_firstThirdIconPathFile.exists() == false) {
        m_firstThirdIconPath = ICON_FILE;
    }
    QFileInfo m_firstFourthIconPathFile(m_firstFourthIconPath);
    if (m_firstFourthIconPathFile.exists() == false) {
        m_firstFourthIconPath = ICON_FILE;
    }
    QFileInfo m_firstFifthIconPathFile(m_firstFifthIconPath);
    if (m_firstFifthIconPathFile.exists() == false) {
        m_firstFifthIconPath = ICON_FILE;
    }
    QFileInfo m_firstSixthIconPathFile(m_firstSixthIconPath);
    if (m_firstSixthIconPathFile.exists() == false) {
        m_firstSixthIconPath = ICON_FILE;
    }
    QFileInfo m_firstSeventhIconPathFile(m_firstSeventhIconPath);
    if (m_firstSeventhIconPathFile.exists() == false) {
        m_firstSeventhIconPath = ICON_FILE;
    }
    QFileInfo m_firstEighthIconPathFile(m_firstEighthIconPath);
    if (m_firstEighthIconPathFile.exists() == false) {
        m_firstEighthIconPath = ICON_FILE;
    }

    QFileInfo m_secondFirstIconPathFile(m_secondFirstIconPath);
    if (m_secondFirstIconPathFile.exists() == false) {
        m_secondFirstIconPath = ICON_FILE;
    }
    QFileInfo m_secondSecondIconPathFile(m_secondSecondIconPath);
    if (m_secondSecondIconPathFile.exists() == false) {
        m_secondSecondIconPath = ICON_FILE;
    }
    QFileInfo m_secondThirdIconPathFile(m_secondThirdIconPath);
    if (m_secondThirdIconPathFile.exists() == false) {
        m_secondThirdIconPath = ICON_FILE;
    }
    QFileInfo m_secondFourthIconPathFile(m_secondFourthIconPath);
    if (m_secondFourthIconPathFile.exists() == false) {
        m_secondFourthIconPath = ICON_FILE;
    }
    QFileInfo m_secondFifthIconPathFile(m_secondFifthIconPath);
    if (m_secondFifthIconPathFile.exists() == false) {
        m_secondFifthIconPath = ICON_FILE;
    }
    QFileInfo m_secondSixthIconPathFile(m_secondSixthIconPath);
    if (m_secondSixthIconPathFile.exists() == false) {
        m_secondSixthIconPath = ICON_FILE;
    }
    QFileInfo m_secondSeventhIconPathFile(m_secondSeventhIconPath);
    if (m_secondSeventhIconPathFile.exists() == false) {
        m_secondSeventhIconPath = ICON_FILE;
    }
    QFileInfo m_secondEighthIconPathFile(m_secondEighthIconPath);
    if (m_secondEighthIconPathFile.exists() == false) {
        m_secondEighthIconPath = ICON_FILE;
    }

    QFileInfo m_thirdFirstIconPathFile(m_thirdFirstIconPath);
    if (m_thirdFirstIconPathFile.exists() == false) {
        m_thirdFirstIconPath = ICON_FILE;
    }
    QFileInfo m_thirdSecondIconPathFile(m_thirdSecondIconPath);
    if (m_thirdSecondIconPathFile.exists() == false) {
        m_thirdSecondIconPath = ICON_FILE;
    }
    QFileInfo m_thirdThirdIconPathFile(m_thirdThirdIconPath);
    if (m_thirdThirdIconPathFile.exists() == false) {
        m_thirdThirdIconPath = ICON_FILE;
    }
    QFileInfo m_thirdFourthIconPathFile(m_thirdFourthIconPath);
    if (m_thirdFourthIconPathFile.exists() == false) {
        m_thirdFourthIconPath = ICON_FILE;
    }
    QFileInfo m_thirdFifthIconPathFile(m_thirdFifthIconPath);
    if (m_thirdFifthIconPathFile.exists() == false) {
        m_thirdFifthIconPath = ICON_FILE;
    }
    QFileInfo m_thirdSixthIconPathFile(m_thirdSixthIconPath);
    if (m_thirdSixthIconPathFile.exists() == false) {
        m_thirdSixthIconPath = ICON_FILE;
    }
    QFileInfo m_thirdSeventhIconPathFile(m_thirdSeventhIconPath);
    if (m_thirdSeventhIconPathFile.exists() == false) {
        m_thirdSeventhIconPath = ICON_FILE;
    }
    QFileInfo m_thirdEighthIconPathFile(m_thirdEighthIconPath);
    if (m_thirdEighthIconPathFile.exists() == false) {
        m_thirdEighthIconPath = ICON_FILE;
    }


    // ---------- 第一页 -------------
    m_onehourWeatherFirstFirst->m_time->setText(tmp_list.at(0).time);
    m_onehourWeatherFirstFirst->m_icon->setPixmap(QPixmap(m_firstFirstIconPath));
    m_onehourWeatherFirstFirst->m_temperature->setText(tmp_list.at(0).tmp);

    m_onehourWeatherFirstSecond->m_time->setText(tmp_list.at(1).time);
    m_onehourWeatherFirstSecond->m_icon->setPixmap(QPixmap(m_firstSecondIconPath));
    m_onehourWeatherFirstSecond->m_temperature->setText(tmp_list.at(1).tmp);

    m_onehourWeatherFirstThird->m_time->setText(tmp_list.at(2).time);
    m_onehourWeatherFirstThird->m_icon->setPixmap(QPixmap(m_firstThirdIconPath));
    m_onehourWeatherFirstThird->m_temperature->setText(tmp_list.at(2).tmp);

    m_onehourWeatherFirstFourth->m_time->setText(tmp_list.at(3).time);
    m_onehourWeatherFirstFourth->m_icon->setPixmap(QPixmap(m_firstFourthIconPath));
    m_onehourWeatherFirstFourth->m_temperature->setText(tmp_list.at(3).tmp);

    m_onehourWeatherFirstFifth->m_time->setText(tmp_list.at(4).time);
    m_onehourWeatherFirstFifth->m_icon->setPixmap(QPixmap(m_firstFifthIconPath));
    m_onehourWeatherFirstFifth->m_temperature->setText(tmp_list.at(4).tmp);

    m_onehourWeatherFirstSixth->m_time->setText(tmp_list.at(5).time);
    m_onehourWeatherFirstSixth->m_icon->setPixmap(QPixmap(m_firstSixthIconPath));
    m_onehourWeatherFirstSixth->m_temperature->setText(tmp_list.at(5).tmp);

    m_onehourWeatherFirstSeventh->m_time->setText(tmp_list.at(6).time);
    m_onehourWeatherFirstSeventh->m_icon->setPixmap(QPixmap(m_firstSeventhIconPath));
    m_onehourWeatherFirstSeventh->m_temperature->setText(tmp_list.at(6).tmp);

    m_onehourWeatherFirstEighth->m_time->setText(tmp_list.at(7).time);
    m_onehourWeatherFirstEighth->m_icon->setPixmap(QPixmap(m_firstEighthIconPath));
    m_onehourWeatherFirstEighth->m_temperature->setText(tmp_list.at(7).tmp);
    // ----------- 第二页 -------------
    m_onehourWeatherSecondFirst->m_time->setText(tmp_list.at(8).time);
    m_onehourWeatherSecondFirst->m_icon->setPixmap(QPixmap(m_secondFirstIconPath));
    m_onehourWeatherSecondFirst->m_temperature->setText(tmp_list.at(8).tmp);

    m_onehourWeatherSecondSecond->m_time->setText(tmp_list.at(9).time);
    m_onehourWeatherSecondSecond->m_icon->setPixmap(QPixmap(m_secondSecondIconPath));
    m_onehourWeatherSecondSecond->m_temperature->setText(tmp_list.at(9).tmp);

    m_onehourWeatherSecondThird->m_time->setText(tmp_list.at(10).time);
    m_onehourWeatherSecondThird->m_icon->setPixmap(QPixmap(m_secondThirdIconPath));
    m_onehourWeatherSecondThird->m_temperature->setText(tmp_list.at(10).tmp);

    m_onehourWeatherSecondFourth->m_time->setText(tmp_list.at(11).time);
    m_onehourWeatherSecondFourth->m_icon->setPixmap(QPixmap(m_secondFourthIconPath));
    m_onehourWeatherSecondFourth->m_temperature->setText(tmp_list.at(11).tmp);

    m_onehourWeatherSecondFifth->m_time->setText(tmp_list.at(12).time);
    m_onehourWeatherSecondFifth->m_icon->setPixmap(QPixmap(m_secondFifthIconPath));
    m_onehourWeatherSecondFifth->m_temperature->setText(tmp_list.at(12).tmp);

    m_onehourWeatherSecondSixth->m_time->setText(tmp_list.at(13).time);
    m_onehourWeatherSecondSixth->m_icon->setPixmap(QPixmap(m_secondSixthIconPath));
    m_onehourWeatherSecondSixth->m_temperature->setText(tmp_list.at(13).tmp);

    m_onehourWeatherSecondSeventh->m_time->setText(tmp_list.at(14).time);
    m_onehourWeatherSecondSeventh->m_icon->setPixmap(QPixmap(m_secondSeventhIconPath));
    m_onehourWeatherSecondSeventh->m_temperature->setText(tmp_list.at(14).tmp);

    m_onehourWeatherSecondEighth->m_time->setText(tmp_list.at(15).time);
    m_onehourWeatherSecondEighth->m_icon->setPixmap(QPixmap(m_secondEighthIconPath));
    m_onehourWeatherSecondEighth->m_temperature->setText(tmp_list.at(15).tmp);
    // ------------------ 第三页 ----------------------------
    m_onehourWeatherThirdFirst->m_time->setText(tmp_list.at(16).time);
    m_onehourWeatherThirdFirst->m_icon->setPixmap(QPixmap(m_thirdFirstIconPath));
    m_onehourWeatherThirdFirst->m_temperature->setText(tmp_list.at(16).tmp);

    m_onehourWeatherThirdSecond->m_time->setText(tmp_list.at(17).time);
    m_onehourWeatherThirdSecond->m_icon->setPixmap(QPixmap(m_thirdSecondIconPath));
    m_onehourWeatherThirdSecond->m_temperature->setText(tmp_list.at(17).tmp);

    m_onehourWeatherThirdThird->m_time->setText(tmp_list.at(18).time);
    m_onehourWeatherThirdThird->m_icon->setPixmap(QPixmap(m_thirdThirdIconPath));
    m_onehourWeatherThirdThird->m_temperature->setText(tmp_list.at(18).tmp);

    m_onehourWeatherThirdFourth->m_time->setText(tmp_list.at(19).time);
    m_onehourWeatherThirdFourth->m_icon->setPixmap(QPixmap(m_thirdFourthIconPath));
    m_onehourWeatherThirdFourth->m_temperature->setText(tmp_list.at(19).tmp);

    m_onehourWeatherThirdFifth->m_time->setText(tmp_list.at(20).time);
    m_onehourWeatherThirdFifth->m_icon->setPixmap(QPixmap(m_thirdFifthIconPath));
    m_onehourWeatherThirdFifth->m_temperature->setText(tmp_list.at(20).tmp);

    m_onehourWeatherThirdSixth->m_time->setText(tmp_list.at(21).time);
    m_onehourWeatherThirdSixth->m_icon->setPixmap(QPixmap(m_thirdSixthIconPath));
    m_onehourWeatherThirdSixth->m_temperature->setText(tmp_list.at(21).tmp);

    m_onehourWeatherThirdSeventh->m_time->setText(tmp_list.at(22).time);
    m_onehourWeatherThirdSeventh->m_icon->setPixmap(QPixmap(m_thirdSeventhIconPath));
    m_onehourWeatherThirdSeventh->m_temperature->setText(tmp_list.at(22).tmp);

    m_onehourWeatherThirdEighth->m_time->setText(tmp_list.at(23).time);
    m_onehourWeatherThirdEighth->m_icon->setPixmap(QPixmap(m_thirdEighthIconPath));
    m_onehourWeatherThirdEighth->m_temperature->setText(tmp_list.at(23).tmp);
}

void perhour::setHourlyIcon(int m_isFullScreen)
{
    if (tmpList.isEmpty()) {

        return;
    }
    m_firstFirstIconPath = ICON_PATH + tmpList.at(0).cond_code + ".png";
    m_firstSecondIconPath = ICON_PATH + tmpList.at(1).cond_code + ".png";
    m_firstThirdIconPath = ICON_PATH + tmpList.at(2).cond_code + ".png";
    m_firstFourthIconPath = ICON_PATH + tmpList.at(3).cond_code + ".png";
    m_firstFifthIconPath = ICON_PATH + tmpList.at(4).cond_code + ".png";
    m_firstSixthIconPath = ICON_PATH + tmpList.at(5).cond_code + ".png";
    m_firstSeventhIconPath = ICON_PATH + tmpList.at(6).cond_code + ".png";
    m_firstEighthIconPath = ICON_PATH + tmpList.at(7).cond_code + ".png";

    m_secondFirstIconPath = ICON_PATH + tmpList.at(8).cond_code + ".png";
    m_secondSecondIconPath = ICON_PATH + tmpList.at(9).cond_code + ".png";
    m_secondThirdIconPath = ICON_PATH + tmpList.at(10).cond_code + ".png";
    m_secondFourthIconPath = ICON_PATH + tmpList.at(11).cond_code + ".png";
    m_secondFifthIconPath = ICON_PATH + tmpList.at(12).cond_code + ".png";
    m_secondSixthIconPath = ICON_PATH + tmpList.at(13).cond_code + ".png";
    m_secondSeventhIconPath = ICON_PATH + tmpList.at(14).cond_code + ".png";
    m_secondEighthIconPath = ICON_PATH + tmpList.at(15).cond_code + ".png";

    m_thirdFirstIconPath = ICON_PATH + tmpList.at(16).cond_code + ".png";
    m_thirdSecondIconPath = ICON_PATH + tmpList.at(17).cond_code + ".png";
    m_thirdThirdIconPath = ICON_PATH + tmpList.at(18).cond_code + ".png";
    m_thirdFourthIconPath = ICON_PATH + tmpList.at(19).cond_code + ".png";
    m_thirdFifthIconPath = ICON_PATH + tmpList.at(20).cond_code + ".png";
    m_thirdSixthIconPath = ICON_PATH + tmpList.at(21).cond_code + ".png";
    m_thirdSeventhIconPath = ICON_PATH + tmpList.at(22).cond_code + ".png";
    m_thirdEighthIconPath = ICON_PATH + tmpList.at(23).cond_code + ".png";

    QFileInfo m_firstFirstIconPathFile(m_firstFirstIconPath);
    if (m_firstFirstIconPathFile.exists() == false) {
        m_firstFirstIconPath = ICON_FILE;
    }
    QFileInfo m_firstSecondIconPathFile(m_firstSecondIconPath);
    if (m_firstSecondIconPathFile.exists() == false) {
        m_firstSecondIconPath = ICON_FILE;
    }
    QFileInfo m_firstThirdIconPathFile(m_firstThirdIconPath);
    if (m_firstThirdIconPathFile.exists() == false) {
        m_firstThirdIconPath = ICON_FILE;
    }
    QFileInfo m_firstFourthIconPathFile(m_firstFourthIconPath);
    if (m_firstFourthIconPathFile.exists() == false) {
        m_firstFourthIconPath = ICON_FILE;
    }
    QFileInfo m_firstFifthIconPathFile(m_firstFifthIconPath);
    if (m_firstFifthIconPathFile.exists() == false) {
        m_firstFifthIconPath = ICON_FILE;
    }
    QFileInfo m_firstSixthIconPathFile(m_firstSixthIconPath);
    if (m_firstSixthIconPathFile.exists() == false) {
        m_firstSixthIconPath = ICON_FILE;
    }
    QFileInfo m_firstSeventhIconPathFile(m_firstSeventhIconPath);
    if (m_firstSeventhIconPathFile.exists() == false) {
        m_firstSeventhIconPath = ICON_FILE;
    }
    QFileInfo m_firstEighthIconPathFile(m_firstEighthIconPath);
    if (m_firstEighthIconPathFile.exists() == false) {
        m_firstEighthIconPath = ICON_FILE;
    }

    QFileInfo m_secondFirstIconPathFile(m_secondFirstIconPath);
    if (m_secondFirstIconPathFile.exists() == false) {
        m_secondFirstIconPath = ICON_FILE;
    }
    QFileInfo m_secondSecondIconPathFile(m_secondSecondIconPath);
    if (m_secondSecondIconPathFile.exists() == false) {
        m_secondSecondIconPath = ICON_FILE;
    }
    QFileInfo m_secondThirdIconPathFile(m_secondThirdIconPath);
    if (m_secondThirdIconPathFile.exists() == false) {
        m_secondThirdIconPath = ICON_FILE;
    }
    QFileInfo m_secondFourthIconPathFile(m_secondFourthIconPath);
    if (m_secondFourthIconPathFile.exists() == false) {
        m_secondFourthIconPath = ICON_FILE;
    }
    QFileInfo m_secondFifthIconPathFile(m_secondFifthIconPath);
    if (m_secondFifthIconPathFile.exists() == false) {
        m_secondFifthIconPath = ICON_FILE;
    }
    QFileInfo m_secondSixthIconPathFile(m_secondSixthIconPath);
    if (m_secondSixthIconPathFile.exists() == false) {
        m_secondSixthIconPath = ICON_FILE;
    }
    QFileInfo m_secondSeventhIconPathFile(m_secondSeventhIconPath);
    if (m_secondSeventhIconPathFile.exists() == false) {
        m_secondSeventhIconPath = ICON_FILE;
    }
    QFileInfo m_secondEighthIconPathFile(m_secondEighthIconPath);
    if (m_secondEighthIconPathFile.exists() == false) {
        m_secondEighthIconPath = ICON_FILE;
    }

    QFileInfo m_thirdFirstIconPathFile(m_thirdFirstIconPath);
    if (m_thirdFirstIconPathFile.exists() == false) {
        m_thirdFirstIconPath = ICON_FILE;
    }
    QFileInfo m_thirdSecondIconPathFile(m_thirdSecondIconPath);
    if (m_thirdSecondIconPathFile.exists() == false) {
        m_thirdSecondIconPath = ICON_FILE;
    }
    QFileInfo m_thirdThirdIconPathFile(m_thirdThirdIconPath);
    if (m_thirdThirdIconPathFile.exists() == false) {
        m_thirdThirdIconPath = ICON_FILE;
    }
    QFileInfo m_thirdFourthIconPathFile(m_thirdFourthIconPath);
    if (m_thirdFourthIconPathFile.exists() == false) {
        m_thirdFourthIconPath = ICON_FILE;
    }
    QFileInfo m_thirdFifthIconPathFile(m_thirdFifthIconPath);
    if (m_thirdFifthIconPathFile.exists() == false) {
        m_thirdFifthIconPath = ICON_FILE;
    }
    QFileInfo m_thirdSixthIconPathFile(m_thirdSixthIconPath);
    if (m_thirdSixthIconPathFile.exists() == false) {
        m_thirdSixthIconPath = ICON_FILE;
    }
    QFileInfo m_thirdSeventhIconPathFile(m_thirdSeventhIconPath);
    if (m_thirdSeventhIconPathFile.exists() == false) {
        m_thirdSeventhIconPath = ICON_FILE;
    }
    QFileInfo m_thirdEighthIconPathFile(m_thirdEighthIconPath);
    if (m_thirdEighthIconPathFile.exists() == false) {
        m_thirdEighthIconPath = ICON_FILE;
    }

    m_onehourWeatherFirstFirst->m_icon->resize(ICON_SIZE);
    QPixmap firstFirstPixmap(m_firstFirstIconPath);
    m_onehourWeatherFirstFirst->m_icon->setPixmap(firstFirstPixmap);

    m_onehourWeatherFirstSecond->m_icon->resize(ICON_SIZE);
    QPixmap firstSecondPixmap(m_firstSecondIconPath);
    m_onehourWeatherFirstSecond->m_icon->setPixmap(firstSecondPixmap);

    m_onehourWeatherFirstThird->m_icon->resize(72, 66);
    QPixmap firstThirdPixmap(m_firstThirdIconPath);
    m_onehourWeatherFirstThird->m_icon->setPixmap(firstThirdPixmap);

    m_onehourWeatherFirstFourth->m_icon->resize(72, 66);
    QPixmap firstFourthPixmap(m_firstFourthIconPath);
    m_onehourWeatherFirstFourth->m_icon->setPixmap(firstFourthPixmap);

    m_onehourWeatherFirstFifth->m_icon->resize(ICON_SIZE);
    QPixmap firstFifthPixmap(m_firstFifthIconPath);
    m_onehourWeatherFirstFifth->m_icon->setPixmap(firstFifthPixmap);

    m_onehourWeatherFirstSixth->m_icon->resize(ICON_SIZE);
    QPixmap firstSixthPixmap(m_firstSixthIconPath);
    m_onehourWeatherFirstSixth->m_icon->setPixmap(firstSixthPixmap);

    m_onehourWeatherFirstSeventh->m_icon->resize(ICON_SIZE);
    QPixmap firstSeventhPixmap(m_firstSeventhIconPath);
    m_onehourWeatherFirstSeventh->m_icon->setPixmap(firstSeventhPixmap);

    m_onehourWeatherFirstEighth->m_icon->resize(ICON_SIZE);

    QPixmap firstEighthPixmap(m_firstEighthIconPath);
    m_onehourWeatherFirstEighth->m_icon->setPixmap(firstEighthPixmap);
    // ----------- 第二页 -------------
    m_onehourWeatherSecondFirst->m_icon->resize(ICON_SIZE);
    QPixmap secondFirstPixmap(m_secondFirstIconPath);
    m_onehourWeatherSecondFirst->m_icon->setPixmap(secondFirstPixmap);

    m_onehourWeatherSecondSecond->m_icon->resize(ICON_SIZE);
    QPixmap secondSecondPixmap(m_secondSecondIconPath);
    m_onehourWeatherSecondSecond->m_icon->setPixmap(secondSecondPixmap);

    m_onehourWeatherSecondThird->m_icon->resize(ICON_SIZE);
    QPixmap secondThirdPixmap(m_secondThirdIconPath);
    m_onehourWeatherSecondThird->m_icon->setPixmap(secondThirdPixmap);

    m_onehourWeatherSecondFourth->m_icon->resize(ICON_SIZE);
    QPixmap secondFourthPixmap(m_secondFourthIconPath);
    m_onehourWeatherSecondFourth->m_icon->setPixmap(secondFourthPixmap);

    m_onehourWeatherSecondFifth->m_icon->resize(ICON_SIZE);
    QPixmap secondFifthPixmap(m_secondFifthIconPath);
    m_onehourWeatherSecondFifth->m_icon->setPixmap(secondFifthPixmap);

    m_onehourWeatherSecondSixth->m_icon->resize(ICON_SIZE);
    QPixmap secondSixthPixmap(m_secondSixthIconPath);
    m_onehourWeatherSecondSixth->m_icon->setPixmap(secondSixthPixmap);

    m_onehourWeatherSecondSeventh->m_icon->resize(ICON_SIZE);
    QPixmap secondSeventhPixmap(m_secondSeventhIconPath);
    m_onehourWeatherSecondSeventh->m_icon->setPixmap(secondSeventhPixmap);

    m_onehourWeatherSecondEighth->m_icon->resize(ICON_SIZE);
    QPixmap secondEighthPixmap(m_secondEighthIconPath);
    m_onehourWeatherSecondEighth->m_icon->setPixmap(secondEighthPixmap);
    // ------------------ 第三页 ----------------------------
    m_onehourWeatherThirdFirst->m_icon->resize(ICON_SIZE);
    QPixmap thirdFirstPixmap(m_thirdFirstIconPath);
    m_onehourWeatherThirdFirst->m_icon->setPixmap(thirdFirstPixmap);

    m_onehourWeatherThirdSecond->m_icon->resize(ICON_SIZE);
    QPixmap thirdSecondPixmap(m_thirdSecondIconPath);
    m_onehourWeatherThirdSecond->m_icon->setPixmap(thirdSecondPixmap);

    m_onehourWeatherThirdThird->m_icon->resize(ICON_SIZE);
    QPixmap thirdThirdPixmap(m_thirdThirdIconPath);
    m_onehourWeatherThirdThird->m_icon->setPixmap(thirdThirdPixmap);

    m_onehourWeatherThirdFourth->m_icon->resize(ICON_SIZE);
    QPixmap thirdFourthPixmap(m_thirdFourthIconPath);
    m_onehourWeatherThirdFourth->m_icon->setPixmap(thirdFourthPixmap);

    m_onehourWeatherThirdFifth->m_icon->resize(ICON_SIZE);
    QPixmap thirdFifthPixmap(m_thirdFifthIconPath);
    m_onehourWeatherThirdFifth->m_icon->setPixmap(thirdFifthPixmap);

    m_onehourWeatherThirdSixth->m_icon->resize(ICON_SIZE);
    QPixmap thirdSixthPixmap(m_thirdSixthIconPath);
    m_onehourWeatherThirdSixth->m_icon->setPixmap(thirdSixthPixmap);

    m_onehourWeatherThirdSeventh->m_icon->resize(ICON_SIZE);
    QPixmap thirdSeventhPixmap(m_thirdSeventhIconPath);
    m_onehourWeatherThirdSeventh->m_icon->setPixmap(thirdSeventhPixmap);

    m_onehourWeatherThirdEighth->m_icon->resize(ICON_SIZE);
    QPixmap thirdEighthPixmap(m_thirdEighthIconPath);
    m_onehourWeatherThirdEighth->m_icon->setPixmap(thirdEighthPixmap);
}

void perhour::initConnect()
{
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherFirstFirst, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherFirstSecond, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherFirstThird, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherFirstFourth, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherFirstFifth, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherFirstSixth, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherFirstSeventh, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherFirstEighth, &onehourweather::isFullScreen);

    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherSecondFirst, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherSecondSecond, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherSecondThird, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherSecondFourth, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherSecondFifth, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherSecondSixth, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherSecondSeventh, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherSecondEighth, &onehourweather::isFullScreen);

    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherThirdFirst, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherThirdSecond, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherThirdThird, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherThirdFourth, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherThirdFifth, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherThirdSixth, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherThirdSeventh, &onehourweather::isFullScreen);
    connect(this, &perhour::sendIsFullScreen, m_onehourWeatherThirdEighth, &onehourweather::isFullScreen);

    connect(ViewVar::getInstance(), &ViewVar::sigChangeModeToPc, this, &perhour::slotChangePCMode);
    connect(ViewVar::getInstance(), &ViewVar::sigChangeModeToPadH, this, &perhour::slotChangePadHMode);
    connect(ViewVar::getInstance(), &ViewVar::sigChangeModeToPadV, this, &perhour::slotChangePadVMode);
}

void perhour::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);  // 反锯齿;
    //设置背景颜色
    QColor color = this->palette().color(QPalette::Dark);
    QPalette pal(this->palette());
    pal.setColor(QPalette::Background, QColor(color));
    this->setPalette(pal);
    QBrush brush = QBrush(color);
    painter.setBrush(brush);
    painter.setOpacity(0.1);
    painter.setPen(Qt::transparent);
    int radius = 3 * ViewVar::SAME_ITEMRADIUS;
    QStyleOption opt;
    opt.init(this);
    painter.drawRoundedRect(opt.rect, radius, radius);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
    QWidget::paintEvent(event);
}
// 平板模式（竖）
void perhour::slotChangePadHMode()
{
    this->setFixedHeight(214);
    m_scrollArea->setFixedSize(1240, 214);
    int space = (m_scrollArea->width() - (8 * 80) - (2 * 10)) / 7;
    m_perhourLayout->setSpacing(space);
    m_perhourLayout->setMargin(0);
    m_perhourLayout->setContentsMargins(10, 40, 10, 0);
    m_perhourWid->resize(((24 * 80) + (23 * space)), 160);
    return;
}
// 平板模式（竖）
void perhour::slotChangePadVMode()
{ 
    this->setFixedHeight(214);
    m_scrollArea->setFixedSize(790, 214);
    int space = (m_scrollArea->width() - (8 * 80) - (2 * 10)) / 7;
    m_perhourLayout->setSpacing(space);
    m_perhourLayout->setMargin(0);
    m_perhourLayout->setContentsMargins(10, 40, 10, 0);
    m_perhourWid->resize(((24 * 80) + (23 * space)), 160);
    return;
}
// PC模式
void perhour::slotChangePCMode()
{
    this->setFixedHeight(200);
    m_scrollArea->setFixedSize(730, 200);
    int space = (m_scrollArea->width() - (8 * 80) - (2 * 10)) / 7;
    m_perhourLayout->setSpacing(space);
    m_perhourLayout->setMargin(0);
    m_perhourLayout->setContentsMargins(10, 40, 10, 0);
    m_perhourWid->resize(((24 * 80) + (23 * space)), 140);
    return;
}
