Skip to content

Commit

Permalink
Small bugfix for item selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFeldmann committed Feb 25, 2024
1 parent 50e6941 commit 38b518e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions YUViewLib/src/video/rgb/videoHandlerRGB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ const auto componentShowMapper =
*/
videoHandlerRGB::RGBFormatList::RGBFormatList()
{
append(PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB));
append(PixelFormatRGB(10, DataLayout::Packed, ChannelOrder::RGB));
append(PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB, AlphaMode::First));
append(PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BRG));
append(PixelFormatRGB(10, DataLayout::Packed, ChannelOrder::BRG));
append(PixelFormatRGB(10, DataLayout::Planar, ChannelOrder::RGB));
this->append(PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB));
this->append(PixelFormatRGB(10, DataLayout::Packed, ChannelOrder::RGB));
this->append(PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB, AlphaMode::First));
this->append(PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BRG));
this->append(PixelFormatRGB(10, DataLayout::Packed, ChannelOrder::BRG));
this->append(PixelFormatRGB(10, DataLayout::Planar, ChannelOrder::RGB));
}

/* Put all the names of the RGB formats into a list and return it
Expand Down Expand Up @@ -400,11 +400,11 @@ void videoHandlerRGB::slotRGBFormatControlChanged()
auto selectionIdx = ui.rgbFormatComboBox->currentIndex();
auto nrBytesOldFormat = getBytesPerFrame();

if (selectionIdx == this->rgbPresetList.count())
const auto customFormatSelected = selectionIdx == this->rgbPresetList.count();
if (customFormatSelected)
{
DEBUG_RGB("videoHandlerRGB::slotRGBFormatControlChanged custom format");

// The user selected the "custom format..." option
videoHandlerRGBCustomFormatDialog dialog(this->srcPixelFormat);
if (dialog.exec() == QDialog::Accepted)
this->srcPixelFormat = dialog.getSelectedRGBFormat();
Expand All @@ -415,24 +415,24 @@ void videoHandlerRGB::slotRGBFormatControlChanged()
{
// Valid pixel format which is not in the list. Add it...
this->rgbPresetList.append(this->srcPixelFormat);
int nrItems = ui.rgbFormatComboBox->count();
const QSignalBlocker blocker(ui.rgbFormatComboBox);
ui.rgbFormatComboBox->insertItem(nrItems - 1,
QString::fromStdString(this->srcPixelFormat.getName()));
int nrItems = this->ui.rgbFormatComboBox->count();
const QSignalBlocker blocker(this->ui.rgbFormatComboBox);
this->ui.rgbFormatComboBox->insertItem(
nrItems - 1, QString::fromStdString(this->srcPixelFormat.getName()));
idx = this->rgbPresetList.indexOf(this->srcPixelFormat);
}

if (idx > 0)
if (idx >= 0)
{
// Format found. Set it without another call to this function.
const QSignalBlocker blocker(ui.rgbFormatComboBox);
const QSignalBlocker blocker(this->ui.rgbFormatComboBox);
ui.rgbFormatComboBox->setCurrentIndex(idx);
}

selectionIdx = idx;
}

this->setSrcPixelFormat(rgbPresetList.at(selectionIdx));
this->setSrcPixelFormat(this->rgbPresetList.at(selectionIdx));

// Set the current frame in the buffer to be invalid and clear the cache.
// Emit that this item needs redraw and the cache needs updating.
Expand Down

0 comments on commit 38b518e

Please sign in to comment.