<commit_before>#include "drm_setup_wizard.h"
#include <src/libs/steam_vdf_parse.hpp>
#include <src/database.h>
#include <src/gui/stack/library.h>

#include <QtConcurrent/QtConcurrent>

#include <iostream>
#include <thread>
#include <future>

GameList addedVector;

/** DRMSetupWizard constructor
 * Defines the pages and initializes the database with the path given. Also sets up some window-related properties,
 * such as title and initial size.
 * \param parent Parent widget to draw from
 * \param dbPath Path to the database used
 */
DRMSetupWizard::DRMSetupWizard(QWidget* parent) : QWizard(parent)
{
    std::map<std::string, DRMType*> drmMap;
    SteamDRM* steam = new SteamDRM;
    steam->checkExists();
    if (steam->getIsInstalled())
    {
        drmMap.insert(std::make_pair(std::string("Steam"), steam));
    }

#if defined(_WIN32) || defined(_WIN64) || defined(__APPLE__)
    OriginDRM* origin = new OriginDRM;
    origin->checkOriginExists();
    if (origin->getIsInstalled())
    {
        drmMap.insert(std::make_pair("Origin", origin));
    }
#endif

#if defined(_WIN32) || defined (_WIN64)
    UplayDRM* uplay = new UplayDRM;
    uplay->checkUplayExists();
    if (uplay->getIsInstalled())
    {
        drmMap.insert(std::make_pair("Uplay", uplay));
    }
#endif

    setPage(pages::INTRO, new IntroPage(this));
    setPage(pages::DRM, new DRMPage(drmMap, this));
    setPage(pages::RESULTS, new ResultsPage(drmMap, this));
    setPage(pages::FINAL, new FinalPage(this));
    setWindowTitle("Project Ascension setup");
    setFixedSize(QSize(700, 450));
    addedVector.erase(addedVector.begin(), addedVector.end());
 }

/** IntroPage constructor
 * Defines some initial properties for the introduction page.
 * \param parent Parent widget to draw from
 */
IntroPage::IntroPage(QWidget* parent) : QWizardPage(parent)
{
    setTitle("Finding games");
    setSubTitle("This wizard will try to find all your games.");
    QGridLayout* layout = new QGridLayout(this);
    QLabel* label = new QLabel("Click next to attempt to find Steam, Origin and Uplay games where applicable.");
    layout->addWidget(label);
    setLayout(layout);
}

/** DRMPage constructor
 * Defines some initial properties for the DRM page.
 * \param parent Parent widget to draw from
 */
DRMPage::DRMPage(std::map<std::string, DRMType*> drmMap, QWidget *parent) : QWizardPage(parent), drmMap(drmMap)
{
    setTitle("Found installed candidates");
    layout = new QGridLayout(this);

    static int count = 0;
    for (auto& drm : drmMap)
    {
        layout->addWidget(drm.second->getPlatformLabel(), count, 0, 0);
        layout->addWidget(drm.second->getDescLabel(), count+1, 0, 0);
        layout->addWidget(drm.second->getStatusLabel(), count, 0, 0);
        count += 3;
    }

    setLayout(layout);
}

/** ResultsPage constructor
 * Defines some initial properties for the results page.
 */
ResultsPage::ResultsPage(std::map<std::string, DRMType*> drmMap, QWidget* parent) : QWizardPage(parent)
{
    setSubTitle("We found the following on your system.");
    steam = static_cast<SteamDRM*>(drmMap.find(std::string("Steam"))->second);
    origin = static_cast<OriginDRM*>(drmMap.find(std::string("Origin"))->second);
    uplay = static_cast<UplayDRM*>(drmMap.find(std::string("Uplay"))->second);
}

/** FinalPage constructor
 * Defines some initial properties for the final page.
 */
FinalPage::FinalPage(QWidget* parent) : QWizardPage(parent)
{
    setTitle("Done");
}

/** Initializes the results page. This function is called when the NextButton on the previous page is clicked,
 * which allows the state of the previous page to be transferred to this one.
 * The function then runs each respective check*Exists function, and populates the various sections with correct information.
 */
void ResultsPage::initializePage()
{
    setTitle(QString("We found "));

    bool steamFound = steam->getIsInstalled();
    bool originFound = origin->getIsInstalled();
    bool uplayFound = uplay->getIsInstalled();

    if (!uplayFound && !steamFound && !originFound)
    {
        setTitle(title() + "no games.");
        setSubTitle("Install Steam, Origin and/or Uplay to find games with this wizard, or check current installation(s).");
    }
    else
    {
        setSubTitle("Change the title for each game by clicking the text box and editing.");
        tabWidget = new QTabWidget(this);
        topLayout = new QGridLayout(this);
        QProgressDialog dialog;
        dialog.setCancelButtonText("Cancel");
        dialog.setRange(0, 3);
        dialog.setWindowTitle("Project Ascension");
        dialog.setLabelText("Working");
        dialog.setWindowModality(Qt::WindowModal);
        dialog.show();
        dialog.setValue(0);

        QApplication::processEvents();
        if (steamFound)<commit_msg>Some linux fixes<commit_after>#include "drm_setup_wizard.h"
#include <src/libs/steam_vdf_parse.hpp>
#include <src/database.h>
#include <src/gui/stack/library.h>

#include <QtConcurrent/QtConcurrent>

#include <iostream>
#include <thread>
#include <future>

GameList addedVector;

/** DRMSetupWizard constructor
 * Defines the pages and initializes the database with the path given. Also sets up some window-related properties,
 * such as title and initial size.
 * \param parent Parent widget to draw from
 * \param dbPath Path to the database used
 */
DRMSetupWizard::DRMSetupWizard(QWidget* parent) : QWizard(parent)
{
    std::map<std::string, DRMType*> drmMap;
    SteamDRM* steam = new SteamDRM;
    OriginDRM* origin = new OriginDRM;
    UplayDRM* uplay = new UplayDRM;
    steam->checkExists();

#if defined(_WIN32) || defined(_WIN64) || defined(__APPLE__)
    origin->checkOriginExists();
#endif

#if defined(_WIN32) || defined (_WIN64)
    uplay->checkUplayExists();
#endif

    drmMap.insert(std::make_pair("Steam", steam));
    drmMap.insert(std::make_pair("Origin", origin));
    drmMap.insert(std::make_pair("Uplay", uplay));

    setPage(pages::INTRO, new IntroPage(this));
    setPage(pages::DRM, new DRMPage(drmMap, this));
    setPage(pages::RESULTS, new ResultsPage(drmMap, this));
    setPage(pages::FINAL, new FinalPage(this));
    setWindowTitle("Project Ascension setup");
    setFixedSize(QSize(700, 450));
    addedVector.erase(addedVector.begin(), addedVector.end());
 }

/** IntroPage constructor
 * Defines some initial properties for the introduction page.
 * \param parent Parent widget to draw from
 */
IntroPage::IntroPage(QWidget* parent) : QWizardPage(parent)
{
    setTitle("Finding games");
    setSubTitle("This wizard will try to find all your games.");
    QGridLayout* layout = new QGridLayout(this);
    QLabel* label = new QLabel("Click next to attempt to find Steam, Origin and Uplay games where applicable.");
    layout->addWidget(label);
    setLayout(layout);
}

/** DRMPage constructor
 * Defines some initial properties for the DRM page.
 * \param parent Parent widget to draw from
 */
DRMPage::DRMPage(std::map<std::string, DRMType*> drmMap, QWidget *parent) : QWizardPage(parent), drmMap(drmMap)
{
    setTitle("Found installed candidates");
    layout = new QGridLayout(this);

    static int count = 0;
    for (auto& drm : drmMap)
    {
        if (drm.second->getIsInstalled())
        {
            layout->addWidget(drm.second->getPlatformLabel(), count, 0, 0);
            layout->addWidget(drm.second->getDescLabel(), count+1, 0, 0);
            layout->addWidget(drm.second->getStatusLabel(), count, 0, 0);
            count += 3;
        }
    }

    setLayout(layout);
}

/** ResultsPage constructor
 * Defines some initial properties for the results page.
 */
ResultsPage::ResultsPage(std::map<std::string, DRMType*> drmMap, QWidget* parent) : QWizardPage(parent)
{
    setSubTitle("We found the following on your system.");
    steam = static_cast<SteamDRM*>(drmMap.find(std::string("Steam"))->second);
    origin = static_cast<OriginDRM*>(drmMap.find(std::string("Origin"))->second);
    uplay = static_cast<UplayDRM*>(drmMap.find(std::string("Uplay"))->second);
}

/** FinalPage constructor
 * Defines some initial properties for the final page.
 */
FinalPage::FinalPage(QWidget* parent) : QWizardPage(parent)
{
    setTitle("Done");
}

/** Initializes the results page. This function is called when the NextButton on the previous page is clicked,
 * which allows the state of the previous page to be transferred to this one.
 * The function then runs each respective check*Exists function, and populates the various sections with correct information.
 */
void ResultsPage::initializePage()
{
    setTitle(QString("We found "));

    bool steamFound = steam->getIsInstalled();
    bool originFound = origin->getIsInstalled();
    bool uplayFound = uplay->getIsInstalled();

    if (!uplayFound && !steamFound && !originFound)
    {
        setTitle(title() + "no games.");
        setSubTitle("Install Steam, Origin and/or Uplay to find games with this wizard, or check current installation(s).");
    }
    else
    {
        setSubTitle("Change the title for each game by clicking the text box and editing.");
        tabWidget = new QTabWidget(this);
        topLayout = new QGridLayout(this);
        QProgressDialog dialog;
        dialog.setCancelButtonText("Cancel");
        dialog.setRange(0, 3);
        dialog.setWindowTitle("Project Ascension");
        dialog.setLabelText("Working");
        dialog.setWindowModality(Qt::NonModal);
        dialog.show();
        dialog.setValue(0);
        QApplication::processEvents();

        if (steamFound)
{'fraction_non_alphanumeric': 0.1285144775493076, 'fraction_numerical': 0.005455308434746118, 'mean_word_length': 4.030606860158311, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 65, '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': '6596386', 'n_tokens_mistral': 2915, 'n_tokens_neox': 2837, 'n_words': 769}