<commit_before>#include "includes/SWidgets/SWebView.hpp"
#include "includes/SWidgets/STabWidget.hpp"
#include "includes/SMainWindow.hpp"

#include <QMessageBox>
#include <QVBoxLayout>

SWebView::SWebView(QWidget * parent, STabWidget *parentTab, QUrl url) :
	QWebEngineView(parent),
	m_parent(parent),
	m_parentTab(parentTab)
{
    connect(this->page(), &QWebEnginePage::fullScreenRequested, this, &SWebView::setFullScreen);

    load(url);
}

SWebView::~SWebView()
{
	// Empty
}

void SWebView::changeParent(QWidget * parent, STabWidget *parentTab)
{
	setParent(parent);
	m_parent = parent;
	m_parentTab = parentTab;
}

void SWebView::contextMenuEvent(QContextMenuEvent *event)
{
	// Get the action of current context menu
	QMenu *contextMenu{ page()->createStandardContextMenu() };

	// If the user right click on a link, we add the "open in new tab" action 
	if (!page()->contextMenuData().linkUrl().isEmpty()) {
		contextMenu->insertAction(page()->action(QWebEnginePage::OpenLinkInThisWindow), page()->action(QWebEnginePage::OpenLinkInNewTab));
	}

	// Execute the context menu
	contextMenu->exec(event->globalPos());
}

SWebView * SWebView::createWindow(QWebEnginePage::WebWindowType type)<commit_msg>Enable close request by some web site<commit_after>#include "includes/SWidgets/SWebView.hpp"
#include "includes/SWidgets/STabWidget.hpp"
#include "includes/SMainWindow.hpp"

#include <QMessageBox>
#include <QVBoxLayout>

SWebView::SWebView(QWidget * parent, STabWidget *parentTab, QUrl url) :
	QWebEngineView(parent),
	m_parent(parent),
	m_parentTab(parentTab)
{
    connect(this->page(), &QWebEnginePage::fullScreenRequested, this, &SWebView::setFullScreen);

	if (parentTab == nullptr)
		connect(this->page(), &QWebEnginePage::windowCloseRequested, this, &SWebView::close);

    load(url);
}

SWebView::~SWebView()
{
	// Empty
}

void SWebView::changeParent(QWidget * parent, STabWidget *parentTab)
{
	setParent(parent);
	m_parent = parent;
	m_parentTab = parentTab;
}

void SWebView::contextMenuEvent(QContextMenuEvent *event)
{
	// Get the action of current context menu
	QMenu *contextMenu{ page()->createStandardContextMenu() };

	// If the user right click on a link, we add the "open in new tab" action 
	if (!page()->contextMenuData().linkUrl().isEmpty()) {
		contextMenu->insertAction(page()->action(QWebEnginePage::OpenLinkInThisWindow), page()->action(QWebEnginePage::OpenLinkInNewTab));
	}

	// Execute the context menu
	contextMenu->exec(event->globalPos());
}

SWebView * SWebView::createWindow(QWebEnginePage::WebWindowType type)
{'fraction_non_alphanumeric': 0.1411764705882353, 'fraction_numerical': 0.0, 'mean_word_length': 6.637724550898204, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 24, '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': '2852161', 'n_tokens_mistral': 862, 'n_tokens_neox': 848, 'n_words': 166}