summaryrefslogtreecommitdiff
path: root/client/mainwindow.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2013-12-25 09:00:59 +0100
committerTreeki <treeki@gmail.com>2013-12-25 09:00:59 +0100
commitb7a8b597b00eedde277836eb8530ba742edcad5d (patch)
tree1b959fa0eec02ff4e22e168aa4379b2b64575ce3 /client/mainwindow.cpp
downloadbounce_qt-master.tar.gz
bounce_qt-master.zip
commit initial bitsHEADmaster
Diffstat (limited to '')
-rw-r--r--client/mainwindow.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp
new file mode 100644
index 0000000..1dfee5e
--- /dev/null
+++ b/client/mainwindow.cpp
@@ -0,0 +1,44 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+#include "../server/client.h"
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+
+ connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(handleLineEntered()));
+
+ m_client = new Client(this);
+ connect(m_client, SIGNAL(consoleOutput(QString)), this, SLOT(handleConsoleOutput(QString)));
+
+ m_client->connectToHost("localhost", 6744);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+
+
+void MainWindow::handleLineEntered() {
+ QString line = ui->lineEdit->text();
+ ui->lineEdit->clear();
+
+ m_client->consoleInput(line);
+}
+
+void MainWindow::handleConsoleOutput(const QString &str) {
+ QTextCursor cursor = ui->textEdit->textCursor();
+ bool isAtEnd = cursor.atEnd();
+
+ cursor.movePosition(QTextCursor::End);
+ cursor.clearSelection();
+ cursor.insertText(str);
+ cursor.insertText("\n");
+
+ if (isAtEnd)
+ ui->textEdit->setTextCursor(cursor);
+}