<commit_before>/**
 *  Copyright (C) 2014 3D Repo Ltd
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

//------------------------------------------------------------------------------
// Qt
#include <QMessageBox>
#include <QtSvg>

//------------------------------------------------------------------------------
// GUI
#include "repo_gui.h"
#include "ui_repo_gui.h"
#include "dialogs/repo_dialog_commit.h"
#include "dialogs/repo_dialog_history.h"
#include "dialogs/repo_dialog_settings.h"
#include "dialogs/repo_dialog_about.h"
#include "../logger/repo_logger.h"
#include "dialogs/repo_dialog_connect.h"
#include "widgets/repo_widget_repository.h"
#include "widgets/repo_text_browser.h"
#include "widgets/repo_widget_flags.h"
#include "widgets/repo_widget_tree_dock.h"
#include "widgets/repo_widget_manager_3ddiff.h"
#include "../workers/repo_worker_commit.h"
#include "../workers/repo_worker_file_export.h"
#include "../workers/repo_worker_optimize.h"
#include "primitives/repo_fontawesome.h"
#include "primitives/repo_color.h"
#include "dialogs/repo_dialog_manager_abstract.h"
#include "dialogs/repo_dialog_federation.h"
#include "dialogs/repo_dialog_map.h"


//------------------------------------------------------------------------------
#include "dialogs/repo_dialog_manager_access.h"
#include "dialogs/repo_dialog_manager_connect.h"
//------------------------------------------------------------------------------

const QString repo::gui::RepoGUI::REPO_SETTINGS_GUI_GEOMETRY    = "RepoGUI/geometry";
const QString repo::gui::RepoGUI::REPO_SETTINGS_GUI_STATE       = "RepoGUI/state";
const QString repo::gui::RepoGUI::REPO_SETTINGS_LINK_WINDOWS    = "RepoGUI/link";

repo::gui::RepoGUI::RepoGUI(
        repo::RepoController *controller,
        QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::RepoGUI)
    , controller(controller)
    , panelsMenu(0)
    , navigationModeActionGroup(new QActionGroup(this))
{
    ui->setupUi(this);
    restoreSettings();

    this->setWindowTitle(
                QCoreApplication::applicationName() +
                " v" +
                QCoreApplication::applicationVersion());

    //Subscribe logger to broadcaster who taps into repo bouncer library logs
    repo::logger::RepoLogger::getInstance()->subscribe(ui->logTextBrowser);

    QIcon icon(":/images/3drepo-icon.svg");
    this->setWindowIcon(icon);

    //--------------------------------------------------------------------------
    // For docks and windows not to update as they are slow to repaint.
    this->setAnimated(false);

    //--------------------------------------------------------------------------
    // Force opengl format settings by default.
    QGLFormat format(QGL::SampleBuffers);
    format.setSwapInterval(1); // vsync
    format.setSamples(16); // Antialiasing (multisample)
    QGLFormat::setDefaultFormat(format);

    //--------------------------------------------------------------------------
    //
    // File
    //
    //--------------------------------------------------------------------------
    // Open
    QObject::connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
    ui->actionOpen->setIcon(primitive::RepoFontAwesome::getInstance().getIcon(primitive::RepoFontAwesome::fa_folder_open));

    // Save As
    QObject::connect(ui->actionSave_As, SIGNAL(triggered()), this,
                     SLOT(saveAs()));
    ui->actionSave_As->setIcon(primitive::RepoFontAwesome::getInstance().getIcon(primitive::RepoFontAwesome::fa_floppy_o));

    // Save Screenshot
    QObject::connect(ui->actionSave_Screenshot, SIGNAL(triggered()), this,
                     SLOT(saveScreenshot()));


    QObject::connect(ui->actionClose, &QAction::triggered,
                     ui->mdiArea, &widget::RepoMdiArea::closeActiveSubWindow);

    QObject::connect(ui->actionClose_All, &QAction::triggered,
                     ui->mdiArea, &widget::RepoMdiArea::closeAllSubWindows);

    QObject::connect(ui->actionClose_All, &QAction::triggered,
                     ui->mdiArea, &widget::RepoMdiArea::closeHiddenSubWindows);

    //--------------------------------------------------------------------------
    // Exit
    QObject::connect(ui->actionExit, SIGNAL(triggered()),
                     QApplication::instance(), SLOT(quit()));
    ui->actionExit->setIcon(
                primitive::RepoFontAwesome::getInstance().getIcon(
                    primitive::RepoFontAwesome::fa_times, QColor(Qt::darkRed)));


    //--------------------------------------------------------------------------
    //
    // Repository
    //
    //--------------------------------------------------------------------------
    // Connect
    QObject::connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(connectDB()));
    ui->actionConnect->setIcon(primitive::RepoFontAwesome::getConnectIcon());

    // Disconnect
    QObject::connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(disconnectDB()));
    ui->actionDisconnect->setIcon(primitive::RepoFontAwesome::getDisconnectIcon());

    // Refresh
    QObject::connect(ui->actionRefresh, SIGNAL(triggered()), this, SLOT(refresh()));
    ui->actionRefresh->setIcon(
                primitive::RepoFontAwesome::getInstance().getIcon(
                    primitive::RepoFontAwesome::fa_refresh,
                    QColor(Qt::darkGreen)));

    // Head
    QObject::connect(ui->actionHead, SIGNAL(triggered()), this, SLOT(fetchHead()));
    ui->actionHead->setIcon(
                primitive::RepoFontAwesome::getInstance().getIcon(
                    primitive::RepoFontAwesome::fa_download));

    // History
    QObject::connect(ui->actionHistory, SIGNAL(triggered()), this, SLOT(history()));
    ui->actionHistory->setIcon(primitive::RepoFontAwesome::getHistoryIcon());


    // Commit
    QObject::connect(ui->actionCommit, SIGNAL(triggered()), this, SLOT(commit()));
    ui->actionCommit->setIcon(primitive::RepoFontAwesome::getCommitIcon());

    // Federate...
    QObject::connect(ui->actionFederate, SIGNAL(triggered()),
                     this, SLOT(federate()));

    QObject::connect(ui->actionAccessManager, SIGNAL(triggered()),
                     this, SLOT(openAccessManager()));

    // Add Map Tiles...
    QObject::connect(ui->actionAddMapTiles, SIGNAL(triggered()),
                     this, SLOT(addMapTiles()));

    //--------------------------------------------------------------------------
    // Drop
    QObject::connect(ui->actionRemoveProject, SIGNAL(triggered()), this, SLOT(removeProject()));
    QObject::connect(ui->actionDrop, SIGNAL(triggered()), this, SLOT(drop()));
    ui->actionDrop->setIcon(primitive::RepoFontAwesome::getInstance().getIcon(primitive::RepoFontAwesome::fa_trash_o));




    //--------------------------------------------------------------------------
    //
    // Rendering
    //
    //--------------------------------------------------------------------------
    // Link
    QObject::connect(ui->actionLink, SIGNAL(triggered(bool)), ui->mdiArea, SLOT(chainSubWindows(bool)));
    ui->actionLink->setIcon(
                primitive::RepoFontAwesome::getInstance().getIcon(
                    primitive::RepoFontAwesome::fa_link,
                    primitive::RepoFontAwesome::fa_chain_broken));



    //--------------------------------------------------------------------------<commit_msg>#138 set trash icon to remove project as well<commit_after>/**
 *  Copyright (C) 2014 3D Repo Ltd
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

//------------------------------------------------------------------------------
// Qt
#include <QMessageBox>
#include <QtSvg>

//------------------------------------------------------------------------------
// GUI
#include "repo_gui.h"
#include "ui_repo_gui.h"
#include "dialogs/repo_dialog_commit.h"
#include "dialogs/repo_dialog_history.h"
#include "dialogs/repo_dialog_settings.h"
#include "dialogs/repo_dialog_about.h"
#include "../logger/repo_logger.h"
#include "dialogs/repo_dialog_connect.h"
#include "widgets/repo_widget_repository.h"
#include "widgets/repo_text_browser.h"
#include "widgets/repo_widget_flags.h"
#include "widgets/repo_widget_tree_dock.h"
#include "widgets/repo_widget_manager_3ddiff.h"
#include "../workers/repo_worker_commit.h"
#include "../workers/repo_worker_file_export.h"
#include "../workers/repo_worker_optimize.h"
#include "primitives/repo_fontawesome.h"
#include "primitives/repo_color.h"
#include "dialogs/repo_dialog_manager_abstract.h"
#include "dialogs/repo_dialog_federation.h"
#include "dialogs/repo_dialog_map.h"


//------------------------------------------------------------------------------
#include "dialogs/repo_dialog_manager_access.h"
#include "dialogs/repo_dialog_manager_connect.h"
//------------------------------------------------------------------------------

const QString repo::gui::RepoGUI::REPO_SETTINGS_GUI_GEOMETRY    = "RepoGUI/geometry";
const QString repo::gui::RepoGUI::REPO_SETTINGS_GUI_STATE       = "RepoGUI/state";
const QString repo::gui::RepoGUI::REPO_SETTINGS_LINK_WINDOWS    = "RepoGUI/link";

repo::gui::RepoGUI::RepoGUI(
        repo::RepoController *controller,
        QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::RepoGUI)
    , controller(controller)
    , panelsMenu(0)
    , navigationModeActionGroup(new QActionGroup(this))
{
    ui->setupUi(this);
    restoreSettings();

    this->setWindowTitle(
                QCoreApplication::applicationName() +
                " v" +
                QCoreApplication::applicationVersion());

    //Subscribe logger to broadcaster who taps into repo bouncer library logs
    repo::logger::RepoLogger::getInstance()->subscribe(ui->logTextBrowser);

    QIcon icon(":/images/3drepo-icon.svg");
    this->setWindowIcon(icon);

    //--------------------------------------------------------------------------
    // For docks and windows not to update as they are slow to repaint.
    this->setAnimated(false);

    //--------------------------------------------------------------------------
    // Force opengl format settings by default.
    QGLFormat format(QGL::SampleBuffers);
    format.setSwapInterval(1); // vsync
    format.setSamples(16); // Antialiasing (multisample)
    QGLFormat::setDefaultFormat(format);

    //--------------------------------------------------------------------------
    //
    // File
    //
    //--------------------------------------------------------------------------
    // Open
    QObject::connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
    ui->actionOpen->setIcon(primitive::RepoFontAwesome::getInstance().getIcon(primitive::RepoFontAwesome::fa_folder_open));

    // Save As
    QObject::connect(ui->actionSave_As, SIGNAL(triggered()), this,
                     SLOT(saveAs()));
    ui->actionSave_As->setIcon(primitive::RepoFontAwesome::getInstance().getIcon(primitive::RepoFontAwesome::fa_floppy_o));

    // Save Screenshot
    QObject::connect(ui->actionSave_Screenshot, SIGNAL(triggered()), this,
                     SLOT(saveScreenshot()));


    QObject::connect(ui->actionClose, &QAction::triggered,
                     ui->mdiArea, &widget::RepoMdiArea::closeActiveSubWindow);

    QObject::connect(ui->actionClose_All, &QAction::triggered,
                     ui->mdiArea, &widget::RepoMdiArea::closeAllSubWindows);

    QObject::connect(ui->actionClose_All, &QAction::triggered,
                     ui->mdiArea, &widget::RepoMdiArea::closeHiddenSubWindows);

    //--------------------------------------------------------------------------
    // Exit
    QObject::connect(ui->actionExit, SIGNAL(triggered()),
                     QApplication::instance(), SLOT(quit()));
    ui->actionExit->setIcon(
                primitive::RepoFontAwesome::getInstance().getIcon(
                    primitive::RepoFontAwesome::fa_times, QColor(Qt::darkRed)));


    //--------------------------------------------------------------------------
    //
    // Repository
    //
    //--------------------------------------------------------------------------
    // Connect
    QObject::connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(connectDB()));
    ui->actionConnect->setIcon(primitive::RepoFontAwesome::getConnectIcon());

    // Disconnect
    QObject::connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(disconnectDB()));
    ui->actionDisconnect->setIcon(primitive::RepoFontAwesome::getDisconnectIcon());

    // Refresh
    QObject::connect(ui->actionRefresh, SIGNAL(triggered()), this, SLOT(refresh()));
    ui->actionRefresh->setIcon(
                primitive::RepoFontAwesome::getInstance().getIcon(
                    primitive::RepoFontAwesome::fa_refresh,
                    QColor(Qt::darkGreen)));

    // Head
    QObject::connect(ui->actionHead, SIGNAL(triggered()), this, SLOT(fetchHead()));
    ui->actionHead->setIcon(
                primitive::RepoFontAwesome::getInstance().getIcon(
                    primitive::RepoFontAwesome::fa_download));

    // History
    QObject::connect(ui->actionHistory, SIGNAL(triggered()), this, SLOT(history()));
    ui->actionHistory->setIcon(primitive::RepoFontAwesome::getHistoryIcon());


    // Commit
    QObject::connect(ui->actionCommit, SIGNAL(triggered()), this, SLOT(commit()));
    ui->actionCommit->setIcon(primitive::RepoFontAwesome::getCommitIcon());

    // Federate...
    QObject::connect(ui->actionFederate, SIGNAL(triggered()),
                     this, SLOT(federate()));

    QObject::connect(ui->actionAccessManager, SIGNAL(triggered()),
                     this, SLOT(openAccessManager()));

    // Add Map Tiles...
    QObject::connect(ui->actionAddMapTiles, SIGNAL(triggered()),
                     this, SLOT(addMapTiles()));

    //--------------------------------------------------------------------------
    // Drop
    QObject::connect(ui->actionRemoveProject, SIGNAL(triggered()), this, SLOT(removeProject()));
    ui->actionRemoveProject->setIcon(primitive::RepoFontAwesome::getInstance().getIcon(primitive::RepoFontAwesome::fa_trash_o));
    QObject::connect(ui->actionDrop, SIGNAL(triggered()), this, SLOT(drop()));
    ui->actionDrop->setIcon(primitive::RepoFontAwesome::getInstance().getIcon(primitive::RepoFontAwesome::fa_trash_o));




    //--------------------------------------------------------------------------
    //
    // Rendering
    //
    //--------------------------------------------------------------------------
    // Link
    QObject::connect(ui->actionLink, SIGNAL(triggered(bool)), ui->mdiArea, SLOT(chainSubWindows(bool)));
    ui->actionLink->setIcon(
                primitive::RepoFontAwesome::getInstance().getIcon(
                    primitive::RepoFontAwesome::fa_link,
                    primitive::RepoFontAwesome::fa_chain_broken));



    //--------------------------------------------------------------------------
{'fraction_non_alphanumeric': 0.2620710973724884, 'fraction_numerical': 0.001669242658423493, 'mean_word_length': 2.0642167077097935, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4480310', 'n_tokens_mistral': 4403, 'n_tokens_neox': 4256, 'n_words': 715}