Scribus
Open source desktop publishing at your fingertips
stylemanager.h
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 #ifndef STYLEMANAGER_H
9 #define STYLEMANAGER_H
10 
11 #include <QPointer>
12 
13 class QEvent;
14 
15 #include "ui/scrpalettebase.h"
16 #include "ui_stylemanager.h"
17 
18 class StyleItem;
19 class ScribusDoc;
20 class ShortcutWidget;
21 class ScrAction;
22 struct Keys;
23 
24 class SCRIBUS_API StyleManager : public ScrPaletteBase, Ui::StyleManager
25 {
26  Q_OBJECT
27 public:
28  StyleManager(QWidget *parent = 0, const char *name = "StyleManager");
29  ~StyleManager();
30 
31  virtual void changeEvent(QEvent *e);
32 
33  void addStyle(StyleItem *item);
34  void updateColorList();
35 
36  QMap<QString,Keys> keyMap();
37 
38 public slots:
39  void setDoc(ScribusDoc *doc);
40  void languageChange();
41  void unitChange();
42 
43 signals:
44  void closed();
45 
46 protected:
47  void hideEvent(QHideEvent *e);
48  void closeEvent(QCloseEvent *e);
49  void showEvent(QShowEvent *e);
50 
51 private:
52  QList<StyleItem*> m_items;
53  StyleItem *m_item;
54  QGridLayout *m_layout;
55  QTabWidget *m_widget;
56  ShortcutWidget *m_shortcutWidget;
57  QString m_currentType;
58  QMenu *m_newPopup;
59  QMenu *m_rightClickPopup;
60 
61  QAction *m_rcpNewId;
62  QAction *m_rcpDeleteId;
63  QAction *m_rcpEditId;
64  QAction *m_rcpCloneId;
65 // QAction *m_rcpToScrapId;
66  ScrAction *m_selectedStyleAction;
67 
68  bool m_isEditMode;
69  bool m_isStoryEditMode;
70  QPoint m_editPosition;
71  QString m_rcStyle;
72  QString m_rcType;
73  QString m_exitEditModeOk;
74  QString m_enterEditModeOk;
75  QString m_doneText;
76  QString m_editText;
77 
78  ScribusDoc *m_doc;
79  PrefsContext *m_prefs;
80 
81  QMap<QString, QPointer<ScrAction> > m_styleActions;
82 
83  static const int NAME_COL = 0;
84  static const int SHORTCUT_COL = 1;
85  static const QString SEPARATOR;
86 
87  void insertShortcutPage(QTabWidget *twidget);
88 
89  bool nameIsUnique(const QString &name);
90 
91  // will be used to map plural style name to it's singular
92  QMap<QString, QString> m_styleClassesPS;
93  QMap<QString, QString> m_styleClassesSP;
94 
95  // QPair.first will be the type name (null if nothing is selected or
96  // if there are styles from more than one type in the selection)
97  // QPair.second will be the selected styles
98  QPair<QString, QStringList> namesFromSelection();
99  void loadType(const QString &name);
100  void addNewType(StyleItem *item, bool loadFromDoc = true);
101  void createNewStyle(const QString &typeName, const QString &fromParent = QString::null);
102  void reloadStyleView(bool loadFromDoc = true); // are the styles loaded from doc or from tmp cache
103  bool shortcutExists(const QString &keys);
104  void updateActionName(const QString &oldName, const QString &newName);
105  /* QPair.first = type name and QPair.second = style name */
106  void setSelection(const QList<QPair<QString, QString> > &selected);
107  void setOkButtonText();
108 
109 private slots:
110  void slotOk();
111  void slotApply();
112  void slotDelete();
113  void slotImport();
114  void slotEdit();
115  void slotClone();
116  void slotNew();
118  void slotNewPopup(QAction *);
122  void slotNewPopup();
123  void slotScrap();
124  void slotRightClick(const QPoint &point);
125  void slotDoubleClick(QTreeWidgetItem * item, int column);
126 
127  void slotNameChanged(const QString& name);
128  void slotShortcutChanged(const QString& shortcut);
129  void slotSetupWidget();
130 
131  void slotApplyStyle(QTreeWidgetItem *item);
132  void slotApplyStyle(QTreeWidgetItem *newitem, QTreeWidgetItem *olditem);
133  void slotApplyStyle(QTreeWidgetItem *item, int column);
134 
135  void slotDocSelectionChanged();
136  void slotDocStylesChanged();
137 
138  void slotDirty();
139  void slotClean();
140 
141  void slotApplyStyle(QString keyString); // keyString == styleClass$$$$styleName
142 };
143 
144 #endif
User defined key-shortcuts for Style Manager dialog.
Definition: shortcutwidget.h:21
Definition: scribusstructs.h:194
virtual void showEvent(QShowEvent *showEvent)
Restore the geometry of the window when showing it.
Definition: scrpalettebase.cpp:156
Definition: stylemanager.h:24
Represents a style type that can be added to the Style Manager.
Definition: styleitem.h:37
virtual void hideEvent(QHideEvent *)
Stores the geometry of the window when hiding.
Definition: scrpalettebase.cpp:150
the Document Class
Definition: scribusdoc.h:90
virtual void closeEvent(QCloseEvent *closeEvent)
Captures the close event and changes it to hide.
Definition: scrpalettebase.cpp:143
Definition: scraction.h:33
Definition: prefscontext.h:40
Definition: scrpalettebase.h:38