| @@ -20,19 +20,22 @@ SOURCES += main.cpp\ | |||||
| produititem.cpp \ | produititem.cpp \ | ||||
| infosproduitdialog.cpp \ | infosproduitdialog.cpp \ | ||||
| gestionmagasinsdialog.cpp \ | gestionmagasinsdialog.cpp \ | ||||
| aboutdialog.cpp | |||||
| aboutdialog.cpp \ | |||||
| scannerdialog.cpp | |||||
| HEADERS += mainwindow.h \ | HEADERS += mainwindow.h \ | ||||
| produititem.h \ | produititem.h \ | ||||
| infosproduitdialog.h \ | infosproduitdialog.h \ | ||||
| gestionmagasinsdialog.h \ | gestionmagasinsdialog.h \ | ||||
| aboutdialog.h | |||||
| aboutdialog.h \ | |||||
| scannerdialog.h | |||||
| FORMS += mainwindow.ui \ | FORMS += mainwindow.ui \ | ||||
| produititem.ui \ | produititem.ui \ | ||||
| infosproduitdialog.ui \ | infosproduitdialog.ui \ | ||||
| gestionmagasinsdialog.ui \ | gestionmagasinsdialog.ui \ | ||||
| aboutdialog.ui | |||||
| aboutdialog.ui \ | |||||
| scannerdialog.ui | |||||
| RESOURCES += \ | RESOURCES += \ | ||||
| resources.qrc | resources.qrc | ||||
| @@ -1,6 +1,6 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE QtCreatorProject> | <!DOCTYPE QtCreatorProject> | ||||
| <!-- Written by QtCreator 3.1.0, 2014-05-29T09:34:22. --> | |||||
| <!-- Written by QtCreator 3.1.0, 2014-06-03T13:28:18. --> | |||||
| <qtcreator> | <qtcreator> | ||||
| <data> | <data> | ||||
| <variable>ProjectExplorer.Project.ActiveTarget</variable> | <variable>ProjectExplorer.Project.ActiveTarget</variable> | ||||
| @@ -13,12 +13,7 @@ GestionMagasinsDialog::GestionMagasinsDialog(QWidget *parent) : | |||||
| { | { | ||||
| ui->setupUi(this); | ui->setupUi(this); | ||||
| QDir dir(QDir::homePath()+"/.deuchnord-hermes"); | |||||
| if(!dir.exists()) | |||||
| dir.mkdir(QDir::homePath()+"/.deuchnord-hermes"); | |||||
| QFile fichierMagasins(QDir::homePath()+"/.deuchnord-hermes/manufacturers.xml"); | |||||
| QFile fichierMagasins(QDir::homePath()+"/deuchnord-hermes/manufacturers.xml"); | |||||
| fichierMagasins.open(QFile::ReadOnly); | fichierMagasins.open(QFile::ReadOnly); | ||||
| if(fichierMagasins.isOpen()) | if(fichierMagasins.isOpen()) | ||||
| { | { | ||||
| @@ -69,7 +64,12 @@ void GestionMagasinsDialog::on_btnAjoutMagasin_clicked() | |||||
| void GestionMagasinsDialog::on_btnSupprMagasin_clicked() | void GestionMagasinsDialog::on_btnSupprMagasin_clicked() | ||||
| { | { | ||||
| delete ui->listMagasins->currentItem(); | |||||
| if(QMessageBox::question(this, "Supprimer "+ui->listMagasins->currentItem()->text()+" ?", "Voulez-vous vraiment supprimer ce magasin ?<br />Tous les produits associés perdront cette information, <em>même si vous cliquez sur Annuler plus tard</em>.", QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes) | |||||
| { | |||||
| int row = ui->listMagasins->currentRow(); | |||||
| delete ui->listMagasins->currentItem(); | |||||
| emit magasinDeleted(row); | |||||
| } | |||||
| } | } | ||||
| void GestionMagasinsDialog::on_listMagasins_currentRowChanged() | void GestionMagasinsDialog::on_listMagasins_currentRowChanged() | ||||
| @@ -94,7 +94,7 @@ void GestionMagasinsDialog::on_buttonBox_accepted() | |||||
| manufacturer.appendChild(nomMagasin); | manufacturer.appendChild(nomMagasin); | ||||
| } | } | ||||
| QFile fileManu(QDir::homePath()+"/.deuchnord-hermes/manufacturers.xml"); | |||||
| QFile fileManu(QDir::homePath()+"/deuchnord-hermes/manufacturers.xml"); | |||||
| if(fileManu.open(QFile::WriteOnly)) | if(fileManu.open(QFile::WriteOnly)) | ||||
| { | { | ||||
| fileManu.write(dom.toString().toUtf8()); | fileManu.write(dom.toString().toUtf8()); | ||||
| @@ -21,6 +21,9 @@ public slots: | |||||
| void on_listMagasins_currentRowChanged(); | void on_listMagasins_currentRowChanged(); | ||||
| void on_buttonBox_accepted(); | void on_buttonBox_accepted(); | ||||
| signals: | |||||
| void magasinDeleted(int indexMagasin); | |||||
| private: | private: | ||||
| Ui::GestionMagasinsDialog *ui; | Ui::GestionMagasinsDialog *ui; | ||||
| }; | }; | ||||
| @@ -19,8 +19,11 @@ InfosProduitDialog::InfosProduitDialog(QWidget *parent, QWidget *mainWindow, QSt | |||||
| ui->setupUi(this); | ui->setupUi(this); | ||||
| parentWidget = parent; | parentWidget = parent; | ||||
| // On ajoute une ligne vide, conrrespondant à un magasin non reseigné. Il correspond à un indexMagasin de -1 | |||||
| ui->comboMagasin->addItem(""); | |||||
| // Récupération de la liste des magasins enregistrés | // Récupération de la liste des magasins enregistrés | ||||
| QFile fichierMagasins(QDir::homePath()+"/.deuchnord-hermes/manufacturers.xml"); | |||||
| QFile fichierMagasins(QDir::homePath()+"/deuchnord-hermes/manufacturers.xml"); | |||||
| fichierMagasins.open(QFile::ReadOnly); | fichierMagasins.open(QFile::ReadOnly); | ||||
| if(fichierMagasins.isOpen()) | if(fichierMagasins.isOpen()) | ||||
| { | { | ||||
| @@ -55,7 +58,7 @@ InfosProduitDialog::InfosProduitDialog(QWidget *parent, QWidget *mainWindow, QSt | |||||
| ui->checkGarantieAVie->setChecked(true); | ui->checkGarantieAVie->setChecked(true); | ||||
| } | } | ||||
| ui->comboMagasin->setCurrentIndex(indexMagasin); | |||||
| ui->comboMagasin->setCurrentIndex(indexMagasin+1); | |||||
| ui->checkSAV->setChecked(enSAV); | ui->checkSAV->setChecked(enSAV); | ||||
| ui->image->setPixmap(image); | ui->image->setPixmap(image); | ||||
| this->image = image; | this->image = image; | ||||
| @@ -115,6 +118,41 @@ 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 | |||||
| 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() | |||||
| { | |||||
| QString fileName = QDir::tempPath()+"/output.pdf"; | |||||
| QFile::rename(fileName, QDir::tempPath()+"/Facture.pdf"); | |||||
| fileName = QDir::tempPath()+"/Facture.pdf"; | |||||
| QFile fichier(fileName); | |||||
| QFileInfo infoFile(fichier.fileName()); | |||||
| fichier.open(QFile::ReadOnly); | |||||
| if(fichier.isReadable()) | |||||
| { | |||||
| QByteArray contenuFichier = fichier.readAll(); | |||||
| fichier.close(); | |||||
| facturePDF.insert(infoFile.fileName(), contenuFichier); | |||||
| ui->listFactures->addItem(infoFile.fileName()); | |||||
| } | |||||
| else | |||||
| QMessageBox::critical(this, "Erreur", "Une erreur s'est produite lors de l'ajout de votre document numérisé.\nVous pouvez toujours ajouter le document manuellement, il se trouve ici : "+fileName); | |||||
| } | |||||
| void InfosProduitDialog::on_listFactures_currentRowChanged() | void InfosProduitDialog::on_listFactures_currentRowChanged() | ||||
| { | { | ||||
| ui->btnSupprFacture->setEnabled(true); | ui->btnSupprFacture->setEnabled(true); | ||||
| @@ -164,6 +202,41 @@ 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() | |||||
| { | |||||
| QString fileName = QDir::tempPath()+"/output.pdf"; | |||||
| QFile::rename(fileName, QDir::tempPath()+"/Garantie.pdf"); | |||||
| fileName = QDir::tempPath()+"/Garantie.pdf"; | |||||
| QFile fichier(fileName); | |||||
| QFileInfo infoFile(fichier.fileName()); | |||||
| fichier.open(QFile::ReadOnly); | |||||
| if(fichier.isReadable()) | |||||
| { | |||||
| QByteArray contenuFichier = fichier.readAll(); | |||||
| fichier.close(); | |||||
| garantiePDF.insert(infoFile.fileName(), contenuFichier); | |||||
| ui->listGaranties->addItem(infoFile.fileName()); | |||||
| } | |||||
| else | |||||
| QMessageBox::critical(this, "Erreur", "Une erreur s'est produite lors de l'ajout de votre document numérisé.\nVous pouvez toujours ajouter le document manuellement, il se trouve ici : "+fileName); | |||||
| } | |||||
| void InfosProduitDialog::on_listGaranties_currentRowChanged() | void InfosProduitDialog::on_listGaranties_currentRowChanged() | ||||
| { | { | ||||
| ui->btnSupprGarantie->setEnabled(true); | ui->btnSupprGarantie->setEnabled(true); | ||||
| @@ -205,7 +278,7 @@ void InfosProduitDialog::on_buttonBox_accepted() | |||||
| getParentItem()->setDateFinGarantie(QDate(1970, 1, 1)); | getParentItem()->setDateFinGarantie(QDate(1970, 1, 1)); | ||||
| getParentItem()->setImage(this->image); | getParentItem()->setImage(this->image); | ||||
| getParentItem()->setMagasin(ui->comboMagasin->currentIndex()); | |||||
| getParentItem()->setMagasin(ui->comboMagasin->currentIndex()-1); | |||||
| getParentItem()->setEnSAV(ui->checkSAV->isChecked()); | getParentItem()->setEnSAV(ui->checkSAV->isChecked()); | ||||
| getParentItem()->setFactures(this->facturePDF); | getParentItem()->setFactures(this->facturePDF); | ||||
| getParentItem()->setGaranties(this->garantiePDF); | getParentItem()->setGaranties(this->garantiePDF); | ||||
| @@ -6,7 +6,9 @@ | |||||
| #include <QHash> | #include <QHash> | ||||
| #include <QListWidget> | #include <QListWidget> | ||||
| #include <QPixmap> | #include <QPixmap> | ||||
| #include "produititem.h" | #include "produititem.h" | ||||
| #include "scannerdialog.h" | |||||
| namespace Ui { | namespace Ui { | ||||
| class InfosProduitDialog; | class InfosProduitDialog; | ||||
| @@ -23,25 +25,27 @@ public: | |||||
| ~InfosProduitDialog(); | ~InfosProduitDialog(); | ||||
| public slots: | public slots: | ||||
| void on_checkGarantieAVie_toggled(bool checked); | |||||
| // Image | // Image | ||||
| void on_btnImageParcourir_clicked(); | void on_btnImageParcourir_clicked(); | ||||
| void on_btnImageSupprimer_clicked(); | void on_btnImageSupprimer_clicked(); | ||||
| // Factures | // Factures | ||||
| void on_btnAjoutFacture_clicked(); | void on_btnAjoutFacture_clicked(); | ||||
| void on_btnScannerFacture_clicked(); | |||||
| void on_factureScanned(); | |||||
| void on_listFactures_currentRowChanged(); | void on_listFactures_currentRowChanged(); | ||||
| void on_listFactures_itemDoubleClicked(QListWidgetItem *item); | void on_listFactures_itemDoubleClicked(QListWidgetItem *item); | ||||
| void on_btnSupprFacture_clicked(); | void on_btnSupprFacture_clicked(); | ||||
| // Garanties | // Garanties | ||||
| void on_btnAjoutGarantie_clicked(); | void on_btnAjoutGarantie_clicked(); | ||||
| void on_btnScannerGarantie_clicked(); | |||||
| void on_garantieScanned(); | |||||
| void on_listGaranties_currentRowChanged(); | void on_listGaranties_currentRowChanged(); | ||||
| void on_listGaranties_itemDoubleClicked(QListWidgetItem *item); | void on_listGaranties_itemDoubleClicked(QListWidgetItem *item); | ||||
| void on_btnSupprGarantie_clicked(); | void on_btnSupprGarantie_clicked(); | ||||
| // Boutons du bas | // Boutons du bas | ||||
| void on_buttonBox_accepted(); | void on_buttonBox_accepted(); | ||||
| private slots: | |||||
| void on_checkGarantieAVie_toggled(bool checked); | |||||
| private: | private: | ||||
| QPixmap image; | QPixmap image; | ||||
| Ui::InfosProduitDialog *ui; | Ui::InfosProduitDialog *ui; | ||||
| @@ -196,6 +196,20 @@ Vous pouvez ouvrir une facture ou une garantie en double-cliquant dessus.</strin | |||||
| </property> | </property> | ||||
| </widget> | </widget> | ||||
| </item> | </item> | ||||
| <item> | |||||
| <widget class="QPushButton" name="btnScannerFacture"> | |||||
| <property name="toolTip"> | |||||
| <string>Numériser une facture et l'ajouter</string> | |||||
| </property> | |||||
| <property name="text"> | |||||
| <string/> | |||||
| </property> | |||||
| <property name="icon"> | |||||
| <iconset resource="resources.qrc"> | |||||
| <normaloff>:/icons/scanner.png</normaloff>:/icons/scanner.png</iconset> | |||||
| </property> | |||||
| </widget> | |||||
| </item> | |||||
| <item> | <item> | ||||
| <widget class="QPushButton" name="btnSupprFacture"> | <widget class="QPushButton" name="btnSupprFacture"> | ||||
| <property name="enabled"> | <property name="enabled"> | ||||
| @@ -259,6 +273,20 @@ Vous pouvez ouvrir une facture ou une garantie en double-cliquant dessus.</strin | |||||
| </property> | </property> | ||||
| </widget> | </widget> | ||||
| </item> | </item> | ||||
| <item> | |||||
| <widget class="QPushButton" name="btnScannerGarantie"> | |||||
| <property name="toolTip"> | |||||
| <string>Numériser une garantie et l'ajouter</string> | |||||
| </property> | |||||
| <property name="text"> | |||||
| <string/> | |||||
| </property> | |||||
| <property name="icon"> | |||||
| <iconset resource="resources.qrc"> | |||||
| <normaloff>:/icons/scanner.png</normaloff>:/icons/scanner.png</iconset> | |||||
| </property> | |||||
| </widget> | |||||
| </item> | |||||
| <item> | <item> | ||||
| <widget class="QPushButton" name="btnSupprGarantie"> | <widget class="QPushButton" name="btnSupprGarantie"> | ||||
| <property name="enabled"> | <property name="enabled"> | ||||
| @@ -30,7 +30,7 @@ MainWindow::MainWindow(QWidget *parent) : | |||||
| { | { | ||||
| ui->setupUi(this); | ui->setupUi(this); | ||||
| version = "0.2"; | |||||
| version = "0.3"; | |||||
| searchBox = new QLineEdit(this); | searchBox = new QLineEdit(this); | ||||
| searchBox->addAction(QIcon(":/icons/icon-search.png"), QLineEdit::LeadingPosition); | searchBox->addAction(QIcon(":/icons/icon-search.png"), QLineEdit::LeadingPosition); | ||||
| @@ -43,9 +43,19 @@ MainWindow::MainWindow(QWidget *parent) : | |||||
| ui->mainToolBar->addSeparator(); | ui->mainToolBar->addSeparator(); | ||||
| ui->mainToolBar->addWidget(searchBox); | ui->mainToolBar->addWidget(searchBox); | ||||
| // Récupération de la configuration | |||||
| // Migration des fichiers si l'utilisateur vient d'une version antérieure à la 0.3 | |||||
| QDir dir(QDir::homePath()+"/.deuchnord-hermes"); | |||||
| if(dir.exists(QDir::homePath()+"/.deuchnord-hermes")) | |||||
| dir.rename(QDir::homePath()+"/.deuchnord-hermes", QDir::homePath()+"/deuchnord-hermes"); | |||||
| 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"); | |||||
| QFile saveFile(QDir::homePath()+"/hermes.hrms"); | |||||
| // Récupération de la configuration | |||||
| QFile saveFile(QDir::homePath()+"/deuchnord-hermes/products.hrms"); | |||||
| QDataStream content(&saveFile); | QDataStream content(&saveFile); | ||||
| content.setVersion(QDataStream::Qt_5_0); | content.setVersion(QDataStream::Qt_5_0); | ||||
| @@ -122,7 +132,7 @@ void MainWindow::searchProduit(QString search) | |||||
| void MainWindow::on_actionNouveauProduit_triggered() | void MainWindow::on_actionNouveauProduit_triggered() | ||||
| { | { | ||||
| QFile fichierMagasins(QDir::homePath()+"/.deuchnord-hermes/manufacturers.xml"); | |||||
| QFile fichierMagasins(QDir::homePath()+"/deuchnord-hermes/manufacturers.xml"); | |||||
| fichierMagasins.open(QFile::ReadOnly); | fichierMagasins.open(QFile::ReadOnly); | ||||
| int nbMagasins = 0; | int nbMagasins = 0; | ||||
| @@ -200,6 +210,21 @@ void MainWindow::on_actionGererMagasins_triggered() | |||||
| GestionMagasinsDialog *dialog = new GestionMagasinsDialog(this); | GestionMagasinsDialog *dialog = new GestionMagasinsDialog(this); | ||||
| dialog->setModal(true); | dialog->setModal(true); | ||||
| dialog->show(); | dialog->show(); | ||||
| connect(dialog, SIGNAL(magasinDeleted(int)), SLOT(magasinDeleted(int))); | |||||
| } | |||||
| void MainWindow::magasinDeleted(int indexMagasin) | |||||
| { | |||||
| // Si un magasin a été supprimé, on change le magasin pour une valeur vide. | |||||
| for(int i = 0; i < ui->listeProduits->count(); i++) | |||||
| { | |||||
| ProduitItem* item = (ProduitItem*) ui->listeProduits->itemWidget(ui->listeProduits->item(i)); | |||||
| if(item->getMagasin() == indexMagasin) | |||||
| item->setMagasin(-1); | |||||
| if(item->getMagasin() > indexMagasin) | |||||
| item->setMagasin(item->getMagasin()-1); | |||||
| } | |||||
| } | } | ||||
| QListWidgetItem* MainWindow::ajouterProduit(ProduitItem *produit) | QListWidgetItem* MainWindow::ajouterProduit(ProduitItem *produit) | ||||
| @@ -249,7 +274,7 @@ void MainWindow::updateStatusMessage() | |||||
| MainWindow::~MainWindow() | MainWindow::~MainWindow() | ||||
| { | { | ||||
| // Enregistrement de la configuration | // Enregistrement de la configuration | ||||
| QFile saveFile(QDir::homePath()+"/hermes.hrms"); | |||||
| QFile saveFile(QDir::homePath()+"/deuchnord-hermes/products.hrms"); | |||||
| QDataStream content(&saveFile); | QDataStream content(&saveFile); | ||||
| content.setVersion(QDataStream::Qt_5_0); | content.setVersion(QDataStream::Qt_5_0); | ||||
| QList<ProduitInfo> listProd; | QList<ProduitInfo> listProd; | ||||
| @@ -29,6 +29,7 @@ public slots: | |||||
| void on_actionNouveauProduit_triggered(); | void on_actionNouveauProduit_triggered(); | ||||
| void on_actionSupprimerProduit_triggered(bool dontAskConfirm = true); | void on_actionSupprimerProduit_triggered(bool dontAskConfirm = true); | ||||
| void on_actionGererMagasins_triggered(); | void on_actionGererMagasins_triggered(); | ||||
| void magasinDeleted(int indexMagasin); | |||||
| void on_actionAPropos_triggered(); | void on_actionAPropos_triggered(); | ||||
| void on_actionAide_triggered(); | void on_actionAide_triggered(); | ||||
| void on_actionReportBug_triggered(); | void on_actionReportBug_triggered(); | ||||
| @@ -88,6 +88,11 @@ void ProduitItem::setImage(QPixmap image) | |||||
| ui->image->setPixmap(image); | ui->image->setPixmap(image); | ||||
| } | } | ||||
| int ProduitItem::getMagasin() | |||||
| { | |||||
| return this->indexMagasin; | |||||
| } | |||||
| void ProduitItem::setMagasin(int index) | void ProduitItem::setMagasin(int index) | ||||
| { | { | ||||
| this->indexMagasin = index; | this->indexMagasin = index; | ||||
| @@ -52,6 +52,8 @@ public: | |||||
| void setFactures(QHash<QString, QByteArray> factures); | void setFactures(QHash<QString, QByteArray> factures); | ||||
| void setGaranties(QHash<QString, QByteArray> garanties); | void setGaranties(QHash<QString, QByteArray> garanties); | ||||
| int getMagasin(); | |||||
| void updateDescription(); | void updateDescription(); | ||||
| void openDialog(bool deleteOnCancel = false); | void openDialog(bool deleteOnCancel = false); | ||||
| @@ -7,5 +7,6 @@ | |||||
| <file>remove.png</file> | <file>remove.png</file> | ||||
| <file>add.png</file> | <file>add.png</file> | ||||
| <file>icon-search.png</file> | <file>icon-search.png</file> | ||||
| <file>scanner.png</file> | |||||
| </qresource> | </qresource> | ||||
| </RCC> | </RCC> | ||||
| @@ -0,0 +1,93 @@ | |||||
| #include "scannerdialog.h" | |||||
| #include "ui_scannerdialog.h" | |||||
| #include <QDir> | |||||
| #include <QDesktopServices> | |||||
| #include <QUrl> | |||||
| #include <QProcess> | |||||
| #include <QMessageBox> | |||||
| #include <iostream> | |||||
| ScannerDialog::ScannerDialog(QWidget *parent) : | |||||
| QDialog(parent), | |||||
| ui(new Ui::ScannerDialog) | |||||
| { | |||||
| ui->setupUi(this); | |||||
| ui->progressBar->hide(); | |||||
| } | |||||
| ScannerDialog::~ScannerDialog() | |||||
| { | |||||
| delete ui; | |||||
| } | |||||
| void ScannerDialog::on_btnTest_clicked() | |||||
| { | |||||
| #ifdef Q_OS_LINUX | |||||
| ui->btnTest->setEnabled(false); | |||||
| ui->btnScan->setEnabled(false); | |||||
| ui->btnAnnuler->setEnabled(false); | |||||
| QProcess* process = new QProcess(); | |||||
| process->setStandardOutputFile(QDir::tempPath() + "/test.pnm"); | |||||
| process->start("scanimage"); | |||||
| ui->progressBar->show(); | |||||
| connect(process, SIGNAL(finished(int)), SLOT(scanTestFinished(int))); | |||||
| #endif | |||||
| } | |||||
| void ScannerDialog::scanTestFinished(int r) | |||||
| { | |||||
| ui->progressBar->hide(); | |||||
| ui->btnTest->setEnabled(true); | |||||
| ui->btnScan->setEnabled(true); | |||||
| ui->btnAnnuler->setEnabled(true); | |||||
| std::string s = "convert " + QDir::tempPath().toStdString() + "/test.pnm " + QDir::tempPath().toStdString() + "/test.pdf"; | |||||
| if(r == 0) | |||||
| { | |||||
| int c = system(s.c_str()); | |||||
| if(c == 0) | |||||
| QDesktopServices::openUrl(QUrl("file://"+QDir::tempPath()+"/test.pdf")); | |||||
| else | |||||
| QMessageBox::critical(this, "Erreur", "Votre document a pu être numérisé, mais un problème est survenu lors de son traitement.\nErreur "+QString::number(c)); | |||||
| } | |||||
| 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."); | |||||
| } | |||||
| void ScannerDialog::on_btnScan_clicked() | |||||
| { | |||||
| #ifdef Q_OS_LINUX | |||||
| ui->btnTest->setEnabled(false); | |||||
| ui->btnScan->setEnabled(false); | |||||
| ui->btnAnnuler->setEnabled(false); | |||||
| QProcess* process = new QProcess(); | |||||
| process->setStandardOutputFile(QDir::tempPath() + "/output.pnm"); | |||||
| process->start("scanimage --resolution 200"); | |||||
| ui->progressBar->show(); | |||||
| connect(process, SIGNAL(finished(int)), SLOT(scanFinished(int))); | |||||
| #endif | |||||
| } | |||||
| void ScannerDialog::scanFinished(int r) | |||||
| { | |||||
| ui->progressBar->hide(); | |||||
| std::string s = "convert " + QDir::tempPath().toStdString() + "/output.pnm " + QDir::tempPath().toStdString() + "/output.pdf"; | |||||
| if(r == 0) | |||||
| { | |||||
| int c = system(s.c_str()); | |||||
| if(c != 0) | |||||
| QMessageBox::critical(this, "Erreur", "Votre document a pu être numérisé, mais un problème est survenu lors de son traitement.\nErreur "+QString::number(c)); | |||||
| else | |||||
| this->accept(); | |||||
| } | |||||
| 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."); | |||||
| } | |||||
| @@ -0,0 +1,28 @@ | |||||
| #ifndef SCANNERDIALOG_H | |||||
| #define SCANNERDIALOG_H | |||||
| #include <QDialog> | |||||
| namespace Ui { | |||||
| class ScannerDialog; | |||||
| } | |||||
| class ScannerDialog : public QDialog | |||||
| { | |||||
| Q_OBJECT | |||||
| public: | |||||
| explicit ScannerDialog(QWidget *parent = 0); | |||||
| ~ScannerDialog(); | |||||
| private slots: | |||||
| void on_btnTest_clicked(); | |||||
| void scanTestFinished(int r); | |||||
| void on_btnScan_clicked(); | |||||
| void scanFinished(int r); | |||||
| private: | |||||
| Ui::ScannerDialog *ui; | |||||
| }; | |||||
| #endif // SCANNERDIALOG_H | |||||
| @@ -0,0 +1,137 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <ui version="4.0"> | |||||
| <class>ScannerDialog</class> | |||||
| <widget class="QDialog" name="ScannerDialog"> | |||||
| <property name="geometry"> | |||||
| <rect> | |||||
| <x>0</x> | |||||
| <y>0</y> | |||||
| <width>649</width> | |||||
| <height>246</height> | |||||
| </rect> | |||||
| </property> | |||||
| <property name="windowTitle"> | |||||
| <string>Dialog</string> | |||||
| </property> | |||||
| <layout class="QVBoxLayout" name="verticalLayout"> | |||||
| <item> | |||||
| <widget class="QLabel" name="label"> | |||||
| <property name="sizePolicy"> | |||||
| <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> | |||||
| <horstretch>0</horstretch> | |||||
| <verstretch>0</verstretch> | |||||
| </sizepolicy> | |||||
| </property> | |||||
| <property name="text"> | |||||
| <string><html><head/><body><p><span style=" font-size:xx-large; font-weight:600;">Numériser un document</span></p></body></html></string> | |||||
| </property> | |||||
| </widget> | |||||
| </item> | |||||
| <item> | |||||
| <widget class="QLabel" name="label_2"> | |||||
| <property name="sizePolicy"> | |||||
| <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> | |||||
| <horstretch>0</horstretch> | |||||
| <verstretch>0</verstretch> | |||||
| </sizepolicy> | |||||
| </property> | |||||
| <property name="text"> | |||||
| <string><html><head/><body><p>Cette fenêtre permet de numériser votre document rapidement.</p><p>Placez votre document dans votre scanner, puis cliquez sur le bouton <span style=" font-style:italic;">Numériser</span> ci-dessous. Vous pouvez également effectuer un essai pour vérifier que votre document est bien placé.</p><p>Remarque : la numérisation de test est effectuée en basse résolution. Elle ne sera pas enregistrée sur Hermès.</p></body></html></string> | |||||
| </property> | |||||
| <property name="alignment"> | |||||
| <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> | |||||
| </property> | |||||
| <property name="wordWrap"> | |||||
| <bool>true</bool> | |||||
| </property> | |||||
| </widget> | |||||
| </item> | |||||
| <item> | |||||
| <widget class="QProgressBar" name="progressBar"> | |||||
| <property name="minimum"> | |||||
| <number>0</number> | |||||
| </property> | |||||
| <property name="maximum"> | |||||
| <number>0</number> | |||||
| </property> | |||||
| <property name="value"> | |||||
| <number>-1</number> | |||||
| </property> | |||||
| <property name="textVisible"> | |||||
| <bool>false</bool> | |||||
| </property> | |||||
| </widget> | |||||
| </item> | |||||
| <item> | |||||
| <spacer name="verticalSpacer"> | |||||
| <property name="orientation"> | |||||
| <enum>Qt::Vertical</enum> | |||||
| </property> | |||||
| <property name="sizeHint" stdset="0"> | |||||
| <size> | |||||
| <width>20</width> | |||||
| <height>40</height> | |||||
| </size> | |||||
| </property> | |||||
| </spacer> | |||||
| </item> | |||||
| <item> | |||||
| <layout class="QHBoxLayout" name="horizontalLayout"> | |||||
| <item> | |||||
| <spacer name="horizontalSpacer"> | |||||
| <property name="orientation"> | |||||
| <enum>Qt::Horizontal</enum> | |||||
| </property> | |||||
| <property name="sizeHint" stdset="0"> | |||||
| <size> | |||||
| <width>40</width> | |||||
| <height>20</height> | |||||
| </size> | |||||
| </property> | |||||
| </spacer> | |||||
| </item> | |||||
| <item> | |||||
| <widget class="QPushButton" name="btnTest"> | |||||
| <property name="text"> | |||||
| <string>Test</string> | |||||
| </property> | |||||
| </widget> | |||||
| </item> | |||||
| <item> | |||||
| <widget class="QPushButton" name="btnScan"> | |||||
| <property name="text"> | |||||
| <string>Numériser</string> | |||||
| </property> | |||||
| </widget> | |||||
| </item> | |||||
| <item> | |||||
| <widget class="QPushButton" name="btnAnnuler"> | |||||
| <property name="text"> | |||||
| <string>Annuler</string> | |||||
| </property> | |||||
| </widget> | |||||
| </item> | |||||
| </layout> | |||||
| </item> | |||||
| </layout> | |||||
| </widget> | |||||
| <resources/> | |||||
| <connections> | |||||
| <connection> | |||||
| <sender>btnAnnuler</sender> | |||||
| <signal>clicked()</signal> | |||||
| <receiver>ScannerDialog</receiver> | |||||
| <slot>reject()</slot> | |||||
| <hints> | |||||
| <hint type="sourcelabel"> | |||||
| <x>586</x> | |||||
| <y>218</y> | |||||
| </hint> | |||||
| <hint type="destinationlabel"> | |||||
| <x>640</x> | |||||
| <y>182</y> | |||||
| </hint> | |||||
| </hints> | |||||
| </connection> | |||||
| </connections> | |||||
| </ui> | |||||