HWInfo::HWInfo(QObject *parent, const QVariantList &args) : SM::Applet(parent, args), m_info(0), m_icon(0) { resize(234 + 20 + 23, 135 + 20 + 25); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(updateHtml())); }
void FOX16_HtmlLabel::create() { FXFrame::create(); if (m_icon) m_icon->create(); updateHtml(); recalc(); }
void FOX16_HtmlLabel::layout() { #if 0 int w; m_haveDefaultDims=false; if (options & FLAGS_NO_WORDWRAP) w=-1; else if (options & FLAGS_USE_FULL_WIDTH) { w=width; if (m_icon) w-=(m_icon->getWidth()+ICON_SPACE); } else w=m_maxDefaultWidth; if (m_htmlCtx==NULL) updateHtml(); m_htmlCtx->layout(w-border*2, height-border*2); update(); flags&=~FLAG_DIRTY; #else int w; //DBG_ERROR(0, "Layout[%s]: Width=%d, height=%d", m_text.text(), width, height); if (m_htmlCtx==NULL) updateHtml(); if (!m_haveDefaultDims) calcDefaultDims(); if (options & FLAGS_NO_WORDWRAP) w=-1; else if (options & FLAGS_USE_FULL_WIDTH) { w=width; if (m_icon) w-=(m_icon->getWidth()+ICON_SPACE); } else w=m_defaultWidth; m_htmlCtx->layout(w-border*2, height-border*2); update(); flags&=~FLAG_DIRTY; #endif }
void FOX16_HtmlLabel::setText(const FXString& text) { m_haveDefaultDims=false; m_text=text; updateHtml(); flags|=FLAG_DIRTY; layout(); recalc(); update(); }
void TwitterApiWhoisWidget::avatarFetchError(const QString& remoteUrl, const QString& errMsg) { kDebug(); Q_UNUSED(errMsg); if( remoteUrl == d->currentPost.author.profileImageUrl ){ ///Avatar fetching is failed! but will not disconnect to get the img if it fetches later! QString url = "img://profileImage"; d->wid->document()->addResource( QTextDocument::ImageResource, url, KIcon("image-missing").pixmap(48) ); updateHtml(); } }
void TwitterApiWhoisWidget::avatarFetched(const QString& remoteUrl, const QPixmap& pixmap) { kDebug(); if ( remoteUrl == d->currentPost.author.profileImageUrl ) { QString url = "img://profileImage"; d->wid->document()->addResource( QTextDocument::ImageResource, url, pixmap ); updateHtml(); disconnect( Choqok::MediaManager::self(), SIGNAL( imageFetched(QString,QPixmap)), this, SLOT(avatarFetched(QString, QPixmap) ) ); disconnect( Choqok::MediaManager::self(), SIGNAL(fetchError(QString,QString)), this, SLOT(avatarFetchError(QString,QString)) ); } }
FXint FOX16_HtmlLabel::getDefaultWidth() { int w; if (m_htmlCtx==NULL) updateHtml(); if (!m_haveDefaultDims) calcDefaultDims(); w=m_defaultWidth; if (m_icon) w+=m_icon->getWidth()+ICON_SPACE; //DBG_ERROR(0, "GetDefaultWidth[%s]: Width= %d", m_text.text(), w); return w; }
FXint FOX16_HtmlLabel::getDefaultHeight() { int h; if (m_htmlCtx==NULL) updateHtml(); if (!m_haveDefaultDims) calcDefaultDims(); h=m_defaultHeight; if (m_icon) { int ih; ih=m_icon->getHeight(); if (ih>h) h=ih; } //DBG_ERROR(0, "GetDefaultHeight[%s]: Height= %d", m_text.text(), h); return h; }
void TwitterApiWhoisWidget::userInfoReceived(KJob* job) { kDebug(); if(job->error()){ kError()<<"Job Error: "<<job->errorString(); if( Choqok::UI::Global::mainWindow()->statusBar() ) Choqok::UI::Global::mainWindow()->statusBar()->showMessage(job->errorString()); slotCancel(); return; } KIO::StoredTransferJob *stj = qobject_cast<KIO::StoredTransferJob *>(job); // kDebug()<<stj->data(); QJson::Parser parser; bool ok; QVariantMap map = parser.parse(stj->data(), &ok).toMap(); Choqok::Post post; if ( !ok ){ kDebug()<<"JSON parsing failed! Data is:\n\t"<<stj->data(); d->errorMessage = i18n("Cannot load user information."); updateHtml(); showForm(); return; } QString timeStr; d->errorMessage = map["error"].toString(); if( d->errorMessage.isEmpty() ) { //No Error post.author.realName = map["name"].toString(); post.author.userName = map["screen_name"].toString(); post.author.location = map["location"].toString(); post.author.description = map["description"].toString(); post.author.profileImageUrl = map["profile_image_url"].toString(); post.author.homePageUrl = map["url"].toString(); d->timeZone = map["time_zone"].toString(); d->followersCount = map["followers_count"].toString(); d->friendsCount = map["friends_count"].toString(); d->statusesCount = map["statuses_count"].toString(); QVariantMap var = map["status"].toMap(); post.content = var["text"].toString(); post.creationDateTime = d->mBlog->dateFromString(var["created_at"].toString()); post.isFavorited = var["favorited"].toBool(); post.postId = var["id"].toString(); post.replyToPostId = var["in_reply_to_status_id"].toString(); post.replyToUserId = var["in_reply_to_user_id"].toString(); post.replyToUserName = var["in_reply_to_screen_name"].toString(); post.source = var["source"].toString(); d->currentPost = post; } updateHtml(); showForm(); QPixmap *userAvatar = Choqok::MediaManager::self()->fetchImage( post.author.profileImageUrl, Choqok::MediaManager::Async ); if(userAvatar) { d->wid->document()->addResource( QTextDocument::ImageResource, QUrl("img://profileImage"), *(userAvatar) ); } else { connect( Choqok::MediaManager::self(), SIGNAL( imageFetched(QString,QPixmap)), this, SLOT(avatarFetched(QString, QPixmap) ) ); connect( Choqok::MediaManager::self(), SIGNAL(fetchError(QString,QString)), this, SLOT(avatarFetchError(QString,QString)) ); } }