Developer Documentation
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
45
46
47#ifndef OPTIONSWIDGET_HH
48#define OPTIONSWIDGET_HH
49
50#include <OpenFlipper/Core/PluginInfo.hh>
51#include <ACG/Scenegraph/DrawModes.hh>
52
53#include "ui_optionsWidget.h"
54
55#include <QStringList>
56#include <QProgressDialog>
57#include <QtNetwork>
58
59
60//map for keyBindings
61typedef std::multimap< std::pair< QObject*, int >, std::pair< int, Qt::KeyboardModifiers > > InverseKeyMap;
62
63
64class OptionsWidget : public QWidget, public Ui::OptionsWidget
65{
66
67Q_OBJECT
68
69public:
70 OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, InverseKeyMap& _invKeys, QWidget* parent =0 );
71
72signals:
73 void applyOptions();
74 void saveOptions();
75
76 void addKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);
77
78private slots:
80 void slotOk();
82 void slotApply();
83
85 void slotCancel();
86
88 void slotCheckUpdates();
89
91 void slotGetUpdates();
92
94 void getBackgroundColor();
95 void getDefaultColor();
96
98 void keyTreeItemChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous );
99
100 void keyTreeDoubleClicked(QTreeWidgetItem* _item, int col);
101
102 void updateShortcut();
103
104 void slotShowPluginOptions(const QString& _pluginName );
105
107 void restoreKeyPresets();
108
110 void updateViewerSettings(int _row);
111
113 void viewerSettingsChanged(QListWidgetItem* _item);
114 void viewerSettingsChanged(int _index);
115
117 void switchStackedWidget();
118
122 void slotPreviewStereoSettings(int _tmpParam = 0);
123
125 void slotClearSettings();
126
128 void slotClearINI();
129
131 void slotReloadShaders();
132
133protected:
134 void showEvent ( QShowEvent * event );
135
136private:
137
138 // plugin Options
139 void initPluginOptions();
140
141 QVBoxLayout* pluginOptionsLayout;
142
143 //key-bindings
144 std::vector<PluginInfo>& plugins_;
145 std::vector<KeyBinding>& coreKeys_;
146
147 InverseKeyMap& keys_;
148
149 int getPluginInfo(const QString &pluginName);
150
151 void initKeyTree();
152
153 void applyShortcuts();
154
155 // flag indicating if something went wrong and the request has to be aborted
156 bool httpRequestAborted;
157
158
159 // Request variable
160 QNetworkAccessManager *networkMan_;
161 // current request
162 QNetworkReply* downloadRep_;
163
164 // File for http downloads
165 QFile *file;
166
167 // ProgressDialog for Downloads
168 QProgressDialog *progressDialog_;
169
170 // What type of download is currently active
171 enum DOWNLOAD {
172 NONE,
173 VERSIONS_FILE,
174 PLUGIN,
175 WINDOWS_SETUP
176 } downloadType;
177
178 // remember changes to viewer properties
179 std::vector< ACG::SceneGraph::DrawModes::DrawMode > defaultDrawModes_;
180 std::vector< bool > defaultProjectionMode_;
181 std::vector< int > defaultViewingDirections_;
182 std::vector< bool > defaultRotationLocks_;
183
184 bool updatingViewerSettings_;
185
186 // Store current background color
187 QColor backgroundColor_;
188
189private:
191 void startDownload( QString _url );
192
194 void compareVersions();
195
197 bool isNewer(QString _current, QString _latest);
198
200 void updateVersionsTable();
201
202private slots:
203
204 // This slot is called when a http request has been finished
205 void httpRequestFinished(QNetworkReply *_qnr);
206
207 // Updates the progress Dialog while downloading
208 void updateDataReadProgress(qint64 _bytesReceived, qint64 _bytesTotal);
209
211 void showError(QNetworkReply::NetworkError _error);
212
213 // Progress dialog callback for cancel
214 void cancelDownload();
215
216 // Update component of OpenFlipper
217 void updateComponent();
218
219 // Tracks whether another language has been selected
220 void slotTranslationIndexChanged(int);
221
223 void authentication ( QNetworkReply* _reply, QAuthenticator* _authenticator );
224
225private:
228 QStringList updatedPlugins_;
229
232 QString pluginPath_;
233
237
241 bool exitOnClose_;
242
243
244};
245
246#endif //OPTIONSWIDGET_HH
void updateViewerSettings(int _row)
update the dialog if the selected viewer changes
QString pluginPath_
void slotCheckUpdates()
Checks for updates.
void keyTreeDoubleClicked(QTreeWidgetItem *_item, int col)
doubleclick in the keyTree
Definition: keyBindings.cc:59
void slotClearINI()
Clear OpenFlipper INI.
void initKeyTree()
init the TreeWidget containing the keyBindings
Definition: keyBindings.cc:196
void switchStackedWidget()
Switch between the stacked widgets of the stereo settings.
void slotClearSettings()
Clear all OpenFlipper settings.
void restoreKeyPresets()
restore keyBinding Presets
Definition: keyBindings.cc:159
void updateVersionsTable()
Redraws the version table.
QStringList updatedPlugins_
void slotApply()
Update Options and tell others about changed Options.
void slotPreviewStereoSettings(int _tmpParam=0)
void authentication(QNetworkReply *_reply, QAuthenticator *_authenticator)
authentication
Definition: downloader.cc:104
void slotReloadShaders()
Clear the Shader Cache.
void applyShortcuts()
check which of the shortcuts changed and inform the core about the change
Definition: keyBindings.cc:123
void slotOk()
call slotApply and hide widget
void slotGetUpdates()
Download updates.
void compareVersions()
Compares the versions from the downloaded Versions file with the current versions.
void keyTreeItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
keyBinding TreeWidget-Item changed
Definition: keyBindings.cc:70
void viewerSettingsChanged(QListWidgetItem *_item)
remember user changes to viewer properties
QString currentUpdateName_
int getPluginInfo(const QString &pluginName)
get the pluginInfo object corresponding to the given pluginName
Definition: keyBindings.cc:50
void startDownload(QString _url)
Starts the download of the given file.
Definition: downloader.cc:52
void showError(QNetworkReply::NetworkError _error)
error occured while downloading
Definition: downloader.cc:178
void updateShortcut()
check if the shortcut exists and add it if not
Definition: keyBindings.cc:86
void getBackgroundColor()
open a dialog to determine the color
bool isNewer(QString _current, QString _latest)
Compares two version strings and returns if a newer Version is available.
void slotCancel()
Only hide widget.