diff --git a/deuchnord-hermes.pro b/deuchnord-hermes.pro
index 65fc74e..d24d4ac 100644
--- a/deuchnord-hermes.pro
+++ b/deuchnord-hermes.pro
@@ -21,21 +21,24 @@ SOURCES += main.cpp\
infosproduitdialog.cpp \
gestionmagasinsdialog.cpp \
aboutdialog.cpp \
- scannerdialog.cpp
+ scannerdialog.cpp \
+ settingsdialog.cpp
HEADERS += mainwindow.h \
produititem.h \
infosproduitdialog.h \
gestionmagasinsdialog.h \
aboutdialog.h \
- scannerdialog.h
+ scannerdialog.h \
+ settingsdialog.h
FORMS += mainwindow.ui \
produititem.ui \
infosproduitdialog.ui \
gestionmagasinsdialog.ui \
aboutdialog.ui \
- scannerdialog.ui
+ scannerdialog.ui \
+ settingsdialog.ui
RESOURCES += \
resources.qrc
diff --git a/deuchnord-hermes.pro (Copie en conflit de jerome-XPS-L501X 2014-06-12).user b/deuchnord-hermes.pro (Copie en conflit de jerome-XPS-L501X 2014-06-12).user
new file mode 100644
index 0000000..5cfc4a0
--- /dev/null
+++ b/deuchnord-hermes.pro (Copie en conflit de jerome-XPS-L501X 2014-06-12).user
@@ -0,0 +1,260 @@
+
+
+
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ true
+ 1
+ true
+ 0
+ true
+ 0
+ 8
+ true
+ 1
+ true
+ true
+ true
+ false
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ Desktop
+ {8a6bac83-397a-433b-b12b-aaf345693483}
+ 0
+ 0
+ 0
+
+ /home/jerome/Dropbox/Git/Hermes/build-deuchnord-hermes-Desktop-Debug
+
+
+ true
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ false
+ true
+
+ false
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+
+ -w
+ -r
+
+ false
+
+
+
+ 2
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+
+ -w
+ -r
+
+ true
+ clean
+
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Debug
+
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+ true
+
+
+ /home/jerome/Dropbox/Git/Hermes/build-deuchnord-hermes-Desktop-Release
+
+
+ true
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ false
+ true
+
+ false
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+
+ -w
+ -r
+
+ false
+
+
+
+ 2
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+
+ -w
+ -r
+
+ true
+ clean
+
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Release
+
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ true
+
+ 2
+
+
+ 0
+ Deploy
+
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+ Deploy locally
+
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ 1
+ 25
+
+ 1
+ true
+ false
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ 2
+
+ deuchnord-hermes
+
+ Qt4ProjectManager.Qt4RunConfiguration:/home/jerome/Dropbox/Git/Hermes/deuchnord-hermes/deuchnord-hermes.pro
+
+ deuchnord-hermes.pro
+ false
+ false
+
+ 3768
+ true
+ false
+ false
+ false
+ true
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.EnvironmentId
+ {44abd538-5b46-4276-b819-6072e04c10d4}
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 15
+
+
diff --git a/deuchnord-hermes.pro.user b/deuchnord-hermes.pro.user
index 85a45ad..924e767 100644
--- a/deuchnord-hermes.pro.user
+++ b/deuchnord-hermes.pro.user
@@ -1,251 +1,260 @@
-
-
-
-
-
- ProjectExplorer.Project.ActiveTarget
- 0
-
-
- ProjectExplorer.Project.EditorSettings
-
- true
- false
- true
-
- Cpp
-
- CppGlobal
-
-
-
- QmlJS
-
- QmlJSGlobal
-
-
- 2
- UTF-8
- false
- 4
- false
- 80
- true
- true
- 1
- true
- false
- 0
- true
- 0
- 8
- true
- 1
- true
- true
- true
- false
-
-
-
- ProjectExplorer.Project.PluginSettings
-
-
-
- ProjectExplorer.Project.Target.0
-
- Desktop Qt 5.2.1 MinGW 32bit
- Desktop Qt 5.2.1 MinGW 32bit
- qt.521.win32_mingw48.essentials_kit
- 1
- 0
- 0
-
- C:/Users/Jérôme/Dropbox/Git/Hermes/build-deuchnord-hermes-Desktop_Qt_5_2_1_MinGW_32bit-Debug
-
-
- true
- qmake
-
- QtProjectManager.QMakeBuildStep
- false
- true
-
- false
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- false
-
-
-
- 2
- Compiler
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- true
- clean
-
-
- 1
- Nettoyer
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- Debug
-
- Qt4ProjectManager.Qt4BuildConfiguration
- 2
- true
-
-
- C:/Users/Jérôme/Dropbox/Git/Hermes/build-deuchnord-hermes-Desktop_Qt_5_2_1_MinGW_32bit-Release
-
-
- true
- qmake
-
- QtProjectManager.QMakeBuildStep
- false
- true
-
- false
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- false
-
-
-
- 2
- Compiler
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- true
- clean
-
-
- 1
- Nettoyer
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- Release
-
- Qt4ProjectManager.Qt4BuildConfiguration
- 0
- true
-
- 2
-
-
- 0
- Déploiement
-
- ProjectExplorer.BuildSteps.Deploy
-
- 1
- Déployer localement
-
- ProjectExplorer.DefaultDeployConfiguration
-
- 1
-
-
-
- false
- false
- false
- false
- true
- 0.01
- 10
- true
- 1
- 25
-
- 1
- true
- false
- true
- valgrind
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
- 2
-
- deuchnord-hermes
-
- Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Jérôme/Dropbox/Git/Hermes/deuchnord-hermes/deuchnord-hermes.pro
-
- deuchnord-hermes.pro
- false
- false
-
- 3768
- false
- true
- false
- false
- true
-
- 1
-
-
-
- ProjectExplorer.Project.TargetCount
- 1
-
-
- ProjectExplorer.Project.Updater.EnvironmentId
- {60f16766-9e87-40cf-8f8f-b733441f2614}
-
-
- ProjectExplorer.Project.Updater.FileVersion
- 15
-
-
+
+
+
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ true
+ 1
+ true
+ 0
+ true
+ 0
+ 8
+ true
+ 1
+ true
+ true
+ true
+ false
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ Desktop
+ {8a6bac83-397a-433b-b12b-aaf345693483}
+ 1
+ 0
+ 0
+
+ /home/jerome/Dropbox/Git/Hermes/build-deuchnord-hermes-Desktop-Debug
+
+
+ true
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ false
+ true
+
+ false
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+
+ -w
+ -r
+
+ false
+
+
+
+ 2
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+
+ -w
+ -r
+
+ true
+ clean
+
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Debug
+
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+ true
+
+
+ /home/jerome/Dropbox/Git/Hermes/build-deuchnord-hermes-Desktop-Release
+
+
+ true
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ false
+ true
+
+ false
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+
+ -w
+ -r
+
+ false
+
+
+
+ 2
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+
+ -w
+ -r
+
+ true
+ clean
+
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Release
+
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ true
+
+ 2
+
+
+ 0
+ Deploy
+
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+ Deploy locally
+
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ 1
+ 25
+
+ 1
+ true
+ false
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ 2
+
+ deuchnord-hermes
+
+ Qt4ProjectManager.Qt4RunConfiguration:/home/jerome/Dropbox/Git/Hermes/deuchnord-hermes/deuchnord-hermes.pro
+
+ deuchnord-hermes.pro
+ false
+ false
+
+ 3768
+ true
+ false
+ false
+ false
+ true
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.EnvironmentId
+ {44abd538-5b46-4276-b819-6072e04c10d4}
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 15
+
+
diff --git a/gestionmagasinsdialog.cpp b/gestionmagasinsdialog.cpp
index 94e2a32..83e0cf2 100644
--- a/gestionmagasinsdialog.cpp
+++ b/gestionmagasinsdialog.cpp
@@ -13,7 +13,10 @@ GestionMagasinsDialog::GestionMagasinsDialog(QWidget *parent) :
{
ui->setupUi(this);
- QFile fichierMagasins(QDir::homePath()+"/deuchnord-hermes/manufacturers.xml");
+ settings = new QSettings("Deuchnord", "Hermes");
+ placeSave = settings->value("placeSave").toString();
+
+ QFile fichierMagasins(placeSave+"/deuchnord-hermes/manufacturers.xml");
fichierMagasins.open(QFile::ReadOnly);
if(fichierMagasins.isOpen())
{
@@ -94,7 +97,7 @@ void GestionMagasinsDialog::on_buttonBox_accepted()
manufacturer.appendChild(nomMagasin);
}
- QFile fileManu(QDir::homePath()+"/deuchnord-hermes/manufacturers.xml");
+ QFile fileManu(placeSave+"/deuchnord-hermes/manufacturers.xml");
if(fileManu.open(QFile::WriteOnly))
{
fileManu.write(dom.toString().toUtf8());
diff --git a/gestionmagasinsdialog.h b/gestionmagasinsdialog.h
index e28ff22..f412d1d 100644
--- a/gestionmagasinsdialog.h
+++ b/gestionmagasinsdialog.h
@@ -2,6 +2,7 @@
#define GESTIONMAGASINSDIALOG_H
#include
+#include
namespace Ui {
class GestionMagasinsDialog;
@@ -26,6 +27,8 @@ signals:
private:
Ui::GestionMagasinsDialog *ui;
+ QSettings *settings;
+ QString placeSave;
};
#endif // GESTIONMAGASINSDIALOG_H
diff --git a/infosproduitdialog.cpp b/infosproduitdialog.cpp
index bde2749..70ede7a 100644
--- a/infosproduitdialog.cpp
+++ b/infosproduitdialog.cpp
@@ -78,6 +78,12 @@ InfosProduitDialog::InfosProduitDialog(QWidget *parent, QWidget *mainWindow, QSt
ui->txtNom->setFocus();
ui->listFactures->setCurrentItem(ui->listFactures->item(0));
ui->listGaranties->setCurrentItem(ui->listGaranties->item(0));
+
+#if !defined Q_OS_LINUX
+ // Le bouton ne sera pas disponible sur les systèmes autres que GNU/Linux
+ ui->btnScannerFacture->hide();
+ ui->btnScannerGarantie->hide();
+#endif
}
void InfosProduitDialog::on_btnImageParcourir_clicked()
@@ -99,7 +105,7 @@ void InfosProduitDialog::on_btnImageSupprimer_clicked()
void InfosProduitDialog::on_btnAjoutFacture_clicked()
{
- QString fileName = QFileDialog::getOpenFileName(this, "Sélectionnez une facture", "", "Fichiers PDF (*.pdf);;Image (*.jpg *.jpeg *.png)");
+ QString fileName = QFileDialog::getOpenFileName(this, "Sélectionnez une facture", "", "Fichiers supportés (*.pdf *.jpg *.jpeg *.png);;Fichiers PDF (*.pdf);;Images (*.jpg *.jpeg *.png)");
if(fileName != "")
{
QFile fichier(fileName);
@@ -120,16 +126,13 @@ void InfosProduitDialog::on_btnAjoutFacture_clicked()
void InfosProduitDialog::on_btnScannerFacture_clicked()
{
- // Ne fonctionne que sous Linux pour le moment. Dépendances : libsane et imagemagick
-#ifdef Q_OS_LINUX
+ // Ne fonctionne que sous Linux pour le moment. Dépendances : sane et imagemagick
+
ScannerDialog *dialog = new ScannerDialog(this);
dialog->setModal(true);
dialog->show();
connect(dialog, SIGNAL(accepted()), SLOT(on_factureScanned()));
-#else
- QMessageBox::warning(this, "Fonction indisponible", "Cette fonction n'est pas disponible pour votre système actuellement.\nDésolé pour la gêne.");
-#endif
}
void InfosProduitDialog::on_factureScanned()
@@ -205,15 +208,11 @@ void InfosProduitDialog::on_btnAjoutGarantie_clicked()
void InfosProduitDialog::on_btnScannerGarantie_clicked()
{
// Ne fonctionne que sous Linux pour le moment. Dépendances : libsane et imagemagick
-#ifdef Q_OS_LINUX
ScannerDialog *dialog = new ScannerDialog(this);
dialog->setModal(true);
dialog->show();
connect(dialog, SIGNAL(accepted()), SLOT(on_garantieScanned()));
-#else
- QMessageBox::warning(this, "Fonction indisponible", "Cette fonction n'est pas disponible pour votre système actuellement.\nDésolé pour la gêne.");
-#endif
}
void InfosProduitDialog::on_garantieScanned()
diff --git a/mainwindow.cpp b/mainwindow.cpp
index fe0de7f..4910338 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -2,6 +2,7 @@
#include "produititem.h"
#include "gestionmagasinsdialog.h"
#include "aboutdialog.h"
+#include "settingsdialog.h"
#include "ui_mainwindow.h"
#include
@@ -30,7 +31,9 @@ MainWindow::MainWindow(QWidget *parent) :
{
ui->setupUi(this);
- version = "0.3";
+ saveOnQuit = true;
+
+ version = "0.4";
searchBox = new QLineEdit(this);
searchBox->addAction(QIcon(":/icons/icon-search.png"), QLineEdit::LeadingPosition);
@@ -50,12 +53,16 @@ MainWindow::MainWindow(QWidget *parent) :
if(QFile::exists(QDir::homePath()+"/hermes.hrms"))
QFile::rename(QDir::homePath()+"/hermes.hrms", QDir::homePath()+"/deuchnord-hermes/products.hrms");
- dir = QDir(QDir::homePath()+"/deuchnord-hermes");
- if(!dir.exists(QDir::homePath()+"/deuchnord-hermes"))
- dir.mkdir(QDir::homePath()+"/deuchnord-hermes");
-
// Récupération de la configuration
- QFile saveFile(QDir::homePath()+"/deuchnord-hermes/products.hrms");
+ settings = new QSettings("Deuchnord", "Hermes");
+ QString placeSave = settings->value("placeSave").toString();
+ if(placeSave == "")
+ {
+ settings->setValue("placeSave", QDir::homePath());
+ placeSave = settings->value("placeSave").toString();
+ }
+
+ QFile saveFile(placeSave + "/deuchnord-hermes/products.hrms");
QDataStream content(&saveFile);
content.setVersion(QDataStream::Qt_5_0);
@@ -239,6 +246,21 @@ QListWidgetItem* MainWindow::ajouterProduit(ProduitItem *produit)
return widgetItem;
}
+
+void MainWindow::on_actionSettings_triggered()
+{
+ SettingsDialog *settingsDialog = new SettingsDialog(this);
+ settingsDialog->setModal(true);
+ settingsDialog->show();
+
+ connect(settingsDialog, SIGNAL(dontSaveOnQuit()), SLOT(settings_dontSaveOnQuit()));
+}
+
+void MainWindow::settings_dontSaveOnQuit()
+{
+ saveOnQuit = false;
+}
+
void MainWindow::on_actionAPropos_triggered()
{
AboutDialog *dialog = new AboutDialog(this, version);
@@ -274,25 +296,32 @@ void MainWindow::updateStatusMessage()
MainWindow::~MainWindow()
{
// Enregistrement de la configuration
- QFile saveFile(QDir::homePath()+"/deuchnord-hermes/products.hrms");
- QDataStream content(&saveFile);
- content.setVersion(QDataStream::Qt_5_0);
- QList listProd;
-
- if(saveFile.open(QFile::WriteOnly))
+ if(saveOnQuit)
{
- for(int i = 0; i < ui->listeProduits->count(); i++)
+ QString place = settings->value("placeSave").toString();
+ QDir dir(place+"/deuchnord-hermes");
+ if(!dir.exists())
+ dir.mkdir(place+"/deuchnord-hermes");
+
+ QFile saveFile(place+"/deuchnord-hermes/products.hrms");
+ QDataStream content(&saveFile);
+ content.setVersion(QDataStream::Qt_5_0);
+ QList listProd;
+
+ if(saveFile.open(QFile::WriteOnly))
{
- ProduitItem* item = (ProduitItem*) ui->listeProduits->itemWidget(ui->listeProduits->item(i));
- ProduitInfo prod = item->getProduitInfo();
- listProd << prod;
+ for(int i = 0; i < ui->listeProduits->count(); i++)
+ {
+ ProduitItem* item = (ProduitItem*) ui->listeProduits->itemWidget(ui->listeProduits->item(i));
+ ProduitInfo prod = item->getProduitInfo();
+ listProd << prod;
+ }
}
- }
- content << listProd;
+ content << listProd;
- saveFile.close();
+ saveFile.close();
+ }
delete ui;
}
-
diff --git a/mainwindow.h b/mainwindow.h
index 466951c..43a1f43 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -5,6 +5,7 @@
#include
#include
#include
+#include
#include "produititem.h"
@@ -38,8 +39,13 @@ public slots:
void deleteAsked();
+ void on_actionSettings_triggered();
+ void settings_dontSaveOnQuit();
+
private:
Ui::MainWindow *ui;
+ QSettings *settings;
+ bool saveOnQuit;
QListWidgetItem *ajouterProduit(ProduitItem *produit);
QLineEdit *searchBox;
QString version;
diff --git a/mainwindow.ui b/mainwindow.ui
index 5c3abc3..fabfd91 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -53,7 +53,14 @@
+
+
@@ -115,6 +122,11 @@
Signaler un bug...
+
+
+ Préférences
+
+
diff --git a/scannerdialog.cpp b/scannerdialog.cpp
index 3dc935a..2335758 100644
--- a/scannerdialog.cpp
+++ b/scannerdialog.cpp
@@ -8,6 +8,15 @@
#include
#include
+#ifdef Q_OS_WIN32
+// Includes propre à Windows pour l'utilisation du scanner (via le service Windows Image Acquisition)
+#include
+#include
+#include
+#include
+#include
+#endif
+
ScannerDialog::ScannerDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ScannerDialog)
@@ -23,7 +32,7 @@ ScannerDialog::~ScannerDialog()
void ScannerDialog::on_btnTest_clicked()
{
-#ifdef Q_OS_LINUX
+#if defined Q_OS_LINUX
ui->btnTest->setEnabled(false);
ui->btnScan->setEnabled(false);
ui->btnAnnuler->setEnabled(false);
@@ -38,8 +47,11 @@ void ScannerDialog::on_btnTest_clicked()
#endif
}
-void ScannerDialog::scanTestFinished(int r)
+void ScannerDialog::scanTestFinished(int r = 0)
{
+#if defined Q_OS_WIN32
+ QMessageBox::information(this, "test", "ok");
+#elif defined Q_OS_LINUX
ui->progressBar->hide();
ui->btnTest->setEnabled(true);
@@ -57,6 +69,7 @@ void ScannerDialog::scanTestFinished(int r)
}
else
QMessageBox::critical(this, "Erreur", "Impossible de communiquer avec votre scanner. Vérifiez qu'il est bien relié à l'ordinateur' et qu'il est sous tension, puis réessayez.\nSi le problème persiste, il est probable que votre scanner ne soit pas pris en charge.");
+#endif
}
void ScannerDialog::on_btnScan_clicked()
diff --git a/scannerdialog.ui b/scannerdialog.ui
index e3daed1..44ec235 100644
--- a/scannerdialog.ui
+++ b/scannerdialog.ui
@@ -11,7 +11,7 @@
- Dialog
+ Numériser un document
-
diff --git a/settingsdialog.cpp b/settingsdialog.cpp
new file mode 100644
index 0000000..b22ade5
--- /dev/null
+++ b/settingsdialog.cpp
@@ -0,0 +1,88 @@
+#include "settingsdialog.h"
+#include "ui_settingsdialog.h"
+
+#include
+#include
+#include
+
+SettingsDialog::SettingsDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::SettingsDialog)
+{
+ ui->setupUi(this);
+
+ settings = new QSettings("Deuchnord", "Hermes");
+ savePlace = settings->value("placeSave").toString();
+
+ ui->currentPlaceSave->setText(savePlace);
+}
+
+void SettingsDialog::on_btnChangeSavePlace_clicked()
+{
+ QString savePlace = QFileDialog::getExistingDirectory(this, "Choisir un dossier de sauvegarde", settings->value("placeSave").toString());
+ bool ok = true;
+ bool replaceFile = false;
+ QDir dir(savePlace+"/deuchnord-hermes");
+ if(dir.exists())
+ {
+ int whatToDo = QMessageBox::question(this, "Confirmation", "Des fichiers appartenant à Hermès semblent être déjà présents. Que voulez-vous faire ?
Cliquez sur Appliquer pour utiliser les fichiers présents à cet emplacement.
Cliquez sur Réinitialiser pour écraser les fichiers présents à cet emplacement.
Cliquez sur Annuler pour ne pas changer l'emplacement.", QMessageBox::Apply | QMessageBox::Reset | QMessageBox::Cancel, QMessageBox::Cancel);
+
+ switch(whatToDo)
+ {
+ case QMessageBox::Reset:
+ replaceFile = true;
+ break;
+ case QMessageBox::Cancel:
+ ok = false;
+ break;
+ }
+ }
+ else
+ replaceFile = true;
+
+ if(ok)
+ {
+ ui->currentPlaceSave->setText(savePlace);
+ this->savePlace = savePlace;
+ this->replaceFile = replaceFile;
+ }
+}
+
+void SettingsDialog::on_buttonBox_accepted()
+{
+ bool restartNeeded = false, restartWillSave = true;
+
+ // Emplacement de la sauvegarde
+ if(savePlace != settings->value("placeSave").toString())
+ {
+ if(!replaceFile)
+ {
+ restartNeeded = true;
+ restartWillSave = false;
+ emit dontSaveOnQuit();
+ }
+
+ else
+ {
+ QDir dir(savePlace+"/deuchnord-hermes");
+ dir.mkdir(savePlace+"/deuchnord-hermes");
+ QFile::copy(settings->value("placeSave").toString()+"/deuchnord-hermes/manufacturers.xml", savePlace+"/deuchnord-hermes/manufacturers.xml");
+ }
+
+ settings->setValue("placeSave", savePlace);
+ }
+
+ // Affichage d'un message s'il faut redémarrer Hermès
+ if(restartNeeded)
+ {
+ QString message = "Certains changements dans votre configuration nécessite de relancer Hermès.";
+ if(!restartWillSave)
+ message += "\nAttention, les changements effectués ne seront pas enregistrés !";
+ QMessageBox::warning(this, "Mise à jour de la configuration", message);
+ }
+}
+
+SettingsDialog::~SettingsDialog()
+{
+ delete ui;
+}
diff --git a/settingsdialog.h b/settingsdialog.h
new file mode 100644
index 0000000..31e0d97
--- /dev/null
+++ b/settingsdialog.h
@@ -0,0 +1,33 @@
+#ifndef SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include
+#include
+
+namespace Ui {
+class SettingsDialog;
+}
+
+class SettingsDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit SettingsDialog(QWidget *parent = 0);
+ ~SettingsDialog();
+
+private slots:
+ void on_btnChangeSavePlace_clicked();
+ void on_buttonBox_accepted();
+
+signals:
+ void dontSaveOnQuit(); // Signal indiquant à la fenêtre principale de ne pas enregistrer à la fermeture.
+
+private:
+ Ui::SettingsDialog *ui;
+ QSettings *settings;
+ QString savePlace;
+ bool replaceFile;
+};
+
+#endif // SETTINGSDIALOG_H
diff --git a/settingsdialog.ui b/settingsdialog.ui
new file mode 100644
index 0000000..87b0a3a
--- /dev/null
+++ b/settingsdialog.ui
@@ -0,0 +1,113 @@
+
+
+ SettingsDialog
+
+
+
+ 0
+ 0
+ 620
+ 368
+
+
+
+ Préférences
+
+
+ -
+
+
+ Lieu de sauvegarde
+
+
+
+ QFormLayout::AllNonFixedFieldsGrow
+
+
-
+
+
+ Le lieu de sauvegarde actuel est :
+
+
+
+ -
+
+
+ font-weight: bold
+
+
+ TextLabel
+
+
+ true
+
+
+
+ -
+
+
+ Changer l'emplacement
+
+
+
+ -
+
+
+ <html><head/><body><p>Un dossier nommé <span style=" font-style:italic;">deuchnord-hermes</span> contenant vos données sera créé à l'emplacement sélectionné.</p></body></html>
+
+
+ true
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ SettingsDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ SettingsDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+