optionsWidget.hh 3.95 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//=============================================================================
//
//                               OpenFlipper
//        Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
//                           www.openflipper.org
//
//-----------------------------------------------------------------------------
//
//                                License
//
//  OpenFlipper is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
Jan Möbius's avatar
Jan Möbius committed
15
//
16 17 18 19
//  OpenFlipper is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
Jan Möbius's avatar
Jan Möbius committed
20
//
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
//  You should have received a copy of the GNU Lesser General Public License
//  along with OpenFlipper.  If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
//   $Revision: 1909 $
//   $Author: wilden $
//   $Date: 2008-06-03 18:45:21 +0200 (Tue, 03 Jun 2008) $
//
//=============================================================================




#ifndef OPTIONSWIDGET_HH
#define OPTIONSWIDGET_HH

38
#include "ui_optionsWidget.hh"
39 40
#include <QtGui>
#include <QStringList>
Jan Möbius's avatar
Jan Möbius committed
41
#include <QtNetwork>
42

Dirk Wilden's avatar
Dirk Wilden committed
43 44
#include <OpenFlipper/Core/PluginInfo.hh>

45 46
class OptionsWidget : public QWidget, public Ui::OptionsWidget
{
Jan Möbius's avatar
Jan Möbius committed
47

Jan Möbius's avatar
Jan Möbius committed
48
Q_OBJECT
49

Jan Möbius's avatar
Jan Möbius committed
50 51
public:
   OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, QWidget *parent = 0 );
52

Jan Möbius's avatar
Jan Möbius committed
53 54 55
signals:
   void applyOptions();
   void saveOptions();
56

Jan Möbius's avatar
Jan Möbius committed
57 58 59
private slots:
   /// Hide widget, Update Options and tell others about changed Options
   void slotApply();
60

Jan Möbius's avatar
Jan Möbius committed
61 62
   /// Only hide widget
   void slotCancel();
Jan Möbius's avatar
Jan Möbius committed
63

Jan Möbius's avatar
Jan Möbius committed
64 65
   /// Checks for updates
   void slotCheckUpdates();
Jan Möbius's avatar
Jan Möbius committed
66

Jan Möbius's avatar
Jan Möbius committed
67 68 69 70 71
   /// Download updates
   void slotGetUpdates();
    
   /// open a dialog to determine the color
   void getBackgroundColor();
72

Jan Möbius's avatar
Jan Möbius committed
73 74
protected:
   void showEvent ( QShowEvent * event );
Dirk Wilden's avatar
Dirk Wilden committed
75

Jan Möbius's avatar
Jan Möbius committed
76 77 78 79
private:
   //key-bindings
   std::vector<PluginInfo>& plugins_;
   std::vector<KeyBinding>& coreKeys_;
Jan Möbius's avatar
Jan Möbius committed
80

Jan Möbius's avatar
Jan Möbius committed
81 82
   // flag indicating if something went wrong and the request has to be aborted
   bool httpRequestAborted;
Jan Möbius's avatar
Jan Möbius committed
83

Jan Möbius's avatar
Jan Möbius committed
84 85
   // Id of the current request
   int httpGetId;
Jan Möbius's avatar
Jan Möbius committed
86

Jan Möbius's avatar
Jan Möbius committed
87 88
   // Request variable
   QHttp *http;
Jan Möbius's avatar
Jan Möbius committed
89

Jan Möbius's avatar
Jan Möbius committed
90 91
   // File for http downloads
   QFile *file;
Jan Möbius's avatar
Jan Möbius committed
92

Jan Möbius's avatar
Jan Möbius committed
93 94
   // ProgressDialog for Downloads
   QProgressDialog *progressDialog;
Jan Möbius's avatar
Jan Möbius committed
95

Jan Möbius's avatar
Jan Möbius committed
96 97
   // What type of download is currently active
   enum DOWNLOAD {
Jan Möbius's avatar
Jan Möbius committed
98 99
      NONE,
      VERSIONS_FILE,
Jan Möbius's avatar
Jan Möbius committed
100
      COMPONENT,
Jan Möbius's avatar
Jan Möbius committed
101
      WINDOWS_SETUP
Jan Möbius's avatar
Jan Möbius committed
102
   } downloadType;
Jan Möbius's avatar
Jan Möbius committed
103

Jan Möbius's avatar
Jan Möbius committed
104 105 106
private:
   /// Starts the download of the given file
   void startDownload( QString _url );
Jan Möbius's avatar
Jan Möbius committed
107

Jan Möbius's avatar
Jan Möbius committed
108 109
   /// Compares the versions from the downloaded Versions file with the current versions
   void compareVersions();
110

Jan Möbius's avatar
Jan Möbius committed
111 112
   /// Compares two version strings and returns if a newer Version is available
   bool isNewer(QString _current, QString _latest);
113

Jan Möbius's avatar
Jan Möbius committed
114 115
   /// Redraws the version table
   void updateVersionsTable();
Jan Möbius's avatar
Jan Möbius committed
116

Jan Möbius's avatar
Jan Möbius committed
117
private slots:
Jan Möbius's avatar
Jan Möbius committed
118

Jan Möbius's avatar
Jan Möbius committed
119 120
   // This slot is called when a http request has been finished
   void httpRequestFinished(int requestId, bool error);
Jan Möbius's avatar
Jan Möbius committed
121

Jan Möbius's avatar
Jan Möbius committed
122 123
   // Parses the response and gives feedback
   void readResponseHeader(const QHttpResponseHeader &responseHeader);
Jan Möbius's avatar
Jan Möbius committed
124

Jan Möbius's avatar
Jan Möbius committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
   // Updates the progress Dialog while downloading
   void updateDataReadProgress(int bytesRead, int totalBytes);

   // Progress dialog callback for cancel
   void cancelDownload();

   // Update component of OpenFlipper
   void updateComponent();

private:
   /** After checking for updates this variable will contain a list of filenames for which updates are available
    */
   QStringList updatedPlugins_;

   /** Here the architecture specific path for plugins will be created
    */
   QString pluginPath_;

   /** Current filename of the plugin to be updated
    */
   QString currentUpdateName_;
Jan Möbius's avatar
Jan Möbius committed
146 147


148 149 150
};

#endif //OPTIONSWIDGET_HH