void MainWindow::changeEvent(QEvent *e) { if(e->type() == QEvent::ActivationChange && isActiveWindow()) { bringToTop(); } if(e->type() == QEvent::WindowStateChange) { if(isMinimized()) { playlist.hide(); songWindow.hide(); songSearch.hide(); outputSettings.hide(); settingsWindow.hide(); } else { playlist.show(); songWindow.show(); outputSettings.show(); settingsWindow.show(); songSearch.show(); } } QMainWindow::changeEvent(e); }
bool MainWindow::eventFilter(QObject *target, QEvent *event) { switch(event->type()) { case QEvent::Wheel: if(target == &songWindow) { QWheelEvent* wEvent = (QWheelEvent*)event; long timeRange = settings->getViewTimeRange() - wEvent->delta(); timeRange = timeRange < 1000 ? 1000 : timeRange > 10000 ? 10000 : timeRange; settings->setViewTimeRange(timeRange); settingsWindow.refresh(); return true; } break; case QEvent::KeyPress: keyPressEvent((QKeyEvent*)event); break; case QEvent::ApplicationActivate: bringToTop(); return true; case QEvent::Hide: if(target == &songWindow) ui->songCheckbox->setChecked(false); else if(target == & playlist) ui->playlistCheckbox->setChecked(false); else if(target == & outputSettings) ui->outputCheckbox->setChecked(false); else if(target == & settingsWindow) ui->settingsCheckbox->setChecked(false); else if(target == & tutorial) ui->tutorialCheckbox->setChecked(false); else if(target == & songSearch) ui->songSearchCheckbox->setChecked(false); break; case QEvent::Show: if(target == &songWindow) ui->songCheckbox->setChecked(true); else if(target == &playlist) ui->playlistCheckbox->setChecked(true); else if(target == &outputSettings) ui->outputCheckbox->setChecked(true); else if(target == &settingsWindow) ui->settingsCheckbox->setChecked(true); else if(target == & tutorial) ui->tutorialCheckbox->setChecked(true); else if(target == & songSearch) ui->songSearchCheckbox->setChecked(true); if(target == &songWindow || target == &playlist || target == &outputSettings || target == &songSearch || target == &settingsWindow) ((QWidget*)target)->setFocus(); break; default: return false; } return false; }
void bbzneighbors_data_gc() { uint8_t unmarked_count = 0; // Loop through neighbors' data for (uint8_t i = 0; i < bbzringbuf_size(&vm->neighbors.rb); ++i) { bbzneighbors_elem_t* entry = (bbzneighbors_elem_t*)bbzringbuf_at (&vm->neighbors.rb, i); // If it has not a mark, remove it if (!bbzneighbors_data_hasmark(*entry)) { bringToTop(&vm->neighbors.rb, i); ++unmarked_count; #ifndef BBZ_DISABLE_SWARMLIST_BROADCASTS bbzswarm_rmentry(entry->robot); #endif // !BBZ_DISABLE_SWARMLIST_BROADCASTS } else { bbzneighbors_data_unmark(*entry); } } // Delete all removed element for (uint8_t i = 0; i < unmarked_count; ++i) { bbzringbuf_pop(&vm->neighbors.rb); } }