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 #ifndef GUIDEMANAGER_H 8 #define GUIDEMANAGER_H 9 10 #include "scribusapi.h" 11 #include "scrspinbox.h" 12 #include "ui_guidemanager.h" 13 #include "guidemanagercore.h" 14 #include "ui/scrpalettebase.h" 15 #include "scribusstructs.h" 16 #include "scpage.h" 17 18 class GuidesModel; 19 class ScribusDoc; 20 21 22 23 /*! \brief GuideManager is the dialog for guides managing ;). 24 It's scribus non-modal palette now. 25 \warning Be careful with UI file guidemanagerbase.ui it uses ScrPaletteBase 26 as base class instead of QDialog. It should provide correct header file too. 27 28 \author Petr vanek <petr@scribus.info> 29 \author Alessandro Rimoldi 30 \author Franz Schmid 31 */ 32 class SCRIBUS_API GuideManager : public ScrPaletteBase, Ui::GuideManager 33 { 34 Q_OBJECT 35 36 public: 37 GuideManager(QWidget* parent); 38 ~GuideManager(); 39 40 /*! \brief Set the doc fo the guidemanager to work on. */ 41 void setDoc(ScribusDoc* doc); 42 43 /*! \brief Reimplement ScrPaletteBase::setVisible() */ 44 void setVisible(bool visible) override; 45 46 /*! \brief Set the widgets on the page change. 47 It has to be called on every page to page transition */ 48 void setupPage(bool storeValues = true); 49 void setupGui(); 50 51 /*! \brief Clear and reset the GUI horizontal list widget. */ 52 void clearRestoreHorizontalList(); 53 /*! \brief Clear and reset the GUI vertical list widget. */ 54 void clearRestoreVerticalList(); 55 56 /*! \brief Get selected standard guides from GUI list. 57 Used in highlight painting. 58 \retval Guides a list with double values */ 59 Guides selectedHorizontals() const; 60 /*! \brief Get selected standard guides from GUI list. 61 Used in highlight painting. 62 \retval Guides a list with double values */ 63 Guides selectedVerticals() const; 64 65 /*! \brief check the current page number to prevent drawing 66 marks on the others pages. See GuideManagerCore::drawPage. 67 \retval int page no */ pageNr()68 int pageNr() const { return ((currentPage) ? currentPage->pageNr() : -1); } 69 currentIndex()70 int currentIndex() const { return tabWidget->currentIndex(); } 71 72 void setGuideLock(bool guidesLocked); 73 74 protected: 75 void changeEvent(QEvent *e) override; 76 77 private: 78 //! \brief Store the guide values in the Qt4 model 79 GuidesModel * horizontalModel; 80 //! \brief Store the guide values in the Qt4 model 81 GuidesModel * verticalModel; 82 83 ScribusDoc* m_Doc; 84 //! \brief a reference to the current pages 85 ScPage * currentPage; 86 //! \brief A flag to prevent guides drawing when it's not needed 87 bool m_drawGuides; 88 89 //! \brief Initialise the units. Spin boxes gets pt/mm/etc. extensions here. 90 void unitChange(); 91 92 //! \brief Document measurements and metrics 93 int docUnitIndex; 94 95 //! \brief suffix of the unit [mm, ...] 96 QString suffix; 97 98 /*! \brief Copy guides from currentPage to all remaining. 99 All gudes are deleted before copying. 100 \param t a type to clear and copy.*/ 101 void copyGuidesToAllPages(GuideManagerCore::GuideType t); 102 103 /*! \brief Save needed (Auto) values into GuideManagerCore. 104 To be restored on the page return. 105 \param page A reference to the page to store values. */ 106 void storePageValues(ScPage * page); 107 108 /*! \brief Create automatic horizontal guides. 109 Calculates positions of the guides. 110 \param p a Page for what should be calculation performed 111 */ 112 Guides getAutoHorizontals(ScPage * p); 113 114 /*! \brief Create automatic vertical guides. 115 Calculates positions of the guides. 116 \param p a Page for what should be calculation performed 117 */ 118 Guides getAutoVerticals(ScPage * p); 119 120 /*! \brief Recalculate the selection position and measurements for the current page. 121 It's used for automatic guides position. It's called for every 122 selection GUI widgets change to handle selection change only 123 when needed. */ 124 void resetSelectionForPage(); 125 126 /*! \brief Draw guides into painter */ 127 void drawGuides(); 128 129 /*! \brief These methods simulate old button group behaviour. 130 Is there a better way to do it? QButtonGroup? It's more code... 131 */ 132 void setHorizontalRefer(int button); 133 int horizontalRefer(); 134 void setVerticalRefer(int button); 135 int verticalRefer(); 136 void languageChange(); 137 138 private slots: 139 //! Wrapper slot for drawGuides() 140 void forceDrawGuides(const QItemSelection &, const QItemSelection &); 141 void verticalModel_valueChanged(); 142 void horizontalModel_valueChanged(); 143 void addHorButton_clicked(); 144 void delHorButton_clicked(); 145 void addVerButton_clicked(); 146 void delVerButton_clicked(); 147 void applyToAllStdButton_clicked(); 148 void lockCheck_stateChanged( int ); 149 void horizontalAutoGapCheck_stateChanged( int ); 150 void verticalAutoGapCheck_stateChanged( int ); 151 void applyToAllAutoButton_clicked(); 152 void horizontalAutoCountSpin_valueChanged( double ); 153 void verticalAutoCountSpin_valueChanged( double ); 154 void horizontalAutoGapSpin_valueChanged(double); 155 void verticalAutoGapSpin_valueChanged(double); 156 void horizontalPageAutoButton_toggled(bool); 157 void horizontalMarginsAutoButton_toggled(bool); 158 void horizontalSelectionAutoButton_toggled(bool); 159 void verticalPageAutoButton_toggled(bool); 160 void verticalMarginsAutoButton_toggled(bool); 161 void verticalSelectionAutoButton_toggled(bool); 162 void tabWidget_currentChanged(int); 163 void deletePageButton_clicked(); 164 void deleteAllGuides_clicked(); 165 }; 166 167 #endif // GUIDEMANAGER_H 168