1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the examples of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:BSD$
|
---|
10 | ** You may use this file under the terms of the BSD license as follows:
|
---|
11 | **
|
---|
12 | ** "Redistribution and use in source and binary forms, with or without
|
---|
13 | ** modification, are permitted provided that the following conditions are
|
---|
14 | ** met:
|
---|
15 | ** * Redistributions of source code must retain the above copyright
|
---|
16 | ** notice, this list of conditions and the following disclaimer.
|
---|
17 | ** * Redistributions in binary form must reproduce the above copyright
|
---|
18 | ** notice, this list of conditions and the following disclaimer in
|
---|
19 | ** the documentation and/or other materials provided with the
|
---|
20 | ** distribution.
|
---|
21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
---|
22 | ** the names of its contributors may be used to endorse or promote
|
---|
23 | ** products derived from this software without specific prior written
|
---|
24 | ** permission.
|
---|
25 | **
|
---|
26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
---|
29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
---|
30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
---|
36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
---|
37 | ** $QT_END_LICENSE$
|
---|
38 | **
|
---|
39 | ****************************************************************************/
|
---|
40 |
|
---|
41 | #ifndef MAINWINDOW_H
|
---|
42 | #define MAINWINDOW_H
|
---|
43 |
|
---|
44 | #include <QMainWindow>
|
---|
45 |
|
---|
46 | #include "diagramitem.h"
|
---|
47 |
|
---|
48 | class DiagramScene;
|
---|
49 |
|
---|
50 | QT_BEGIN_NAMESPACE
|
---|
51 | class QAction;
|
---|
52 | class QToolBox;
|
---|
53 | class QSpinBox;
|
---|
54 | class QComboBox;
|
---|
55 | class QFontComboBox;
|
---|
56 | class QButtonGroup;
|
---|
57 | class QLineEdit;
|
---|
58 | class QGraphicsTextItem;
|
---|
59 | class QFont;
|
---|
60 | class QToolButton;
|
---|
61 | class QAbstractButton;
|
---|
62 | class QGraphicsView;
|
---|
63 | QT_END_NAMESPACE
|
---|
64 |
|
---|
65 | //! [0]
|
---|
66 | class MainWindow : public QMainWindow
|
---|
67 | {
|
---|
68 | Q_OBJECT
|
---|
69 |
|
---|
70 | public:
|
---|
71 | MainWindow();
|
---|
72 |
|
---|
73 | private slots:
|
---|
74 | void backgroundButtonGroupClicked(QAbstractButton *button);
|
---|
75 | void buttonGroupClicked(int id);
|
---|
76 | void deleteItem();
|
---|
77 | void pointerGroupClicked(int id);
|
---|
78 | void bringToFront();
|
---|
79 | void sendToBack();
|
---|
80 | void itemInserted(DiagramItem *item);
|
---|
81 | void textInserted(QGraphicsTextItem *item);
|
---|
82 | void currentFontChanged(const QFont &font);
|
---|
83 | void fontSizeChanged(const QString &size);
|
---|
84 | void sceneScaleChanged(const QString &scale);
|
---|
85 | void textColorChanged();
|
---|
86 | void itemColorChanged();
|
---|
87 | void lineColorChanged();
|
---|
88 | void textButtonTriggered();
|
---|
89 | void fillButtonTriggered();
|
---|
90 | void lineButtonTriggered();
|
---|
91 | void handleFontChange();
|
---|
92 | void itemSelected(QGraphicsItem *item);
|
---|
93 | void about();
|
---|
94 |
|
---|
95 | private:
|
---|
96 | void createToolBox();
|
---|
97 | void createActions();
|
---|
98 | void createMenus();
|
---|
99 | void createToolbars();
|
---|
100 | QWidget *createBackgroundCellWidget(const QString &text,
|
---|
101 | const QString &image);
|
---|
102 | QWidget *createCellWidget(const QString &text,
|
---|
103 | DiagramItem::DiagramType type);
|
---|
104 | QMenu *createColorMenu(const char *slot, QColor defaultColor);
|
---|
105 | QIcon createColorToolButtonIcon(const QString &image, QColor color);
|
---|
106 | QIcon createColorIcon(QColor color);
|
---|
107 |
|
---|
108 | DiagramScene *scene;
|
---|
109 | QGraphicsView *view;
|
---|
110 |
|
---|
111 | QAction *exitAction;
|
---|
112 | QAction *addAction;
|
---|
113 | QAction *deleteAction;
|
---|
114 |
|
---|
115 | QAction *toFrontAction;
|
---|
116 | QAction *sendBackAction;
|
---|
117 | QAction *aboutAction;
|
---|
118 |
|
---|
119 | QMenu *fileMenu;
|
---|
120 | QMenu *itemMenu;
|
---|
121 | QMenu *aboutMenu;
|
---|
122 |
|
---|
123 | QToolBar *textToolBar;
|
---|
124 | QToolBar *editToolBar;
|
---|
125 | QToolBar *colorToolBar;
|
---|
126 | QToolBar *pointerToolbar;
|
---|
127 |
|
---|
128 | QComboBox *sceneScaleCombo;
|
---|
129 | QComboBox *itemColorCombo;
|
---|
130 | QComboBox *textColorCombo;
|
---|
131 | QComboBox *fontSizeCombo;
|
---|
132 | QFontComboBox *fontCombo;
|
---|
133 |
|
---|
134 | QToolBox *toolBox;
|
---|
135 | QButtonGroup *buttonGroup;
|
---|
136 | QButtonGroup *pointerTypeGroup;
|
---|
137 | QButtonGroup *backgroundButtonGroup;
|
---|
138 | QToolButton *fontColorToolButton;
|
---|
139 | QToolButton *fillColorToolButton;
|
---|
140 | QToolButton *lineColorToolButton;
|
---|
141 | QAction *boldAction;
|
---|
142 | QAction *underlineAction;
|
---|
143 | QAction *italicAction;
|
---|
144 | QAction *textAction;
|
---|
145 | QAction *fillAction;
|
---|
146 | QAction *lineAction;
|
---|
147 | };
|
---|
148 | //! [0]
|
---|
149 |
|
---|
150 | #endif
|
---|