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: 6727 $                                                         *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2009-08-05 08:03:50 +0200 (Mi, 05. Aug 2009) $                   *
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 
00056 //map for keyBindings
00057 typedef std::multimap< std::pair< QObject*, int >, std::pair< int, Qt::KeyboardModifiers > > InverseKeyMap;
00058 
00059 
00060 class OptionsWidget : public QWidget, public Ui::OptionsWidget
00061 {
00062 
00063 Q_OBJECT
00064 
00065 public:
00066    OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, InverseKeyMap& _invKeys, QWidget* parent =0 );
00067 
00068 signals:
00069    void applyOptions();
00070    void saveOptions();
00071 
00072    void addKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);
00073 
00074 private slots:
00076    void slotOk();
00078    void slotApply();
00079 
00081    void slotCancel();
00082 
00084    void slotCheckUpdates();
00085 
00087    void slotGetUpdates();
00088 
00090    void getBackgroundColor();
00091    void getBaseColor();
00092 
00094    void keyTreeItemChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous );
00095 
00096    void keyTreeDoubleClicked(QTreeWidgetItem* _item, int col);
00097 
00098    void updateShortcut();
00099 
00100    void slotShowPluginOptions(const QString& _pluginName );
00101 
00103    void restoreKeyPresets();
00104 
00106    void updateViewerSettings(int _row);
00107 
00109    void viewerSettingsChanged(QListWidgetItem* _item);
00110    void viewerSettingsChanged(int _index);
00111 
00112 protected:
00113    void showEvent ( QShowEvent * event );
00114 
00115 private:
00116 
00117    // plugin Options
00118    void initPluginOptions();
00119 
00120    QVBoxLayout* pluginOptionsLayout;
00121 
00122    //key-bindings
00123    std::vector<PluginInfo>& plugins_;
00124    std::vector<KeyBinding>& coreKeys_;
00125 
00126    InverseKeyMap& keys_;
00127 
00128    int getPluginInfo(QString pluginName);
00129 
00130    void initKeyTree();
00131 
00132    void applyShortcuts();
00133 
00134    // flag indicating if something went wrong and the request has to be aborted
00135    bool httpRequestAborted;
00136 
00137    // Id of the current request
00138    int httpGetId;
00139 
00140    // Request variable
00141    QHttp *http;
00142 
00143    // File for http downloads
00144    QFile *file;
00145 
00146    // ProgressDialog for Downloads
00147    QProgressDialog *progressDialog;
00148 
00149    // What type of download is currently active
00150    enum DOWNLOAD {
00151       NONE,
00152       VERSIONS_FILE,
00153       PLUGIN,
00154       WINDOWS_SETUP
00155    } downloadType;
00156 
00157   // remember changes to viewer properties
00158   std::vector< uint > defaultDrawModes_;
00159   std::vector< int >  defaultProjectionMode_;
00160   std::vector< int >  defaultViewingDirections_;
00161 
00162   bool updatingViewerSettings_;
00163 
00164 private:
00166    void startDownload( QString _url );
00167 
00169    void compareVersions();
00170 
00172    bool isNewer(QString _current, QString _latest);
00173 
00175    void updateVersionsTable();
00176 
00177 private slots:
00178 
00179    // This slot is called when a http request has been finished
00180    void httpRequestFinished(int requestId, bool error);
00181 
00182    // Parses the response and gives feedback
00183    void readResponseHeader(const QHttpResponseHeader &responseHeader);
00184 
00185    // Updates the progress Dialog while downloading
00186    void updateDataReadProgress(int bytesRead, int totalBytes);
00187 
00188    // Progress dialog callback for cancel
00189    void cancelDownload();
00190 
00191    // Update component of OpenFlipper
00192    void updateComponent();
00193 
00194 private:
00197    QStringList updatedPlugins_;
00198 
00201    QString pluginPath_;
00202 
00205    QString currentUpdateName_;
00206 
00207 
00208 };
00209 
00210 #endif //OPTIONSWIDGET_HH

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