Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Palacios GUI Added
[palacios.git] / linux_usr / gui / palacios / vm_mode_dialog.cpp
1 #include <QDebug>
2
3 #include "newpalacios.h"
4
5 VmModeDialog::VmModeDialog(QWidget* parent) {
6         setupDialog();
7 }
8
9 void VmModeDialog::setupDialog() {
10         isV3Cons = false;
11         isV3Stream = false;
12         isV3Vnc = false;
13         
14         // Group box to hold radio buttons
15         v3_modes = new QGroupBox(tr("Select VM mode"));
16         // Widget to give information about stream name
17         // for v3_stream
18         v3_stream_info = new QWidget(v3_modes);
19
20         v3_stream = new QRadioButton(tr("Stream Mode"));
21         v3_cons = new QRadioButton(tr("Console Mode"));
22         v3_vnc = new QRadioButton(tr("VNC mode"));
23         
24         // Setup stream info widget
25         QLabel* v3_stream_label = new QLabel(tr("Stream name"));
26         v3_stream_name = new QLineEdit();
27         
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);
33         
34         // Setup group box
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);
41         
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);
51         
52         setLayout(mainLayout);
53         resize(300, 200);
54         move(200, 200);
55         setWindowTitle("Select VM mode");
56
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()));
63 }
64
65 void VmModeDialog::okButton() {
66         if (isV3Cons == false
67                 && isV3Stream == false
68                 && isV3Vnc == false) {
69             
70             // Do not emit anything
71             close();
72             return;
73         }
74
75         QString name = "";
76         
77         if (isV3Stream) {
78                 name = v3_stream_name->text();
79         }
80         
81         emit setMode(mode, name);
82         close();
83 }
84
85 void VmModeDialog::cancelButton() {
86         close();
87 }
88
89 void VmModeDialog::selectMode(bool checked) {
90         if (checked == true) {
91                 if (v3_cons->isChecked()) {
92                         // If console is checked, then set
93                         // mode to v3_cons
94                         mode = VmConsoleWidget::CONSOLE;
95                         isV3Cons = true;
96                         isV3Stream = false;
97                         isV3Vnc = false;
98                         v3_stream_info->setVisible(false);
99
100                 } else if (v3_stream->isChecked()) {
101                         mode = VmConsoleWidget::STREAM;
102                         isV3Cons = false;
103                         isV3Stream = true;
104                         isV3Vnc = false;
105                         v3_stream_info->setVisible(true);
106
107                 } else if (v3_vnc->isChecked()) {
108                         mode = VmConsoleWidget::VNC;
109                         isV3Cons = false;
110                         isV3Stream = false;
111                         isV3Vnc = true;
112                         v3_stream_info->setVisible(false);
113
114                 } else {
115                         isV3Cons = false;
116                         isV3Stream = false;
117                         isV3Vnc = false;
118                 }
119         }
120 }