MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / UpdateModeUi

Method UpdateModeUi

qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp:769–1094  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767}
768
769void Ui::OpenRGBDevicePage::UpdateModeUi()
770{
771 /*-----------------------------------------------------*\
772 | Read selected mode |
773 \*-----------------------------------------------------*/
774 unsigned int selected_mode = (unsigned int)ui->ModeBox->currentIndex();
775
776 /*-----------------------------------------------------*\
777 | Don't update the UI if the current mode is invalid |
778 \*-----------------------------------------------------*/
779 if(selected_mode < device->modes.size())
780 {
781 bool supports_per_led = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_PER_LED_COLOR );
782 bool supports_mode_specific = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR );
783 bool supports_random = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_RANDOM_COLOR );
784 bool supports_speed = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_SPEED );
785 bool supports_brightness = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_BRIGHTNESS);
786 bool supports_dir_lr = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_LR );
787 bool supports_dir_ud = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_UD );
788 bool supports_dir_hv = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_HV );
789 bool per_led = device->modes[selected_mode].color_mode == MODE_COLORS_PER_LED;
790 bool mode_specific = device->modes[selected_mode].color_mode == MODE_COLORS_MODE_SPECIFIC;
791 bool random = device->modes[selected_mode].color_mode == MODE_COLORS_RANDOM;
792 unsigned int dir = device->modes[selected_mode].direction;
793 bool manual_save = ( device->modes[selected_mode].flags & MODE_FLAG_MANUAL_SAVE );
794 bool automatic_save = ( device->modes[selected_mode].flags & MODE_FLAG_AUTOMATIC_SAVE );
795
796 if(supports_speed)
797 {
798 ui->SpeedSlider->blockSignals(true);
799 int current_speed;
800 InvertedSpeed = device->modes[selected_mode].speed_min > device->modes[selected_mode].speed_max;
801
802 if(InvertedSpeed)
803 {
804 /*-----------------------------------------------------*\
805 | If Speed Slider is inverted, invert value |
806 \*-----------------------------------------------------*/
807 ui->SpeedSlider->setMinimum(device->modes[selected_mode].speed_max);
808 ui->SpeedSlider->setMaximum(device->modes[selected_mode].speed_min);
809 current_speed = device->modes[selected_mode].speed_min - device->modes[selected_mode].speed + device->modes[selected_mode].speed_max;
810 }
811 else
812 {
813 ui->SpeedSlider->setMinimum(device->modes[selected_mode].speed_min);
814 ui->SpeedSlider->setMaximum(device->modes[selected_mode].speed_max);
815 current_speed = device->modes[selected_mode].speed;
816 }
817
818 ui->SpeedSlider->setValue(current_speed);
819 ui->SpeedSlider->setEnabled(true);
820 ui->SpeedSlider->blockSignals(false);
821 }
822 else
823 {
824 ui->SpeedSlider->blockSignals(true);
825 ui->SpeedSlider->setEnabled(false);
826 ui->SpeedSlider->blockSignals(false);

Callers

nothing calls this directly

Calls 4

snprintfFunction · 0.85
sizeMethod · 0.45
setEnabledMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected