3 #include "newpalacios.h"
5 VmModeDialog::VmModeDialog(QWidget* parent) {
9 void VmModeDialog::setupDialog() {
14 // Group box to hold radio buttons
15 v3_modes = new QGroupBox(tr("Select VM mode"));
16 // Widget to give information about stream name
18 v3_stream_info = new QWidget(v3_modes);
20 v3_stream = new QRadioButton(tr("Stream Mode"));
21 v3_cons = new QRadioButton(tr("Console Mode"));
22 v3_vnc = new QRadioButton(tr("VNC mode"));
24 // Setup stream info widget
25 QLabel* v3_stream_label = new QLabel(tr("Stream name"));
26 v3_stream_name = new QLineEdit();
28 QGridLayout* grid = new QGridLayout();
29 grid->addWidget(v3_stream_label, 0, 0);
30 grid->addWidget(v3_stream_name, 0, 1);
31 v3_stream_info->setLayout(grid);
32 v3_stream_info->setVisible(false);
35 QVBoxLayout* box = new QVBoxLayout();
36 box->addWidget(v3_cons);
37 box->addWidget(v3_stream);
38 box->addWidget(v3_stream_info);
39 box->addWidget(v3_vnc);
40 v3_modes->setLayout(box);
42 // Setup main layout for dialog
43 QVBoxLayout* mainLayout = new QVBoxLayout();
44 mainLayout->addWidget(v3_modes);
45 QHBoxLayout* actionLayout = new QHBoxLayout();
46 QPushButton* ok = new QPushButton(tr("OK"));
47 QPushButton* cancel = new QPushButton(tr("Cancel"));
48 actionLayout->addWidget(ok);
49 actionLayout->addWidget(cancel);
50 mainLayout->addLayout(actionLayout);
52 setLayout(mainLayout);
55 setWindowTitle("Select VM mode");
57 // Connect signals and slots
58 connect(v3_cons, SIGNAL(toggled(bool)), this, SLOT(selectMode(bool)));
59 connect(v3_stream, SIGNAL(toggled(bool)), this, SLOT(selectMode(bool)));
60 connect(v3_vnc, SIGNAL(toggled(bool)), this, SLOT(selectMode(bool)));
61 connect(ok, SIGNAL(clicked()), this, SLOT(okButton()));
62 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelButton()));
65 void VmModeDialog::okButton() {
67 && isV3Stream == false
68 && isV3Vnc == false) {
70 // Do not emit anything
78 name = v3_stream_name->text();
81 emit setMode(mode, name);
85 void VmModeDialog::cancelButton() {
89 void VmModeDialog::selectMode(bool checked) {
90 if (checked == true) {
91 if (v3_cons->isChecked()) {
92 // If console is checked, then set
94 mode = VmConsoleWidget::CONSOLE;
98 v3_stream_info->setVisible(false);
100 } else if (v3_stream->isChecked()) {
101 mode = VmConsoleWidget::STREAM;
105 v3_stream_info->setVisible(true);
107 } else if (v3_vnc->isChecked()) {
108 mode = VmConsoleWidget::VNC;
112 v3_stream_info->setVisible(false);