MagicSmoke  $VERSION$
labeldlg.h
Go to the documentation of this file.
1 //
2 // C++ Interface: labeldlg
3 //
4 // Description:
5 //
6 //
7 // Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008-2016
8 //
9 // Copyright: See README/COPYING.GPL files that come with this distribution
10 //
11 //
12 
13 #ifndef MAGICSMOKE_LABELDLG_H
14 #define MAGICSMOKE_LABELDLG_H
15 
16 #include "commonexport.h"
17 
18 #include <QDialog>
19 #include <QPointF>
20 #include <QList>
21 
22 class QDoubleSpinBox;
23 class QPaintDevice;
24 class QCheckBox;
25 class QComboBox;
26 class QLineEdit;
27 class QPrinter;
28 class QLabel;
29 
32 {
33  public:
35  static void configDialog(QWidget*parent=0);
36 
38  enum LabelType {
40  Invalid=0,
42  Ticket=1,
44  Voucher=2
45  };
47  MLabelConfig(){initMeta();}
49  MLabelConfig(LabelType lt):m_type(lt){initMeta();}
51  MLabelConfig(const MLabelConfig&lc):m_type(lc.m_type){initMeta();}
53  MLabelConfig& operator=(const MLabelConfig&lc){m_type=lc.m_type;return *this;}
54 
56  LabelType labelType()const{return m_type;}
57 
59  QString printerName()const;
60 
64  bool configurePrinter(QPrinter&)const;
65 
72  bool selectPrinter(QPrinter&printer,bool force=false);
73 
76  //do not change the order of these entries!
77  //their numerical value is used as index in configDialog()
79  PrintAskAlways=0,
81  PrintAskIfUnknown=1,
83  PrintAskNever=2
84  };
87  //do not change the order of these entries!
88  //their numerical value is used as index in configDialog()
90  PageAskAlways=0,
92  PageAskIfNeeded=1,
94  PageAskNever=2,
95  };
96 
98  PrintAskMode printAskMode()const;
99 
101  PageAskMode pageAskMode()const;
102 
104  enum PrintMode{
105  //do not change the order of these entries!
106  //their numerical value is used as index in configDialog()
108  PrintDirect=0,
110  PrintPixmap=1
111  };
112 
114  PrintMode printMode()const;
115 
116  private:
117  LabelType m_type;
118  static QString tr(const char*,const char*c=0);
119 
121  void storePrinter(QPrinter&);
123  void storeAskModes(PrintAskMode,PageAskMode);
125  void storePrintMode(PrintMode);
127  QString cgroup()const;
128 
130  void initMeta();
131 
132  friend QDataStream&operator<<(QDataStream&,const MLabelConfig&);
133  friend QDataStream&operator>>(QDataStream&,MLabelConfig&);
134 };
135 MAGICSMOKE_COMMON_EXPORT QDataStream &operator<<(QDataStream &out, const MLabelConfig &myObj);
136 MAGICSMOKE_COMMON_EXPORT QDataStream &operator>>(QDataStream &in, MLabelConfig &myObj);
137 
139 
142 {
143  Q_OBJECT
144  public:
146  MLabelDialog(QWidget*parent,QPrinter*printer,int numlabels,QSizeF labelsize);
148  ~MLabelDialog();
149 
151  QPointF labelOffset(int n)const;
153  bool labelNeedsPageTurn(int n)const;
155  bool oneLabelPerPage()const;
156 
163  static inline bool selectPrinter(MLabelConfig::LabelType type, QPrinter&printer, bool force=false)
164  {return MLabelConfig(type).selectPrinter(printer,force);}
165 
166  public slots:
171  bool conditionalExec(MLabelConfig::LabelType);
172 
173  private slots:
175  void toggleRow(int);
177  void toggleColumn(int);
179  void toggleAll();
180 
182  void updatePage();
184  void savePage();
186  void saveSettings();
187 
188  private:
189  QLineEdit *offx,*offy,*sizex,*sizey;
190  QLabel *warning;
191  QSizeF labelsize;
192  QComboBox *metric,*page;
193  QList<QCheckBox*>checks;
194  QList<QList<bool> >checked;
195  QPrinter* printer;
196  int numlabels,oldpage,maxrows,maxcols;
197 
199  int findLabel(int n,int&row,int&col)const;
200 };
201 
202 
205 {
206  Q_OBJECT
207  public:
208  explicit MLabelPrintDialog(QPrinter*,QWidget* parent = 0, Qt::WindowFlags f = 0);
209  public slots:
210  void setButtonLabel(const QString&);
211  private slots:
212  void printerChanged(int);
213  void paperChanged(int);
214  void unitChanged(int);
215 
216  void okBtnPressed();
217  private:
218  QPrinter*mprinter;
219  QComboBox*mprnselect,*mresolution,*mpaper,*munit;
220  QDoubleSpinBox*mmargleft,*mmargright,*mmargtop,*mmargbottom;
221  QDoubleSpinBox*msizex,*msizey;
222  QLabel*mdescript,*mlocation,*mmakemodel;
223  QPushButton*mokbtn;
224  QCheckBox*mfullpage;
225  double moldunit=1.;
226 
227  //internal: initialize paper types
228  void initPaper();
229 };
230 
231 #endif
Dialog that allows to configure details on how to print a label.
Definition: labeldlg.h:204
#define MAGICSMOKE_COMMON_EXPORT
Definition: commonexport.h:7
PrintAskMode
whether to ask for a printer when printing labels
Definition: labeldlg.h:75
dialog that allows to select which labels on a sheet of paper are used
Definition: labeldlg.h:141
PrintMode
how to send data to the printer
Definition: labeldlg.h:104
static bool selectPrinter(MLabelConfig::LabelType type, QPrinter &printer, bool force=false)
configures the printer for this particular label type whether the dialog is shown depends on settings...
Definition: labeldlg.h:163
PageAskMode
whether to ask for the page layout when printing labels
Definition: labeldlg.h:86
MAGICSMOKE_COMMON_EXPORT QDataStream & operator>>(QDataStream &in, MLabelConfig &myObj)
Definition: labeldlg.cpp:174
Q_DECLARE_METATYPE(MLabelConfig)
MLabelConfig(LabelType lt)
instantiates a configuration object for the given label type
Definition: labeldlg.h:49
MLabelConfig & operator=(const MLabelConfig &lc)
copies the config object
Definition: labeldlg.h:53
MLabelConfig(const MLabelConfig &lc)
copies the config object
Definition: labeldlg.h:51
bool selectPrinter(QPrinter &printer, bool force=false)
configures the printer for this particular label type; whether the dialog is shown depends on setting...
Definition: labeldlg.cpp:495
MLabelConfig()
instantiate an empty configuration object
Definition: labeldlg.h:47
access to the label specific configuration
Definition: labeldlg.h:31
MAGICSMOKE_COMMON_EXPORT QDataStream & operator<<(QDataStream &out, const MLabelConfig &myObj)
Definition: labeldlg.cpp:168
LabelType
the type of label whose configuration is being queried
Definition: labeldlg.h:38
LabelType labelType() const
returns the type represented by this config object
Definition: labeldlg.h:56