File indexing completed on 2024-04-21 04:32:13

0001 /*
0002  * Copyright (C) 2010-2015 by Stephen Allewell
0003  * steve.allewell@gmail.com
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2 of the License, or
0008  * (at your option) any later version.
0009  */
0010 
0011 #ifndef PrintSetupDlg_H
0012 #define PrintSetupDlg_H
0013 
0014 #include <QButtonGroup>
0015 #include <QDialog>
0016 #include <QListWidgetItem>
0017 
0018 #include "PagePreviewListWidgetItem.h"
0019 #include "PrinterConfiguration.h"
0020 
0021 #include "ui_PrintSetup.h"
0022 
0023 class QHideEvent;
0024 class QResizeEvent;
0025 class QShowEvent;
0026 class QString;
0027 
0028 class Document;
0029 class Element;
0030 class PageLayoutEditor;
0031 
0032 class PrintSetupDlg : public QDialog
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037     PrintSetupDlg(QWidget *, Document *, QPrinter *);
0038     virtual ~PrintSetupDlg();
0039 
0040     const PrinterConfiguration &printerConfiguration() const;
0041 
0042 protected:
0043     virtual void hideEvent(QHideEvent *) Q_DECL_OVERRIDE;
0044     virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
0045 
0046 private slots:
0047     void on_PageSize_currentIndexChanged(int);
0048     void on_Orientation_currentIndexChanged(int);
0049     void on_Zoom_currentIndexChanged(int);
0050     void on_Pages_currentItemChanged(QListWidgetItem *, QListWidgetItem *);
0051     void on_Templates_clicked();
0052     void on_AddPage_clicked();
0053     void on_InsertPage_clicked();
0054     void on_DeletePage_clicked();
0055     void on_SelectElement_clicked();
0056     void on_TextElement_clicked();
0057     void on_PatternElement_clicked();
0058     void on_ImageElement_clicked();
0059     void on_KeyElement_clicked();
0060     void on_DialogButtonBox_accepted();
0061     void on_DialogButtonBox_rejected();
0062     void on_DialogButtonBox_helpRequested();
0063     void selectionMade(const QRect &);
0064     void elementGeometryChanged();
0065     void previewContextMenuRequested(const QPoint &);
0066 
0067     void properties();
0068     void deleteElement();
0069 
0070 private:
0071     enum ElementMode { Select, Text, Pattern, Key, Image };
0072 
0073     void initialiseFromConfig();
0074     void addPage(int, Page *);
0075     void updatePageNumbers();
0076     //    void selectTemplate();
0077 
0078     QPageSize selectedPageSize();
0079     QPageLayout::Orientation selectedOrientation();
0080     double selectedZoom();
0081 
0082     Ui::PrintSetup ui;
0083 
0084     PrinterConfiguration m_printerConfiguration;
0085 
0086     double m_scale;
0087     QButtonGroup m_buttonGroup;
0088     ElementMode m_elementMode;
0089     Element *m_elementUnderCursor;
0090     Document *m_document;
0091     QPrinter *m_printer;
0092 
0093     PageLayoutEditor *m_pageLayoutEditor;
0094 };
0095 
0096 #endif // PrintSetupDlg_H