/** * App::onImageLoaded(QString url, bool success, QString response) * * Handle the result of a loading image request. * * Basing on the result, we will update UI accordingly. * * --url, the url of the previous url * --success, the flag to indicate if the request was successful. * --response, this will carry some error information if the operation was not successful. * */ void App::onImageLoaded(QString url, bool success, QString response) { //get the LoadImage object LoadImage* img = qobject_cast<LoadImage*>(sender()); if (!img) { return; } connect(this, SIGNAL(finishUpdateImage()), img, SIGNAL(finishThread())); qDebug() << "Download complete: " << url; //find the url to photo index mapping QMap<QString, int>::iterator it = m_imageMap.find(url); if (it != m_imageMap.end()) { //stop indicator ActivityIndicator* activityId = m_root->findChild<ActivityIndicator*>(QString("image%1Indicator").arg(it.value())); if (activityId) { activityId->stop(); activityId->setVisible(false); } if (success) { //show the image ImageView* imageView = m_root->findChild<ImageView*>(QString("image%1").arg(it.value())); if (imageView) { QImage qm = img->getImage().rgbSwapped().scaled(768, 500, Qt::KeepAspectRatioByExpanding); //resize image to fit container bb::cascades::PixelBufferData pb = bb::cascades::PixelBufferData(PixelBufferData::RGBX, qm.width(), qm.height(), qm.width(), qm.bits()); bb::cascades::Image image(pb); imageView->setImage(image); imageView->setVisible(true); } } else { //show the label with the error from the retrieval Label* imageLabel = m_root->findChild<Label*>(QString("image%1Label").arg(it.value())); if (imageLabel) { imageLabel->setText(response); imageLabel->setVisible(true); } } m_imageMap.erase(it); } emit finishUpdateImage(); // no need to explicitly delete img, it has been destroyed when receiving the "finishThread" signal }
App::App() : m_pHighscoreDataModel(0), m_pGameManager(0), m_pScoreCounter(0), m_pSoundManager(0), m_pSettings( 0), m_fullscreenMode(true) { Page* page = Page::create(); Container* cont = Container::create(); cont->setLayout(DockLayout::create()); cont->setBackground(ImagePaint(QUrl("asset:///images/bg.png"))); ActivityIndicator* activity = ActivityIndicator::create(); activity->setPreferredHeight(200); activity->setPreferredWidth(200); activity->setVerticalAlignment(VerticalAlignment::Center); activity->setHorizontalAlignment(HorizontalAlignment::Center); cont->add(activity); activity->start(); page->setContent(cont); Application::instance()->setScene(page); QTimer::singleShot(2, this, SLOT(startApp())); }
void AntiPiracy::checkValidityAndSetScene(AbstractPane* root, QString urlToBypassHash) { // Save internally for future use if (root) { m_normalRoot = root; } m_urlToBypassHash = urlToBypassHash; // Check if the unlock key was already entered previously QSettings settings; settings.beginGroup("AntiPiracy"); if ((settings.contains("unlockKeyEnteredByUser")) && (this->hashThis(settings.value("unlockKeyEnteredByUser", "").toString()) == m_unlockKeyHash)) { // User already entered the correct key previously m_appInstalledFromBBW = true; } else { // The next code will check if the app was downloaded from BBW QDir dir("/pps/system/installer/appdetails/"); dir.setFilter(QDir::Files | QDir::System | QDir::Hidden | QDir::NoDotAndDotDot | QDir::AllEntries); QFileInfoList fileInfoList = dir.entryInfoList(); for (int i = 0; i < fileInfoList.size(); i++) { QString completePath = fileInfoList[i].path() + "/" + fileInfoList[i].fileName() + (fileInfoList[i].isDir() ? "/" : ""); if (this->checkFile(completePath)) { break; }; } } if ((m_appInstalledFromBBW) || (m_appInstalledFromBetaZone)) { // App was either installed from BBW/BetaZone or unlock key was previously entered correctly. // Set the normal main.qml as Scene Application::instance()->setScene(root); this->deleteLater(); } else { /* * Load a custom Page constructed in C++ to make sure it can't be altered * The Page is only a Label and an ActivityIndicator, but it's mostly used to be the * scene where the unlock key prompt will be shown */ Page *keyPromptPage = new Page(this); Container *keyPromptContainer = new Container(); keyPromptContainer->setLayout(new DockLayout()); Label *label = new Label(); label->setText(tr("Checking validity, please wait...")); label->setHorizontalAlignment(HorizontalAlignment::Center); ActivityIndicator *activityIndicator = new ActivityIndicator(); activityIndicator->setHorizontalAlignment(HorizontalAlignment::Center); activityIndicator->setMinHeight(300); activityIndicator->setMinWidth(activityIndicator->minHeight()); Container *container = new Container(); container->setHorizontalAlignment(HorizontalAlignment::Center); container->setVerticalAlignment(VerticalAlignment::Center); container->add(label); container->add(activityIndicator); keyPromptContainer->add(container); keyPromptPage->setContent(keyPromptContainer); Application::instance()->setScene(keyPromptPage); activityIndicator->start(); /* * Check online for a bypass. * This can be used while your app is in review period to avoid having the unlock prompt * shown to a BBW reviewer. To construct the bypass hash, use the function * printToConsoleHashOfThisKey() and pass the app version you'd like to whitelist * as a parameter. Use the hash printed to console and put it online. */ QUrl url(m_urlToBypassHash); QNetworkAccessManager *nam = new QNetworkAccessManager(this); QNetworkReply *reply = nam->get(QNetworkRequest(url)); connect(reply, SIGNAL(finished()), this, SLOT(onReplyFinished())); } }