src/configDialog.h

changeset 183
f1b8cb53d2a2
child 191
9bb6a17305ad
equal deleted inserted replaced
182:9374fea8f77f 183:f1b8cb53d2a2
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 Santeri Piippo
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 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef CONFIGDIALOG_H
20 #define CONFIGDIALOG_H
21
22 #include "gui.h"
23 #include <qdialog.h>
24 #include <qlabel.h>
25 #include <qlineedit.h>
26 #include <qdialogbuttonbox.h>
27 #include <qpushbutton.h>
28 #include <qcheckbox.h>
29 #include <qlistwidget.h>
30 #include <qspinbox.h>
31
32 // =============================================================================
33 class ShortcutListItem : public QListWidgetItem {
34 public:
35 explicit ShortcutListItem (QListWidget* view = null, int type = Type) :
36 QListWidgetItem (view, type) {}
37
38 actionmeta* getActionInfo () const { return m_info; }
39 void setActionInfo (actionmeta* info) { m_info = info; }
40
41 private:
42 actionmeta* m_info;
43 };
44
45 // =============================================================================
46 class ConfigDialog : public QDialog {
47 Q_OBJECT
48
49 public:
50 QTabWidget* tabs;
51 QWidget* mainTab, *shortcutsTab, *quickColorTab, *extProgTab;
52
53 // =========================================================================
54 // Main tab widgets
55 QLabel* lb_viewBg, *lb_viewFg, *lb_viewFgAlpha;
56 QLabel* lb_lineThickness, *lb_iconSize;
57 QPushButton* pb_viewBg, *pb_viewFg;
58 QCheckBox* cb_colorize, *cb_colorBFC, *cb_selFlash, *cb_schemanticInline,
59 *cb_blackEdges;
60 QSlider* sl_viewFgAlpha, *sl_lineThickness, *sl_iconSize;
61
62 // =========================================================================
63 // Shortcuts tab
64 QListWidget* lw_shortcutList;
65 QPushButton* pb_setShortcut, *pb_resetShortcut, *pb_clearShortcut;
66
67 // =========================================================================
68 // Quick color toolbar tab
69 QListWidget* lw_quickColors;
70 QPushButton* pb_addColor, *pb_delColor, *pb_changeColor, *pb_addColorSeparator,
71 *pb_moveColorUp, *pb_moveColorDown, *pb_clearColors;
72 std::vector<QListWidgetItem*> quickColorItems;
73 std::vector<quickColorMetaEntry> quickColorMeta;
74
75 // =========================================================================
76 // Grid tab
77 QLabel* lb_gridLabels[3];
78 QLabel* lb_gridIcons[3];
79 QDoubleSpinBox* dsb_gridData[3][4];
80
81 // =========================================================================
82 QDialogButtonBox* bbx_buttons;
83
84 ConfigDialog (ForgeWindow* parent);
85 ~ConfigDialog ();
86 static void staticDialog ();
87
88 private:
89 void initMainTab ();
90 void initShortcutsTab ();
91 void initQuickColorTab ();
92 void initGridTab ();
93 void initExtProgTab ();
94
95 void makeSlider (QSlider*& slider, short min, short max, short defval);
96 void setButtonBackground (QPushButton* qButton, str zValue);
97 void pickColor (strconfig& cfg, QPushButton* qButton);
98 void updateQuickColorList (quickColorMetaEntry* pSel = null);
99 void setShortcutText (QListWidgetItem* qItem, actionmeta meta);
100 long getItemRow (QListWidgetItem* qItem, std::vector<QListWidgetItem*>& haystack);
101 str makeColorToolBarString ();
102 QListWidgetItem* getSelectedQuickColor ();
103 QList<ShortcutListItem*> getShortcutSelection ();
104
105 private slots:
106 void slot_setGLBackground ();
107 void slot_setGLForeground ();
108
109 void slot_setShortcut ();
110 void slot_resetShortcut ();
111 void slot_clearShortcut ();
112
113 void slot_setColor ();
114 void slot_delColor ();
115 void slot_addColorSeparator ();
116 void slot_moveColor ();
117 void slot_clearColors ();
118
119 void slot_setExtProgPath ();
120 };
121
122 // =============================================================================
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
124 // =============================================================================
125 class KeySequenceDialog : public QDialog {
126 Q_OBJECT
127
128 public:
129 explicit KeySequenceDialog (QKeySequence seq, QWidget* parent = null, Qt::WindowFlags f = 0);
130 static bool staticDialog (actionmeta& meta, QWidget* parent = null);
131
132 QLabel* lb_output;
133 QDialogButtonBox* bbx_buttons;
134 QKeySequence seq;
135
136 private:
137 void updateOutput ();
138
139 private slots:
140 virtual void keyPressEvent (QKeyEvent* ev);
141 };
142
143 #endif // CONFIGDIALOG_H

mercurial