diff --git a/Labcontrol.pro b/Labcontrol.pro index 6046e18..76cba58 100644 --- a/Labcontrol.pro +++ b/Labcontrol.pro @@ -7,6 +7,7 @@ TEMPLATE = app SOURCES += src/localzleafstarter.cpp \ src/main.cpp \ src/mainwindow.cpp \ + src/manualprintingsetup.cpp \ src/sessiondisplay.cpp \ src/sessionstarter.cpp \ src/Lib/client.cpp \ @@ -23,6 +24,7 @@ SOURCES += src/localzleafstarter.cpp \ HEADERS += src/localzleafstarter.h \ src/mainwindow.h \ + src/manualprintingsetup.h \ src/sessiondisplay.h \ src/sessionstarter.h \ src/Lib/client.h \ @@ -40,6 +42,7 @@ HEADERS += src/localzleafstarter.h \ FORMS += src/localzleafstarter.ui \ src/mainwindow.ui \ + src/manualprintingsetup.ui \ src/sessiondisplay.ui \ src/sessionstarter.ui diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5f8634c..1822203 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -25,6 +25,7 @@ #include "localzleafstarter.h" #include "mainwindow.h" +#include "manualprintingsetup.h" #include "Lib/settings.h" extern std::unique_ptr< lc::Settings > settings; @@ -419,23 +420,11 @@ void lc::MainWindow::on_PBOpenTerminal_clicked() { } void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() { - QFileDialog *fileDialog = new QFileDialog{ this, tr( "Please choose a payment file to print." ), - QDir::homePath(), "*.pay" }; - fileDialog->setFileMode( QFileDialog::ExistingFile ); - fileDialog->setOption( QFileDialog::ReadOnly, true ); - if( fileDialog->exec() ) { - QString fileName = fileDialog->selectedFiles().at( 0 ); - QString *dateString = new QString{ fileName.split( '/', QString::KeepEmptyParts, - Qt::CaseInsensitive ).last() - .split( '.', QString::KeepEmptyParts, Qt::CaseInsensitive ).first() }; - QString *workPath = new QString{ fileName }; - workPath->truncate( workPath->lastIndexOf( '/' ) ); - // lcReceiptsHandler *receiptsHandler = new lcReceiptsHandler{ ui->PTEDebugMessages, *workPath, - // ui->CBReceiptsforLocalClients->isChecked(), lablib->GetAnonymousReceiptsPlaceholder(), - // ui->CBReceiptsHeader->currentText(), lablib->GetSettingsItems(), dateString, this }; - // connect( receiptsHandler, &lcReceiptsHandler::PrintingFinished, receiptsHandler, &lcReceiptsHandler::deleteLater ); - } - delete fileDialog; + ManualPrintingSetup *manPrint = new ManualPrintingSetup{ this }; + manPrint->setWindowFlags( Qt::Window ); + manPrint->show(); + connect( manPrint, SIGNAL( destroyed( QObject* ) ), + manPrint, SLOT( deleteLater() ) ); } void lc::MainWindow::on_PBRunzLeaf_clicked() { diff --git a/src/manualprintingsetup.cpp b/src/manualprintingsetup.cpp new file mode 100644 index 0000000..800dc53 --- /dev/null +++ b/src/manualprintingsetup.cpp @@ -0,0 +1,99 @@ +/* + * Copyright 2014-2016 Markus Prasser + * + * This file is part of Labcontrol. + * + * Labcontrol 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 3 of the License, or + * (at your option) any later version. + * + * Labcontrol 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 Labcontrol. If not, see . + */ + +#include + +#include + +#include "manualprintingsetup.h" +#include "ui_manualprintingsetup.h" +#include "Lib/settings.h" + +extern std::unique_ptr< lc::Settings > settings; + +lc::ManualPrintingSetup::ManualPrintingSetup( QWidget *argParent ) : + QWidget{ argParent }, + ui{ new Ui::ManualPrintingSetup } +{ + ui->setupUi( this ); + + if ( settings->dvipsCmd.isEmpty() || settings->latexCmd.isEmpty() + || settings->lcInstDir.isEmpty() || settings->lprCmd.isEmpty() + || settings->postscriptViewer.isEmpty() || settings->ps2pdfCmd.isEmpty() + || settings->rmCmd.isEmpty() || settings->vncViewer.isEmpty() ) { + ui->VLManualPrintingSetup->setEnabled( false ); + QMessageBox::information( this, tr( "Receipts printing will not work" ), + tr( "Some component essential for receipts creation and" + " printing is missing. No receipts will be created or" + " printed." ), QMessageBox::Ok ); + } else { + ui->CBReceiptsHeader->addItems( settings->installedLaTeXHeaders ); + + if ( settings->defaultReceiptIndex + && settings->defaultReceiptIndex < ui->CBReceiptsHeader->count() ) { + ui->CBReceiptsHeader->setCurrentIndex( settings->defaultReceiptIndex ); + } + } +} + +lc::ManualPrintingSetup::~ManualPrintingSetup() { + delete ui; +} + +void lc::ManualPrintingSetup::on_PBSelectFile_clicked() { + QFileDialog fileDialog{ this, tr( "Please choose a payment file to print." ), + QDir::homePath(), "*.pay" }; + fileDialog.setFileMode( QFileDialog::ExistingFile ); + fileDialog.setOption( QFileDialog::ReadOnly, true ); + if ( fileDialog.exec() ) { + ui->PBSelectFile->setStyleSheet( "" ); + const QString tmpFileName{ fileDialog.selectedFiles().at( 0 ) }; + const QString dateString{ tmpFileName.split( '/', QString::KeepEmptyParts, + Qt::CaseInsensitive ).last() + .split( '.', QString::KeepEmptyParts, + Qt::CaseInsensitive ).first() }; + QString workPath{ tmpFileName }; + workPath.truncate( workPath.lastIndexOf( '/' ) ); + } +} + +void lc::ManualPrintingSetup::on_CBReceiptsHeader_activated( int argIndex ) { + Q_UNUSED( argIndex ); + ui->CBReceiptsHeader->setStyleSheet( "" ); +} + +void lc::ManualPrintingSetup::on_ChBPrintAnonymousReceipts_clicked( bool argChecked ) { + ui->ChBPrintAnonymousReceipts->setStyleSheet( "" ); + + ui->LReplaceParticipantNames->setEnabled( argChecked ); + ui->CBReplaceParticipantNames->setEnabled( argChecked ); +} + +void lc::ManualPrintingSetup::on_PBPrint_clicked() { + QString anonymousReceiptsPlaceholder; + if ( ui->ChBPrintAnonymousReceipts->isChecked() ) { + anonymousReceiptsPlaceholder = ui->CBReplaceParticipantNames->currentText(); + } + + emit RequestReceiptsHandler( ui->ChBReceiptsForLocalClients->isChecked(), + anonymousReceiptsPlaceholder, + ui->CBReceiptsHeader->currentText() ); + + this->deleteLater(); +} diff --git a/src/manualprintingsetup.h b/src/manualprintingsetup.h new file mode 100644 index 0000000..e0d5f58 --- /dev/null +++ b/src/manualprintingsetup.h @@ -0,0 +1,56 @@ +/* + * Copyright 2014-2016 Markus Prasser + * + * This file is part of Labcontrol. + * + * Labcontrol 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 3 of the License, or + * (at your option) any later version. + * + * Labcontrol 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 Labcontrol. If not, see . + */ + +#ifndef MANUALPRINTINGSETUP_H +#define MANUALPRINTINGSETUP_H + +#include + +namespace lc { + +namespace Ui { +class ManualPrintingSetup; +} + +class ManualPrintingSetup : public QWidget { + Q_OBJECT + +public: + explicit ManualPrintingSetup( QWidget *argParent = nullptr ); + ~ManualPrintingSetup(); + +signals: + void RequestReceiptsHandler( bool argReceiptsForLocalClients, + QString argAnonymousReceiptsPlaceholder, + QString argLatexHeaderName ); + +private: + QString filePath; + Ui::ManualPrintingSetup *ui = nullptr; + +private slots: + void on_CBReceiptsHeader_activated( int argIndex ); + void on_ChBPrintAnonymousReceipts_clicked( bool argChecked ); + void on_PBPrint_clicked(); + void on_PBSelectFile_clicked(); +}; + +} + +#endif // MANUALPRINTINGSETUP_H diff --git a/src/manualprintingsetup.ui b/src/manualprintingsetup.ui new file mode 100644 index 0000000..f39c12c --- /dev/null +++ b/src/manualprintingsetup.ui @@ -0,0 +1,162 @@ + + + lc::ManualPrintingSetup + + + + 0 + 0 + 256 + 256 + + + + Manual Printing Settings + + + + + + background: cyan; + + + Select file to be printed + + + + + + + Choose the LaTeX template which shall be used for receipts creation. + + + Template for receipts: + + + + + + + Choose the LaTeX template which shall be used for receipts creation. + + + background: cyan; + + + + + + + Check this if you want the created receipts to be anonymous. + + + background: cyan; + + + Print anonymous receipts + + + + + + + false + + + Choose a string which shall replace the participant name on the anonymous receipts. + + + Substitute praticipants' names with: + + + + + + + false + + + Choose a string which shall replace the participant name on the anonymous receipts. + + + true + + + + \hspace{5cm} + + + + + anonym + + + + + anonymous + + + + + nicht ausfüllen + + + + + + + + This decides if receipts shall be printed for any z-Leaf instance running locally on the server. + +Warning: If this is disabled no receipts will be printed for ANY participant whose name contains the character string "local"! + + + Print receipts for local clients + + + true + + + + + + + Starts a ReceiptsHandler instance to print the chosen file. + + + Print + + + + + + + Cancel the process without printing anything. + + + Cancel + + + + + + + + + PBCancel + clicked() + lc::ManualPrintingSetup + deleteLater() + + + 127 + 239 + + + 127 + 127 + + + + +