void Transfer::setStatus(Status s) { if (s != status()) { m_status = s; Logger::log(QString("Transfer::setStatus(). ID: %1, Status: %2").arg(id()).arg(statusString()), Logger::LowVerbosity); emit statusChanged(); } }
void ChatWidget::updateStatus(const QString &peer_id, int status) { if (isChatLobby) { // updateTitle is used return; } /* set font size for status */ if (peer_id.toStdString() == peerId) { // the peers status has changed QString peerName = QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()); // is scrollbar at the end? QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar(); bool atEnd = (scrollbar->value() == scrollbar->maximum()); switch (status) { case RS_STATUS_OFFLINE: ui->infoFrame->setVisible(true); ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online")); break; case RS_STATUS_INACTIVE: ui->infoFrame->setVisible(true); ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply")); break; case RS_STATUS_ONLINE: ui->infoFrame->setVisible(false); break; case RS_STATUS_AWAY: ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply")); ui->infoFrame->setVisible(true); break; case RS_STATUS_BUSY: ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply")); ui->infoFrame->setVisible(true); break; } QString statusString("<span style=\"font-size:11pt; font-weight:500;""\">%1</span>"); ui->titleLabel->setText(peerName + " (" + statusString.arg(StatusDefs::name(status)) + ")") ; peerStatus = status; if (atEnd) { // scroll to the end scrollbar->setValue(scrollbar->maximum()); } emit infoChanged(this); emit statusChanged(status); return; } // ignore status change }
void BStatusView::Draw(BRect updateRect) { if (fBitmap) { BPoint location; location.x = (fStatusBar->Frame().left - fBitmap->Bounds().Width()) / 2; location.y = (Bounds().Height()- fBitmap->Bounds().Height()) / 2; DrawBitmap(fBitmap, location); } BRect bounds(Bounds()); be_control_look->DrawRaisedBorder(this, bounds, updateRect, ViewColor()); SetHighColor(0, 0, 0); BPoint tp = fStatusBar->Frame().LeftBottom(); font_height fh; GetFontHeight(&fh); tp.y += ceilf(fh.leading) + ceilf(fh.ascent); if (IsPaused()) { DrawString(B_TRANSLATE("Paused: click to resume or stop"), tp); return; } BFont font; GetFont(&font); float normalFontSize = font.Size(); float smallFontSize = max_c(normalFontSize * 0.8f, 8.0f); float availableSpace = fStatusBar->Frame().Width(); availableSpace -= be_control_look->DefaultLabelSpacing(); // subtract to provide some room between our two strings float destinationStringWidth = 0.f; BString destinationString(_DestinationString(&destinationStringWidth)); availableSpace -= destinationStringWidth; float statusStringWidth = 0.f; BString statusString(_StatusString(availableSpace, smallFontSize, &statusStringWidth)); if (statusStringWidth > availableSpace) { TruncateString(&destinationString, B_TRUNCATE_MIDDLE, availableSpace + destinationStringWidth - statusStringWidth); } BPoint textPoint = fStatusBar->Frame().LeftBottom(); textPoint.y += ceilf(fh.leading) + ceilf(fh.ascent); if (destinationStringWidth > 0) { DrawString(destinationString.String(), textPoint); } SetHighColor(tint_color(LowColor(), B_DARKEN_4_TINT)); font.SetSize(smallFontSize); SetFont(&font, B_FONT_SIZE); textPoint.x = fStatusBar->Frame().right - statusStringWidth; DrawString(statusString.String(), textPoint); font.SetSize(normalFontSize); SetFont(&font, B_FONT_SIZE); }