1/*
2 * This file Copyright (C) Mnemosyne LLC
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
7 *
8 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
9 *
10 * $Id: prefs-dialog.h 12607 2011-08-01 22:24:24Z jordan $
11 */
12
13#ifndef PREFS_DIALOG_H
14#define PREFS_DIALOG_H
15
16#include <QDialog>
17#include <QSet>
18#include "prefs.h"
19
20class QAbstractButton;
21class QCheckBox;
22class QString;
23class QDoubleSpinBox;
24class QSpinBox;
25class QLabel;
26class QLineEdit;
27class QVBoxLayout;
28class QTime;
29class QTimeEdit;
30class QWidget;
31class QPushButton;
32class QMessageBox;
33class QHttp;
34
35class Prefs;
36class Session;
37
38class PrefsDialog: public QDialog
39{
40        Q_OBJECT
41
42    private slots:
43        void checkBoxToggled( bool checked );
44        void spinBoxEditingFinished( );
45        void timeEditingFinished( );
46        void lineEditingFinished( );
47        void refreshPref( int key );
48        void encryptionEdited( int );
49        void altSpeedDaysEdited( int );
50        void sessionUpdated( );
51        void onWatchClicked( );
52        void onScriptClicked( );
53        void onIncompleteClicked( );
54        void onDestinationClicked( );
55        void onLocationSelected( const QString&, int key );
56        void onPortTested( bool );
57        void onPortTest( );
58
59        void onUpdateBlocklistClicked( );
60        void onUpdateBlocklistCancelled( );
61        void onBlocklistDialogDestroyed( QObject * );
62        void onBlocklistUpdated( int n );
63
64    private:
65        QDoubleSpinBox * doubleSpinBoxNew( int key, double low, double high, double step, int decimals );
66        QCheckBox * checkBoxNew( const QString& text, int key );
67        QSpinBox * spinBoxNew( int key, int low, int high, int step );
68        QTimeEdit * timeEditNew( int key );
69        QLineEdit * lineEditNew( int key, int mode = 0 );
70        void enableBuddyWhenChecked( QCheckBox *, QWidget * );
71        void updateBlocklistLabel( );
72
73    public:
74        PrefsDialog( Session&, Prefs&, QWidget * parent = 0 );
75        ~PrefsDialog( );
76
77    private:
78        void setPref( int key, const QVariant& v );
79        bool isAllowed( int key ) const;
80        QWidget * createTorrentsTab( );
81        QWidget * createDownloadTab( );
82        QWidget * createSpeedTab( );
83        QWidget * createPrivacyTab( );
84        QWidget * createNetworkTab( );
85        QWidget * createDesktopTab( );
86        QWidget * createWebTab( Session& );
87
88    private:
89        typedef QMap<int,QWidget*> key2widget_t;
90        key2widget_t myWidgets;
91        const bool myIsServer;
92        Session& mySession;
93        Prefs& myPrefs;
94        QVBoxLayout * myLayout;
95        QLabel * myPortLabel;
96        QPushButton * myPortButton;
97        QPushButton * myWatchButton;
98        QPushButton * myTorrentDoneScriptButton;
99        QCheckBox * myTorrentDoneScriptCheckbox;
100        QCheckBox * myIncompleteCheckbox;
101        QPushButton * myIncompleteButton;
102        QPushButton * myDestinationButton;
103        QWidgetList myWebWidgets;
104        QWidgetList myWebAuthWidgets;
105        QWidgetList myWebWhitelistWidgets;
106        QWidgetList myProxyWidgets;
107        QWidgetList myProxyAuthWidgets;
108        QWidgetList mySchedWidgets;
109        QWidgetList myBlockWidgets;
110        QWidgetList myUnsupportedWhenRemote;
111
112        int myBlocklistHttpTag;
113        QHttp * myBlocklistHttp;
114        QMessageBox * myBlocklistDialog;
115        QLabel * myBlocklistLabel;
116};
117
118#endif
119