<commit_before>#include "videosettings.h"

#include "ui_videosettings.h"

#include <ui/settings/camerainfo.h>
#include "settingshelper.h"
#include "settingskeys.h"

#include "common.h"

#include <QTableWidgetItem>
#include <QThread>
#include <QComboBox>

// video/DeviceID and video/Device are no checked in case we don't have a camera

const QStringList neededSettings = {SettingsKey::videoResultionWidth,
                                    SettingsKey::videoResultionHeight,
                                    SettingsKey::videoResolutionID,
                                    SettingsKey::videoInputFormat,
                                    SettingsKey::videoYUVThreads,
                                    SettingsKey::videoRGBThreads,
                                    SettingsKey::videoOpenHEVCThreads,
                                    SettingsKey::videoFramerateID,
                                    SettingsKey::videoFramerate,
                                    SettingsKey::videoFlipEnabled,
                                    SettingsKey::videoForceFlip,
                                    SettingsKey::videoOpenGL
                                   };

const QStringList kvazaarSettings = {SettingsKey::videoQP,
                                     SettingsKey::videoIntra,
                                     SettingsKey::videoSlices,
                                     SettingsKey::videoKvzThreads,
                                     SettingsKey::videoWPP,
                                     SettingsKey::videoOWF,
                                     SettingsKey::videoTiles,
                                     SettingsKey::videoTileDimensions,
                                     SettingsKey::videoVPS,
                                     SettingsKey::videoBitrate,
                                     SettingsKey::videoRCAlgorithm,
                                     SettingsKey::videoOBAClipNeighbours,
                                     SettingsKey::videoScalingList,
                                     SettingsKey::videoLossless,
                                     SettingsKey::videoMVConstraint,
                                     SettingsKey::videoQPInCU,
                                     SettingsKey::videoVAQ,
                                     SettingsKey::videoPreset
                                   };



VideoSettings::VideoSettings(QWidget* parent,
                             std::shared_ptr<CameraInfo> info)
  :
  QDialog(parent),
  currentDevice_(0),
  videoSettingsUI_(new Ui::VideoSettings),
  cam_(info),
  settings_(settingsFile, settingsFileFormat)
{
  videoSettingsUI_->setupUi(this);

  // the buttons are named so that the slots are called automatically
  // Overloads are needed, because QComboBox has overloaded the signal and
  // the connect can't figure out which one to use.
  QObject::connect(videoSettingsUI_->format_box, QOverload<int>::of(&QComboBox::activated),
                   this, &VideoSettings::refreshResolutions);
  QObject::connect(videoSettingsUI_->resolution, QOverload<int>::of(&QComboBox::activated),
                   this, &VideoSettings::refreshFramerates);

  videoSettingsUI_->custom_parameters->setContextMenuPolicy(Qt::CustomContextMenu);
  connect(videoSettingsUI_->custom_parameters, &QWidget::customContextMenuRequested,
          this, &VideoSettings::showParameterContextMenu);

  connect(videoSettingsUI_->bitrate_slider, &QSlider::valueChanged,
          this, &VideoSettings::updateBitrate);

  connect(videoSettingsUI_->wpp, &QCheckBox::clicked,
          this, &VideoSettings::updateSliceBoxStatus);

  connect(videoSettingsUI_->tiles_checkbox, &QCheckBox::clicked,
          this, &VideoSettings::updateSliceBoxStatus);

  connect(videoSettingsUI_->rc_algorithm,
          QOverload<int>::of(&QComboBox::currentIndexChanged),
          this, &VideoSettings::updateObaStatus);
}


void VideoSettings::init(int deviceID)
{
  currentDevice_ = deviceID;

  restoreSettings();
}


void VideoSettings::showParameterContextMenu(const QPoint& pos)
{
  if (videoSettingsUI_->custom_parameters->rowCount() != 0)
  {
    showContextMenu(pos, videoSettingsUI_->custom_parameters, this,
                    QStringList() << "Delete", QStringList()
                    << SLOT(deleteListParameter()));
  }
}


void VideoSettings::deleteListParameter()
{
  videoSettingsUI_->custom_parameters->removeRow(
        videoSettingsUI_->custom_parameters->currentRow());
}


void VideoSettings::changedDevice(uint16_t deviceIndex)
{
  currentDevice_ = deviceIndex;
  initializeFormat();
  saveCameraCapabilities(deviceIndex); // record the new camerasettings.
}


void VideoSettings::resetSettings(int deviceID)
{
  printNormal(this, "Resettings video settings fomr UI");

  currentDevice_ = deviceID;
  initializeFormat();
  saveSettings();
  updateSliceBoxStatus();
  updateTilesStatus();
}


void VideoSettings::on_video_ok_clicked()
{
  printNormal(this, "Saving video settings");
  saveSettings();
  emit settingsChanged();
  //emit hidden();
  //hide();
}


void VideoSettings::on_video_close_clicked()
{
  printNormal(this, "Cancelled modifying video settings. Getting settings from system.");
  restoreSettings();
  hide();
  emit hidden();
}

<commit_msg>fix(Settings): Enable resetting the OWF correctly<commit_after>#include "videosettings.h"

#include "ui_videosettings.h"

#include <ui/settings/camerainfo.h>
#include "settingshelper.h"
#include "settingskeys.h"

#include "common.h"

#include <QTableWidgetItem>
#include <QThread>
#include <QComboBox>

// video/DeviceID and video/Device are no checked in case we don't have a camera

const QStringList neededSettings = {SettingsKey::videoResultionWidth,
                                    SettingsKey::videoResultionHeight,
                                    SettingsKey::videoResolutionID,
                                    SettingsKey::videoInputFormat,
                                    SettingsKey::videoYUVThreads,
                                    SettingsKey::videoRGBThreads,
                                    SettingsKey::videoOpenHEVCThreads,
                                    SettingsKey::videoFramerateID,
                                    SettingsKey::videoFramerate,
                                    SettingsKey::videoFlipEnabled,
                                    SettingsKey::videoForceFlip,
                                    SettingsKey::videoOpenGL
                                   };

const QStringList kvazaarSettings = {SettingsKey::videoQP,
                                     SettingsKey::videoIntra,
                                     SettingsKey::videoSlices,
                                     SettingsKey::videoKvzThreads,
                                     SettingsKey::videoWPP,
                                     SettingsKey::videoOWF,
                                     SettingsKey::videoTiles,
                                     SettingsKey::videoTileDimensions,
                                     SettingsKey::videoVPS,
                                     SettingsKey::videoBitrate,
                                     SettingsKey::videoRCAlgorithm,
                                     SettingsKey::videoOBAClipNeighbours,
                                     SettingsKey::videoScalingList,
                                     SettingsKey::videoLossless,
                                     SettingsKey::videoMVConstraint,
                                     SettingsKey::videoQPInCU,
                                     SettingsKey::videoVAQ,
                                     SettingsKey::videoPreset
                                   };



VideoSettings::VideoSettings(QWidget* parent,
                             std::shared_ptr<CameraInfo> info)
  :
  QDialog(parent),
  currentDevice_(0),
  videoSettingsUI_(new Ui::VideoSettings),
  cam_(info),
  settings_(settingsFile, settingsFileFormat)
{
  videoSettingsUI_->setupUi(this);

  // the buttons are named so that the slots are called automatically
  // Overloads are needed, because QComboBox has overloaded the signal and
  // the connect can't figure out which one to use.
  QObject::connect(videoSettingsUI_->format_box, QOverload<int>::of(&QComboBox::activated),
                   this, &VideoSettings::refreshResolutions);
  QObject::connect(videoSettingsUI_->resolution, QOverload<int>::of(&QComboBox::activated),
                   this, &VideoSettings::refreshFramerates);

  videoSettingsUI_->custom_parameters->setContextMenuPolicy(Qt::CustomContextMenu);
  connect(videoSettingsUI_->custom_parameters, &QWidget::customContextMenuRequested,
          this, &VideoSettings::showParameterContextMenu);

  connect(videoSettingsUI_->bitrate_slider, &QSlider::valueChanged,
          this, &VideoSettings::updateBitrate);

  connect(videoSettingsUI_->wpp, &QCheckBox::clicked,
          this, &VideoSettings::updateSliceBoxStatus);

  connect(videoSettingsUI_->tiles_checkbox, &QCheckBox::clicked,
          this, &VideoSettings::updateSliceBoxStatus);

  connect(videoSettingsUI_->rc_algorithm,
          QOverload<int>::of(&QComboBox::currentIndexChanged),
          this, &VideoSettings::updateObaStatus);
}


void VideoSettings::init(int deviceID)
{
  currentDevice_ = deviceID;

  restoreSettings();
}


void VideoSettings::showParameterContextMenu(const QPoint& pos)
{
  if (videoSettingsUI_->custom_parameters->rowCount() != 0)
  {
    showContextMenu(pos, videoSettingsUI_->custom_parameters, this,
                    QStringList() << "Delete", QStringList()
                    << SLOT(deleteListParameter()));
  }
}


void VideoSettings::deleteListParameter()
{
  videoSettingsUI_->custom_parameters->removeRow(
        videoSettingsUI_->custom_parameters->currentRow());
}


void VideoSettings::changedDevice(uint16_t deviceIndex)
{
  currentDevice_ = deviceIndex;
  initializeFormat();
  saveCameraCapabilities(deviceIndex); // record the new camerasettings.
}


void VideoSettings::resetSettings(int deviceID)
{
  printNormal(this, "Resettings video settings from UI");

  currentDevice_ = deviceID;
  initializeFormat();
  initializeThreads();
  saveSettings();
  updateSliceBoxStatus();
  updateTilesStatus();
}


void VideoSettings::on_video_ok_clicked()
{
  printNormal(this, "Saving video settings");
  saveSettings();
  emit settingsChanged();
  //emit hidden();
  //hide();
}


void VideoSettings::on_video_close_clicked()
{
  printNormal(this, "Cancelled modifying video settings. Getting settings from system.");
  restoreSettings();
  hide();
  emit hidden();
}


{'fraction_non_alphanumeric': 0.09066063518989728, 'fraction_numerical': 0.0007539345961737819, 'mean_word_length': 2.140574134359278, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 60, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '344643', 'n_tokens_mistral': 2673, 'n_tokens_neox': 2537, 'n_words': 436}