Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
optionsWidget.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 #ifndef OPTIONSWIDGET_HH
54 #define OPTIONSWIDGET_HH
55 
56 #include <OpenFlipper/Core/PluginInfo.hh>
57 #include <ACG/Scenegraph/DrawModes.hh>
58 
59 #include "ui_optionsWidget.hh"
60 
61 #if QT_VERSION >= 0x050000
62  #include <QtWidgets>
63 #else
64  #include <QtGui>
65 #endif
66 
67 #include <QStringList>
68 #include <QProgressDialog>
69 #include <QtNetwork>
70 
71 
72 //map for keyBindings
73 typedef std::multimap< std::pair< QObject*, int >, std::pair< int, Qt::KeyboardModifiers > > InverseKeyMap;
74 
75 
76 class OptionsWidget : public QWidget, public Ui::OptionsWidget
77 {
78 
79 Q_OBJECT
80 
81 public:
82  OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, InverseKeyMap& _invKeys, QWidget* parent =0 );
83 
84 signals:
85  void applyOptions();
86  void saveOptions();
87 
88  void addKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);
89 
90 private slots:
92  void slotOk();
94  void slotApply();
95 
97  void slotCancel();
98 
100  void slotCheckUpdates();
101 
103  void slotGetUpdates();
104 
106  void getBackgroundColor();
107  void getDefaultColor();
108 
110  void keyTreeItemChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous );
111 
112  void keyTreeDoubleClicked(QTreeWidgetItem* _item, int col);
113 
114  void updateShortcut();
115 
116  void slotShowPluginOptions(const QString& _pluginName );
117 
119  void restoreKeyPresets();
120 
122  void updateViewerSettings(int _row);
123 
125  void viewerSettingsChanged(QListWidgetItem* _item);
126  void viewerSettingsChanged(int _index);
127 
129  void switchStackedWidget();
130 
134  void slotPreviewStereoSettings(int _tmpParam = 0);
135 
137  void slotClearSettings();
138 
140  void slotClearINI();
141 
143  void slotReloadShaders();
144 
145 protected:
146  void showEvent ( QShowEvent * event );
147 
148 private:
149 
150  // plugin Options
151  void initPluginOptions();
152 
153  QVBoxLayout* pluginOptionsLayout;
154 
155  //key-bindings
156  std::vector<PluginInfo>& plugins_;
157  std::vector<KeyBinding>& coreKeys_;
158 
159  InverseKeyMap& keys_;
160 
161  int getPluginInfo(QString pluginName);
162 
163  void initKeyTree();
164 
165  void applyShortcuts();
166 
167  // flag indicating if something went wrong and the request has to be aborted
168  bool httpRequestAborted;
169 
170 
171  // Request variable
172  QNetworkAccessManager *networkMan_;
173  // current request
174  QNetworkReply* downloadRep_;
175 
176  // File for http downloads
177  QFile *file;
178 
179  // ProgressDialog for Downloads
180  QProgressDialog *progressDialog_;
181 
182  // What type of download is currently active
183  enum DOWNLOAD {
184  NONE,
185  VERSIONS_FILE,
186  PLUGIN,
187  WINDOWS_SETUP
188  } downloadType;
189 
190  // remember changes to viewer properties
191  std::vector< ACG::SceneGraph::DrawModes::DrawMode > defaultDrawModes_;
192  std::vector< bool > defaultProjectionMode_;
193  std::vector< int > defaultViewingDirections_;
194  std::vector< bool > defaultRotationLocks_;
195 
196  bool updatingViewerSettings_;
197 
198  // Store current background color
199  QColor backgroundColor_;
200 
201 private:
203  void startDownload( QString _url );
204 
206  void compareVersions();
207 
209  bool isNewer(QString _current, QString _latest);
210 
212  void updateVersionsTable();
213 
214 private slots:
215 
216  // This slot is called when a http request has been finished
217  void httpRequestFinished(QNetworkReply *_qnr);
218 
219  // Updates the progress Dialog while downloading
220  void updateDataReadProgress(qint64 _bytesReceived, qint64 _bytesTotal);
221 
223  void showError(QNetworkReply::NetworkError _error);
224 
225  // Progress dialog callback for cancel
226  void cancelDownload();
227 
228  // Update component of OpenFlipper
229  void updateComponent();
230 
231  // Tracks whether another language has been selected
232  void slotTranslationIndexChanged(int);
233 
235  void authentication ( QNetworkReply* _reply, QAuthenticator* _authenticator );
236 
237 private:
240  QStringList updatedPlugins_;
241 
244  QString pluginPath_;
245 
249 
253  bool exitOnClose_;
254 
255 
256 };
257 
258 #endif //OPTIONSWIDGET_HH
QStringList updatedPlugins_
void slotGetUpdates()
Download updates.
int getPluginInfo(QString pluginName)
get the pluginInfo object corresponding to the given pluginName
Definition: keyBindings.cc:55
void slotClearINI()
Clear OpenFlipper INI.
void showError(QNetworkReply::NetworkError _error)
error occured while downloading
Definition: downloader.cc:183
void slotReloadShaders()
Clear the Shader Cache.
void startDownload(QString _url)
Starts the download of the given file.
Definition: downloader.cc:57
void keyTreeItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
keyBinding TreeWidget-Item changed
Definition: keyBindings.cc:75
void restoreKeyPresets()
restore keyBinding Presets
Definition: keyBindings.cc:164
QString pluginPath_
bool isNewer(QString _current, QString _latest)
Compares two version strings and returns if a newer Version is available.
void slotOk()
call slotApply and hide widget
QString currentUpdateName_
void slotApply()
Update Options and tell others about changed Options.
void slotPreviewStereoSettings(int _tmpParam=0)
void slotCheckUpdates()
Checks for updates.
void getBackgroundColor()
open a dialog to determine the color
void slotClearSettings()
Clear all OpenFlipper settings.
void slotCancel()
Only hide widget.
void updateVersionsTable()
Redraws the version table.
void updateShortcut()
check if the shortcut exists and add it if not
Definition: keyBindings.cc:91
void authentication(QNetworkReply *_reply, QAuthenticator *_authenticator)
authentication
Definition: downloader.cc:109
void initKeyTree()
init the TreeWidget containing the keyBindings
Definition: keyBindings.cc:201
void keyTreeDoubleClicked(QTreeWidgetItem *_item, int col)
doubleclick in the keyTree
Definition: keyBindings.cc:64
void compareVersions()
Compares the versions from the downloaded Versions file with the current versions.
void viewerSettingsChanged(QListWidgetItem *_item)
remember user changes to viewer properties
void switchStackedWidget()
Switch between the stacked widgets of the stereo settings.
void applyShortcuts()
check which of the shortcuts changed and inform the core about the change
Definition: keyBindings.cc:128
void updateViewerSettings(int _row)
update the dialog if the selected viewer changes