Time for a major overhaul of aesalon, again.
[aesalon.git] / src / gui / ProgramDisplay.cpp
bloba3c35a81f881c7bf13e6d9a2ac1c033bffaae353
1 #include <iostream>
2 #include <QSettings>
3 #include "ProgramDisplay.h"
4 #include "ProgramDisplay.moc"
6 #include "misc/String.h"
8 namespace Aesalon {
9 namespace GUI {
11 ProgramDisplay::ProgramDisplay(QWidget *parent) {
12 this->hide();
13 this->resize(600, 300);
14 this->setWindowTitle("Unlaunched program");
16 create_launch_widget();
19 ProgramDisplay::~ProgramDisplay() {
23 void ProgramDisplay::create_launch_widget() {
24 QSettings settings;
25 launch_widget = new QWidget();
26 launch_layout = new QVBoxLayout();
28 launch_program_layout = new QFormLayout();
30 launch_program_name = new QComboBox();
31 launch_program_name->setEditable(true);
32 launch_program_name->setInsertPolicy(QComboBox::InsertAtTop);
33 launch_program_name->insertItems(0, settings.value("Program/executable", "").toStringList());
34 launch_program_name->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
35 launch_program_layout->addRow(tr("Executable path:"), launch_program_name);
37 launch_program_arguments = new QComboBox();
38 launch_program_arguments->setEditable(true);
39 launch_program_arguments->setInsertPolicy(QComboBox::InsertAtTop);
40 launch_program_arguments->addItems(settings.value("Program/arguments", "").toStringList());
41 launch_program_arguments->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
42 launch_program_layout->addRow(tr("Program arguments:"), launch_program_arguments);
44 launch_port = new QSpinBox();
45 launch_port->setMinimum(1024);
46 launch_port->setMaximum(65535);
47 launch_port->setValue(settings.value("Program/port", 6321).toInt());
48 launch_port->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
49 launch_program_layout->addRow(tr("TCP port to use: "), launch_port);
51 launch_program_xterm = new QCheckBox("&Launch executable in terminal");
52 launch_program_layout->addRow(launch_program_xterm);
54 launch_program_layout->setFormAlignment(Qt::AlignTop | Qt::AlignRight);
55 launch_program_layout->setLabelAlignment(Qt::AlignLeft);
56 launch_program_layout->setHorizontalSpacing(25);
57 launch_layout->addLayout(launch_program_layout);
59 launch_layout->addStretch();
60 launch_program_button = new QPushButton(tr("&Begin execution"));
61 launch_program_button->show();
62 connect(launch_program_button, SIGNAL(clicked()), this, SLOT(begin_program()));
63 launch_layout->addWidget(launch_program_button, 1, Qt::AlignBottom);
65 launch_widget->setLayout(launch_layout);
66 setWidget(launch_widget);
69 void ProgramDisplay::create_running_widget() {
70 running_widget = new QWidget();
71 running_layout = new QVBoxLayout();
72 running_tab_bar = new QTabWidget();
74 program_block_display = new ProgramBlockDisplay();
75 program_reference_display = new ProgramReferenceDisplay();
78 running_general = new QWidget();
79 running_general_layout = new QVBoxLayout();
82 running_general_program_layout = new QHBoxLayout();
84 running_general_program_label = new QLabel(tr("Executable path:"));
85 running_general_program_layout->addWidget(running_general_program_label);
86 running_general_program_name_label = new QLabel(launch_program_name->lineEdit()->text());
87 running_general_program_layout->addWidget(running_general_program_name_label);
89 running_general_layout->addLayout(running_general_program_layout);
91 running_general_layout->addStretch();
93 running_general->setLayout(running_general_layout);
95 running_tab_bar->addTab(running_general, "&General information");
96 running_tab_bar->addTab(program_block_display, "&Block display");
97 running_tab_bar->addTab(program_reference_display, "&Reference display");
99 running_layout->addWidget(running_tab_bar);
101 running_widget->setLayout(running_layout);
102 setWidget(running_widget);
104 setWindowTitle(tr("Running program (") + launch_program_name->currentText() + tr(")"));
107 void ProgramDisplay::begin_program() {
108 create_running_widget();
110 QSettings settings;
111 settings.setValue("Program/executable", launch_program_name->currentText());
112 program = new Program();
115 bool ProgramDisplay::close() {
116 if(!program->is_running()) return QMdiSubWindow::close();
117 return false;
120 } // namespace GUI
121 } // namespace Aesalon