<commit_before>#include "cmainwindow.h"
#include "settingsui/csettingsdialog.h"
#include "settings/csettingspagecamera.h"
#include "settings/settings.h"
#include "settings/csettings.h"
#include "updater/cupdaterdialog.h"

DISABLE_COMPILER_WARNINGS
#include "ui_cmainwindow.h"

#include <QCamera>
#include <QCameraInfo>
#include <QDateTime>
#include <QDebug>
#include <QImage>
#include <QMessageBox>
#include <QMouseEvent>
#include <QPainter>
RESTORE_COMPILER_WARNINGS

#include <Windows.h>

CMainWindow::CMainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::CMainWindow),
	_cameraViewWidget(this),
	_trayIcon(QIcon(":/icon.ico"), this),
	_camerasListDialog(this)
{
	ui->setupUi(this);

	_cameraViewWidget.setContextMenuPolicy(Qt::CustomContextMenu);
	setCentralWidget(&_cameraViewWidget);
	_cameraViewWidget.show();

	_frameAnalysisTimer.start(700);
	connect(&_frameAnalysisTimer, &QTimer::timeout, this, &CMainWindow::analyzeFrame);

	_camerasListUpdateTimer.start(2000);
	connect(&_camerasListUpdateTimer, &QTimer::timeout, this, &CMainWindow::updateCamerasList);

	setupTrayIcon();

	updateCamerasList();

	connect(&_cameraViewWidget, &QWidget::customContextMenuRequested, [this](const QPoint& point){
		QMenu menu(this);
		const QAction * const cropImageAction = menu.addAction("Crop image");
		if (menu.exec(_cameraViewWidget.mapToGlobal(point)) == cropImageAction)
		{
			_cropHandler.activate();
			_cameraViewWidget.update(); // To render the hint text
		}
	});

	_cameraViewWidget.installEventFilter(&_cropHandler);
	connect(&_cropHandler, &CCropFrameHandler::cropFrameEdited, [this](const QRect frame) {

		CSettings().setValue(SETTINGS_KEY_IMAGE_WIDTH, frame.width());
		CSettings().setValue(SETTINGS_KEY_IMAGE_HEIGHT, frame.height());
		applyViewFinderResolutionSettings();
	});

	// Check for updates
	if (CSettings().value(SETTINGS_KEY_LAST_UPDATE_CHECK_TIMESTAMP, QDateTime::fromTime_t(1)).toDateTime().msecsTo(QDateTime::currentDateTime()) >= 1000 * 3600 * 24)
	{
		CSettings().setValue(SETTINGS_KEY_LAST_UPDATE_CHECK_TIMESTAMP, QDateTime::currentDateTime());
		auto dlg = new CUpdaterDialog(this, true);
		connect(dlg, &QDialog::rejected, dlg, &QDialog::deleteLater);
		connect(dlg, &QDialog::accepted, dlg, &QDialog::deleteLater);
	}
}

CMainWindow::~CMainWindow()
{
	delete ui;
}<commit_msg>Disabled the non-working crop feature<commit_after>#include "cmainwindow.h"
#include "settingsui/csettingsdialog.h"
#include "settings/csettingspagecamera.h"
#include "settings/settings.h"
#include "settings/csettings.h"
#include "updater/cupdaterdialog.h"

DISABLE_COMPILER_WARNINGS
#include "ui_cmainwindow.h"

#include <QCamera>
#include <QCameraInfo>
#include <QDateTime>
#include <QDebug>
#include <QImage>
#include <QMessageBox>
#include <QMouseEvent>
#include <QPainter>
RESTORE_COMPILER_WARNINGS

#include <Windows.h>

CMainWindow::CMainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::CMainWindow),
	_cameraViewWidget(this),
	_trayIcon(QIcon(":/icon.ico"), this),
	_camerasListDialog(this)
{
	ui->setupUi(this);

	_cameraViewWidget.setContextMenuPolicy(Qt::CustomContextMenu);
	setCentralWidget(&_cameraViewWidget);
	_cameraViewWidget.show();

	_frameAnalysisTimer.start(700);
	connect(&_frameAnalysisTimer, &QTimer::timeout, this, &CMainWindow::analyzeFrame);

	_camerasListUpdateTimer.start(2000);
	connect(&_camerasListUpdateTimer, &QTimer::timeout, this, &CMainWindow::updateCamerasList);

	setupTrayIcon();

	updateCamerasList();

// 	connect(&_cameraViewWidget, &QWidget::customContextMenuRequested, [this](const QPoint& point){
// 		QMenu menu(this);
// 		const QAction * const cropImageAction = menu.addAction("Crop image");
// 		if (menu.exec(_cameraViewWidget.mapToGlobal(point)) == cropImageAction)
// 		{
// 			_cropHandler.activate();
// 			_cameraViewWidget.update(); // To render the hint text
// 		}
// 	});

	_cameraViewWidget.installEventFilter(&_cropHandler);
	connect(&_cropHandler, &CCropFrameHandler::cropFrameEdited, [this](const QRect frame) {

		CSettings().setValue(SETTINGS_KEY_IMAGE_WIDTH, frame.width());
		CSettings().setValue(SETTINGS_KEY_IMAGE_HEIGHT, frame.height());
		applyViewFinderResolutionSettings();
	});

	// Check for updates
	if (CSettings().value(SETTINGS_KEY_LAST_UPDATE_CHECK_TIMESTAMP, QDateTime::fromTime_t(1)).toDateTime().msecsTo(QDateTime::currentDateTime()) >= 1000 * 3600 * 24)
	{
		CSettings().setValue(SETTINGS_KEY_LAST_UPDATE_CHECK_TIMESTAMP, QDateTime::currentDateTime());
		auto dlg = new CUpdaterDialog(this, true);
		connect(dlg, &QDialog::rejected, dlg, &QDialog::deleteLater);
		connect(dlg, &QDialog::accepted, dlg, &QDialog::deleteLater);
	}
}

CMainWindow::~CMainWindow()
{
	delete ui;
}
{'fraction_non_alphanumeric': 0.14255273812060515, 'fraction_numerical': 0.0076709993607500535, 'mean_word_length': 7.907020872865275, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6157469', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1624, 'n_words': 244}