UBOpenSankoreImporterWidget.cpp 3.92 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1
/*
2
 * Copyright (C) 2015-2018 Département de l'Instruction Publique (DIP-SEM)
Craig Watson's avatar
Craig Watson committed
3
 *
Claudio Valerio's avatar
Claudio Valerio committed
4
 * Copyright (C) 2013 Open Education Foundation
5
 *
Claudio Valerio's avatar
Claudio Valerio committed
6 7
 * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour
 * l'Education Numérique en Afrique (GIP ENA)
8
 *
Claudio Valerio's avatar
Claudio Valerio committed
9 10 11
 * This file is part of OpenBoard.
 *
 * OpenBoard is free software: you can redistribute it and/or modify
12 13 14 15 16 17
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License,
 * with a specific linking exception for the OpenSSL project's
 * "OpenSSL" library (or with modified versions of it that use the
 * same license as the "OpenSSL" library).
 *
Claudio Valerio's avatar
Claudio Valerio committed
18
 * OpenBoard is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Claudio Valerio's avatar
Claudio Valerio committed
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 22 23
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
Claudio Valerio's avatar
Claudio Valerio committed
24
 * along with OpenBoard. If not, see <http://www.gnu.org/licenses/>.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
 */


#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QTextEdit>
#include <QCheckBox>
#include <QPushButton>

#include "core/UBSettings.h"

#include "UBOpenSankoreImporterWidget.h"

UBOpenSankoreImporterWidget::UBOpenSankoreImporterWidget(QWidget *parent):
    UBFloatingPalette(Qt::TopRightCorner,parent)
{
Claudio Valerio's avatar
Claudio Valerio committed
42 43
    setBackgroundBrush(QBrush(Qt::white));

44 45
    setObjectName("UBOpenSankoreImporterWidget");
    setFixedSize(700,450);
Claudio Valerio's avatar
Claudio Valerio committed
46
    setStyleSheet("QWidget#UBOpenSankoreImporterWidget { background-color : red; }");
47 48 49 50 51 52

    QVBoxLayout* mLayout = new QVBoxLayout(this);
    mLayout->setContentsMargins(20,38,20,20);
    setLayout(mLayout);

    QLabel* title = new QLabel(this);
Claudio Valerio's avatar
Claudio Valerio committed
53 54
    title->setStyleSheet("font-size : 18px; font-weight : bold;");
    title->setText(tr("Open-Sankore Documents Detected"));
55
    mLayout->addWidget(title);
Claudio Valerio's avatar
Claudio Valerio committed
56
    mLayout->addSpacing(20);
57 58

    QTextEdit* helpText = new QTextEdit(this);
Claudio Valerio's avatar
Claudio Valerio committed
59
    helpText->setText(tr("Open-Sankoré documents are present on your computer. It is possible to import them to OpenBoard by pressing the “Proceed” button to launch the importer application."));
60 61
    helpText->setAcceptDrops(false);
    helpText->setReadOnly(true);
Claudio Valerio's avatar
Claudio Valerio committed
62
    helpText->setStyleSheet("border : none;");
63 64 65 66 67 68 69
    mLayout->addWidget(helpText);

    mDisplayOnNextRestart = new QCheckBox(this);
    mDisplayOnNextRestart->setText(tr("Show this panel next time"));
    mDisplayOnNextRestart->setChecked(true);
    connect(mDisplayOnNextRestart,SIGNAL(clicked(bool)),this,SLOT(onNextRestartCheckBoxClicked(bool)));
    mLayout->addWidget(mDisplayOnNextRestart);
Claudio Valerio's avatar
Claudio Valerio committed
70
    mLayout->addSpacing(100);
Claudio Valerio's avatar
Claudio Valerio committed
71 72 73 74

    QTextEdit* warningText = new QTextEdit(this);
    warningText->setText(tr("You can always access the OpenBoard Document Importer through the Preferences panel in the About tab. Warning, if you have already imported your Open-Sankore datas, you might loose your current OpenBoard documents."));
    warningText->setReadOnly(true);
Claudio Valerio's avatar
Claudio Valerio committed
75
    warningText->setStyleSheet("border : none;");
Claudio Valerio's avatar
Claudio Valerio committed
76
    mLayout->addWidget(warningText);
77 78 79 80 81 82 83 84 85 86 87 88 89 90

    QHBoxLayout* buttonLayout = new QHBoxLayout();
    QPushButton* mCancelButton = new QPushButton(this);
    mCancelButton->setText(tr("Cancel"));
    buttonLayout->addWidget(mCancelButton);
    buttonLayout->addStretch();
    connect(mCancelButton,SIGNAL(clicked()),this,SLOT(close()));

    mProceedButton = new QPushButton(this);
    mProceedButton->setText(tr("Proceed"));
    buttonLayout->addWidget(mProceedButton);

    mLayout->addLayout(buttonLayout);

Claudio Valerio's avatar
Claudio Valerio committed
91

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
    show();
}

void UBOpenSankoreImporterWidget::onNextRestartCheckBoxClicked(bool clicked)
{
    UBSettings::settings()->appLookForOpenSankoreInstall->setBool(clicked);
}

void UBOpenSankoreImporterWidget::showEvent(QShowEvent *event)
{
    Q_UNUSED(event);
    adjustSizeAndPosition();
    move((parentWidget()->width() - width()) / 2, (parentWidget()->height() - height()) / 5);
}


int UBOpenSankoreImporterWidget::border()
{
    return 10;
}