28 |
#include <QMessageBox> |
#include <QMessageBox> |
29 |
#include <QFontDialog> |
#include <QFontDialog> |
30 |
|
|
|
namespace QSampler { |
|
|
|
|
|
OptionsForm::OptionsForm(QWidget* parent) : QDialog(parent) { |
|
|
ui.setupUi(this); |
|
31 |
|
|
32 |
// No settings descriptor initially (the caller will set it). |
namespace QSampler { |
|
m_pOptions = NULL; |
|
33 |
|
|
34 |
// Initialize dirty control state. |
OptionsForm::OptionsForm(QWidget* parent) : QDialog(parent) |
35 |
m_iDirtySetup = 0; |
{ |
36 |
m_iDirtyCount = 0; |
ui.setupUi(this); |
37 |
|
|
38 |
// Set dialog validators... |
// No settings descriptor initially (the caller will set it). |
39 |
ui.ServerPortComboBox->setValidator(new QIntValidator(ui.ServerPortComboBox)); |
m_pOptions = NULL; |
40 |
|
|
41 |
// Try to restore old window positioning. |
// Initialize dirty control state. |
42 |
adjustSize(); |
m_iDirtySetup = 0; |
43 |
|
m_iDirtyCount = 0; |
44 |
|
|
45 |
|
// Set dialog validators... |
46 |
|
ui.ServerPortComboBox->setValidator(new QIntValidator(ui.ServerPortComboBox)); |
47 |
|
|
48 |
|
// Try to restore old window positioning. |
49 |
|
adjustSize(); |
50 |
|
|
51 |
|
QObject::connect(ui.ServerHostComboBox, |
52 |
|
SIGNAL(editTextChanged(const QString&)), |
53 |
|
SLOT(optionsChanged())); |
54 |
|
QObject::connect(ui.ServerPortComboBox, |
55 |
|
SIGNAL(editTextChanged(const QString&)), |
56 |
|
SLOT(optionsChanged())); |
57 |
|
QObject::connect(ui.ServerTimeoutSpinBox, |
58 |
|
SIGNAL(valueChanged(int)), |
59 |
|
SLOT(optionsChanged())); |
60 |
|
QObject::connect(ui.ServerStartCheckBox, |
61 |
|
SIGNAL(stateChanged(int)), |
62 |
|
SLOT(optionsChanged())); |
63 |
|
QObject::connect(ui.ServerCmdLineComboBox, |
64 |
|
SIGNAL(editTextChanged(const QString&)), |
65 |
|
SLOT(optionsChanged())); |
66 |
|
QObject::connect(ui.StartDelaySpinBox, |
67 |
|
SIGNAL(valueChanged(int)), |
68 |
|
SLOT(optionsChanged())); |
69 |
|
QObject::connect(ui.DisplayFontPushButton, |
70 |
|
SIGNAL(clicked()), |
71 |
|
SLOT(chooseDisplayFont())); |
72 |
|
QObject::connect(ui.DisplayEffectCheckBox, |
73 |
|
SIGNAL(toggled(bool)), |
74 |
|
SLOT(toggleDisplayEffect(bool))); |
75 |
|
QObject::connect(ui.AutoRefreshCheckBox, |
76 |
|
SIGNAL(stateChanged(int)), |
77 |
|
SLOT(optionsChanged())); |
78 |
|
QObject::connect(ui.AutoRefreshTimeSpinBox, |
79 |
|
SIGNAL(valueChanged(int)), |
80 |
|
SLOT(optionsChanged())); |
81 |
|
QObject::connect(ui.MaxVolumeSpinBox, |
82 |
|
SIGNAL(valueChanged(int)), |
83 |
|
SLOT(optionsChanged())); |
84 |
|
QObject::connect(ui.MessagesFontPushButton, |
85 |
|
SIGNAL(clicked()), |
86 |
|
SLOT(chooseMessagesFont())); |
87 |
|
QObject::connect(ui.MessagesLimitCheckBox, |
88 |
|
SIGNAL(stateChanged(int)), |
89 |
|
SLOT(optionsChanged())); |
90 |
|
QObject::connect(ui.MessagesLimitLinesSpinBox, |
91 |
|
SIGNAL(valueChanged(int)), |
92 |
|
SLOT(optionsChanged())); |
93 |
|
QObject::connect(ui.ConfirmRemoveCheckBox, |
94 |
|
SIGNAL(stateChanged(int)), |
95 |
|
SLOT(optionsChanged())); |
96 |
|
QObject::connect(ui.KeepOnTopCheckBox, |
97 |
|
SIGNAL(stateChanged(int)), |
98 |
|
SLOT(optionsChanged())); |
99 |
|
QObject::connect(ui.StdoutCaptureCheckBox, |
100 |
|
SIGNAL(stateChanged(int)), |
101 |
|
SLOT(optionsChanged())); |
102 |
|
QObject::connect(ui.MaxRecentFilesSpinBox, |
103 |
|
SIGNAL(valueChanged(int)), |
104 |
|
SLOT(optionsChanged())); |
105 |
|
QObject::connect(ui.CompletePathCheckBox, |
106 |
|
SIGNAL(stateChanged(int)), |
107 |
|
SLOT(optionsChanged())); |
108 |
|
QObject::connect(ui.InstrumentNamesCheckBox, |
109 |
|
SIGNAL(stateChanged(int)), |
110 |
|
SLOT(optionsChanged())); |
111 |
|
QObject::connect(ui.OkPushButton, |
112 |
|
SIGNAL(clicked()), |
113 |
|
SLOT(accept())); |
114 |
|
QObject::connect(ui.CancelPushButton, |
115 |
|
SIGNAL(clicked()), |
116 |
|
SLOT(reject())); |
117 |
} |
} |
118 |
|
|
119 |
OptionsForm::~OptionsForm() { |
OptionsForm::~OptionsForm() |
120 |
|
{ |
121 |
} |
} |
122 |
|
|
123 |
// Populate (setup) dialog controls from settings descriptors. |
// Populate (setup) dialog controls from settings descriptors. |
137 |
m_pOptions->loadComboBoxHistory(ui.ServerCmdLineComboBox); |
m_pOptions->loadComboBoxHistory(ui.ServerCmdLineComboBox); |
138 |
|
|
139 |
// Load Server settings... |
// Load Server settings... |
140 |
ui.ServerHostComboBox->setCurrentText(m_pOptions->sServerHost); |
ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost); |
141 |
ui.ServerPortComboBox->setCurrentText(QString::number(m_pOptions->iServerPort)); |
ui.ServerPortComboBox->setEditText(QString::number(m_pOptions->iServerPort)); |
142 |
ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout); |
ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout); |
143 |
ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart); |
ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart); |
144 |
ui.ServerCmdLineComboBox->setCurrentText(m_pOptions->sServerCmdLine); |
ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine); |
145 |
ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay); |
ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay); |
146 |
|
|
147 |
// Load Display options... |
// Load Display options... |
148 |
QFont font; |
QFont font; |
149 |
|
QPalette pal; |
150 |
|
|
151 |
// Display font. |
// Display font. |
152 |
if (m_pOptions->sDisplayFont.isEmpty() || !font.fromString(m_pOptions->sDisplayFont)) |
if (m_pOptions->sDisplayFont.isEmpty() || !font.fromString(m_pOptions->sDisplayFont)) |
166 |
// Messages font. |
// Messages font. |
167 |
if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont)) |
if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont)) |
168 |
font = QFont("Fixed", 8); |
font = QFont("Fixed", 8); |
169 |
|
pal = ui.MessagesFontTextLabel->palette(); |
170 |
|
pal.setColor(QPalette::Background, Qt::white); |
171 |
|
ui.MessagesFontTextLabel->setPalette(pal); |
172 |
ui.MessagesFontTextLabel->setFont(font); |
ui.MessagesFontTextLabel->setFont(font); |
173 |
ui.MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize())); |
ui.MessagesFontTextLabel->setText(font.family() + ' ' + QString::number(font.pointSize())); |
174 |
|
|
175 |
// Messages limit option. |
// Messages limit option. |
176 |
ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit); |
ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit); |
200 |
// Save options... |
// Save options... |
201 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
202 |
// Server settings.... |
// Server settings.... |
203 |
m_pOptions->sServerHost = ui.ServerHostComboBox->currentText().stripWhiteSpace(); |
m_pOptions->sServerHost = ui.ServerHostComboBox->currentText().trimmed(); |
204 |
m_pOptions->iServerPort = ui.ServerPortComboBox->currentText().toInt(); |
m_pOptions->iServerPort = ui.ServerPortComboBox->currentText().toInt(); |
205 |
m_pOptions->iServerTimeout = ui.ServerTimeoutSpinBox->value(); |
m_pOptions->iServerTimeout = ui.ServerTimeoutSpinBox->value(); |
206 |
m_pOptions->bServerStart = ui.ServerStartCheckBox->isChecked(); |
m_pOptions->bServerStart = ui.ServerStartCheckBox->isChecked(); |
207 |
m_pOptions->sServerCmdLine = ui.ServerCmdLineComboBox->currentText().stripWhiteSpace(); |
m_pOptions->sServerCmdLine = ui.ServerCmdLineComboBox->currentText().trimmed(); |
208 |
m_pOptions->iStartDelay = ui.StartDelaySpinBox->value(); |
m_pOptions->iStartDelay = ui.StartDelaySpinBox->value(); |
209 |
// Channels options... |
// Channels options... |
210 |
m_pOptions->sDisplayFont = ui.DisplayFontTextLabel->font().toString(); |
m_pOptions->sDisplayFont = ui.DisplayFontTextLabel->font().toString(); |
320 |
// The channel display effect demo changer. |
// The channel display effect demo changer. |
321 |
void OptionsForm::toggleDisplayEffect ( bool bOn ) |
void OptionsForm::toggleDisplayEffect ( bool bOn ) |
322 |
{ |
{ |
323 |
QPixmap pm; |
QPalette pal; |
324 |
if (bOn) |
pal.setColor(QPalette::Foreground, Qt::green); |
325 |
pm = QPixmap(":/qsampler/pixmaps/displaybg1.png"); |
if (bOn) { |
326 |
ui.DisplayFontTextLabel->setPaletteBackgroundPixmap(pm); |
QPixmap pm(":/icons/displaybg1.png"); |
327 |
|
pal.setBrush(QPalette::Background, QBrush(pm)); |
328 |
|
} else { |
329 |
|
pal.setColor(QPalette::Background, Qt::black); |
330 |
|
} |
331 |
|
ui.DisplayFontTextLabel->setPalette(pal); |
332 |
|
|
333 |
optionsChanged(); |
optionsChanged(); |
334 |
} |
} |
335 |
|
|
336 |
} // namespace QSampler |
} // namespace QSampler |
337 |
|
|
338 |
|
|
|
// end of qsamplerOptionsForm.cpp |
|
339 |
|
// end of qsamplerOptionsForm.cpp |