1 | /**
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * "VM serial port settings" dialog UI include (Qt Designer)
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | /****************************************************************************
|
---|
24 | ** ui.h extension file, included from the uic-generated form implementation.
|
---|
25 | **
|
---|
26 | ** If you wish to add, delete or rename functions or slots use
|
---|
27 | ** Qt Designer which will update this file, preserving your code. Create an
|
---|
28 | ** init() function in place of a constructor, and a destroy() function in
|
---|
29 | ** place of a destructor.
|
---|
30 | *****************************************************************************/
|
---|
31 |
|
---|
32 |
|
---|
33 | void VBoxVMSerialPortSettings::init()
|
---|
34 | {
|
---|
35 | /* setup validation */
|
---|
36 |
|
---|
37 | mIRQLine->setValidator (new QIULongValidator (0, 255, this));
|
---|
38 | mIOPortLine->setValidator (new QIULongValidator (0, 0xFFFF, this));
|
---|
39 |
|
---|
40 | mPortPathLine->setValidator (new QRegExpValidator (QRegExp (".+"), this));
|
---|
41 |
|
---|
42 | /* setup constraints */
|
---|
43 |
|
---|
44 | mIRQLine->setMaximumWidth (mIRQLine->fontMetrics().width ("888888")
|
---|
45 | + mIRQLine->frameWidth() * 2);
|
---|
46 | mIRQLine->setMinimumWidth (mIRQLine->minimumWidth());
|
---|
47 |
|
---|
48 | mIOPortLine->setMaximumWidth (mIOPortLine->fontMetrics().width ("8888888")
|
---|
49 | + mIOPortLine->frameWidth() * 2);
|
---|
50 | mIOPortLine->setMinimumWidth (mIOPortLine->minimumWidth());
|
---|
51 |
|
---|
52 | /* set initial values */
|
---|
53 |
|
---|
54 | mPortNumCombo->insertStringList (vboxGlobal().COMPortNames());
|
---|
55 | mPortNumCombo->insertItem (vboxGlobal().toCOMPortName (0, 0));
|
---|
56 |
|
---|
57 | mHostModeCombo->insertItem (vboxGlobal().toString (KPortMode_Disconnected));
|
---|
58 | mHostModeCombo->insertItem (vboxGlobal().toString (KPortMode_HostPipe));
|
---|
59 | mHostModeCombo->insertItem (vboxGlobal().toString (KPortMode_HostDevice));
|
---|
60 | }
|
---|
61 |
|
---|
62 | void VBoxVMSerialPortSettings::getFromPort (const CSerialPort &aPort)
|
---|
63 | {
|
---|
64 | mPort = aPort;
|
---|
65 |
|
---|
66 | mSerialPortBox->setChecked (mPort.GetEnabled());
|
---|
67 |
|
---|
68 | ulong IRQ = mPort.GetIRQ();
|
---|
69 | ulong IOBase = mPort.GetIOBase();
|
---|
70 | mPortNumCombo->setCurrentText (vboxGlobal().toCOMPortName (IRQ, IOBase));
|
---|
71 | mIRQLine->setText (QString::number (IRQ));
|
---|
72 | mIOPortLine->setText ("0x" + QString::number (IOBase, 16).upper());
|
---|
73 |
|
---|
74 | mHostModeCombo->setCurrentText (vboxGlobal().toString (mPort.GetHostMode()));
|
---|
75 | mServerCheck->setChecked (mPort.GetServer());
|
---|
76 | mPortPathLine->setText (mPort.GetPath());
|
---|
77 |
|
---|
78 | /* ensure everything is up-to-date */
|
---|
79 | mSerialPortBox_toggled (mSerialPortBox->isChecked());
|
---|
80 | }
|
---|
81 |
|
---|
82 | void VBoxVMSerialPortSettings::putBackToPort()
|
---|
83 | {
|
---|
84 | mPort.SetEnabled (mSerialPortBox->isChecked());
|
---|
85 |
|
---|
86 | mPort.SetIRQ (mIRQLine->text().toULong (NULL, 0));
|
---|
87 | mPort.SetIOBase (mIOPortLine->text().toULong (NULL, 0));
|
---|
88 |
|
---|
89 | mPort.SetPath (QDir::convertSeparators (mPortPathLine->text()));
|
---|
90 |
|
---|
91 | mPort.SetHostMode (vboxGlobal().toPortMode (mHostModeCombo->currentText()));
|
---|
92 | mPort.SetServer (mServerCheck->isChecked());
|
---|
93 | }
|
---|
94 |
|
---|
95 | bool VBoxVMSerialPortSettings::isUserDefined()
|
---|
96 | {
|
---|
97 | ulong a, b;
|
---|
98 | return !vboxGlobal().toCOMPortNumbers (mPortNumCombo->currentText(), a, b);
|
---|
99 | }
|
---|
100 |
|
---|
101 | void VBoxVMSerialPortSettings::mSerialPortBox_toggled (bool aOn)
|
---|
102 | {
|
---|
103 | if (aOn)
|
---|
104 | {
|
---|
105 | mPortNumCombo_activated (mPortNumCombo->currentText());
|
---|
106 | mHostModeCombo_activated (mHostModeCombo->currentText());
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | void VBoxVMSerialPortSettings::mPortNumCombo_activated (const QString &aText)
|
---|
111 | {
|
---|
112 | ulong IRQ, IOBase;
|
---|
113 | bool std = vboxGlobal().toCOMPortNumbers (aText, IRQ, IOBase);
|
---|
114 |
|
---|
115 | mIRQLine->setEnabled (!std);
|
---|
116 | mIOPortLine->setEnabled (!std);
|
---|
117 | if (std)
|
---|
118 | {
|
---|
119 | mIRQLine->setText (QString::number (IRQ));
|
---|
120 | mIOPortLine->setText ("0x" + QString::number (IOBase, 16).upper());
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | void VBoxVMSerialPortSettings::mHostModeCombo_activated (const QString &aText)
|
---|
125 | {
|
---|
126 | KPortMode mode = vboxGlobal().toPortMode (aText);
|
---|
127 | mServerCheck->setEnabled (mode == KPortMode_HostPipe);
|
---|
128 | mPortPathLine->setEnabled (mode != KPortMode_Disconnected);
|
---|
129 | }
|
---|