From 2061d47d50cafad5fd5d412b25c1dae110cd85ab Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Thu, 8 Mar 2018 22:30:19 +0300
Subject: Add option to change pin code into char selection dialog.

---
 src/gui/windows/charselectdialog.cpp | 20 ++++++++++++++++++++
 src/gui/windows/charselectdialog.h   |  1 +
 2 files changed, 21 insertions(+)

(limited to 'src')

diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index d48a1a162..638e5caa0 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -82,6 +82,7 @@ CharSelectDialog::CharSelectDialog(LoginData &data) :
     mDeleteButton(new Button(this, _("Delete"), "delete", this)),
     // TRANSLATORS: char select dialog. button.
     mRenameButton(nullptr),
+    mChangePinButton(nullptr),
     mCharacterView(nullptr),
     mCharacterEntries(0),
     mCharServerHandler(charServerHandler),
@@ -116,6 +117,18 @@ CharSelectDialog::CharSelectDialog(LoginData &data) :
         placer(n, 0, mRenameButton, 1, 1);
         n ++;
     }
+#ifdef TMWA_SUPPORT
+    if (serverFeatures->havePincode())
+#endif
+    {
+        mChangePinButton = new Button(this,
+            // TRANSLATORS: change pincode button
+            _("Change pin"),
+            "changepin",
+            this);
+        placer(n, 0, mChangePinButton, 1, 1);
+        n ++;
+    }
     placer(n, 0, mInfoButton, 1, 1);
     n ++;
 
@@ -321,6 +334,13 @@ void CharSelectDialog::action(const ActionEvent &event)
         }
         mDeleteIndex = -1;
     }
+    else if (eventId == "changepin")
+    {
+        if (blocked)
+            return;
+        pincodeManager.setState(PincodeState::Change);
+        pincodeManager.updateState();
+    }
 }
 
 void CharSelectDialog::use(const int selected)
diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h
index ea51f0b14..f5105bae5 100644
--- a/src/gui/windows/charselectdialog.h
+++ b/src/gui/windows/charselectdialog.h
@@ -122,6 +122,7 @@ class CharSelectDialog final : public Window,
         Button *mInfoButton A_NONNULLPOINTER;
         Button *mDeleteButton A_NONNULLPOINTER;
         Button *mRenameButton;
+        Button *mChangePinButton;
         CharacterViewBase *mCharacterView;
 
         STD_VECTOR<CharacterDisplay*> mCharacterEntries;
-- 
cgit v1.2.3-70-g09d2