Exemplo n.º 1
0
Dialog::Dialog(QWidget * nextWidget,QWidget *parent) :
    nextWidget(nextWidget),
    QDialog(parent),
    ui(new Ui::Dialog)
{

    logoButton = new QPushButton(this);

    QPalette palette(this->palette());
    palette.setColor(QPalette::Background,Qt::darkGray);
    this->setPalette(palette);

//    QPixmap pixmap(":/logo.bmp");
    QPixmap pixmap(":/logo.jpg");

    this->logoButton->resize(QSize(pixmap.width(),pixmap.height()));

    this->logoButton->setIconSize(QSize(pixmap.width(),pixmap.height()));

     this->logoButton->setIcon(QIcon(pixmap));

    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint|Qt::WindowSystemMenuHint);
    timer.setInterval(40);

    if (nextWidget)
    {
        connect(this,SIGNAL(turnToYou()),nextWidget,SLOT(startTimer()));
    }

    connect(&timer,SIGNAL(timeout()),this,SLOT(moveLogo()));

    this->logoButton->setVisible(false);
}
void ScreenManager::SetScreen(SCREEN_NAME::ENUM screen)
{
    //if( !screenMap.contains(screen) )
    //{
    //    LOG_ERROR( "Tried to set active screen to non-existant screen");
    //    return;
    //}
    CatanScreen *newScreen = screenMap[screen];
    Q_ASSERT( newScreen );

    if( activeScreen == newScreen )
        return;

    if( activeScreen )
    {
        QPoint deltaPos = newScreen->GetPos() - activeScreen->GetPos();

        activeScreen->SlideTo(QPoint(mainWindow->width()*-deltaPos.x(),
                                     mainWindow->height()*-deltaPos.y()),
                                     ScreenTransitionSpeed //speed
                              );
        activeScreen->setEnabled(false);
        activeScreen->SetActive(false);
        activeScreen->setFocusPolicy(Qt::NoFocus);

        newScreen->move(QPoint(mainWindow->width()*deltaPos.x(),
                               mainWindow->height()*deltaPos.y()));
        newScreen->SlideTo(QPoint(0,0), ScreenTransitionSpeed);

        connect( activeScreen, SIGNAL(SlideFinished()),
                 this, SLOT(hideScreen()) );
    }
    else
    {
        newScreen->move(QPoint(0,0));
        newScreen->setEnabled(true);
    }
    activeScreen = newScreen;
    newScreen->SetActive(true);
    newScreen->setVisible(true);
    newScreen->setFocusPolicy(Qt::StrongFocus);
    //newScreen->setFocus();
    currentScreen = screen;

    moveLogo();
    newScreen->setFocus();
}
void ScreenManager::ForceSetScreen(SCREEN_NAME::ENUM screen)
{
    CatanScreen *newScreen = screenMap[screen];
    if( activeScreen )
    {
        activeScreen->setVisible(false);
        activeScreen->setEnabled(false);
        activeScreen->SetActive(false);
        activeScreen->setFocusPolicy(Qt::NoFocus);
    }
    activeScreen = newScreen;
    newScreen->move(QPoint(0,0));
    newScreen->setEnabled(true);
    newScreen->SetActive(true);
    newScreen->setVisible(true);
    newScreen->setFocusPolicy(Qt::StrongFocus);
    newScreen->setFocus();
    currentScreen = screen;
    moveLogo();
}