#include "widget.h"
#include "ui_widget.h"
#include <QPixmap>


Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    n=0;
    ui->setupUi(this);

    // 设置 imageLable 的图片资源
    QPixmap pixmap;
    // : 开头表示引用 Qt 的资源文件
    pixmap.load(":/images/mario"); // 加载像素图
    ui->imageLable->resize(200,200);
    ui->imageLable->setPixmap(pixmap); // 设置 QLable 显示图片

    marioGif = new QMovie(":/images/mario");
    ui->imageLable->setMovie(marioGif);

}

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


void Widget::on_hotBtn_clicked()
{
    ui->whatLable->setText("巧乐兹");
}

void Widget::on_coldBtn_clicked()
{
    ui->whatLable->setText("厚棉被");
}

void Widget::on_coldBtn_2_clicked()
{

}

void Widget::on_setTitleIconBtn_clicked()
{
    n++;
    if(n%2==0){

        this->setWindowIcon(QIcon(":/images/save"));
        this->setWindowTitle("标题被修改了");
        showMaximized();
    } else{
        this->setWindowIcon(QIcon(""));
        this->setWindowTitle("");
        showNormal();
    }
}

void Widget::on_showImg_pressed()
{
    //ui->imageLable->hide();
    marioGif->start();
}

void Widget::on_showImg_released()
{
    marioGif->stop();
    //ui->imageLable->show();
}

void Widget::on_setImgBtn_pressed()
{
    QPixmap pixmap2;
    pixmap2.load(":/images/sunny");

    ui->showImg->setText("");
    ui->showImg->setIconSize(QSize(200,200));
    ui->showImg->setIcon(pixmap2);
}

void Widget::on_setImgBtn_released()
{
    ui->showImg->setText("图片运输中");
    ui->showImg->setIcon(QPixmap());
}

void Widget::on_setbgBtn_clicked()
{
//    setStyleSheet("background-color: red; color: white; font-size: 16px;");
    //setStyleSheet("background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #FF0000, stop:0.17 #FF7F00, stop:0.33 #FFFF00, stop:0.5 #00FF00, stop:0.67 #0000FF, stop:0.83 #4B0082, stop:1 #8B00FF);");
    //QString styleSheet = "background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0.5 #000000, stop:0 #FF00F0,stop:1 #0F0F0F);";
    //setStyleSheet(styleSheet);
    showFullScreen();


}

