1 #ifndef __PREFERENCES_H__
2 #define __PREFERENCES_H__
3 
4 #include <stdlib.h>
5 #include <LDLib/LDrawModelViewer.h>
6 #include <LDLib/LDPreferences.h>
7 #include <LDLib/LDInputHandler.h>
8 #include "ui_PreferencesPanel.h"
9 #if QT_VERSION < 0x50000
10 #include <QWindowsStyle>
11 #else
12 #include <QStyleFactory>
13 #endif
14 
15 class ModelViewerWidget;
16 
17 typedef enum
18 {
19 	LDVPollNone,
20 	LDVPollPrompt,
21 	LDVPollAuto,
22 	LDVPollBackground
23 } LDVPollMode;
24 
25 class Preferences : public QDialog, Ui::PreferencesPanel
26 {
27 	Q_OBJECT
28 public:
29 	Preferences(QWidget *parent, ModelViewerWidget *modelWidget = NULL);
30 	~Preferences(void);
31 
32 	void abandonChanges(void);
33 	bool getAllowPrimitiveSubstitution(void);
34 	void getRGB(int color, int &r, int &g, int &b);
35 	void getBackgroundColor(int &r, int &g, int &b);
36 	bool getShowErrors(void);
37 	void setAniso(int);
38 
39 	void setShowError(int errorNumber, bool value);
40 	bool getShowError(int errorNumber);
41 
getStatusBar(void)42 	bool getStatusBar(void) { return statusBar; }
43 	void setStatusBar(bool value);
getToolBar(void)44 	bool getToolBar(void) { return toolBar; }
45 	void setToolBar(bool value);
46 	void setButtonState(QCheckBox *button, bool state);
47 	void setButtonState(QRadioButton *button, bool state);
48 	void setWindowSize(int width, int height);
49 	int getWindowWidth(void);
50 	int getWindowHeight(void);
51 	void setDrawWireframe(bool);
52 	bool getDrawWireframe(void);
53 	void setUseWireframeFog(bool);
54 	bool getUseWireframeFog(void);
55 	void setRemoveHiddenLines(bool);
56 	bool getRemoveHiddenLines(void);
57 	void setTextureStud(bool);
58 	bool getTextureStud(void);
59 	void setEdgeOnly(bool);
60 	void setConditionalLine(bool);
61 	void setHighQuality(bool);
62 	void setAlwaysBlack(bool);
getEdgeOnly(void)63 	bool getEdgeOnly(void) {return ldPrefs->getEdgesOnly();}
getConditionalLine(void)64     bool getConditionalLine(void) {return ldPrefs->getDrawConditionalHighlights();}
getHighQuality(void)65     bool getHighQuality(void) {return ldPrefs->getUsePolygonOffset();}
getAlwaysBlack(void)66     bool getAlwaysBlack(void) {return ldPrefs->getBlackHighlights();}
67 	void setRedBackFaces(bool);
68 	void setGreenFrontFaces(bool);
69 	void setBlueNeutralFaces(bool);
getRedBackFaces(void)70 	bool getRedBackFaces(void) {return ldPrefs->getRedBackFaces();}
getGreenFrontFaces(void)71 	bool getGreenFrontFaces(void) {return ldPrefs->getGreenFrontFaces();}
getBlueNeutralFaces(void)72 	bool getBlueNeutralFaces(void) {return ldPrefs->getBlueNeutralFaces();}
73 	void setShowsHighlightLines(bool);
74 	bool getShowsHighlightLines(void);
75 	void setUseLighting(bool);
76 	bool getUseLighting(void);
77 	bool getUseBFC(void);
78 	void setUseBFC(bool);
79 	bool getShowAxes(void);
80 	void setShowAxes(bool);
81 	void setAllowPrimitiveSubstitution(bool);
82 	void setUseSeams(bool);
83 	bool getUseSeams(void);
84 
85 	static char *getLastOpenPath(char *pathKey = NULL);
86 	static void setLastOpenPath(const char *path, char *pathKey = NULL);
87 	static char *getLDrawDir(void);
88 	static void setLDrawDir(const char *path);
89 	static long getMaxRecentFiles(void);
90 	static char *getRecentFile(int index);
91 	static void setRecentFile(int index, char *filename);
92 	static LDVPollMode getPollMode(void);
93 	static void setPollMode(LDVPollMode value);
94 	static LDInputHandler::ViewMode getViewMode(void);
95 	static void setViewMode(LDInputHandler::ViewMode value);
96 	static bool getLatLongMode(void);
97 	static void setLatLongMode(bool);
98 	static bool getKeepRightSideUp(void);
99 	static void setKeepRightSideUp(bool);
100 	static bool getPovAspectRatio(void);
101 	void performHotKey(int);
102     void setupPrefSetsList(void);
103 	void userDefaultChangedAlertCallback(TCAlert *alert);
104 	void checkLightVector(void);
105 	void browseForDir(QString prompt, QLineEdit *textField, QString &dir);
getSaveDir(LDPreferences::SaveOp saveOp,const std::string & filename)106 	QString getSaveDir(LDPreferences::SaveOp saveOp,const std::string &filename) { return QString(ldPrefs->getDefaultSaveDir(saveOp, filename).c_str()); }
107 
108 public slots:
109 	void doApply(void);
110 	void doOk(void);
111 	void enableApply(void);
112 	void enableProxy(void);
113 	void disableProxy(void);
114 	void doCancel(void);
115 	void doResetGeneral(void);
116 	void doResetGeometry(void);
117 	void doResetEffects(void);
118 	void doResetPrimitives(void);
119 	void doResetUpdates(void);
120 	void doResetTimesUpdates(void);
121 	void doWireframeCutaway(bool value);
122 	void doLighting(bool value);
123 	void doProxyServer(bool value);
124 	void doUpdateMissingparts(bool value);
125 	void doStereo(bool value);
126 	void doWireframe(bool value);
127 	void doSortTransparency(bool value);
128 	void doStippleTransparency(bool value);
129 	void doBFC(bool value);
130 	void doEdgeLines(bool value);
131 	void doConditionalShow(bool value);
132 	void doPrimitiveSubstitution(bool value);
133 	void doTextureStuds(bool value);
134     void doNewPreferenceSet(void);
135     void doDelPreferenceSet(void);
136     void doHotkeyPreferenceSet(void);
doPrefSetSelected()137 	bool doPrefSetSelected() {return doPrefSetSelected(false);}
doPrefSetSelected(QListWidgetItem *,QListWidgetItem *)138 	void doPrefSetSelected(QListWidgetItem *, QListWidgetItem *) {doPrefSetSelected(false);}
139 	bool doPrefSetSelected(bool);
140 	void doPrefSetsApply(void);
141 	void show(void);
142 	void doBackgroundColor();
143 	void doDefaultColor();
144 	void doAnisotropic();
145 	void doAnisotropicSlider(int);
146 	void doDrawLightDats();
147 	void doSaveDefaultViewAngle();
148     void snapshotSaveDirBoxChanged();
149     void partsListsSaveDirBoxChanged();
150 	void exportsListsSaveDirBoxChanged();
151 	void snapshotSaveDirBrowse();
152 	void partsListsSaveDirBrowse();
153 	void exportsSaveDirBrowse();
154 
155 protected:
156 	void doGeneralApply(void);
157 	void doGeometryApply(void);
158 	void doEffectsApply(void);
159 	void doPrimitivesApply(void);
160 	void doUpdatesApply(void);
161 
162 	void loadSettings(void);
163 	void loadOtherSettings(void);
164 
165 	void loadDefaultOtherSettings(void);
166 
167 	void reflectSettings(void);
168 	void reflectGeneralSettings(void);
169 	void reflectGeometrySettings(void);
170 	void reflectWireframeSettings(void);
171 	void reflectBFCSettings(void);
172 	void reflectEffectsSettings(void);
173 	void reflectPrimitivesSettings(void);
174 	void reflectUpdatesSettings(void);
175 
176 	void setRangeValue(QSpinBox *rangeConrol, int value);
177 	void setRangeValue(QSlider *rangeConrol, int value);
178 
179 	void enableWireframeCutaway(void);
180 	void enableLighting(void);
181 	void enableStereo(void);
182 	void enableWireframe(void);
183 	void enableBFC(void);
184 	void enableEdgeLines(void);
185 	void enableConditionalShow(void);
186 	void enablePrimitiveSubstitution(void);
187 	void enableTextureStuds(void);
188 	void enableTexmaps(void);
189 	void enableProxyServer(void);
190 
191 	void disableWireframeCutaway(void);
192 	void disableLighting(void);
193 	void disableStereo(void);
194 	void disableWireframe(void);
195 	void disableBFC(void);
196 	void disableEdgeLines(void);
197 	void disableConditionalShow(void);
198 	void disablePrimitiveSubstitution(void);
199 	void disableTextureStuds(void);
200 	void disableTexmaps(void);
201 	void disableProxyServer(void);
202 	void updateTexmapsEnabled(void);
203 	void setupDefaultRotationMatrix(void);
204 	void uncheckLightDirections(void);
205 	LDPreferences::LightDirection getSelectedLightDirection(void);
206 	void selectLightDirection(LDPreferences::LightDirection);
207 	void updateSaveDir(QLineEdit *textField, QPushButton *button,
208                        LDPreferences::DefaultDirMode dirMode,
209                        QString &filename);
210 	void setupSaveDir(QComboBox *comboBox, QLineEdit *textField,
211                       QPushButton *button, LDPreferences::DefaultDirMode dirMode,
212                       QString &filename);
213 	void setupSaveDirs(void);
214 	const char *getPrefSet(int);
215 	const char *getSelectedPrefSet(void);
216 	void selectPrefSet(const char *prefSet = NULL, bool force = false);
217 	char *getHotKey(int);
218 	int getHotKey(const char*);
219 	int getCurrentHotKey(void);
220 	void saveCurrentHotKey(void);
221 
222 	char *getErrorKey(int errorNumber);
223 	static const QString &getRecentFileKey(int index);
224 
225 	ModelViewerWidget *modelWidget;
226 	LDrawModelViewer *modelViewer;
227 	LDPreferences *ldPrefs;
228 
229 	bool checkAbandon;
230 	int hotKeyIndex;
231 
232 	// Other Settings
233 	bool statusBar;
234 	bool toolBar;
235 	int windowWidth;
236 	int windowHeight;
237 	QString snapshotDir, partsListDir, exportDir;
238 	QIntValidator *proxyPortValidator;
239 #if QT_VERSION < 0x50000
240 	QWindowsStyle qlStyle;
241 #endif
242 };
243 
244 #endif // __PREFERENCES_H__
245