-
Notifications
You must be signed in to change notification settings - Fork 0
/
widget.cpp
44 lines (37 loc) · 1.2 KB
/
widget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "widget.h"
#include "ui_widget.h"
#include <QFileDialog>
#include <QDir>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
m_client = new LocalSocketIpcClient("/home/smit/.calligra/pipe.in", this);
connect(m_client, SIGNAL(messageReceived(QString)), this, SLOT(messageReceived(QString)));
connect(ui->pushButtonSend, SIGNAL(clicked()), this, SLOT(send_button_clicked()));
}
Widget::~Widget()
{
delete ui;
}
void Widget::send_button_clicked()
{
if (!ui->socket->text().isEmpty()) {
m_client->send_MessageToServer(ui->textBrowser->toPlainText());
} else {
ui->textBrowser_2->append("Connect to server first");
}
}
void Widget::messageReceived(QString message)
{
ui->textBrowser_2->append(message);
}
void Widget::on_connect_clicked()
{
ui->socket->setText(QFileDialog::getOpenFileName(this, "Open socket file",
QDir::home().absolutePath().append(QDir::separator()).append(".calligra")));
if (!ui->socket->text().isEmpty()) {
m_client = new LocalSocketIpcClient(ui->socket->text(), this);
}
}