1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 /*************************************************************************** 8 * * 9 * This program is free software; you can redistribute it and/or modify * 10 * it under the terms of the GNU General Public License as published by * 11 * the Free Software Foundation; either version 2 of the License, or * 12 * (at your option) any later version. * 13 * * 14 ***************************************************************************/ 15 16 #ifndef _LOREMIPSUM_H_ 17 #define _LOREMIPSUM_H_ 18 19 #include <QDialog> 20 #include <QMap> 21 22 #include "scribusapi.h" 23 24 class QEvent; 25 class QGridLayout; 26 class QHBoxLayout; 27 class QLabel; 28 class QPushButton; 29 class QSpacerItem; 30 class QSpinBox; 31 class QCheckBox; 32 class QString; 33 class QStringList; 34 class QTreeWidget; 35 class QVBoxLayout; 36 37 class ScribusDoc; 38 class UndoManager; 39 // class LanguageManager; 40 41 42 /*! \brief XML parser for Lorem Ipsum file. 43 This helper class reads one file 44 \author Petr Vanek <petr@yarpen.cz> 45 */ 46 class SCRIBUS_API LoremParser 47 { 48 public: 49 /*! parse a XML file with given name 50 \param filename string fith the file name with full/relative path */ 51 LoremParser(const QString& filename); ~LoremParser()52 ~LoremParser(){}; 53 54 //! Is the LI correct? 55 bool correct {false}; 56 //! Name to display 57 QString name {"n/a"}; 58 //! Author of the LI 59 QString author {"n/a"}; 60 //! Website of the LI 61 QString url {"n/a"}; 62 //! Paragraphs of the LI 63 QStringList loremIpsum; 64 65 /*! Construct a LI 66 \param parCount count of the paragraphs */ 67 QString createLorem(uint parCount, bool random = true); 68 }; 69 70 /*! \brief This module provides simple interface to the various Lorem Ipsum variants. 71 Scribus LI are stored in the set of XML files. 72 The file has followind structure: 73 \<?xml version="1.0" encoding="utf8"?\> 74 \<lorem\> 75 \<name\>name to display\</name\> 76 \<author\>person name\</author\> 77 \<url\>web interface\</url\> 78 \<p\>text\</p\> 79 \<p\>...\</p\> 80 \</lorem\> 81 Files are in UTF8 encoding. 82 \author Petr Vanek <petr@yarpen.cz> 83 */ 84 class SCRIBUS_API LoremManager : public QDialog 85 { 86 Q_OBJECT 87 88 public: 89 /*! Reads all XML files in cfg directory. */ 90 LoremManager(ScribusDoc* doc, QWidget* parent = nullptr); 91 92 /*! Apply created LI into a frame 93 \param name filename of the selected LI 94 \param paraCount count of the paragraphs 95 */ 96 void insertLoremIpsum(const QString& name, int paraCount, bool random = true); 97 98 //! Lorem Ipsum as QString 99 QString loremIpsum(); 100 101 //! Count of the paragraphs selected in GUI 102 int paragraphCount(); 103 104 //! Name of the Lorem Ipsum file including extension. 105 QString getName(); 106 107 //! Flag if use "random" paragraphs, taken from GUI. 108 bool randomize(); 109 110 protected: 111 void changeEvent(QEvent *e) override; 112 113 private: 114 QCheckBox* appendCheckBox {nullptr}; 115 QCheckBox* randomCheckBox {nullptr}; 116 QGridLayout* LoremManagerLayout {nullptr}; 117 QHBoxLayout* layout1 {nullptr}; 118 QHBoxLayout* layout2 {nullptr}; 119 QLabel* paraLabel {nullptr}; 120 QPushButton* cancelButton {nullptr}; 121 QPushButton* okButton {nullptr}; 122 QSpacerItem* buttonSpacer {nullptr}; 123 QSpacerItem* paraSpacer {nullptr}; 124 QSpinBox* paraBox {nullptr}; 125 QString standardloremtext; 126 QTreeWidget* loremList {nullptr}; 127 QVBoxLayout* layout3 {nullptr}; 128 ScribusDoc* m_Doc {nullptr}; 129 UndoManager* undoManager {nullptr}; 130 131 //! all lorems with Public Name -> filename structure 132 QMap<QString,QString> availableLorems; 133 134 protected slots: 135 void languageChange(); 136 137 }; 138 139 #endif 140