You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.5 KiB

6 months ago
/******************************************************************
Copyright © Deng Zhimao Co., Ltd. 1990-2021. All rights reserved.
* @projectName 03_appmainview
* @brief widget.cpp
* @author Deng Zhimao
* @email 1252699831@qq.com
* @net www.openedv.com
* @date 2021-06-09
*******************************************************************/
#include "widget.h"
#include <QPushButton>
#include <QDebug>
#include <QThread>
AppMainView::AppMainView(QWidget *parent)
{
this->setParent(parent);
this->setGeometry(0, 0, 800, 480);
this->setMinimumSize(800, 480);
bgWidget = new QWidget(this);
bgWidget->setStyleSheet("border-image: url(:/images/bg.png)");
mySlidePage = new SlidePage(this);
mySlidePage->resize(this->size());
/*for (int i = 0; i < 3; i++) {
appDemo[i] = new AppDemo();
mySlidePage->addPage(appDemo[i]);
}*/
appDemo[0] = new AppDemo();
mySlidePage->addPage(appDemo[0]);
musicplay = new music();
/*
线
music *musicplay;
QThread* musictread;
musicplay->moveToThread(musictread);
connect(musictread, &QThread::started, musicplay, &music::startPlaying); // 线程开始时开始播放
connect(musictread, &QThread::finished, musicplay, &QObject::deleteLater); // 线程结束时删除 musicplay 对象
connect(musictread, &QThread::finished, musictread, &QObject::deleteLater); // 线程结束时删除线程对象
*/
//music
connect(appDemo[0], SIGNAL(Music_State(bool)),this, SLOT(Music_Handle(bool)));
connect(musicplay, SIGNAL(Music_close(bool)),this, SLOT(Music_Handle(bool)));
connect(musicplay,SIGNAL(Music_Minisize(bool)),this, SLOT(Music_Mini(bool)));
}
AppMainView::~AppMainView()
{
}
void AppMainView::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
mySlidePage->resize(this->size());
bgWidget->resize(this->size());
}
void AppMainView::Music_Handle(bool FlMusic)
{
if(FlMusic)
{
mySlidePage->close();
musicplay->show();
qDebug() << "open success";
}
else
{
mySlidePage->show();
musicplay->close();
musicplay->stopmusic();
qDebug() << "close success";
}
}
void AppMainView::Music_Mini(bool FlMusic)
{
if(FlMusic)
{
musicplay->showMinimized(); // 最小化窗口
mySlidePage->show();
qDebug() << "最小化music";
}
else {
musicplay->showNormal(); // 恢复窗口
qDebug() << "Music player restored.";
}
}