Added 'lc::ManualPrintingSetup' class to prepare for manual printing
parent
4b5c956242
commit
e8af25467d
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#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();
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MANUALPRINTINGSETUP_H
|
||||
#define MANUALPRINTINGSETUP_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
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
|
@ -0,0 +1,162 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>lc::ManualPrintingSetup</class>
|
||||
<widget class="QWidget" name="lc::ManualPrintingSetup">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>256</width>
|
||||
<height>256</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Manual Printing Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="VLManualPrintingSetup">
|
||||
<item>
|
||||
<widget class="QPushButton" name="PBSelectFile">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: cyan;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select file to be printed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="LReceiptsHeader">
|
||||
<property name="toolTip">
|
||||
<string>Choose the LaTeX template which shall be used for receipts creation.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Template for receipts:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="CBReceiptsHeader">
|
||||
<property name="toolTip">
|
||||
<string>Choose the LaTeX template which shall be used for receipts creation.</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: cyan;</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ChBPrintAnonymousReceipts">
|
||||
<property name="toolTip">
|
||||
<string>Check this if you want the created receipts to be anonymous.</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: cyan;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Print anonymous receipts</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="LReplaceParticipantNames">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Choose a string which shall replace the participant name on the anonymous receipts.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Substitute praticipants' names with:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="CBReplaceParticipantNames">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Choose a string which shall replace the participant name on the anonymous receipts.</string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>\hspace{5cm}</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>anonym</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>anonymous</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>nicht ausfüllen</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ChBReceiptsForLocalClients">
|
||||
<property name="toolTip">
|
||||
<string>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"!</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Print receipts for local clients</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="PBPrint">
|
||||
<property name="toolTip">
|
||||
<string>Starts a ReceiptsHandler instance to print the chosen file.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Print</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="PBCancel">
|
||||
<property name="toolTip">
|
||||
<string>Cancel the process without printing anything.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>PBCancel</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>lc::ManualPrintingSetup</receiver>
|
||||
<slot>deleteLater()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>127</x>
|
||||
<y>239</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>127</x>
|
||||
<y>127</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in New Issue