Make fonts/sizes changeable again Fixes #664
[quassel.git] / src / qtui / settingspages / identityeditwidget.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef IDENTITYEDITWIDGET_H
22 #define IDENTITYEDITWIDGET_H
23
24 #include "ui_identityeditwidget.h"
25 #include "ui_nickeditdlg.h"
26
27 #ifdef HAVE_SSL
28 #include <QSslCertificate>
29 #include <QSslKey>
30 #endif
31
32 #include "clientidentity.h"
33
34 class IdentityEditWidget : public QWidget {
35   Q_OBJECT
36
37 public:
38   IdentityEditWidget(QWidget *parent = 0);
39
40   enum SslState {
41     NoSsl,
42     UnsecureSsl,
43     AllowSsl
44   };
45
46   void displayIdentity(CertIdentity *id, CertIdentity *saveId = 0);
47   void saveToIdentity(CertIdentity *id);
48
49 public slots:
50   void setSslState(SslState state);
51   void showAdvanced(bool advanced);
52
53 protected:
54 #ifdef HAVE_SSL
55   virtual bool eventFilter(QObject *watched, QEvent *event);
56 #endif
57
58 signals:
59   void requestEditSsl();
60   void widgetHasChanged();
61
62 private slots:
63   void on_addNick_clicked();
64   void on_deleteNick_clicked();
65   void on_renameNick_clicked();
66   void on_nickUp_clicked();
67   void on_nickDown_clicked();
68
69 #ifdef HAVE_SSL
70   void on_clearOrLoadKeyButton_clicked();
71   void on_clearOrLoadCertButton_clicked();
72 #endif
73   void setWidgetStates();
74
75 #ifdef HAVE_SSL
76   void sslDragEnterEvent(QDragEnterEvent *event);
77   void sslDropEvent(QDropEvent *event, bool isCert);
78 #endif
79
80 private:
81   Ui::IdentityEditWidget ui;
82   bool _editSsl;
83
84 #ifdef HAVE_SSL
85   QSslKey keyByFilename(const QString &filename);
86   void showKeyState(const QSslKey &key);
87   QSslCertificate certByFilename(const QString &filename);
88   void showCertState(const QSslCertificate &cert);
89 #endif
90
91   bool testHasChanged();
92 };
93
94 class NickEditDlg : public QDialog {
95   Q_OBJECT
96
97 public:
98   NickEditDlg(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0);
99
100   QString nick() const;
101
102 private slots:
103   void on_nickEdit_textChanged(const QString &);
104
105 private:
106   Ui::NickEditDlg ui;
107
108   QString oldNick;
109   QStringList existing;
110
111 };
112
113 #endif //IDENTITYEDITWIDGET_H