Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
optionsWidget.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
5 * www.openflipper.org *
6 * *
7 *--------------------------------------------------------------------------- *
8 * This file is part of OpenFlipper. *
9 * *
10 * OpenFlipper is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenFlipper is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenFlipper. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36 * *
37 * $Revision: 12305 $ *
38 * $LastChangedBy: moebius $ *
39 * $Date: 2011-09-09 16:05:57 +0200 (Fr, 09 Sep 2011) $ *
40 * *
41 \*===========================================================================*/
42 
43 
44 
45 
46 #ifndef OPTIONSWIDGET_HH
47 #define OPTIONSWIDGET_HH
48 
49 #include "ui_optionsWidget.hh"
50 #include <QtGui>
51 #include <QStringList>
52 #include <QtNetwork>
53 
54 #include <OpenFlipper/Core/PluginInfo.hh>
55 #include <ACG/Scenegraph/DrawModes.hh>
56 
57 //map for keyBindings
58 typedef std::multimap< std::pair< QObject*, int >, std::pair< int, Qt::KeyboardModifiers > > InverseKeyMap;
59 
60 
61 class OptionsWidget : public QWidget, public Ui::OptionsWidget
62 {
63 
64 Q_OBJECT
65 
66 public:
67  OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, InverseKeyMap& _invKeys, QWidget* parent =0 );
68 
69 signals:
70  void applyOptions();
71  void saveOptions();
72 
73  void addKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);
74 
75 private slots:
77  void slotOk();
79  void slotApply();
80 
82  void slotCancel();
83 
85  void slotCheckUpdates();
86 
88  void slotGetUpdates();
89 
91  void getBackgroundColor();
92  void getBaseColor();
93 
95  void keyTreeItemChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous );
96 
97  void keyTreeDoubleClicked(QTreeWidgetItem* _item, int col);
98 
99  void updateShortcut();
100 
101  void slotShowPluginOptions(const QString& _pluginName );
102 
104  void restoreKeyPresets();
105 
107  void updateViewerSettings(int _row);
108 
110  void viewerSettingsChanged(QListWidgetItem* _item);
111  void viewerSettingsChanged(int _index);
112 
114  void switchStackedWidget();
115 
119  void slotPreviewStereoSettings(int _tmpParam = 0);
120 
122  void slotClearSettings();
123 
125  void slotClearINI();
126 
127 protected:
128  void showEvent ( QShowEvent * event );
129 
130 private:
131 
132  // plugin Options
133  void initPluginOptions();
134 
135  QVBoxLayout* pluginOptionsLayout;
136 
137  //key-bindings
138  std::vector<PluginInfo>& plugins_;
139  std::vector<KeyBinding>& coreKeys_;
140 
141  InverseKeyMap& keys_;
142 
143  int getPluginInfo(QString pluginName);
144 
145  void initKeyTree();
146 
147  void applyShortcuts();
148 
149  // flag indicating if something went wrong and the request has to be aborted
150  bool httpRequestAborted;
151 
152  // Id of the current request
153  int httpGetId;
154 
155  // Request variable
156  QHttp *http;
157 
158  // File for http downloads
159  QFile *file;
160 
161  // ProgressDialog for Downloads
162  QProgressDialog *progressDialog;
163 
164  // What type of download is currently active
165  enum DOWNLOAD {
166  NONE,
167  VERSIONS_FILE,
168  PLUGIN,
169  WINDOWS_SETUP
170  } downloadType;
171 
172  // remember changes to viewer properties
173  std::vector< ACG::SceneGraph::DrawModes::DrawMode > defaultDrawModes_;
174  std::vector< bool > defaultProjectionMode_;
175  std::vector< int > defaultViewingDirections_;
176  std::vector< bool > defaultRotationLocks_;
177 
178  bool updatingViewerSettings_;
179 
180  // Store current background color
181  QColor backgroundColor_;
182 
183 private:
185  void startDownload( QString _url );
186 
188  void compareVersions();
189 
191  bool isNewer(QString _current, QString _latest);
192 
194  void updateVersionsTable();
195 
196 private slots:
197 
198  // This slot is called when a http request has been finished
199  void httpRequestFinished(int requestId, bool error);
200 
201  // Parses the response and gives feedback
202  void readResponseHeader(const QHttpResponseHeader &responseHeader);
203 
204  // Updates the progress Dialog while downloading
205  void updateDataReadProgress(int bytesRead, int totalBytes);
206 
207  // Progress dialog callback for cancel
208  void cancelDownload();
209 
210  // Update component of OpenFlipper
211  void updateComponent();
212 
213  // Tracks whether another language has been selected
214  void slotTranslationIndexChanged(int);
215 
216 private:
219  QStringList updatedPlugins_;
220 
223  QString pluginPath_;
224 
228 
232  bool exitOnClose_;
233 
234 
235 };
236 
237 #endif //OPTIONSWIDGET_HH