cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / qtui / settingspages / identityeditwidget.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2022 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 #pragma once
22
23 #include <QSslCertificate>
24 #include <QSslKey>
25
26 #include "clientidentity.h"
27
28 #include "ui_identityeditwidget.h"
29 #include "ui_nickeditdlg.h"
30
31 class IdentityEditWidget : public QWidget
32 {
33     Q_OBJECT
34
35 public:
36     IdentityEditWidget(QWidget* parent = nullptr);
37
38     enum SslState
39     {
40         NoSsl,
41         UnsecureSsl,
42         AllowSsl
43     };
44
45     void displayIdentity(CertIdentity* id, CertIdentity* saveId = nullptr);
46     void saveToIdentity(CertIdentity* id);
47
48 public slots:
49     void setSslState(SslState state);
50     void showAdvanced(bool advanced);
51
52 protected:
53     bool eventFilter(QObject* watched, QEvent* event) override;
54
55 signals:
56     void requestEditSsl();
57     void widgetHasChanged();
58
59 private slots:
60     void on_addNick_clicked();
61     void on_deleteNick_clicked();
62     void on_renameNick_clicked();
63     void on_nickUp_clicked();
64     void on_nickDown_clicked();
65
66     void on_clearOrLoadKeyButton_clicked();
67     void on_clearOrLoadCertButton_clicked();
68     void setWidgetStates();
69
70     void sslDragEnterEvent(QDragEnterEvent* event);
71     void sslDropEvent(QDropEvent* event, bool isCert);
72
73 private:
74     Ui::IdentityEditWidget ui;
75     bool _editSsl;
76
77     QSslKey keyByFilename(const QString& filename);
78     void showKeyState(const QSslKey& key);
79     QSslCertificate certByFilename(const QString& filename);
80     void showCertState(const QSslCertificate& cert);
81
82     bool testHasChanged();
83 };
84
85 class NickEditDlg : public QDialog
86 {
87     Q_OBJECT
88
89 public:
90     NickEditDlg(const QString& oldnick, QStringList existing = QStringList(), QWidget* parent = nullptr);
91
92     QString nick() const;
93
94 private slots:
95     void on_nickEdit_textChanged(const QString&);
96
97 private:
98     Ui::NickEditDlg ui;
99
100     QString oldNick;
101     QStringList existing;
102 };