##// END OF EJS Templates
New data sources system switch complete...
New data sources system switch complete Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1495:9c439b3d7daf
r1495:9c439b3d7daf
Show More
MainWindow.cpp
203 lines | 6.6 KiB | text/x-c | CppLexer
Initialisation de l'application multithread avec le spimpl....
r21 /*------------------------------------------------------------------------------
Refactoring of app module to avoir vera++ warning and to dispatch sources files in the corrects paths
r54 -- This file is a part of the SciQLop Software
-- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
Initialisation de l'application multithread avec le spimpl....
r21 --
-- This program 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; either version 2 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 General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------*/
/*-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@member.fsf.org
----------------------------------------------------------------------------*/
Refactoring of app module to avoir vera++ warning and to dispatch sources files in the corrects paths
r54 #include "MainWindow.h"
#include "ui_MainWindow.h"
Alexandre Leroux
Connects data source widget to data source controller
r84
Check unsaved data on close
r1239 #include <Catalogue/CatalogueController.h>
Set revision to 1.1.0 some work to bring back catalogs...
r1460 #include <Catalogue2/browser.h>
PySide2 bindings + some GUI clean...
r1478 #include <DataSource/DataSourceItem.h>
Alexandre Leroux
Connects data source widget to data source controller
r84 #include <DataSource/DataSourceWidget.h>
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r463 #include <Settings/SqpSettingsDialog.h>
Alexandre Leroux
Creates widget for "general settings" and registers it to the dialog
r465 #include <Settings/SqpSettingsGeneralWidget.h>
Add button on the SidePane widgets to open left or right inspectors
r101 #include <SidePane/SqpSidePane.h>
Alexandre Leroux
Connects data source widget to data source controller
r84 #include <SqpApplication.h>
add TimeWidget connection
r192 #include <Time/TimeController.h>
Modificaiton of the sidepane :...
r133 #include <TimeWidget/TimeWidget.h>
Alexandre Leroux
Connects data source widget to data source controller
r84
Refactored main toolbar to make it suck less :)...
r1462 #include "toolbar.h"
Initialisation de l'application multithread avec le spimpl....
r21 #include <QAction>
Check unsaved data on close
r1239 #include <QCloseEvent>
Initialisation de l'application multithread avec le spimpl....
r21 #include <QDate>
#include <QDir>
#include <QFileDialog>
Check unsaved data on close
r1239 #include <QMessageBox>
Add button on the SidePane widgets to open left or right inspectors
r101 #include <QToolBar>
Factorisation of the lambda connected to the side pane button
r138 #include <QToolButton>
Add button on the SidePane widgets to open left or right inspectors
r101 #include <memory.h>
Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
New Catalogue API WIP, basic models and views implemented...
r1406 class MainWindow::MainWindowPrivate
{
Add button on the SidePane widgets to open left or right inspectors
r101 public:
New Catalogue API WIP, basic models and views implemented...
r1406 explicit MainWindowPrivate(MainWindow* mainWindow)
PySide2 bindings + some GUI clean...
r1478 : m_GeneralSettingsWidget { new SqpSettingsGeneralWidget { mainWindow } }
New Catalogue API WIP, basic models and views implemented...
r1406 , m_SettingsDialog { new SqpSettingsDialog { mainWindow } }
Set revision to 1.1.0 some work to bring back catalogs...
r1460 , m_CatalogExplorer { new CataloguesBrowser { mainWindow } }
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r463 {
}
Alexandre Leroux
Creates widget for "general settings" and registers it to the dialog
r465 /// General settings widget. MainWindow has the ownership
New Catalogue API WIP, basic models and views implemented...
r1406 SqpSettingsGeneralWidget* m_GeneralSettingsWidget;
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r463 /// Settings dialog. MainWindow has the ownership
New Catalogue API WIP, basic models and views implemented...
r1406 SqpSettingsDialog* m_SettingsDialog;
Add a button in the application toolbar to open the catalogues
r1094 /// Catalogue dialog. MainWindow has the ownership
Set revision to 1.1.0 some work to bring back catalogs...
r1460 CataloguesBrowser* m_CatalogExplorer;
Check unsaved data on close
r1239
New Catalogue API WIP, basic models and views implemented...
r1406 bool checkDataToSave(QWidget* parentWidget);
Add button on the SidePane widgets to open left or right inspectors
r101 };
New Catalogue API WIP, basic models and views implemented...
r1406 MainWindow::MainWindow(QWidget* parent)
: QMainWindow { parent }
, m_Ui { new Ui::MainWindow }
, impl { spimpl::make_unique_impl<MainWindowPrivate>(this) }
Initialisation de l'application multithread avec le spimpl....
r21 {
Refactoring of app module to avoir vera++ warning and to dispatch sources files in the corrects paths
r54 m_Ui->setupUi(this);
Set SciQLop Version to 1.0.0 🍾...
r1458 setWindowTitle(QString("SciQLop v%1").arg(SCIQLOP_VERSION));
Add skelleton of the gui
r56
Toolbar for interactions modes
r957 // //////////////// //
// Menu and Toolbar //
// //////////////// //
PRC: add tr on text...
r102 this->menuBar()->addAction(tr("File"));
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r463 auto toolsMenu = this->menuBar()->addMenu(tr("Tools"));
toolsMenu->addAction(tr("Settings..."), [this]() {
Alexandre Leroux
Settings binding (4)...
r469 // Loads settings
impl->m_SettingsDialog->loadSettings();
// Open settings dialog and save settings if the dialog is accepted
New Catalogue API WIP, basic models and views implemented...
r1406 if (impl->m_SettingsDialog->exec() == QDialog::Accepted)
{
Alexandre Leroux
Settings binding (4)...
r469 impl->m_SettingsDialog->saveSettings();
}
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r463 });
Refactored main toolbar to make it suck less :)...
r1462 auto mainToolBar = new ToolBar(this);
this->addToolBar(mainToolBar);
connect(mainToolBar, &ToolBar::setPlotsInteractionMode, sqpApp,
&SqpApplication::setPlotsInteractionMode);
connect(mainToolBar, &ToolBar::setPlotsCursorMode, sqpApp, &SqpApplication::setPlotsCursorMode);
connect(mainToolBar, &ToolBar::showCataloguesBrowser,
Set revision to 1.1.0 some work to bring back catalogs...
r1460 [this]() { impl->m_CatalogExplorer->show(); });
Add a button in the application toolbar to open the catalogues
r1094
Alexandre Leroux
Creates widget for "general settings" and registers it to the dialog
r465 // //////// //
// Settings //
// //////// //
// Registers "general settings" widget to the settings dialog
New Catalogue API WIP, basic models and views implemented...
r1406 impl->m_SettingsDialog->registerWidget(
QStringLiteral("General"), impl->m_GeneralSettingsWidget);
Alexandre Leroux
Creates widget for "general settings" and registers it to the dialog
r465
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r463 // /////////// //
// Connections //
// /////////// //
Alexandre Leroux
Connects data source widget to data source controller
r84 // Widgets / controllers connections
add TimeWidget connection
r192
// Time
Refactored main toolbar to make it suck less :)...
r1462 // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(),
// SLOT(onTimeToUpdate(DateTimeRange)));
connect(mainToolBar, &ToolBar::timeUpdated, &sqpApp->timeController(),
&TimeController::setDateTimeRange);
add TimeWidget connection
r192
Alexandre Leroux
Connects variable widget to visualization widget...
r249 // Widgets / widgets connections
// For the following connections, we use DirectConnection to allow each widget that can
// potentially attach a menu to the variable's menu to do so before this menu is displayed.
// The order of connections is also important, since it determines the order in which each
// widget will attach its menu
New Catalogue API WIP, basic models and views implemented...
r1406 connect(m_Ui->variableInspectorWidget,
SIGNAL(tableMenuAboutToBeDisplayed(QMenu*, const QVector<std::shared_ptr<Variable>>&)),
m_Ui->view, SLOT(attachVariableMenu(QMenu*, const QVector<std::shared_ptr<Variable>>&)),
Alexandre Leroux
Changes signal to pass a list of variables...
r288 Qt::DirectConnection);
Initialisation de l'application multithread avec le spimpl....
r21 }
New Catalogue API WIP, basic models and views implemented...
r1406 MainWindow::~MainWindow() {}
Initialisation de l'application multithread avec le spimpl....
r21
New Catalogue API WIP, basic models and views implemented...
r1406 void MainWindow::changeEvent(QEvent* e)
Initialisation de l'application multithread avec le spimpl....
r21 {
QMainWindow::changeEvent(e);
New Catalogue API WIP, basic models and views implemented...
r1406 switch (e->type())
{
Initialisation de l'application multithread avec le spimpl....
r21 case QEvent::LanguageChange:
Refactoring of app module to avoir vera++ warning and to dispatch sources files in the corrects paths
r54 m_Ui->retranslateUi(this);
Initialisation de l'application multithread avec le spimpl....
r21 break;
default:
break;
}
}
Check unsaved data on close
r1239
New Catalogue API WIP, basic models and views implemented...
r1406 void MainWindow::closeEvent(QCloseEvent* event)
Check unsaved data on close
r1239 {
New Catalogue API WIP, basic models and views implemented...
r1406 if (!impl->checkDataToSave(this))
{
Check unsaved data on close
r1239 event->ignore();
}
New Catalogue API WIP, basic models and views implemented...
r1406 else
{
Check unsaved data on close
r1239 event->accept();
}
}
New Catalogue API WIP, basic models and views implemented...
r1406 void MainWindow::keyPressEvent(QKeyEvent* event)
Restored graph D&D and added full screen mode (F11)...
r1376 {
switch (event->key())
{
New Catalogue API WIP, basic models and views implemented...
r1406 case Qt::Key_F11:
if (this->isFullScreen())
{
this->showNormal();
}
else
{
this->showFullScreen();
}
break;
default:
break;
Restored graph D&D and added full screen mode (F11)...
r1376 }
}
New Catalogue API WIP, basic models and views implemented...
r1406 bool MainWindow::MainWindowPrivate::checkDataToSave(QWidget* parentWidget)
Check unsaved data on close
r1239 {
New Catalogue API WIP, basic models and views implemented...
r1406 // auto hasChanges = sqpApp->catalogueController().hasChanges();
// if (hasChanges)
// {
// // There are some unsaved changes
// switch (QMessageBox::question(parentWidget, tr("Save changes"),
// tr("The catalogue controller has unsaved changes.\nDo you want to save them ?"),
// QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel,
// QMessageBox::SaveAll))
// {
// case QMessageBox::SaveAll:
// sqpApp->catalogueController().saveAll();
// break;
// case QMessageBox::Discard:
// break;
// case QMessageBox::Cancel:
// default:
// return false;
// }
// }
Check unsaved data on close
r1239
return true;
}