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 "gui/configuration/configpage.h"
27 #include "dptr.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=NULL);
41 
42  QIcon icon() const { return QIcon(":/icons/padlock.png"); }
43  QString name() const { return tr("Server Passwords"); }
44 
45  void readSettings();
46 
47  protected:
48  void saveSettings();
49 
50  private:
52 
53  void addServerPasswordToTable(const ServerPassword& password);
54  void clearTable(QTableWidget* table);
55  int findPassphraseInTable(const QString& phrase);
56  void hidePasswords();
57  bool isPassphraseInTable(const QString& phrase);
58  void revealPasswords();
59  ServerPassword serverPasswordFromRow(int row);
60  void setPasswordInRow(int row, const ServerPassword& password);
61  void setServersInTable(const ServerPassword& password);
62  QTableWidgetItem* toolTipItem(const QString& contents);
63  void updatePassword(const ServerPassword& password);
64 
65  private slots:
66  void addPasswordFromLineEdit();
67  void onPasswordTableCellChange(int currentRow, int currentColumn,
68  int previousRow, int previousColumn);
69  void removeSelectedPasswords();
70  void removeSelectedServers();
71  void showServerLossWarningIfNecessary();
72  void toggleRevealHide();
73 };
74 
75 #endif
QIcon icon() const
Reimplement this to return a displayable icon for the ConfigPage.
void saveSettings()
Reimplement this to write settings to config from widgets.
void readSettings()
Reimplement this to read settings from config into widgets.
QString name() const
Reimplement this to return a list-displayable name for this ConfigPage.
Base class for configuration pages.
Definition: configpage.h:44