diff --git a/resources/forms/preferences.ui b/resources/forms/preferences.ui
index 29f0ddef..ac262e72 100644
--- a/resources/forms/preferences.ui
+++ b/resources/forms/preferences.ui
@@ -24,7 +24,7 @@
-
- 5
+ 6
@@ -2781,6 +2781,44 @@ p, li { white-space: pre-wrap; }
+ -
+
+
+
+ 0
+ 70
+
+
+
+
+ 16777215
+ 70
+
+
+
+ Open-Sankoré Importer
+
+
+
+ true
+
+
+
+ 10
+ 30
+ 551
+ 21
+
+
+
+ Check if Open-Sankoré data could be imported at launch
+
+
+ true
+
+
+
+
diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp
index b30326a0..04ff286d 100644
--- a/src/core/UBApplicationController.cpp
+++ b/src/core/UBApplicationController.cpp
@@ -135,6 +135,9 @@ UBApplicationController::~UBApplicationController()
delete mBlackScene;
delete mMirror;
if (mHttp) delete mHttp;
+
+ delete(mOpenSankoreImporter);
+ mOpenSankoreImporter = NULL;
}
@@ -525,7 +528,7 @@ void UBApplicationController::downloadJsonFinished(QString currentJson)
void UBApplicationController::checkAtLaunch()
{
- UBOpenSankoreImporter();
+ mOpenSankoreImporter = new UBOpenSankoreImporter(mMainWindow->centralWidget());
if(UBSettings::settings()->appEnableAutomaticSoftwareUpdates->get().toBool()){
isNoUpdateDisplayed = false;
@@ -610,6 +613,7 @@ void UBApplicationController::closing()
if (UBApplication::documentController)
UBApplication::documentController->closing();
+
}
diff --git a/src/core/UBApplicationController.h b/src/core/UBApplicationController.h
index 6fbedc98..a79c23c1 100644
--- a/src/core/UBApplicationController.h
+++ b/src/core/UBApplicationController.h
@@ -40,11 +40,11 @@ class QNetworkAccessManager;
class QNetworkReply;
class QHttp;
class UBRightPalette;
-
+class UBOpenSankoreImporter;
class UBApplicationController : public QObject
{
- Q_OBJECT;
+ Q_OBJECT
public:
@@ -148,6 +148,8 @@ class UBApplicationController : public QObject
UBMainWindow *mMainWindow;
+ UBOpenSankoreImporter *mOpenSankoreImporter;
+
UBBoardView *mControlView;
UBBoardView *mDisplayView;
QList mPreviousViews;
diff --git a/src/core/UBOpenSankoreImporter.cpp b/src/core/UBOpenSankoreImporter.cpp
index e0a0713e..2a1e73fa 100644
--- a/src/core/UBOpenSankoreImporter.cpp
+++ b/src/core/UBOpenSankoreImporter.cpp
@@ -27,29 +27,37 @@
#include "core/UBApplication.h"
#include "gui/UBMainWindow.h"
+#include "gui/UBOpenSankoreImporterWidget.h"
-
-UBOpenSankoreImporter::UBOpenSankoreImporter(QObject *parent) :
+UBOpenSankoreImporter::UBOpenSankoreImporter(QWidget* mainWidget, QObject *parent) :
QObject(parent)
+ , mImporterWidget(NULL)
{
if(UBSettings::settings()->appLookForOpenSankoreInstall->get().toBool() &&
QDir(UBSettings::userDataDirectory().replace(qApp->applicationName(),"Sankore")).exists()){
- if(UBApplication::mainWindow->yesNoQuestion(tr("Open-Sankoré data detected"),tr("Open-Sankoré directory is present on the disk. It's possible to import the Open-Sankoré documents into OpenBoard as the preferences. Pushing Ok will close OpenBoard and run the importer application."))){
- QProcess newProcess;
+
+ mImporterWidget = new UBOpenSankoreImporterWidget(mainWidget);
+
+ connect(mImporterWidget->proceedButton(),SIGNAL(clicked()),mImporterWidget,SLOT(close()));
+ connect(mImporterWidget->proceedButton(),SIGNAL(clicked()),this,SLOT(onProceedClicked()));
+ }
+}
+
+void UBOpenSankoreImporter::onProceedClicked()
+{
+ QProcess newProcess;
#ifdef Q_WS_X11
- newProcess.startDetached(qApp->applicationDirPath()+"/Importer/OpenBoardImporter");
+ newProcess.startDetached(qApp->applicationDirPath()+"/Importer/OpenBoardImporter");
#elif defined Q_WS_MACX
- newProcess.startDetached(qApp->applicationDirPath()+"/../Resources/OpenBoardImporter.app/Contents/MacOS/OpenBoardImporter");
+ newProcess.startDetached(qApp->applicationDirPath()+"/../Resources/OpenBoardImporter.app/Contents/MacOS/OpenBoardImporter");
#else
- // Windows does not allows to run easily an exe located in a subdirectory when the main
- // directory is placed into programs files.
- //newProcess.startDetached(qApp->applicationDirPath()+"\\Importer\\OpenBoardImporter.exe");
- newProcess.startDetached("C:/OpenBoard/Importer/OpenBoardImporter.exe");
+ // Windows does not allows to run easily an exe located in a subdirectory when the main
+ // directory is placed into programs files.
+ //newProcess.startDetached(qApp->applicationDirPath()+"\\Importer\\OpenBoardImporter.exe");
+ newProcess.startDetached("C:/OpenBoard/Importer/OpenBoardImporter.exe");
#endif
- qApp->exit(0);
- }
- }
+ qApp->exit(0);
+
}
-
\ No newline at end of file
diff --git a/src/core/UBOpenSankoreImporter.h b/src/core/UBOpenSankoreImporter.h
index 692ab38c..adc1d836 100644
--- a/src/core/UBOpenSankoreImporter.h
+++ b/src/core/UBOpenSankoreImporter.h
@@ -23,17 +23,23 @@
#ifndef UBOPENSANKOREIMPORTER_H
#define UBOPENSANKOREIMPORTER_H
+class UBOpenSankoreImporterWidget;
+
#include
class UBOpenSankoreImporter : public QObject
{
Q_OBJECT
public:
- explicit UBOpenSankoreImporter(QObject *parent = 0);
+ explicit UBOpenSankoreImporter(QWidget *mainWidget, QObject *parent = 0);
signals:
public slots:
+ void onProceedClicked();
+
+private:
+ UBOpenSankoreImporterWidget* mImporterWidget;
};
diff --git a/src/core/UBPreferencesController.cpp b/src/core/UBPreferencesController.cpp
index b1aa8f99..4223bda6 100644
--- a/src/core/UBPreferencesController.cpp
+++ b/src/core/UBPreferencesController.cpp
@@ -175,6 +175,7 @@ void UBPreferencesController::wire()
// about tab
connect(mPreferencesUI->checkSoftwareUpdateAtLaunchCheckBox, SIGNAL(clicked(bool)), settings->appEnableAutomaticSoftwareUpdates, SLOT(setBool(bool)));
+ connect(mPreferencesUI->checkOpenSankoreAtStartup, SIGNAL(clicked(bool)), settings->appLookForOpenSankoreInstall, SLOT(setBool(bool)));
}
void UBPreferencesController::init()
@@ -183,6 +184,7 @@ void UBPreferencesController::init()
// about tab
mPreferencesUI->checkSoftwareUpdateAtLaunchCheckBox->setChecked(settings->appEnableAutomaticSoftwareUpdates->get().toBool());
+ mPreferencesUI->checkOpenSankoreAtStartup->setChecked(settings->appLookForOpenSankoreInstall->get().toBool());
// display tab
for(int i=0; ikeyboardPaletteKeyButtonSize->count(); i++)
@@ -297,6 +299,10 @@ void UBPreferencesController::defaultSettings()
{
bool defaultValue = settings->appEnableAutomaticSoftwareUpdates->reset().toBool();
mPreferencesUI->checkSoftwareUpdateAtLaunchCheckBox->setChecked(defaultValue);
+
+ defaultValue = settings->appLookForOpenSankoreInstall->reset().toBool();
+ mPreferencesUI->checkOpenSankoreAtStartup->setChecked(defaultValue);
+
}
else if(mPreferencesUI->mainTabWidget->currentWidget() == mPreferencesUI->networkTab){
bool defaultValue = settings->webUseExternalBrowser->reset().toBool();
diff --git a/src/gui/UBMainWindow.cpp b/src/gui/UBMainWindow.cpp
index 61f77f9d..490434d4 100644
--- a/src/gui/UBMainWindow.cpp
+++ b/src/gui/UBMainWindow.cpp
@@ -27,6 +27,8 @@
#include "core/UBApplication.h"
#include "core/UBApplicationController.h"
#include "board/UBBoardController.h"
+#include "core/UBDisplayManager.h"
+
// work around for handling tablet events on MAC OS with Qt 4.8.0 and above
#if defined(Q_WS_MACX)
#include "board/UBBoardView.h"
@@ -133,14 +135,6 @@ void UBMainWindow::switchToDocumentsWidget()
void UBMainWindow::keyPressEvent(QKeyEvent *event)
{
QMainWindow::keyPressEvent(event);
-
- /*
- if (event->key() == Qt::Key_B && !event->isAccepted())
- {
- UBApplication::applicationController->blackout();
- event->accept();
- }
- */
}
void UBMainWindow::closeEvent(QCloseEvent *event)
@@ -191,8 +185,6 @@ void UBMainWindow::onExportDone()
actionDocumentAdd->setEnabled(true);
}
-#include "core/UBDisplayManager.h"
-
bool UBMainWindow::yesNoQuestion(QString windowTitle, QString text)
{
QMessageBox messageBox;
diff --git a/src/gui/UBOpenSankoreImporterWidget.cpp b/src/gui/UBOpenSankoreImporterWidget.cpp
new file mode 100644
index 00000000..bbb6eabe
--- /dev/null
+++ b/src/gui/UBOpenSankoreImporterWidget.cpp
@@ -0,0 +1,95 @@
+/* Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA)
+ *
+ * This file is part of Open-Sankoré.
+ *
+ * Open-Sankoré is free software: you can redistribute it and/or modify
+ * 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).
+ *
+ * Open-Sankoré 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Open-Sankoré. If not, see .
+ */
+
+
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "core/UBSettings.h"
+
+#include "UBOpenSankoreImporterWidget.h"
+
+UBOpenSankoreImporterWidget::UBOpenSankoreImporterWidget(QWidget *parent):
+ UBFloatingPalette(Qt::TopRightCorner,parent)
+{
+ setObjectName("UBOpenSankoreImporterWidget");
+ setFixedSize(700,450);
+
+ QVBoxLayout* mLayout = new QVBoxLayout(this);
+ mLayout->setContentsMargins(20,38,20,20);
+ setLayout(mLayout);
+
+ QLabel* title = new QLabel(this);
+ title->setText(tr("Open-Sankoré data detected"));
+ mLayout->addWidget(title);
+
+ QTextEdit* helpText = new QTextEdit(this);
+ helpText->setText(tr("Open-Sankoré directory is present on the disk. It's possible to import the Open-Sankoré documents into OpenBoard as the preferences. Pushing \"Proceed\" will close OpenBoard and run the importer application."));
+ helpText->setAcceptDrops(false);
+ helpText->setReadOnly(true);
+ 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->addStretch();
+ mLayout->addWidget(mDisplayOnNextRestart);
+ mLayout->addStretch();
+
+ 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);
+
+ 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;
+}
+
diff --git a/src/gui/UBOpenSankoreImporterWidget.h b/src/gui/UBOpenSankoreImporterWidget.h
new file mode 100644
index 00000000..a384440c
--- /dev/null
+++ b/src/gui/UBOpenSankoreImporterWidget.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA)
+ *
+ * This file is part of Open-Sankoré.
+ *
+ * Open-Sankoré is free software: you can redistribute it and/or modify
+ * 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).
+ *
+ * Open-Sankoré 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Open-Sankoré. If not, see .
+ */
+
+
+
+
+#ifndef UBOPENSANKOREIMPORTERWIDGET_H
+#define UBOPENSANKOREIMPORTERWIDGET_H
+
+class QCheckBox;
+class QPushButton;
+
+#include "UBFloatingPalette.h"
+
+class UBOpenSankoreImporterWidget : public UBFloatingPalette
+{
+ Q_OBJECT
+
+public:
+ UBOpenSankoreImporterWidget(QWidget* parent);
+ QPushButton* proceedButton(){return mProceedButton;}
+
+protected:
+ void showEvent(QShowEvent *event);
+ int border();
+
+ QCheckBox* mDisplayOnNextRestart;
+ QPushButton* mProceedButton;
+
+private slots:
+ void onNextRestartCheckBoxClicked(bool clicked);
+
+
+};
+
+#endif // UBOPENSANKOREIMPORTERWIDGET_H
diff --git a/src/gui/gui.pri b/src/gui/gui.pri
index f941edfe..76d72f7f 100644
--- a/src/gui/gui.pri
+++ b/src/gui/gui.pri
@@ -39,7 +39,8 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBDockDownloadWidget.h \
src/gui/UBFeaturesWidget.h \
src/gui/UBFeaturesActionBar.h \
- src/gui/UBMessagesDialog.h
+ src/gui/UBMessagesDialog.h \
+ src/gui/UBOpenSankoreImporterWidget.h
SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \
src/gui/UBToolbarButtonGroup.cpp \
@@ -81,7 +82,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBDockDownloadWidget.cpp \
src/gui/UBFeaturesWidget.cpp \
src/gui/UBFeaturesActionBar.cpp \
- src/gui/UBMessagesDialog.cpp
+ src/gui/UBMessagesDialog.cpp \
+ src/gui/UBOpenSankoreImporterWidget.cpp
win32:SOURCES += src/gui/UBKeyboardPalette_win.cpp
macx:SOURCES += src/gui/UBKeyboardPalette_mac.cpp
linux-g++:SOURCES += src/gui/UBKeyboardPalette_linux.cpp