oksirc/ui.cpp

44 lines
1.3 KiB
C++
Raw Permalink Normal View History

#include "ui.h"
ui::ui(int argc, char **argv) {
this->argc = argc;
this->argv = argv;
app = new QApplication(this->argc, this->argv);
mainWindow = new QWidget();
2018-12-11 03:15:54 -08:00
mainWindow->resize(1600, 900);
mainWindow->setWindowTitle("oksirc - early Qt test");
mainLog = new QPlainTextEdit();
mainLog->setReadOnly(true);
textEntry = new QLineEdit();
QPushButton *sendButton = new QPushButton(QApplication::translate("send", "Send"));
QObject::connect(sendButton, &QPushButton::clicked, this, &ui::sendButtonClicked);
QObject::connect(textEntry, &QLineEdit::returnPressed, this, &ui::returnOnTextEntry);
QHBoxLayout *entryLineLayout = new QHBoxLayout();
entryLineLayout->addWidget(textEntry);
entryLineLayout->addWidget(sendButton);
QVBoxLayout *mainLogAndLineLayout = new QVBoxLayout();
mainLogAndLineLayout->addWidget(mainLog);
mainLogAndLineLayout->addLayout(entryLineLayout);
mainWindow->setLayout(mainLogAndLineLayout);
mainWindow->show();
textEntry->setFocus();
}
int ui::exec() {
return app->exec();
}
void ui::returnOnTextEntry() {
mainLog->appendPlainText("Return key pressed!");
mainLog->appendPlainText(textEntry->text());
textEntry->clear();
}
void ui::sendButtonClicked(bool checked) {
mainLog->appendPlainText("Send button clicked!");
mainLog->appendPlainText(textEntry->text());
textEntry->clear();
}