-
Notifications
You must be signed in to change notification settings - Fork 0
/
qcontainerwidget.cpp
84 lines (69 loc) · 2.12 KB
/
qcontainerwidget.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <QtCore/QProcess>
#include "qcontainerwidget.h"
#include "ui_qcontainerwidget.h"
QContainerWidget::QContainerWidget(QWidget *parent, QString name, QString id, QString status) :
QWidget(parent),
ui(new Ui::QContainerWidget)
{
ui->setupUi(this);
uiMan = new manager();
ui->ContIdLabel->setText(id);
ui->ContNameLabel->setText(name);
this->status = status;
ui->ContStatusLabel->setText(status);
idS = id.toStdString();
this->id = id;
refresh();
setupBtns();
}
QContainerWidget::~QContainerWidget()
{
delete ui;
}
void QContainerWidget::openTerminal() {
QProcess* proc = new QProcess();
proc->start("konsole -e \"bash -c 'docker attach " + id + "';bash");
proc->waitForStarted();
}
void QContainerWidget::start() {
uiMan->getDocker()->start(idS);
refresh();
}
void QContainerWidget::stop() {
uiMan->getDocker()->stop(idS);
refresh();
}
void QContainerWidget::add() {
//apri form add e poi routeAdd();
refresh();
}
void QContainerWidget::refreshR() {
route = uiMan->getDocker()->route(idS);
ui->ContRTextBrowser->setText(QString::fromStdString(route));
}
void QContainerWidget::deleteC() {
stop();
uiMan->getDocker()->delCont(idS);
delete this;
}
void QContainerWidget::deleteR() {
//apri form del e poi routeDel();
refreshR();
}
void QContainerWidget::setupBtns() {
connect(ui->ContTermOpenBtn, SIGNAL (released()), this, SLOT (openTerminal()));
connect(ui->ContStartBtn, SIGNAL (released()), this, SLOT (start()));
connect(ui->ContStopBtn, SIGNAL (released()), this, SLOT (stop()));
connect(ui->ContDelBtn, SIGNAL (released()), this, SLOT (deleteC()));
connect(ui->ContBtnRAdd, SIGNAL (released()), this, SLOT (add()));
connect(ui->ContBtnRDel, SIGNAL (released()), this, SLOT (deleteR()));
connect(ui->ContBtnRRefresh, SIGNAL (released()), this, SLOT (refreshR()));
}
void QContainerWidget::refreshStatus() {
status = QString::fromStdString(uiMan->getDocker()->getContStatus(idS));
ui->ContStatusLabel->setText(status);
}
void QContainerWidget::refresh() {
refreshR();
refreshStatus();
}