void Capture::timerEvent( QTimerEvent * event ) { if ( event->timerId() != m_timer.timerId() || m_geometry.isNull() ) return QObject::timerEvent( event ); QPixmap grabbedPixmap = QPixmap::grabWindow( #ifdef Q_WS_X11 QX11Info::appRootWindow(), #else QApplication::desktop()->winId(), #endif m_geometry.left(), m_geometry.top(), m_geometry.width(), m_geometry.height() ); emit gotPixmap( grabbedPixmap, QCursor::pos() - QPoint( m_geometry.topLeft() ) ); #if 0 emit gotImage( m_images[ 4-m_currentIndex ] ); // TEMP m_timer.stop(); // rotate index if ( ++m_currentIndex >= m_images.size() ) m_currentIndex = 0; #endif }
void SelfAvatarFetcher::handleGetFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); const QImage& image = QImage::fromData (reply->readAll ()); emit gotImage (image); }
VCardDialog::VCardDialog (const UserInfo& info, PhotoStorage *storage, GeoResolver *geo, ICoreProxy_ptr proxy, QWidget *parent) : QDialog (parent) , Proxy_ (proxy) , Info_ (info) , Storage_ (storage) { Ui_.setupUi (this); setAttribute (Qt::WA_DeleteOnClose); Ui_.FirstName_->setText (info.FirstName_); Ui_.LastName_->setText (info.LastName_); Ui_.Nickname_->setText (info.Nick_); Ui_.Birthday_->setDate (info.Birthday_); Ui_.Birthday_->setDisplayFormat (info.Birthday_.year () != 1800 ? "dd MMMM yyyy" : "dd MMMM"); if (info.Gender_) Ui_.Gender_->setText (info.Gender_ == 1 ? tr ("female") : tr ("male")); Ui_.HomePhone_->setText (info.HomePhone_); Ui_.MobilePhone_->setText (info.MobilePhone_); auto timezoneText = QString::number (info.Timezone_) + " GMT"; if (info.Timezone_ > 0) timezoneText.prepend ('+'); Ui_.Timezone_->setText (timezoneText); QPointer<VCardDialog> safeThis (this); if (info.Country_ > 0) geo->GetCountry (info.Country_, [safeThis, this] (const QString& country) { if (safeThis) Ui_.Country_->setText (country); }); if (info.City_ > 0) geo->GetCity (info.City_, [safeThis, this] (const QString& country) { if (safeThis) Ui_.City_->setText (country); }); if (!info.BigPhoto_.isValid ()) return; const auto& image = storage->GetImage (info.BigPhoto_); if (image.isNull ()) connect (storage, SIGNAL (gotImage (QUrl)), this, SLOT (handleImage (QUrl))); else Ui_.PhotoLabel_->setPixmap (QPixmap::fromImage (image) .scaled (Ui_.PhotoLabel_->size (), Qt::KeepAspectRatio, Qt::SmoothTransformation)); }