void VoiceStateWidget::UpdateVoiceActivity() { voice_activity_ -= static_cast<double>(VOICE_ACTIVITY_UPDATE_INTERVAL_MS_)/VOICE_ACTIVITY_FADEOUT_MAX_MS_; if (voice_activity_ < 0) voice_activity_ = 0; UpdateStyleSheet(); }
void VoiceStateWidget::setState(State state) { State old_state = state_; state_ = state; if (old_state == STATE_OFFLINE && state == STATE_ONLINE) voice_activity_ = 1.0; // for notificate user about voice tranmission set on UpdateStyleSheet(); emit StateChanged(); }
bool StyleSheetLoader::eventFilter(QObject* obj, QEvent* event) { if (event->type() != QEvent::PaletteChange) return false; QWidget* widget = qobject_cast<QWidget*>(obj); if (!widget || !filenames_.contains(widget)) return false; UpdateStyleSheet(widget); return false; }
VoiceStateWidget::VoiceStateWidget() : QPushButton(0), state_(STATE_OFFLINE) { setObjectName("stateIndicatorWidget"); // for style sheets ( works only if there is only one instance of this class ) UpdateStyleSheet(); setMinimumSize(32,32); update_timer_.start(VOICE_ACTIVITY_UPDATE_INTERVAL_MS_); update_timer_.setSingleShot(false); connect(&update_timer_, SIGNAL(timeout()), SLOT(UpdateVoiceActivity()) ); }
void VoiceStateWidget::SetVoiceActivity(double activity) { if (activity > 1) activity = 1; if (activity < 0) activity = 0; if (activity > voice_activity_) voice_activity_ = activity; UpdateStyleSheet(); }
VoiceUsersInfoWidget::VoiceUsersInfoWidget(QWidget* parent) : QPushButton(parent), count_label_(new QLabel(this)), user_count_(0) { count_label_->setObjectName("voiceUserCount"); setMinimumSize(42,32); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); setObjectName("voiceUsersInfoWidget"); // for stylesheets (There can be obly one instance of this class) UpdateStyleSheet(); }
void StyleSheetLoader::SetStyleSheet(QWidget* widget, const QString &filename) { filenames_[widget] = filename; widget->installEventFilter(this); UpdateStyleSheet(widget); }
void VoiceUsersInfoWidget::SetUsersCount(int count) { user_count_ = count; UpdateStyleSheet(); }