<commit_before>#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "wordpool.h"
#include <cstdio>
#include <QDir>
#include <QDebug>
#include "statisticwidget.h"
#include <QMessageBox>
#include <QFrame>
#include "settingswidget.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenu* file = this->ui->menuBar->addMenu("&Datei");
    QAction* quit = new QAction("&Schlieen", this);
    file->addAction(quit);
    QAction* abort = new QAction("&Abbrechen", this);
    file->addAction(abort);
    QMenu* lesson = this->ui->menuBar->addMenu("&bung");
    QList<QAction*> lessons;
    QDir dir("wp");
    dir.setFilter(QDir::Files);
    dir.setSorting(QDir::Name);
    dir.setNameFilters(QStringList("*.wp"));
    QStringList files = dir.entryList();
    for (int i=0; i<files.size(); i++)
    {
        QAction* action = new QAction(files.at(i), this);
        lessons.append(action);
        lesson->addAction(action);
        qDebug() << "added lesson" << files.at(i);
    }
    QMenu* statistic = this->ui->menuBar->addMenu("&Statistik");
    QAction* show = new QAction("&Anzeigen", this);
    statistic->addAction(show);
    QAction* reset = new QAction("&Zurcksetzen", this);
    statistic->addAction(reset);
    QMenu* settingsMenu = this->ui->menuBar->addMenu("&Einstellungen");
    QAction* settingsAction = new QAction("&ndern", this);
    settingsMenu->addAction(settingsAction);
    QAction* resetSettingsAction = new QAction("&Zurcksetzen", this);
    settingsMenu->addAction(resetSettingsAction);
    QMenu* aboutMenu = this->ui->menuBar->addMenu("&ber");
    QAction* aboutAction = new QAction("&ber", this);
    aboutMenu->addAction(aboutAction);
    this->stats = new Statistic();
    ui->type->preinit(this->ui->display, stats, this, ui->keyboard, ui->timeLeft, ui->hits, ui->mistakes, ui->hitsPerMinute, ui->mistakesper100);
    connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(show, SIGNAL(triggered()), this, SLOT(openStatistic()));
    connect(reset, SIGNAL(triggered()), this, SLOT(resetStatistic()));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout()));
    connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettings()));
    connect(resetSettingsAction, SIGNAL(triggered()), this, SLOT(resetSettings()));
    connect(abort, SIGNAL(triggered()), this->ui->type, SLOT(abort()));
    for (int i=0; i<files.size(); i++)
    {
        connect(lessons.at(i), SIGNAL(triggered()), ui->type, SLOT(init()));
    }
}

void MainWindow::showSettings()
{
    QFrame* f = new QFrame();
    SettingsWidget* w = new SettingsWidget(f);
    f->setWindowTitle("Einstellungen");
    f->setMinimumSize(w->size());
    f->show();
}

void MainWindow::openStatistic()
{
    QFrame* f = new QFrame();
    StatisticWidget* w = new StatisticWidget(f);
    f->setWindowTitle("Statistik");
    f->setMinimumSize(w->size());
    f->show();
}

void MainWindow::resetStatistic()
{
    QMessageBox msgBox;
    msgBox.setWindowTitle("Statistik zurcksetzen");
    msgBox.setText("Mchten Sie wirklich die gesamte Statistik zurcksetzen?");
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::No);
    if(msgBox.exec() == QMessageBox::Yes)
    {
        QDir dir("wp");
        dir.setFilter(QDir::Files);
        dir.setSorting(QDir::Name);
        dir.setNameFilters(QStringList("*.stats"));
        QStringList files = dir.entryList();<commit_msg>test main menu with utf8<commit_after>﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "wordpool.h"
#include <cstdio>
#include <QDir>
#include <QDebug>
#include "statisticwidget.h"
#include <QMessageBox>
#include <QFrame>
#include "settingswidget.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenu* file = this->ui->menuBar->addMenu("&Datei");
    QAction* quit = new QAction("&Schließen", this);
    file->addAction(quit);
    QAction* abort = new QAction("&Abbrechen", this);
    file->addAction(abort);
    QMenu* lesson = this->ui->menuBar->addMenu("&Übung");
    QList<QAction*> lessons;
    QDir dir("wp");
    dir.setFilter(QDir::Files);
    dir.setSorting(QDir::Name);
    dir.setNameFilters(QStringList("*.wp"));
    QStringList files = dir.entryList();
    for (int i=0; i<files.size(); i++)
    {
        QAction* action = new QAction(files.at(i), this);
        lessons.append(action);
        lesson->addAction(action);
        qDebug() << "added lesson" << files.at(i);
    }
    QMenu* statistic = this->ui->menuBar->addMenu("&Statistik");
    QAction* show = new QAction("&Anzeigen", this);
    statistic->addAction(show);
    QAction* reset = new QAction("&Zurücksetzen", this);
    statistic->addAction(reset);
    QMenu* settingsMenu = this->ui->menuBar->addMenu("&Einstellungen");
    QAction* settingsAction = new QAction("&Ändern", this);
    settingsMenu->addAction(settingsAction);
    QAction* resetSettingsAction = new QAction("&Zurücksetzen", this);
    settingsMenu->addAction(resetSettingsAction);
    QMenu* aboutMenu = this->ui->menuBar->addMenu("&Über");
    QAction* aboutAction = new QAction("&Über", this);
    aboutMenu->addAction(aboutAction);
    this->stats = new Statistic();
    ui->type->preinit(this->ui->display, stats, this, ui->keyboard, ui->timeLeft, ui->hits, ui->mistakes, ui->hitsPerMinute, ui->mistakesper100);
    connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(show, SIGNAL(triggered()), this, SLOT(openStatistic()));
    connect(reset, SIGNAL(triggered()), this, SLOT(resetStatistic()));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout()));
    connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettings()));
    connect(resetSettingsAction, SIGNAL(triggered()), this, SLOT(resetSettings()));
    connect(abort, SIGNAL(triggered()), this->ui->type, SLOT(abort()));
    for (int i=0; i<files.size(); i++)
    {
        connect(lessons.at(i), SIGNAL(triggered()), ui->type, SLOT(init()));
    }
}

void MainWindow::showSettings()
{
    QFrame* f = new QFrame();
    SettingsWidget* w = new SettingsWidget(f);
    f->setWindowTitle("Einstellungen");
    f->setMinimumSize(w->size());
    f->show();
}

void MainWindow::openStatistic()
{
    QFrame* f = new QFrame();
    StatisticWidget* w = new StatisticWidget(f);
    f->setWindowTitle("Statistik");
    f->setMinimumSize(w->size());
    f->show();
}

void MainWindow::resetStatistic()
{
    QMessageBox msgBox;
    msgBox.setWindowTitle("Statistik zurücksetzen");
    msgBox.setText("Möchten Sie wirklich die gesamte Statistik zurücksetzen?");
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::No);
    if(msgBox.exec() == QMessageBox::Yes)
    {
        QDir dir("wp");
        dir.setFilter(QDir::Files);
        dir.setSorting(QDir::Name);
        dir.setNameFilters(QStringList("*.stats"));
        QStringList files = dir.entryList();
{'fraction_non_alphanumeric': 0.17732804981602038, 'fraction_numerical': 0.0015567506368525334, 'mean_word_length': 4.482544608223429, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 107, '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': '5480053', 'n_tokens_mistral': 2392, 'n_tokens_neox': 2382, 'n_words': 423}