add validator for prefix
diff --git a/demo/settingdialog.cpp b/demo/settingdialog.cpp
index be0bb42..d9640dc 100644
--- a/demo/settingdialog.cpp
+++ b/demo/settingdialog.cpp
@@ -1,4 +1,6 @@
 #include "settingdialog.h"
+#include <QRegExp>
+#include <QValidator>
 
 SettingDialog::SettingDialog(QWidget *parent, QString nick, QString chatroom, QString prefix)
   : QDialog(parent)
@@ -7,6 +9,14 @@
   nickEdit->setPlaceholderText(nick);
   roomEdit->setPlaceholderText(chatroom);
   prefixEdit->setPlaceholderText(prefix);
+
+  // simple validator for ccnx prefix
+  QRegExp rx("(^(/[^/]+)+$)|(^/$)");
+  QValidator *validator = new QRegExpValidator(rx, this);
+  prefixEdit->setValidator(validator);
+
+  cancelButton->setDefault(true);
+
   connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
   connect(okButton, SIGNAL(clicked()), this, SLOT(update()));
 }
@@ -17,3 +27,15 @@
   emit updated(nickEdit->text(), roomEdit->text(), prefixEdit->text()); 
   accept();
 }
+
+void
+SettingDialog::keyPressEvent(QKeyEvent *e)
+{
+  switch(e->key()) {
+    case Qt::Key_Enter:
+      update();
+      break;
+    default:
+      QDialog::keyPressEvent(e);
+  }
+}
diff --git a/demo/settingdialog.h b/demo/settingdialog.h
index ac63777..f9fc31c 100644
--- a/demo/settingdialog.h
+++ b/demo/settingdialog.h
@@ -1,6 +1,7 @@
 #ifndef SETTINGDIALOG_H
 #define SETTINGDIALOG_H
 #include "ui_settingdialog.h"
+#include <QKeyEvent>
 
 class SettingDialog : public QDialog, private Ui::SettingDialog
 {
@@ -8,6 +9,7 @@
 
 public:
   SettingDialog(QWidget *parent = 0, QString nick = QString("NULL"), QString chatroom = QString("NULL"), QString prefix = QString("NULL"));
+  virtual void keyPressEvent(QKeyEvent *e);
 
 private slots:
   void update();