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
61 typedef std::multimap< std::pair< QObject*, int >, std::pair< int, Qt::KeyboardModifiers > > InverseKeyMap;
62
63
64 class OptionsWidget : public QWidget, public Ui::OptionsWidget
65 {
66
67 Q_OBJECT
68
69 public:
70 OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, InverseKeyMap& _invKeys, QWidget* parent =0 );
71
72 signals:
73 void applyOptions();
74 void saveOptions();
75
76 void addKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);
77
78 private 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
133 protected:
134 void showEvent ( QShowEvent * event );
135
136 private:
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(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
189 private:
191 void startDownload( QString _url );
192
194 void compareVersions();
195
197 bool isNewer(QString _current, QString _latest);
198
200 void updateVersionsTable();
201
202 private 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
225 private:
228 QStringList updatedPlugins_;
229
232 QString pluginPath_;
233
236 QString currentUpdateName_;
237
240 bool restartRequired_;
241 bool exitOnClose_;
242
243
244 };
245
246 #endif //OPTIONSWIDGET_HH
OptionsWidget::getBackgroundColor
void getBackgroundColor()
open a dialog to determine the color
Definition: optionsWidget.cc:173
OptionsWidget::slotClearSettings
void slotClearSettings()
Clear all OpenFlipper settings.
Definition: optionsWidget.cc:1013
OptionsWidget
Definition: optionsWidget.hh:64
OptionsWidget::slotPreviewStereoSettings
void slotPreviewStereoSettings(int _tmpParam=0)
Definition: optionsWidget.cc:996
OptionsWidget::slotCheckUpdates
void slotCheckUpdates()
Checks for updates.
Definition: optionsWidget.cc:804
OptionsWidget::updateShortcut
void updateShortcut()
check if the shortcut exists and add it if not
Definition: keyBindings.cc:86
OptionsWidget::authentication
void authentication(QNetworkReply *_reply, QAuthenticator *_authenticator)
authentication
Definition: downloader.cc:104
OptionsWidget::initKeyTree
void initKeyTree()
init the TreeWidget containing the keyBindings
Definition: keyBindings.cc:196
OptionsWidget::compareVersions
void compareVersions()
Compares the versions from the downloaded Versions file with the current versions.
Definition: optionsWidget.cc:944
OptionsWidget::switchStackedWidget
void switchStackedWidget()
Switch between the stacked widgets of the stereo settings.
Definition: optionsWidget.cc:219
OptionsWidget::updateVersionsTable
void updateVersionsTable()
Redraws the version table.
Definition: optionsWidget.cc:474
OptionsWidget::slotCancel
void slotCancel()
Only hide widget.
Definition: optionsWidget.cc:800
OptionsWidget::updateViewerSettings
void updateViewerSettings(int _row)
update the dialog if the selected viewer changes
Definition: optionsWidget.cc:238
OptionsWidget::keyTreeDoubleClicked
void keyTreeDoubleClicked(QTreeWidgetItem *_item, int col)
doubleclick in the keyTree
Definition: keyBindings.cc:59
OptionsWidget::viewerSettingsChanged
void viewerSettingsChanged(QListWidgetItem *_item)
remember user changes to viewer properties
Definition: optionsWidget.cc:193
OptionsWidget::updatedPlugins_
QStringList updatedPlugins_
Definition: optionsWidget.hh:228
OptionsWidget::applyShortcuts
void applyShortcuts()
check which of the shortcuts changed and inform the core about the change
Definition: keyBindings.cc:123
OptionsWidget::slotGetUpdates
void slotGetUpdates()
Download updates.
Definition: optionsWidget.cc:818
OptionsWidget::slotClearINI
void slotClearINI()
Clear OpenFlipper INI.
Definition: optionsWidget.cc:1018
OptionsWidget::restartRequired_
bool restartRequired_
Definition: optionsWidget.hh:240
OptionsWidget::showError
void showError(QNetworkReply::NetworkError _error)
error occured while downloading
Definition: downloader.cc:178
OptionsWidget::getPluginInfo
int getPluginInfo(QString pluginName)
get the pluginInfo object corresponding to the given pluginName
Definition: keyBindings.cc:50
OptionsWidget::keyTreeItemChanged
void keyTreeItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
keyBinding TreeWidget-Item changed
Definition: keyBindings.cc:70
OptionsWidget::isNewer
bool isNewer(QString _current, QString _latest)
Compares two version strings and returns if a newer Version is available.
Definition: optionsWidget.cc:912
OptionsWidget::slotReloadShaders
void slotReloadShaders()
Clear the Shader Cache.
Definition: optionsWidget.cc:1026
OptionsWidget::startDownload
void startDownload(QString _url)
Starts the download of the given file.
Definition: downloader.cc:52
OptionsWidget::restoreKeyPresets
void restoreKeyPresets()
restore keyBinding Presets
Definition: keyBindings.cc:159
OptionsWidget::pluginPath_
QString pluginPath_
Definition: optionsWidget.hh:232
OptionsWidget::slotApply
void slotApply()
Update Options and tell others about changed Options.
Definition: optionsWidget.cc:629
OptionsWidget::currentUpdateName_
QString currentUpdateName_
Definition: optionsWidget.hh:236
OptionsWidget::slotOk
void slotOk()
call slotApply and hide widget
Definition: optionsWidget.cc:795