From b7a8b597b00eedde277836eb8530ba742edcad5d Mon Sep 17 00:00:00 2001 From: Treeki Date: Wed, 25 Dec 2013 09:00:59 +0100 Subject: commit initial bits --- client/bounce_client.pro | 28 ++++++++++++++++++++++++++++ client/main.cpp | 11 +++++++++++ client/mainwindow.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ client/mainwindow.h | 29 +++++++++++++++++++++++++++++ client/mainwindow.ui | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 146 insertions(+) create mode 100644 client/bounce_client.pro create mode 100644 client/main.cpp create mode 100644 client/mainwindow.cpp create mode 100644 client/mainwindow.h create mode 100644 client/mainwindow.ui (limited to 'client') diff --git a/client/bounce_client.pro b/client/bounce_client.pro new file mode 100644 index 0000000..bfb6faf --- /dev/null +++ b/client/bounce_client.pro @@ -0,0 +1,28 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2013-12-16T07:46:22 +# +#------------------------------------------------- + +QT += core gui network + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = bounce_client +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp \ + ../server/socket.cpp \ + ../server/packetwriter.cpp \ + ../server/packetreader.cpp \ + ../server/client.cpp + +HEADERS += mainwindow.h \ + ../server/socket.h \ + ../server/packetwriter.h \ + ../server/packetreader.h \ + ../server/client.h + +FORMS += mainwindow.ui diff --git a/client/main.cpp b/client/main.cpp new file mode 100644 index 0000000..a080bdd --- /dev/null +++ b/client/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} 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); +} diff --git a/client/mainwindow.h b/client/mainwindow.h new file mode 100644 index 0000000..9cd58cf --- /dev/null +++ b/client/mainwindow.h @@ -0,0 +1,29 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +class Client; + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; + + Client *m_client; + +private slots: + void handleLineEntered(); + void handleConsoleOutput(const QString &str); +}; + +#endif // MAINWINDOW_H diff --git a/client/mainwindow.ui b/client/mainwindow.ui new file mode 100644 index 0000000..437f0ca --- /dev/null +++ b/client/mainwindow.ui @@ -0,0 +1,34 @@ + + + MainWindow + + + + 0 + 0 + 508 + 364 + + + + MainWindow + + + + + + + true + + + + + + + + + + + + + -- cgit v1.2.3