From 0904a8aca15016a7813db9f088b65d902872f6ce Mon Sep 17 00:00:00 2001 From: nin0dev Date: Wed, 14 Aug 2024 14:54:24 -0400 Subject: [PATCH] Added basic UI --- main.cpp | 2 +- mainwindow.cpp | 19 +++++++++++++++++++ mainwindow.h | 8 +++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index b601322..44d0169 100644 --- a/main.cpp +++ b/main.cpp @@ -11,7 +11,7 @@ int main(int argc, char *argv[]) MainWindow w; w.setWindowTitle("txtcord"); - w.setFixedSize(640, 480); + w.setMinimumSize(400, 300); w.show(); return a.exec(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 72b0927..799614a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include +#include #include MainWindow::MainWindow(QWidget *parent) @@ -9,6 +10,24 @@ MainWindow::MainWindow(QWidget *parent) QWidget *centralWidget = new QWidget(this); m_layout = new QVBoxLayout(centralWidget); setCentralWidget(centralWidget); + // init chatlog + m_chatlog = new QTextEdit(); + m_chatlog->setReadOnly(true); + m_chatlog->append("Welcome to txtcord, the minimal Discord client."); + m_layout->addWidget(m_chatlog); + // init chatbox + QWidget *chatboxWidget = new QWidget(); + QHBoxLayout *chatboxLayout = new QHBoxLayout(); + m_box = new QLineEdit(); + m_box->setPlaceholderText("Message (or /command)"); + chatboxLayout->addWidget(m_box); + m_send = new QPushButton(); + m_send->setText("Send"); + chatboxLayout->addWidget(m_send); + chatboxWidget->setLayout(chatboxLayout); + m_layout->addWidget(chatboxWidget); + // init chatlog + } MainWindow::~MainWindow() { diff --git a/mainwindow.h b/mainwindow.h index aabeedc..02f4950 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -1,10 +1,12 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include #include #include #include #include +#include #include class MainWindow : public QMainWindow @@ -16,8 +18,8 @@ public: ~MainWindow(); private: QVBoxLayout *m_layout; - QPushButton *m_button; - QProgressBar *m_bar; - QSlider *m_slider; + QTextEdit *m_chatlog; + QLineEdit *m_box; + QPushButton *m_send; }; #endif // MAINWINDOW_H