add validator for prefix
This commit is contained in:
1 parent
3472e3f804
commit
7d38556d5b
2 files changed
+24
No files matched your search
@@ -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 @@ SettingDialog::SettingDialog(QWidget *parent, QString nick, QString chatroom, QS
|
||||
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 @@ SettingDialog::update()
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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 @@ class SettingDialog : public QDialog, private Ui::SettingDialog
|
||||
|
||||
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();
|
||||
|
||||
Reference in new issue
Block a user