Implement password changing from client.
[quassel.git] / src / qtui / mainwin.cpp
index 70e2285..6d8aa6b 100644 (file)
@@ -25,6 +25,7 @@
 #include <QMessageBox>
 #include <QStatusBar>
 #include <QToolBar>
+#include <QInputDialog>
 
 #ifdef HAVE_KDE4
 #  include <KHelpMenu>
@@ -196,6 +197,8 @@ void MainWin::init()
     connect(Client::coreConnection(), SIGNAL(handleSslErrors(const QSslSocket *, bool *, bool *)), SLOT(handleSslErrors(const QSslSocket *, bool *, bool *)));
 #endif
 
+    connect(this, SIGNAL(changePassword(QString)), Client::instance(), SLOT(changePassword(QString)));
+
     // Setup Dock Areas
     setDockNestingEnabled(true);
     setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
@@ -410,6 +413,10 @@ void MainWin::setupActions()
 #endif
     coll->addAction("ConfigureQuassel", configureQuasselAct);
 
+    QAction *changePasswordAct = new Action(QIcon::fromTheme("dialog-password"), tr("&Change password..."), coll,
+        this, SLOT(showChangePasswordDialog()));
+    coll->addAction("ChangePassword", changePasswordAct);
+
     // Help
     QAction *aboutQuasselAct = new Action(QIcon(":/icons/quassel.png"), tr("&About Quassel"), coll,
         this, SLOT(showAboutDlg()));
@@ -552,8 +559,10 @@ void MainWin::setupMenus()
 #else
     _settingsMenu->addAction(coll->action("ConfigureShortcuts"));
 #endif
+    _settingsMenu->addAction(coll->action("ChangePassword"));
     _settingsMenu->addAction(coll->action("ConfigureQuassel"));
 
+
     _helpMenu = menuBar()->addMenu(tr("&Help"));
 
     _helpMenu->addAction(coll->action("AboutQuassel"));
@@ -731,6 +740,15 @@ void MainWin::changeActiveBufferView(int bufferViewId)
     nextBufferView(); // fallback
 }
 
+void MainWin::showChangePasswordDialog()
+{
+    bool ok;
+    QString newPassword = QInputDialog::getText(this, tr("Set new password"), tr("New password:"), QLineEdit::Password, QString(), &ok);
+    if (ok && !newPassword.isEmpty()) {
+        emit changePassword(newPassword);
+    }
+}
+
 
 void MainWin::changeActiveBufferView(bool backwards)
 {