void LfmItem::loadImage( const QUrl& url ) { QString imageUrl = url.toString(); QNetworkReply* reply = lastfm::nam()->get(QNetworkRequest( url )); connect( reply, SIGNAL( finished()), this, SLOT( onImageLoaded())); }
bool StelTexture::bind() { // qDebug() << "TEST bind" << fullPath; if (id != 0) { // The texture is already fully loaded, just bind and return true; #ifdef USE_OPENGL_ES2 glActiveTexture(GL_TEXTURE0); #endif glBindTexture(GL_TEXTURE_2D, id); return true; } if (errorOccured) return false; if (!isLoadingImage && loader == NULL) { isLoadingImage = true; loader = new ImageLoader(fullPath, 100); connect(loader, SIGNAL(finished(QImage)), this, SLOT(onImageLoaded(QImage))); connect(loader, SIGNAL(error(QString)), this, SLOT(onLoadingError(QString))); } return false; }
BioWidget::BioWidget( QWidget* p ) :QTextBrowser( p ), m_currentHoverWidget(0) { setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); connect(document()->documentLayout(), SIGNAL( documentSizeChanged(QSizeF)), SLOT( onBioChanged(QSizeF))); connect(this, SIGNAL(anchorClicked(QUrl)), SLOT(onAnchorClicked(QUrl))); m_widgetTextObject = new WidgetTextObject; viewport()->installEventFilter( this ); document()->documentLayout()->registerHandler( WidgetImageFormat, m_widgetTextObject ); ui.image = new HttpImageWidget(this); ui.image->setFixedWidth( 160 ); ui.image->setAlignment( Qt::AlignTop ); ui.onTour = new BannerWidget( tr("On Tour" ) ); ui.onTour->setBannerVisible( false ); ui.onTour->setWidget( ui.image ); ui.onTour->setFixedWidth( 170 ); ui.onTour->setObjectName( "onTour" ); connect( ui.image, SIGNAL(loaded()), SLOT(onImageLoaded())); connect( ui.image, SIGNAL(loaded()), SLOT(update())); connect( this, SIGNAL(highlighted(QString)), SLOT(onHighlighted(QString)) ); qDebug() << fontInfo().pixelSize(); }
void StelQGLTextureBackend::startAsynchronousLoading() { invariant(); startedLoading(); bool http = path.startsWith("http://"); bool pvr = path.endsWith(".pvr"); Q_ASSERT_X(!(http && pvr), Q_FUNC_INFO, "Can't load .pvr textures from network"); if(pvr) { // We're using a single QGLContext::bindTexture() call to load .pvr, // and that must be done in the main (GL) thread. // // (TODO): It might be possible to load it manually through GL calls // and separate file loading (separate thread) from uploading to the GPU // (GL thread). qWarning() << "Trying to load a .pvr texture asynchronously." "Asynchronous loading of .pvr is not implemented at the moment." "Will load the texture normally (this might cause lag)"; loadFromPVR(); return; } if(http) { loader = new StelHTTPTextureLoader(path, 100, renderer->getLoaderThread()); connect(loader, SIGNAL(finished(QImage)), this, SLOT(onImageLoaded(QImage))); connect(loader, SIGNAL(error(QString)), this, SLOT(onLoadingError(QString))); return; } loader = new StelFileTextureLoader(path, 100, renderer->getLoaderThread()); connect(loader, SIGNAL(finished(QImage)), this, SLOT(onImageLoaded(QImage))); connect(loader, SIGNAL(error(QString)), this, SLOT(onLoadingError(QString))); invariant(); }
PyObject* DetailView::loadDetail(PyObject *dict) { static QString nameFmt = "<span style=\" font-size:16pt; font-weight:600;\">%1</span> (rating: %2)"; if (!PyDict_Check(dict)) { PyErr_SetString(PyExc_TypeError, "The argument is not a dict."); return NULL; } PyObject *item; QString name; //name if (NULL != (item = PyDict_GetItemString(dict, "name"))) { name = PyString_AsQString(item); setWindowTitle(name + tr(" - Detail page")); } //rating if (NULL != (item = PyDict_GetItemString(dict, "rating"))) ui->nameLabel->setText(nameFmt.arg(name, QString::number(PyFloat_AsDouble(item)))); else ui->nameLabel->setText(nameFmt.arg(name, tr("Unknown"))); //length if (NULL != (item = PyDict_GetItemString(dict, "length"))) ui->lengthLabel->setText(PyString_AsQString(item)); else ui->lengthLabel->setText(tr("Unknown")); //summary if (NULL != (item = PyDict_GetItemString(dict, "summary"))) ui->summaryLabel->setText(PyString_AsQString(item)); else ui->summaryLabel->setText(tr("Unknown")); //others struct Item {const char *item_name; QLabel *label;}; struct Item items[] = { {"directors", ui->directorLabel}, {"script_writers", ui->scriptwriterLabel}, {"players", ui->playerLabel}, {"types", ui->typeLabel}, {"nations", ui->nationLabel}, {"languages", ui->langLabel}, {"dates", ui->dateLabel}, {"alt_names", ui->alternameLabel}, {NULL, NULL} }; for (struct Item *i = items; i->item_name; i++) { item = PyDict_GetItemString(dict, i->item_name); if (item) { QStringList list = PyList_AsQStringList(item); i->label->setText(list.join(" / ").simplified()); } else i->label->setText(tr("Unknown")); } // Source ui->sourceListWidget->clear(); urls.clear(); item = PyDict_GetItemString(dict, "source"); if (item) { int n = PyList_Size(item); for (int i = 0; i < n; i += 2) { QString name = PyString_AsQString(PyList_GetItem(item, i)); const char *url = PyString_AsString(PyList_GetItem(item, i+1)); ui->sourceListWidget->addItem(name); urls.append(url); } } // Image item = PyDict_GetItemString(dict, "image"); if (item) { QNetworkRequest request(QUrl(PyString_AsQString(item))); request.setRawHeader("User-Agent", "moonplayer"); reply = access_manager->get(request); connect(reply, SIGNAL(finished()), this, SLOT(onImageLoaded())); } Py_IncRef(Py_None); return Py_None; }