369 |
{ |
{ |
370 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
371 |
if (pWidget) { |
if (pWidget) { |
372 |
|
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
373 |
|
#if QT_VERSION >= 0x050000 |
374 |
|
const QByteArray& geometry |
375 |
|
= m_settings.value("/geometry").toByteArray(); |
376 |
|
if (!geometry.isEmpty()) |
377 |
|
pWidget->restoreGeometry(geometry); |
378 |
|
else |
379 |
|
#else//--LOAD_OLD_GEOMETRY |
380 |
QPoint wpos; |
QPoint wpos; |
381 |
QSize wsize; |
QSize wsize; |
|
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
|
382 |
wpos.setX(m_settings.value("/x", -1).toInt()); |
wpos.setX(m_settings.value("/x", -1).toInt()); |
383 |
wpos.setY(m_settings.value("/y", -1).toInt()); |
wpos.setY(m_settings.value("/y", -1).toInt()); |
384 |
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
385 |
wsize.setHeight(m_settings.value("/height", -1).toInt()); |
wsize.setHeight(m_settings.value("/height", -1).toInt()); |
|
if (!bVisible) bVisible = m_settings.value("/visible", false).toBool(); |
|
|
m_settings.endGroup(); |
|
386 |
if (wpos.x() > 0 && wpos.y() > 0) |
if (wpos.x() > 0 && wpos.y() > 0) |
387 |
pWidget->move(wpos); |
pWidget->move(wpos); |
388 |
if (wsize.width() > 0 && wsize.height() > 0) |
if (wsize.width() > 0 && wsize.height() > 0) |
389 |
pWidget->resize(wsize); |
pWidget->resize(wsize); |
390 |
// else |
else |
391 |
// pWidget->adjustSize(); |
#endif |
392 |
|
pWidget->adjustSize(); |
393 |
|
if (!bVisible) |
394 |
|
bVisible = m_settings.value("/visible", false).toBool(); |
395 |
if (bVisible) |
if (bVisible) |
396 |
pWidget->show(); |
pWidget->show(); |
397 |
// else |
else |
398 |
// pWidget->hide(); |
pWidget->hide(); |
399 |
|
m_settings.endGroup(); |
400 |
} |
} |
401 |
} |
} |
402 |
|
|
408 |
// only save the form geometry while its up and visible) |
// only save the form geometry while its up and visible) |
409 |
if (pWidget) { |
if (pWidget) { |
410 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
411 |
|
#if QT_VERSION >= 0x050000 |
412 |
|
m_settings.setValue("/geometry", pWidget->saveGeometry()); |
413 |
|
#else//--SAVE_OLD_GEOMETRY |
414 |
const QPoint& wpos = pWidget->pos(); |
const QPoint& wpos = pWidget->pos(); |
415 |
const QSize& wsize = pWidget->size(); |
const QSize& wsize = pWidget->size(); |
|
if (!bVisible) bVisible = pWidget->isVisible(); |
|
416 |
m_settings.setValue("/x", wpos.x()); |
m_settings.setValue("/x", wpos.x()); |
417 |
m_settings.setValue("/y", wpos.y()); |
m_settings.setValue("/y", wpos.y()); |
418 |
m_settings.setValue("/width", wsize.width()); |
m_settings.setValue("/width", wsize.width()); |
419 |
m_settings.setValue("/height", wsize.height()); |
m_settings.setValue("/height", wsize.height()); |
420 |
|
#endif |
421 |
|
if (!bVisible) bVisible = pWidget->isVisible(); |
422 |
m_settings.setValue("/visible", bVisible); |
m_settings.setValue("/visible", bVisible); |
423 |
m_settings.endGroup(); |
m_settings.endGroup(); |
424 |
} |
} |
430 |
|
|
431 |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
432 |
{ |
{ |
433 |
|
const bool bBlockSignals = pComboBox->blockSignals(true); |
434 |
|
|
435 |
// Load combobox list from configuration settings file... |
// Load combobox list from configuration settings file... |
436 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
437 |
|
|
439 |
pComboBox->setUpdatesEnabled(false); |
pComboBox->setUpdatesEnabled(false); |
440 |
pComboBox->setDuplicatesEnabled(false); |
pComboBox->setDuplicatesEnabled(false); |
441 |
pComboBox->clear(); |
pComboBox->clear(); |
442 |
for (int i = 0; i < iLimit; i++) { |
for (int i = 0; i < iLimit; ++i) { |
443 |
const QString& sText = m_settings.value( |
const QString& sText = m_settings.value( |
444 |
"/Item" + QString::number(i + 1)).toString(); |
"/Item" + QString::number(i + 1)).toString(); |
445 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
450 |
} |
} |
451 |
|
|
452 |
m_settings.endGroup(); |
m_settings.endGroup(); |
453 |
|
|
454 |
|
pComboBox->blockSignals(bBlockSignals); |
455 |
} |
} |
456 |
|
|
457 |
|
|
458 |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
459 |
{ |
{ |
460 |
|
const bool bBlockSignals = pComboBox->blockSignals(true); |
461 |
|
|
462 |
// Add current text as latest item... |
// Add current text as latest item... |
463 |
const QString& sCurrentText = pComboBox->currentText(); |
const QString sCurrentText = pComboBox->currentText(); |
464 |
int iCount = pComboBox->count(); |
int iCount = pComboBox->count(); |
465 |
for (int i = 0; i < iCount; i++) { |
for (int i = 0; i < iCount; i++) { |
466 |
const QString& sText = pComboBox->itemText(i); |
const QString& sText = pComboBox->itemText(i); |
467 |
if (sText == sCurrentText) { |
if (sText == sCurrentText) { |
468 |
pComboBox->removeItem(i); |
pComboBox->removeItem(i); |
469 |
iCount--; |
--iCount; |
470 |
break; |
break; |
471 |
} |
} |
472 |
} |
} |
473 |
while (iCount >= iLimit) |
while (iCount >= iLimit) |
474 |
pComboBox->removeItem(--iCount); |
pComboBox->removeItem(--iCount); |
475 |
pComboBox->insertItem(0, sCurrentText); |
pComboBox->insertItem(0, sCurrentText); |
476 |
iCount++; |
pComboBox->setCurrentIndex(0); |
477 |
|
++iCount; |
478 |
|
|
479 |
// Save combobox list to configuration settings file... |
// Save combobox list to configuration settings file... |
480 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
481 |
for (int i = 0; i < iCount; i++) { |
for (int i = 0; i < iCount; ++i) { |
482 |
const QString& sText = pComboBox->itemText(i); |
const QString& sText = pComboBox->itemText(i); |
483 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
484 |
break; |
break; |
485 |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
486 |
} |
} |
487 |
m_settings.endGroup(); |
m_settings.endGroup(); |
488 |
|
|
489 |
|
pComboBox->blockSignals(bBlockSignals); |
490 |
} |
} |
491 |
|
|
492 |
|
|
493 |
int Options::getMaxVoices() { |
int Options::getMaxVoices() { |
494 |
#ifndef CONFIG_MAX_VOICES |
#ifndef CONFIG_MAX_VOICES |
495 |
return -1; |
return -1; |