Commit c59e67b4 authored by Mathieu Faverge's avatar Mathieu Faverge

Restructure export settings

parent ce4e70c5
......@@ -65,7 +65,11 @@
using namespace std;
/*
*
* Minimap Settings
*
*/
MinimapSettings::MinimapSettings(){
// Initialize Minimap default
_x = 0;
......@@ -122,9 +126,24 @@ void MinimapSettings::save(int x, int y, int w, int h, bool hidden ) {
save();
}
/*
*
* Export Settings
*
*/
ExportSettings::ExportSettings() {
file_dialog_state = QByteArray::number(-1);
}
bool ExportSettings::is_default() {
return file_dialog_state == QByteArray::number(-1);
}
const QByteArray Session::Export::DEFAULT_STATE = QByteArray::number(-1);
QByteArray Session::Export::file_dialog_state = Session::Export::DEFAULT_STATE;
/*
*
* Common Settings
*
*/
//QSettings *Session::_settings = NULL;
Session *Session::S = NULL;
......@@ -135,6 +154,7 @@ bool Session::_use_palettes = false;
bool Session::_use_palettes_is_set = false;
MinimapSettings *Session::_mmSettings = NULL;
ExportSettings *Session::_exportSettings = NULL;
Session::Session() : QSettings( VITE_ORGANISATION_NAME, VITE_APPLICATION_NAME ) {
QCoreApplication::setOrganizationName(VITE_ORGANISATION_NAME);
......@@ -143,6 +163,8 @@ Session::Session() : QSettings( VITE_ORGANISATION_NAME, VITE_APPLICATION_NAME )
}
Session::~Session() {
delete _mmSettings;
delete _exportSettings;
}
void Session::init() {
......@@ -151,6 +173,7 @@ void Session::init() {
_palettes_event = get_palette("event_types", get_current_palette("event_types"));
_mmSettings = new MinimapSettings();
_exportSettings = new ExportSettings();
}
const QStringList Session::get_recent_files() {
......
......@@ -120,6 +120,23 @@ public:
void save(int x, int y, int w, int h, bool hidden );
};
/*!
* \brief Sub structure to store export information.
*/
class ExportSettings {
public:
/*!
* \brief Store the export file dialog state.
*/
QByteArray file_dialog_state;
ExportSettings();
bool is_default();
};
/*!
* \brief Class used to store information between two software launch.
*
......@@ -129,6 +146,7 @@ class Session : public QSettings {
protected:
static Session *S;
static MinimapSettings *_mmSettings;
static ExportSettings *_exportSettings;
static Palette *_palettes_state;
static Palette *_palettes_link;
......@@ -139,13 +157,6 @@ protected:
//boolean used to know if the previous one is set (ugly but avoids rereading from settings file each time)
static bool _use_palettes_is_set;
/*!
* \brief Sub structure to store render information.
*/
struct Render{
};
/*!
* \brief The class constructor.
*/
......@@ -155,22 +166,6 @@ protected:
public:
/*!
* \brief Sub structure to store export information.
*/
struct Export{
/*!
* \brief Store the export file dialog state.
*/
static QByteArray file_dialog_state;
/*!
* \brief Default value of the export dialog state.
*/
const static QByteArray DEFAULT_STATE;
};
static Session &getSession() {
if (S == NULL) {
S = new Session();
......@@ -183,6 +178,10 @@ public:
return *(getSession()._mmSettings);
}
static ExportSettings &getSessionExport() {
return *(getSession()._exportSettings);
}
/*!
* \brief The class destructor.
*/
......@@ -193,7 +192,6 @@ public:
*/
static const int _MAX_NB_RECENT_FILES = 10;
static void save_config_file();
static void load_config_file();
......
This diff is collapsed.
......@@ -70,10 +70,11 @@ using namespace std;
Settings_window::Settings_window(Core *c, QWidget *parent) : QWidget(parent), _c(c) {
setupUi(this);
plugin_load_dirs_name();
reload_general_tab();
_changed=false;
_changed = false;
Session &S = Session::getSession();
......
......@@ -6,13 +6,13 @@
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
......@@ -23,7 +23,7 @@
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
......@@ -37,7 +37,7 @@
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
** - VUCHENER Clément
**
*/
/*!
......@@ -61,16 +61,16 @@ class Color;
*/
class Settings_window : public QWidget, protected Ui::settings {
Q_OBJECT
private:
Core *_c;
//used to check if leaving the tab needs an apply first when OK button is pressed
bool _changed;
/*!
* \brief Load in the QListWidget the directory name from the Session
*/
......@@ -96,12 +96,12 @@ private:
* \brief Reload the minimap tab.
*/
void reload_minimap_tab();
/*!
* \brief Fill the event types table
*/
void fill_event_types_table(const std::string &text);
/*!
* \brief add an event type to the table
*/
......@@ -109,29 +109,29 @@ private:
/*!
* \brief Fill the link types table
*/
*/
void fill_link_types_table(const std::string &text);
/*!
* \brief add a link type to the table
*/
*/
void add_link_type_line(int&, std::string, Color*, bool);
/*!
* \brief add a palette to the list, for a given type
*/
*/
void add_palette(QComboBox* list, const std::string type);
/*!
* \brief removes a palette from the list, for a given type
*/
*/
void rm_palette(QComboBox* list, const std::string type);
/*!
* \brief copies a palette from the list, for a given type
*/
*/
QString copy_palette(QTableWidget* table, QComboBox* list, const std::string type);
public:
/*!
* Default constructor
......@@ -146,7 +146,7 @@ public:
* (to get them back if we cancel for example)
*/
void show();
public slots:
/*!
* \fn on_tabWidget_currentChanged(int index)
......@@ -164,14 +164,14 @@ private slots:
* Pop up a window asking for the name and the color of the new state.
*/
void on_add_state_btn_clicked();
/*!
* \fn on_rm_state_btn_clicked()
* \brief (state tab) Called when the user click on the remove state button.
* Erase the current state.
*/
void on_rm_state_btn_clicked();
/*!
* \fn on_palette_list_currentIndexChanged(const QString &text)
* \brief (state tab) Called when the user changes the current palette.
......@@ -235,15 +235,15 @@ private slots:
* Quit the window without saving changes.
*/
void on_cancel_clicked();
/*!
* \fn on_event_types_palette_list_currentIndexChanged()
* \brief (event types tab) Called when the user changes the current event types palette.
* \param text : the name of the palette.
* Fill the event types table with the state of the new palette.
*/
void on_event_types_palette_list_currentIndexChanged(const QString &text);
/*!
......@@ -268,64 +268,64 @@ private slots:
* Reload data from the actual file and fill the displayed table with it.
*/
void on_reload_event_types_palette_btn_clicked();
/*!
* \fn on_copy_link_types_palette_btn_clicked()
* \brief (link types tab) Called when the user click on the copy palette button.
* Copy the palette and its colors/states to the new palette.
*/
void on_copy_link_types_palette_btn_clicked();
/*!
* \fn on_copy_event_types_palette_btn_clicked()
* \brief (event types tab) Called when the user click on the copy palette button.
* Copy the palette and its colors/states to the new palette.
*/
void on_copy_event_types_palette_btn_clicked();
/*!
* \fn on_rm_link_types_palette_btn_clicked()
* \brief (link types tab) Called when the user click on the remove button.
* Removes the current palette from the list
*/
void on_rm_link_types_palette_btn_clicked();
/*!
* \fn on_rm_event_types_palette_btn_clicked()
* \brief (event types tab) Called when the user click on the remove button.
* Removes the current palette from the list
*/
void on_rm_event_types_palette_btn_clicked();
/*!
* \fn on_reload_states_btn_clicked()
* \brief (states tab) Called when the user click on the reload button.
* reload the states from the file in the current palette
*/
void on_reload_states_btn_clicked();
/*!
* \fn on_ok_clicked()
* \brief (states tab) Called when the user click on the OK button.
* apply changes and hide the window
*/
void on_ok_clicked();
/*!
* \fn event_types_color_changed(const QColor &c)
* \brief (event_types tab) Called when the user changes an object in the table.
* \param c : the new color
*/
void event_types_color_changed(const QColor &c);
/*!
* \fn link_types_color_changed(const QColor &c)
* \brief (link_types tab) Called when the user changes an object in the table.
* \param c : the new color
*/
void link_types_color_changed(const QColor &c);
/*!
* \fn on_use_palettes_triggered()
* \brief Called when the user changes use palettes setting.
......
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
#include <iostream>
#include <string>
......@@ -120,17 +120,17 @@ void Plugin_window::load_shared_plugins() {
for (it = _plugin_directories.constBegin() ;
it != _plugin_directories.constEnd() ;
++ it) {
QDir dir(QDir::toNativeSeparators((*it))); /* directory name where plugin are stored */
dir.setFilter(QDir::Files);
/* Create if not exists */
if(!dir.exists()) {
dir.mkpath(".");
}
QFileInfoList list = dir.entryInfoList();
for (int i = 0 ; i < list.size() ; ++ i) {
QFileInfo fileInfo = list.at(i);
QString filename = fileInfo.absoluteFilePath();
......@@ -138,9 +138,9 @@ void Plugin_window::load_shared_plugins() {
if(!QLibrary::isLibrary(filename)) {
continue;
}
QLibrary current_plugin(filename);
Plugin *(*f)(void) = (Plugin *(*)(void)) current_plugin.resolve("create");
if(!f) {
cerr << "Unable to load " << current_plugin.errorString().toStdString() <<endl;
......@@ -178,7 +178,7 @@ void Plugin_window::show() {
void Plugin_window::reload_plugin(int index) {
//_plugins[_current_index].unload();
if(index < (int)_plugins.size()) {
_plugins[index]->set_trace(_core->get_trace());
_plugins[index]->set_trace(_core->get_trace());
_current_index = index;
}
}
......@@ -186,8 +186,8 @@ void Plugin_window::reload_plugin(int index) {
void Plugin_window::execute_plugin() {
if(_current_index > (int)_plugins.size() || (_current_index == 0 && _plugins.size() == 0))
return;
_plugins[_current_index]->execute();
_plugins[_current_index]->execute();
}
void Plugin_window::clear_plugins() {
......@@ -210,16 +210,16 @@ void Plugin_window::reload_plugins() {
connect(_tab_widget, SIGNAL(currentChanged(int)), this, SLOT(reload_plugin(int)));
Session::load_plugin_directories(_plugin_directories);
load_shared_plugins();
load_plugin("statistics window");
}
void Plugin_window::load_list() {
// QSettings settings("ViTE", "ViTE");
// QStringList list = settings.value("pluginsList").toStringList();
// for(QStringList::const_iterator i = list.begin() ; i != list.end() ; ++ i) {
// load_plugin((*i).toStdString());
// }
// QSettings settings("ViTE", "ViTE");
// QStringList list = settings.value("pluginsList").toStringList();
// for(QStringList::const_iterator i = list.begin() ; i != list.end() ; ++ i) {
// load_plugin((*i).toStdString());
// }
}
void Plugin_window::load_plugin(const string &plugin_name) {
......@@ -230,11 +230,11 @@ void Plugin_window::load_plugin(const string &plugin_name) {
}
add_plugin(plug);
// // To save/add a plugin in the settings
// QSettings settings("ViTE", "ViTE");
// QStringList plugin_list = settings.value("pluginsList").toStringList();
// settings.setValue("recentFiles", files);
// plugin_list.removeAll(filename);
// plugin_list.prepend(filename);
// settings.setValue("pluginsList", files);
// // To save/add a plugin in the settings
// QSettings settings("ViTE", "ViTE");
// QStringList plugin_list = settings.value("pluginsList").toStringList();
// settings.setValue("recentFiles", files);
// plugin_list.removeAll(filename);
// plugin_list.prepend(filename);
// settings.setValue("pluginsList", files);
}
......@@ -50,7 +50,6 @@
#include <QPainter>
#include <QPen>
#include <QCloseEvent>
#include <QSettings>
#include <QResizeEvent>
#include <QSize>
/* -- */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment