optionsWidget.hh 4.71 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>

Dirk Wilden's avatar
Dirk Wilden committed
45
46
47
48
//map for keyBindings
typedef std::multimap< std::pair< QObject*, int >, std::pair< int, Qt::KeyboardModifiers > > InverseKeyMap;


49
50
class OptionsWidget : public QWidget, public Ui::OptionsWidget
{
Jan Möbius's avatar
Jan Möbius committed
51

52
Q_OBJECT
53

54
public:
Dirk Wilden's avatar
Dirk Wilden committed
55
   OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, InverseKeyMap& _invKeys, QWidget* parent =0 );
56

57
58
59
signals:
   void applyOptions();
   void saveOptions();
60

Dirk Wilden's avatar
Dirk Wilden committed
61
62
   void addKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);

63
private slots:
Dirk Wilden's avatar
Dirk Wilden committed
64
65
66
   /// call slotApply and hide widget
   void slotOk();
   /// Update Options and tell others about changed Options
67
   void slotApply();
68

69
70
   /// Only hide widget
   void slotCancel();
Jan Möbius's avatar
Jan Möbius committed
71

72
73
   /// Checks for updates
   void slotCheckUpdates();
Jan Möbius's avatar
Jan Möbius committed
74

75
76
   /// Download updates
   void slotGetUpdates();
Jan Möbius's avatar
Jan Möbius committed
77

78
79
   /// open a dialog to determine the color
   void getBackgroundColor();
80

Dirk Wilden's avatar
Dirk Wilden committed
81
82
83
84
85
86
87
   /// keyBinding TreeWidget-Item changed
   void keyTreeItemChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous );

   void keyTreeDoubleClicked(QTreeWidgetItem* _item, int col);

   void updateShortcut();

Dirk Wilden's avatar
Dirk Wilden committed
88
89
   void slotShowPluginOptions(const QString& _pluginName );

90
91
protected:
   void showEvent ( QShowEvent * event );
Dirk Wilden's avatar
Dirk Wilden committed
92

93
private:
Dirk Wilden's avatar
Dirk Wilden committed
94

Dirk Wilden's avatar
Dirk Wilden committed
95
96
97
98
99
   // plugin Options
   void initPluginOptions();

   QVBoxLayout* pluginOptionsLayout;

100
101
102
   //key-bindings
   std::vector<PluginInfo>& plugins_;
   std::vector<KeyBinding>& coreKeys_;
Jan Möbius's avatar
Jan Möbius committed
103

Dirk Wilden's avatar
Dirk Wilden committed
104
105
106
107
108
109
110
111
   InverseKeyMap& keys_;

   int getPluginInfo(QString pluginName);

   void initKeyTree();

   void applyShortcuts();

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

115
116
   // Id of the current request
   int httpGetId;
Jan Möbius's avatar
Jan Möbius committed
117

118
119
   // Request variable
   QHttp *http;
Jan Möbius's avatar
Jan Möbius committed
120

121
122
   // File for http downloads
   QFile *file;
Jan Möbius's avatar
Jan Möbius committed
123

124
125
   // ProgressDialog for Downloads
   QProgressDialog *progressDialog;
Jan Möbius's avatar
Jan Möbius committed
126

127
128
   // What type of download is currently active
   enum DOWNLOAD {
Jan Möbius's avatar
Jan Möbius committed
129
130
      NONE,
      VERSIONS_FILE,
Jan Möbius's avatar
Jan Möbius committed
131
      PLUGIN,
Jan Möbius's avatar
Jan Möbius committed
132
      WINDOWS_SETUP
133
   } downloadType;
Jan Möbius's avatar
Jan Möbius committed
134

135
136
137
private:
   /// Starts the download of the given file
   void startDownload( QString _url );
Jan Möbius's avatar
Jan Möbius committed
138

139
140
   /// Compares the versions from the downloaded Versions file with the current versions
   void compareVersions();
141

142
143
   /// Compares two version strings and returns if a newer Version is available
   bool isNewer(QString _current, QString _latest);
144

145
146
   /// Redraws the version table
   void updateVersionsTable();
Jan Möbius's avatar
Jan Möbius committed
147

148
private slots:
Jan Möbius's avatar
Jan Möbius committed
149

150
151
   // 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
152

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

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
   // 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
177
178


179
180
181
};

#endif //OPTIONSWIDGET_HH