optionsWidget.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 8576 $                                                         *
00038  *   $Author: wilden $                                                      *
00039  *   $Date: 2010-02-17 13:25:06 +0100 (Mi, 17. Feb 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 #ifndef OPTIONSWIDGET_HH
00047 #define OPTIONSWIDGET_HH
00048 
00049 #include "ui_optionsWidget.hh"
00050 #include <QtGui>
00051 #include <QStringList>
00052 #include <QtNetwork>
00053 
00054 #include <OpenFlipper/Core/PluginInfo.hh>
00055 #include <ACG/Scenegraph/DrawModes.hh>
00056 
00057 //map for keyBindings
00058 typedef std::multimap< std::pair< QObject*, int >, std::pair< int, Qt::KeyboardModifiers > > InverseKeyMap;
00059 
00060 
00061 class OptionsWidget : public QWidget, public Ui::OptionsWidget
00062 {
00063 
00064 Q_OBJECT
00065 
00066 public:
00067    OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, InverseKeyMap& _invKeys, QWidget* parent =0 );
00068 
00069 signals:
00070    void applyOptions();
00071    void saveOptions();
00072 
00073    void addKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);
00074 
00075 private slots:
00077    void slotOk();
00079    void slotApply();
00080 
00082    void slotCancel();
00083 
00085    void slotCheckUpdates();
00086 
00088    void slotGetUpdates();
00089 
00091    void getBackgroundColor();
00092    void getBaseColor();
00093 
00095    void keyTreeItemChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous );
00096 
00097    void keyTreeDoubleClicked(QTreeWidgetItem* _item, int col);
00098 
00099    void updateShortcut();
00100 
00101    void slotShowPluginOptions(const QString& _pluginName );
00102 
00104    void restoreKeyPresets();
00105 
00107    void updateViewerSettings(int _row);
00108 
00110    void viewerSettingsChanged(QListWidgetItem* _item);
00111    void viewerSettingsChanged(int _index);
00112 
00114    void switchStackedWidget();
00115 
00117    void updateSliderCounter();
00118    
00122    void slotPreviewStereoSettings(int _tmpParam = 0);
00123 
00124 protected:
00125    void showEvent ( QShowEvent * event );
00126 
00127 private:
00128 
00129    // plugin Options
00130    void initPluginOptions();
00131 
00132    QVBoxLayout* pluginOptionsLayout;
00133 
00134    //key-bindings
00135    std::vector<PluginInfo>& plugins_;
00136    std::vector<KeyBinding>& coreKeys_;
00137 
00138    InverseKeyMap& keys_;
00139 
00140    int getPluginInfo(QString pluginName);
00141 
00142    void initKeyTree();
00143 
00144    void applyShortcuts();
00145 
00146    // flag indicating if something went wrong and the request has to be aborted
00147    bool httpRequestAborted;
00148 
00149    // Id of the current request
00150    int httpGetId;
00151 
00152    // Request variable
00153    QHttp *http;
00154 
00155    // File for http downloads
00156    QFile *file;
00157 
00158    // ProgressDialog for Downloads
00159    QProgressDialog *progressDialog;
00160 
00161    // What type of download is currently active
00162    enum DOWNLOAD {
00163       NONE,
00164       VERSIONS_FILE,
00165       PLUGIN,
00166       WINDOWS_SETUP
00167    } downloadType;
00168 
00169   // remember changes to viewer properties
00170   std::vector< ACG::SceneGraph::DrawModes::DrawMode > defaultDrawModes_;
00171   std::vector< int >  defaultProjectionMode_;
00172   std::vector< int >  defaultViewingDirections_;
00173 
00174   bool updatingViewerSettings_;
00175 
00176 private:
00178    void startDownload( QString _url );
00179 
00181    void compareVersions();
00182 
00184    bool isNewer(QString _current, QString _latest);
00185 
00187    void updateVersionsTable();
00188 
00189 private slots:
00190 
00191    // This slot is called when a http request has been finished
00192    void httpRequestFinished(int requestId, bool error);
00193 
00194    // Parses the response and gives feedback
00195    void readResponseHeader(const QHttpResponseHeader &responseHeader);
00196 
00197    // Updates the progress Dialog while downloading
00198    void updateDataReadProgress(int bytesRead, int totalBytes);
00199 
00200    // Progress dialog callback for cancel
00201    void cancelDownload();
00202 
00203    // Update component of OpenFlipper
00204    void updateComponent();
00205 
00206 private:
00209    QStringList updatedPlugins_;
00210 
00213    QString pluginPath_;
00214 
00217    QString currentUpdateName_;
00218 
00219 
00220 };
00221 
00222 #endif //OPTIONSWIDGET_HH

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .