if (m_currentPage && animate)
{
// Don't allow the user to interact with the old page as it's being carried away
m_currentPage->setEnabled(false);
QRect a
= ui
->placeholder
->geometry
();
QRect b
= QRect(a.
width(), a.
y(), a.
width(), a.
height());
QRect c
= QRect(-a.
width(), a.
y(), a.
width(), a.
height());
int animationDuration = 400;
QPropertyAnimation *animation = new QPropertyAnimation(m_currentPage, "geometry", this);
animation->setStartValue(a);
animation->setEndValue(direction == Forward ? c : b);
animation->setDuration(animationDuration);
animation->setEasingCurve(QEasingCurve::OutQuad);
animation->start();
connect(animation, SIGNAL(finished()), m_currentPage, SLOT(deleteLater()));
QPropertyAnimation *animation2 = new QPropertyAnimation(newPage, "geometry", this);
animation2->setStartValue(direction == Forward ? b : c);
animation2->setEndValue(a);
animation2->setDuration(animationDuration);
animation2->setEasingCurve(QEasingCurve::OutQuad);
animation2->start();
connect(animation2, SIGNAL(finished()), newPage, SLOT(setFocus()));
}
else
{
// Remove previous page
clearLayout(ui->placeholder);
}
// Set new page
ui->placeholder->addWidget(newPage);
newPage->setFocus();
connect(newPage,
SIGNAL(setPage(KioskPage*,KioskMainWindow::Direction)),
SLOT(setPage(KioskPage*,KioskMainWindow::Direction)));
newPage->init();
m_currentPage = newPage;
languageChange();
if (animate)
{
newPage->hide();
QTimer::singleShot(100, newPage,
SLOT(show
()));
}
if (m_currentPage && animate)
{
// Don't allow the user to interact with the old page as it's being carried away
m_currentPage->setEnabled(false);
QRect a = ui->placeholder->geometry();
QRect b = QRect(a.width(), a.y(), a.width(), a.height());
QRect c = QRect(-a.width(), a.y(), a.width(), a.height());
int animationDuration = 400;
QPropertyAnimation *animation = new QPropertyAnimation(m_currentPage, "geometry", this);
animation->setStartValue(a);
animation->setEndValue(direction == Forward ? c : b);
animation->setDuration(animationDuration);
animation->setEasingCurve(QEasingCurve::OutQuad);
animation->start();
connect(animation, SIGNAL(finished()), m_currentPage, SLOT(deleteLater()));
QPropertyAnimation *animation2 = new QPropertyAnimation(newPage, "geometry", this);
animation2->setStartValue(direction == Forward ? b : c);
animation2->setEndValue(a);
animation2->setDuration(animationDuration);
animation2->setEasingCurve(QEasingCurve::OutQuad);
animation2->start();
connect(animation2, SIGNAL(finished()), newPage, SLOT(setFocus()));
}
else
{
// Remove previous page
clearLayout(ui->placeholder);
}
// Set new page
newPage->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
ui->placeholder->addWidget(newPage);
newPage->setFocus();
connect(newPage,
SIGNAL(setPage(KioskPage*,KioskMainWindow::Direction)),
SLOT(setPage(KioskPage*,KioskMainWindow::Direction)));
newPage->init();
m_currentPage = newPage;
languageChange();
if (animate)
{
newPage->hide();
QTimer::singleShot(100, newPage, SLOT(show()));
}
To copy to clipboard, switch view to plain text mode
Bookmarks