#include <QPainter>
#include <QSound>
#include <QSettings>
#include "intro.h"
Intro::Intro(QWidget *parent) : QWidget(parent)
{
resize(800,480);
frame = 0;
timerId = startTimer(10);
introEnabled = QSettings("dpf.ini", QSettings::IniFormat).value("ShowIntro", true).toBool();
if (introEnabled)
{
QSound::play("sounds/Startup.wav");
}
}
Intro::~Intro()
{
}
void Intro::paintEvent(QPaintEvent *pe)
{
if (frame < 80) {
QPainter p(this);
p.setPen(Qt::NoPen);
p.setBrush(QColor(frame*3,frame*3,frame*3));
p.drawRect(0,0,800,480);
} else if (frame < 160) {
QPainter p(this);
p.setPen(Qt::NoPen);
p.setBrush(QColor(255,255,255));
p.drawRect(0,0,800,480);
p.drawPixmap(365,230-frame/2,QPixmap("pics/logo.png"));
} else if (frame < 300) {
QPainter p(this);
p.setPen(Qt::NoPen);
p.setBrush(QColor(255,255,255));
p.drawRect(0,0,800,480);
p.drawPixmap(365,230-80,QPixmap("pics/logo.png"));
p.setOpacity((frame-160)/80.0);
p.setPen(QColor(64,32,64));
//p.setFont(QFont("NeuStyle", 16));
//p.drawText(340,280,"InvertedLogic");
p.setFont(QFont("Bank Gothic", 18));
p.drawText(345,280," Samsung");
} else {
QPainter p(this);
p.setOpacity((380-frame)/80.0);
p.setPen(Qt::NoPen);
p.setBrush(QColor(255,255,255));
p.drawRect(0,0,800,480);
p.drawPixmap(365,230-80,QPixmap("pics/logo.png"));
p.setPen(QColor(64,32,64));
//p.setFont(QFont("NeuStyle", 16));
//p.drawText(340,280,"InvertedLogic");
p.setFont(QFont("Bank Gothic", 18));
p.drawText(345,280," Samsung");
}
}
void Intro::timerEvent(QTimerEvent *te)
{
update();
frame++;
const int lastFrame = (introEnabled) ? 300 : 1;
if (frame == lastFrame)
{
emit setStage(-2);
}
if (frame > lastFrame)
{
killTimer(timerId);
hide();
}
}