MobileSettingsWindow::MobileSettingsWindow(const qutim_sdk_0_3::SettingsItemList& settings, QObject* controller) : p(new MobileSettingsWindowPrivate) { setAttribute(Qt::WA_DeleteOnClose); p->controller = controller; //setup ui QWidget *w = new QWidget(this); QVBoxLayout *l = new QVBoxLayout(w); l->setMargin(0); l->setSpacing(0); p->stackedWidget = new SlidingStackedWidget(w); //init widgets p->settingsListWidget = new QListWidget(w); p->categoryListWidget = new QListWidget(w); p->stackedWidget->addWidget(p->categoryListWidget); p->stackedWidget->addWidget(p->settingsListWidget); p->categoryListWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); p->settingsListWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); p->actionBox = new ActionBox(this); p->backAct = new QAction(tr("Back"),this); p->backAct->setVisible(false); p->actionBox->addAction(p->backAct); p->closeAct = new QAction(tr("Close"),this); p->closeAct->setVisible(false); p->actionBox->addAction(p->closeAct); l->addWidget(p->stackedWidget); l->addWidget(p->actionBox); int width = style()->pixelMetric(QStyle::PM_LargeIconSize); QSize size = QSize(width, width); p->categoryListWidget->setIconSize(size); p->settingsListWidget->setIconSize(size); setCentralWidget(w); //connections connect(p->categoryListWidget, SIGNAL(activated(QModelIndex)), SLOT(onCategoryActivated(QModelIndex)) ); connect(p->settingsListWidget, SIGNAL(activated(QModelIndex)), SLOT(onCurrentItemActivated(QModelIndex)) ); connect(p->backAct,SIGNAL(triggered()),SLOT(slideUp())); connect(p->closeAct,SIGNAL(triggered()),SLOT(close())); connect(p->stackedWidget, SIGNAL(fingerGesture(enum SlidingStackedWidget::SlideDirection)), this,SLOT(fingerGesture(enum SlidingStackedWidget::SlideDirection))); loadSettings(settings); QTimer::singleShot(0, this, SLOT(initScrolling())); }
void ScrollingSystem::DoUpdate(float dt) { FOR_EACH_ENTITY_COMPONENT(Scrolling, a, sc) EltIt iter = elements.find(a); if (iter == elements.end()) { if ( glm::abs(glm::length(sc->direction) - 1) <= 0.001) { initScrolling(a, sc); iter = elements.find(a); } continue; } if (!sc->show) { ScrollingElement& se = iter->second; for (int i=0; i<2; i++) { RENDERING(se.e[i])->show = false; } continue; } LOGF_IF(sc->speed < 0, "Scrolling component '" << sc << "' has a speed < 0"); ScrollingElement& se = iter->second; for (int i=0; i<2; i++) { RENDERING(se.e[i])->show = true; AnchorComponent* tc = ANCHOR(se.e[i]); tc->position += sc->direction * (sc->speed * dt); bool isVisible = theRenderingSystem.isVisible(se.e[i]); if (!se.hasBeenVisible[i] && isVisible) { se.hasBeenVisible[i] = true; } else if (se.hasBeenVisible[i] && !isVisible) { se.imageIndex[i] = (se.imageIndex[i] + 2) % sc->images.size(); RENDERING(se.e[i])->texture = sc->images[se.imageIndex[i]]; const auto* ptc = TRANSFORM(a); tc->position = ANCHOR(se.e[(i+1)%2])->position - glm::vec2(sc->direction.x * ptc->size.x, sc->direction.y * ptc->size.y); se.hasBeenVisible[i] = false; } } END_FOR_EACH() }