Add detection progress bar to the user interface
This commit is contained in:
parent
aaa2ecddc7
commit
e84cb98055
4 changed files with 65 additions and 6 deletions
|
|
@ -84,6 +84,11 @@ void ResourceManager::DeviceListChanged()
|
|||
DeviceListChangeMutex.unlock();
|
||||
}
|
||||
|
||||
unsigned int ResourceManager::GetDetectionPercent()
|
||||
{
|
||||
return(detection_percent);
|
||||
}
|
||||
|
||||
void ResourceManager::DetectDevices()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
|
|
@ -95,6 +100,12 @@ void ResourceManager::DetectDevices()
|
|||
void ResourceManager::DetectDevicesThreadFunction()
|
||||
{
|
||||
unsigned int prev_count = 0;
|
||||
float percent = 0.0f;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Start at 0% detection progress |
|
||||
\*-------------------------------------------------*/
|
||||
detection_percent = 0;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Detect i2c busses |
|
||||
|
|
@ -120,6 +131,10 @@ void ResourceManager::DetectDevicesThreadFunction()
|
|||
DeviceListChanged();
|
||||
}
|
||||
prev_count = rgb_controllers.size();
|
||||
|
||||
percent = (i2c_detector_idx + 1.0f) / (i2c_device_detectors.size() + device_detectors.size());
|
||||
|
||||
detection_percent = percent * 100.0f;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
|
|
@ -138,5 +153,9 @@ void ResourceManager::DetectDevicesThreadFunction()
|
|||
DeviceListChanged();
|
||||
}
|
||||
prev_count = rgb_controllers.size();
|
||||
|
||||
percent = (detector_idx + 1.0f + i2c_device_detectors.size()) / (i2c_device_detectors.size() + device_detectors.size());
|
||||
|
||||
detection_percent = percent * 100.0f;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ public:
|
|||
|
||||
void RegisterDeviceListChangeCallback(ResourceManagerCallback new_callback, void * new_callback_arg);
|
||||
|
||||
unsigned int GetDetectionPercent();
|
||||
|
||||
void DeviceListChanged();
|
||||
|
||||
void DetectDevices();
|
||||
|
|
@ -43,6 +45,8 @@ public:
|
|||
private:
|
||||
static std::unique_ptr<ResourceManager> instance;
|
||||
|
||||
unsigned int detection_percent;
|
||||
|
||||
std::vector<i2c_smbus_interface*> busses;
|
||||
std::vector<RGBController*> rgb_controllers;
|
||||
std::vector<DeviceDetectorFunction> device_detectors;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,11 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
|||
SMBusToolsPage = NULL;
|
||||
SoftInfoPage = NULL;
|
||||
|
||||
ui->ButtonLoadProfile->setVisible(false);
|
||||
ui->ButtonSaveProfile->setVisible(false);
|
||||
ui->ButtonDeleteProfile->setVisible(false);
|
||||
ui->ProfileBox->setVisible(false);
|
||||
|
||||
ResourceManager::get()->RegisterDeviceListChangeCallback(UpdateInfoCallback, this);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
@ -409,6 +414,20 @@ void OpenRGBDialog2::on_ClientListUpdated()
|
|||
{
|
||||
ClearDevicesList();
|
||||
UpdateDevicesList();
|
||||
|
||||
ui->DetectionProgressBar->setRange(0, 100);
|
||||
ui->DetectionProgressBar->setValue(ResourceManager::get()->GetDetectionPercent());
|
||||
|
||||
if(ResourceManager::get()->GetDetectionPercent() == 100)
|
||||
{
|
||||
ui->DetectionProgressBar->setVisible(false);
|
||||
ui->DetectionProgressLabel->setVisible(false);
|
||||
|
||||
ui->ButtonLoadProfile->setVisible(true);
|
||||
ui->ButtonSaveProfile->setVisible(true);
|
||||
ui->ButtonDeleteProfile->setVisible(true);
|
||||
ui->ProfileBox->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue)
|
||||
|
|
|
|||
|
|
@ -62,27 +62,44 @@
|
|||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="ButtonDeleteProfile">
|
||||
<property name="text">
|
||||
<string>Delete Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QComboBox" name="ProfileBox"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="ButtonLoadProfile">
|
||||
<property name="text">
|
||||
<string>Load Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="ButtonSaveProfile">
|
||||
<property name="text">
|
||||
<string>Save Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="ButtonDeleteProfile">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="DetectionProgressLabel">
|
||||
<property name="text">
|
||||
<string>Delete Profile</string>
|
||||
<string>OpenRGB is detecting devices...</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QProgressBar" name="DetectionProgressBar">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue