common: Make SyncableObject non-copyable
[quassel.git] / src / qtui / settingspages / identityeditwidget.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2020 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  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 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 {
36     Q_OBJECT
37
38 public:
39     IdentityEditWidget(QWidget* parent = nullptr);
40
41     enum SslState
42     {
43         NoSsl,
44         UnsecureSsl,
45         AllowSsl
46     };
47
48     void displayIdentity(CertIdentity* id, CertIdentity* saveId = nullptr);
49     void saveToIdentity(CertIdentity* id);
50
51 public slots:
52     void setSslState(SslState state);
53     void showAdvanced(bool advanced);
54
55 protected:
56 #ifdef HAVE_SSL
57     bool eventFilter(QObject* watched, QEvent* event) override;
58 #endif
59
60 signals:
61     void requestEditSsl();
62     void widgetHasChanged();
63
64 private slots:
65     void on_addNick_clicked();
66     void on_deleteNick_clicked();
67     void on_renameNick_clicked();
68     void on_nickUp_clicked();
69     void on_nickDown_clicked();
70
71 #ifdef HAVE_SSL
72     void on_clearOrLoadKeyButton_clicked();
73     void on_clearOrLoadCertButton_clicked();
74 #endif
75     void setWidgetStates();
76
77 #ifdef HAVE_SSL
78     void sslDragEnterEvent(QDragEnterEvent* event);
79     void sslDropEvent(QDropEvent* event, bool isCert);
80 #endif
81
82 private:
83     Ui::IdentityEditWidget ui;
84     bool _editSsl;
85
86 #ifdef HAVE_SSL
87     QSslKey keyByFilename(const QString& filename);
88     void showKeyState(const QSslKey& key);
89     QSslCertificate certByFilename(const QString& filename);
90     void showCertState(const QSslCertificate& cert);
91 #endif
92
93     bool testHasChanged();
94 };
95
96 class NickEditDlg : public QDialog
97 {
98     Q_OBJECT
99
100 public:
101     NickEditDlg(const QString& oldnick, QStringList existing = QStringList(), QWidget* parent = nullptr);
102
103     QString nick() const;
104
105 private slots:
106     void on_nickEdit_textChanged(const QString&);
107
108 private:
109     Ui::NickEditDlg ui;
110
111     QString oldNick;
112     QStringList existing;
113 };
114
115 #endif  // IDENTITYEDITWIDGET_H