setting dialog
diff --git a/demo/chatdialog.cpp b/demo/chatdialog.cpp
index 0163df9..ca1b3ae 100644
--- a/demo/chatdialog.cpp
+++ b/demo/chatdialog.cpp
@@ -1,5 +1,6 @@
#include <QtGui>
#include "chatdialog.h"
+#include "settingdialog.h"
#include <ctime>
#include <iostream>
@@ -12,6 +13,12 @@
// for test only
m_nick = "Tester";
m_chatroom = "Test";
+ m_prefix = "/ndn/ucla.edu/cs/tester";
+
+ QString settingDisp = QString("<User: %1>, <Chatroom: %2>").arg(m_nick).arg(m_chatroom);
+ infoLabel->setText(settingDisp);
+ QString prefixDisp = QString("<Prefix: %1>").arg(m_prefix);
+ prefixLabel->setText(prefixDisp);
DigestTreeScene *scene = new DigestTreeScene();
@@ -19,6 +26,7 @@
scene->plot();
connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
+ connect(setButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
}
void
@@ -49,9 +57,13 @@
bar->setValue(bar->maximum());
}
-void
-ChatDialog::updateTreeView()
-{
+void
+ChatDialog::formChatMessage(const QString &text, SyncDemo::ChatMessage &msg) {
+ msg.set_from(m_nick.toStdString());
+ msg.set_to(m_chatroom.toStdString());
+ msg.set_data(text.toStdString());
+ time_t seconds = time(NULL);
+ msg.set_timestamp(seconds);
}
void
@@ -69,16 +81,14 @@
// TODO:
// send message
appendMessage(msg);
- updateTreeView();
}
void
-ChatDialog::formChatMessage(const QString &text, SyncDemo::ChatMessage &msg) {
- msg.set_from(m_nick.toStdString());
- msg.set_to(m_chatroom.toStdString());
- msg.set_data(text.toStdString());
- time_t seconds = time(NULL);
- msg.set_timestamp(seconds);
+ChatDialog::buttonPressed()
+{
+ SettingDialog dialog(this, m_nick, m_chatroom, m_prefix);
+ dialog.exec();
+ setButton->setFocusPolicy(Qt::NoFocus);
}
diff --git a/demo/chatdialog.h b/demo/chatdialog.h
index 7a837dc..e30c05e 100644
--- a/demo/chatdialog.h
+++ b/demo/chatdialog.h
@@ -6,6 +6,8 @@
#include "ui_chatdialog.h"
#include "chatbuf.pb.h"
#include <sync-app-socket.h>
+#include <sync-logic.h>
+#include <sync-seq-no.h>
class ChatDialog : public QDialog, private Ui::ChatDialog
{
@@ -14,13 +16,14 @@
public:
ChatDialog(QWidget *parent = 0);
void appendMessage(const SyncDemo::ChatMessage &msg);
- void processData(const std::vector<MissingDataInfo> &, SyncAppSocket *);
+ void processData(const std::vector<Sync::MissingDataInfo> &, Sync::SyncAppSocket *);
private:
void formChatMessage(const QString &text, SyncDemo::ChatMessage &msg);
private slots:
void returnPressed();
+ void buttonPressed();
private:
QString m_nick;
diff --git a/demo/chatdialog.ui b/demo/chatdialog.ui
index b7a6747..9e659ab 100644
--- a/demo/chatdialog.ui
+++ b/demo/chatdialog.ui
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
- <height>400</height>
+ <height>600</height>
</rect>
</property>
<property name="windowTitle">
@@ -24,6 +24,56 @@
<property name="spacing">
<number>6</number>
</property>
+ <item >
+ <layout class="QHBoxLayout">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <layout class = "QVBoxLayout" >
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="infoLabel">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="prefixLabel">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPushButton" name="setButton">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Settings</string>
+ </property>
+ <property name="minimumWidth">
+ <number>150</number>
+ </property>
+ <property name="maximumWidth">
+ <number>150</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item>
<widget class="QGraphicsView" name="treeViewer">
<property name="focusPolicy">
diff --git a/demo/settingdialog.cpp b/demo/settingdialog.cpp
new file mode 100644
index 0000000..8719a84
--- /dev/null
+++ b/demo/settingdialog.cpp
@@ -0,0 +1,12 @@
+#include "settingdialog.h"
+
+SettingDialog::SettingDialog(QWidget *parent, QString nick, QString chatroom, QString prefix)
+ : QDialog(parent)
+{
+ setupUi(this);
+ nickEdit->setPlaceholderText(nick);
+ roomEdit->setPlaceholderText(chatroom);
+ prefixEdit->setPlaceholderText(prefix);
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+ connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
+}
diff --git a/demo/settingdialog.h b/demo/settingdialog.h
new file mode 100644
index 0000000..5487cde
--- /dev/null
+++ b/demo/settingdialog.h
@@ -0,0 +1,13 @@
+#ifndef SETTINGDIALOG_H
+#define SETTINGDIALOG_H
+#include "ui_settingdialog.h"
+
+class SettingDialog : public QDialog, private Ui::SettingDialog
+{
+ Q_OBJECT
+
+public:
+ SettingDialog(QWidget *parent = 0, QString nick = QString("NULL"), QString chatroom = QString("NULL"), QString prefix = QString("NULL"));
+};
+
+#endif
diff --git a/demo/settingdialog.ui b/demo/settingdialog.ui
new file mode 100644
index 0000000..dff4408
--- /dev/null
+++ b/demo/settingdialog.ui
@@ -0,0 +1,100 @@
+<ui version="4.0">
+ <class>SettingDialog</class>
+ <widget class="QDialog" name="SettingDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>300</width>
+ <height>200</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Chat Settings</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <!-- first group -->
+ <item>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel">
+ <property name="text">
+ <string>Nickname</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel">
+ <property name="text">
+ <string>Chatroom</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel">
+ <property name="text">
+ <string>Prefix</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <!-- first group -->
+
+ <!-- second group -->
+ <item>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="nickEdit" />
+ </item>
+ <item>
+ <widget class="QLineEdit" name="roomEdit" />
+ </item>
+ <item>
+ <widget class="QLineEdit" name="prefixEdit" />
+ </item>
+ </layout>
+ </item>
+ <!-- second group -->
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/demo/sync-demo.pri b/demo/sync-demo.pri
index 88ab350..3ff4309 100644
--- a/demo/sync-demo.pri
+++ b/demo/sync-demo.pri
@@ -13,6 +13,6 @@
protobuf_impl.input = PROTOS
protobuf_impl.output = ${QMAKE_FILE_BASE}.pb.cc
protobuf_impl.depends = ${QMAKE_FILE_BASE}.pb.h
-protobuf_impl.commands = $$escape_expand(\n)
+protobuf_impl.commands = $$escape_expand(\\n)
protobuf_impl.variable_out = GENERATED_SOURCES
QMAKE_EXTRA_COMPILERS += protobuf_impl
diff --git a/demo/sync-demo.pro b/demo/sync-demo.pro
index 4ff91a7..96f6c7e 100644
--- a/demo/sync-demo.pro
+++ b/demo/sync-demo.pro
@@ -1,13 +1,16 @@
TEMPLATE = app
TARGET = sync-demo
HEADERS = chatdialog.h \
- digesttreescene.h
+ digesttreescene.h \
+ settingdialog.h
SOURCES = main.cpp \
chatdialog.cpp \
- digesttreescene.cpp
+ digesttreescene.cpp \
+ settingdialog.cpp
-FORMS = chatdialog.ui
+FORMS = chatdialog.ui \
+ settingdialog.ui
QMAKE_CXXFLAGS *= -g
QMAKE_CFLAGS *= -g