cfgserverpasswords.h
1 //------------------------------------------------------------------------------
2 // cfgserverpasswords.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2013 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef idEB6A779F_CFBD_4900_AFC803D7BF80EC31
24 #define idEB6A779F_CFBD_4900_AFC803D7BF80EC31
25 
26 #include "dptr.h"
27 #include "gui/configuration/configpage.h"
28 #include <QIcon>
29 
30 class ServerPassword;
31 class QTableWidget;
32 class QTableWidgetItem;
33 
35 {
36  Q_OBJECT
37 
38 public:
39  CFGServerPasswords(QWidget *parent = nullptr);
40  ~CFGServerPasswords() override;
41 
42  QIcon icon() const override
43  {
44  return QIcon(":/icons/padlock.png");
45  }
46  QString name() const override
47  {
48  return tr("Server Passwords");
49  }
50 
51  void readSettings() override;
52 
53 protected:
54  void saveSettings() override;
55 
56 private:
58 
59  void addServerPasswordToTable(const ServerPassword &password);
60  void clearTable(QTableWidget *table);
61  int findPassphraseInTable(const QString &phrase);
62  void hidePasswords();
63  bool isPassphraseInTable(const QString &phrase);
64  void revealPasswords();
65  ServerPassword serverPasswordFromRow(int row);
66  void setPasswordInRow(int row, const ServerPassword &password);
67  void setServersInTable(const ServerPassword &password);
68  QTableWidgetItem *toolTipItem(const QString &contents);
69  void updatePassword(const ServerPassword &password);
70 
71 private slots:
72  void addPasswordFromLineEdit();
73  void onPasswordTableCellChange(int currentRow, int currentColumn,
74  int previousRow, int previousColumn);
75  void removeSelectedPasswords();
76  void removeSelectedServers();
77  void showServerLossWarningIfNecessary();
78  void toggleRevealHide();
79 };
80 
81 #endif