mainwindow.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /***************************************************************************
  2. * Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
  3. * Copyright (C) 2009-2024 by Robin Stuart <rstuart114@gmail.com> *
  4. * *
  5. * This program is free software: you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation, either version 3 of the License, or *
  8. * (at your option) any later version. *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * You should have received a copy of the GNU General Public License *
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>. *
  15. ***************************************************************************/
  16. /* SPDX-License-Identifier: GPL-3.0-or-later */
  17. #ifndef Z_MAINWINDOW_H
  18. #define Z_MAINWINDOW_H
  19. #include <QButtonGroup>
  20. #include <QMainWindow>
  21. #include <QGraphicsItem>
  22. #include <QGraphicsScene>
  23. #include <QSettings>
  24. class QLabel;
  25. class QShortcut;
  26. class QDoubleSpinBox;
  27. class QPushButton;
  28. class QToolButton;
  29. #include "ui_mainWindow.h"
  30. #include "barcodeitem.h"
  31. class ScaleWindow;
  32. class MainWindow : public QWidget, private Ui::mainWindow
  33. {
  34. Q_OBJECT
  35. public:
  36. MainWindow(QWidget *parent = 0, Qt::WindowFlags fl = Qt::WindowFlags());
  37. ~MainWindow();
  38. static QString get_zint_version(void);
  39. #ifdef Q_OS_MACOS
  40. static void mac_hack_vLayouts(QWidget *win);
  41. static void mac_hack_statusBars(QWidget *win, const char *name = nullptr);
  42. #endif
  43. public slots:
  44. void update_preview();
  45. void change_options();
  46. void fgcolor_clicked();
  47. void bgcolor_clicked();
  48. void fgcolor_changed(const QColor& color);
  49. void bgcolor_changed(const QColor& color);
  50. void fgcolor_edited();
  51. void bgcolor_edited();
  52. void data_ui_set();
  53. void composite_ui_set();
  54. void composite_ean_check();
  55. void maxi_scm_ui_set();
  56. void msi_plessey_ui_set();
  57. void change_cmyk();
  58. void autoheight_ui_set();
  59. void HRTShow_ui_set();
  60. void text_gap_ui_set();
  61. void dotty_ui_set();
  62. void codeone_ui_set();
  63. void upcean_no_quiet_zones_ui_set();
  64. void upcae_no_quiet_zones_ui_set();
  65. void structapp_ui_set();
  66. void clear_text_gap();
  67. void on_encoded();
  68. void on_errored();
  69. void on_dataChanged(const QString& text, bool escaped, int seg_no);
  70. void on_scaleChanged(double scale);
  71. void filter_symbologies();
  72. bool save();
  73. void factory_reset();
  74. void about();
  75. void help();
  76. void preview_bg();
  77. void previewbgcolor_changed(const QColor& color);
  78. void quit_now();
  79. void menu();
  80. void reset_colours();
  81. void reverse_colours();
  82. void open_data_dialog();
  83. void open_data_dialog_seg1();
  84. void open_data_dialog_seg2();
  85. void open_data_dialog_seg3();
  86. void open_sequence_dialog();
  87. void clear_data();
  88. void clear_data_seg1();
  89. void clear_data_seg2();
  90. void clear_data_seg3();
  91. void clear_composite();
  92. void zap();
  93. void open_cli_dialog();
  94. void open_scale_dialog();
  95. void copy_to_clipboard_bmp();
  96. void copy_to_clipboard_emf();
  97. void copy_to_clipboard_eps();
  98. void copy_to_clipboard_gif();
  99. void copy_to_clipboard_png();
  100. void copy_to_clipboard_pcx();
  101. void copy_to_clipboard_svg();
  102. void copy_to_clipboard_tif();
  103. void copy_to_clipboard_errtxt();
  104. void height_per_row_disable();
  105. void height_per_row_default();
  106. void guard_default_upcean();
  107. void guard_default_upca();
  108. void daft_ui_set();
  109. void daft_tracker_default();
  110. void view_context_menu(const QPoint &pos);
  111. void errtxtBar_context_menu(const QPoint &pos);
  112. protected:
  113. void load_settings(QSettings &settings);
  114. bool clear_data_eci_seg(int seg_no);
  115. void color_clicked(QString &colorStr, QLineEdit *txt, QToolButton *btn, const QString& title,
  116. QByteArray& geometry, const char *color_changed);
  117. void color_edited(QString &colorStr, QLineEdit *txt, QToolButton *btn);
  118. void setColorTxtBtn(const QString &colorStr, QLineEdit *txt, QToolButton* btn);
  119. virtual void resizeEvent(QResizeEvent *event) override;
  120. virtual bool event(QEvent *event) override;
  121. virtual bool eventFilter(QObject *watched, QEvent *event) override;
  122. void combobox_item_enabled(QComboBox *comboBox, int index, bool enabled);
  123. bool upcean_addon_gap(const QString &comboBoxName, const QString &labelName, int base);
  124. void upcean_guard_descent(const QString &spnBoxName, const QString &labelName, const QString &btnDefaultName,
  125. bool enabled = true);
  126. void guard_default(const QString &spnBoxName);
  127. double get_height_per_row_default();
  128. bool have_addon();
  129. void set_gs1_mode(bool gs1_mode);
  130. void set_smaller_font(const QString &labelName);
  131. void open_data_dialog_seg(const int seg_no);
  132. void createActions();
  133. void createMenu();
  134. void enableActions();
  135. void copy_to_clipboard(const QString &filename, const QString &name, const char *mimeType = nullptr);
  136. void errtxtBar_clear();
  137. void errtxtBar_set();
  138. void automatic_info_set();
  139. QLineEdit *get_seg_textbox(int seg_no);
  140. QComboBox *get_seg_eci(int seg_no);
  141. QPoint get_context_menu_pos(const QPoint &pos, QWidget *widget);
  142. QWidget *get_widget(const QString &name);
  143. static QString get_setting_name(int symbology);
  144. int get_rad_grp_index(const QStringList &names);
  145. void set_rad_from_setting(QSettings &settings, const QString &setting, const QStringList &names,
  146. int default_val = 0);
  147. bool get_rad_val(const QString &name);
  148. int get_cmb_index(const QString &name);
  149. void set_cmb_from_setting(QSettings &settings, const QString &setting, const QString &name, int default_val = 0);
  150. int get_chk_val(const QString &name);
  151. void set_chk_from_setting(QSettings &settings, const QString &setting, const QString &name, int default_val = 0);
  152. double get_dspn_val(const QString &name);
  153. void set_dspn_from_setting(QSettings &settings, const QString &setting, const QString &name,
  154. float default_val = 0.0f);
  155. QString get_txt_val(const QString &name);
  156. void set_txt_from_setting(QSettings &settings, const QString &setting, const QString &name,
  157. const QString &default_val);
  158. int get_spn_val(const QString &name);
  159. void set_spn_from_setting(QSettings &settings, const QString &setting, const QString &name, int default_val = 0);
  160. void save_sub_settings(QSettings &settings, int symbology);
  161. void load_sub_settings(QSettings &settings, int symbology);
  162. void size_msg_ui_set();
  163. float get_dpmm(const struct Zint::QZintXdimDpVars *vars) const;
  164. const char *getFileType(const struct Zint::QZintXdimDpVars *vars, bool msg = false) const;
  165. private:
  166. QString m_fgstr, m_bgstr;
  167. QByteArray m_fgcolor_geometry, m_bgcolor_geometry, m_previewbgcolor_geometry;
  168. BarcodeItem m_bc;
  169. QColor m_previewBgColor;
  170. QWidget *m_optionWidget;
  171. QGraphicsScene *scene;
  172. int m_symbology;
  173. QMenu *m_menu;
  174. QShortcut *m_saveAsShortcut;
  175. QShortcut *m_factoryResetShortcut;
  176. QShortcut *m_openCLIShortcut;
  177. QShortcut *m_copyBMPShortcut;
  178. QShortcut *m_copyEMFShortcut;
  179. QShortcut *m_copyGIFShortcut;
  180. QShortcut *m_copyPNGShortcut;
  181. QShortcut *m_copySVGShortcut;
  182. QShortcut *m_copyTIFShortcut;
  183. QAction *m_copyBMPAct;
  184. QAction *m_copyEMFAct;
  185. QAction *m_copyEPSAct;
  186. QAction *m_copyGIFAct;
  187. QAction *m_copyPCXAct;
  188. QAction *m_copyPNGAct;
  189. QAction *m_copySVGAct;
  190. QAction *m_copyTIFAct;
  191. QAction *m_openCLIAct;
  192. QAction *m_saveAsAct;
  193. QAction *m_previewBgColorAct;
  194. QAction *m_factoryResetAct;
  195. QAction *m_aboutAct;
  196. QAction *m_helpAct;
  197. QAction *m_quitAct;
  198. QAction *m_copyErrtxtAct;
  199. QLabel *m_lblHeightPerRow;
  200. QDoubleSpinBox *m_spnHeightPerRow;
  201. QPushButton *m_btnHeightPerRowDisable;
  202. QPushButton *m_btnHeightPerRowDefault;
  203. struct Zint::QZintXdimDpVars m_xdimdpVars;
  204. ScaleWindow *m_scaleWindow;
  205. };
  206. /* vim: set ts=4 sw=4 et : */
  207. #endif