1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2009, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
44 |
Options::Options (void) |
Options::Options (void) |
45 |
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
46 |
{ |
{ |
47 |
|
loadOptions(); |
48 |
|
} |
49 |
|
|
50 |
|
|
51 |
|
// Default Destructor. |
52 |
|
Options::~Options (void) |
53 |
|
{ |
54 |
|
saveOptions(); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
// Explicit load method. |
59 |
|
void Options::loadOptions (void) |
60 |
|
{ |
61 |
// Begin into general options group. |
// Begin into general options group. |
62 |
m_settings.beginGroup("/Options"); |
m_settings.beginGroup("/Options"); |
63 |
|
|
154 |
} |
} |
155 |
|
|
156 |
|
|
157 |
// Default Destructor. |
// Explicit save method. |
158 |
Options::~Options (void) |
void Options::saveOptions (void) |
159 |
{ |
{ |
160 |
// Make program version available in the future. |
// Make program version available in the future. |
161 |
m_settings.beginGroup("/Program"); |
m_settings.beginGroup("/Program"); |
239 |
m_settings.setValue("/Volume", iVolume); |
m_settings.setValue("/Volume", iVolume); |
240 |
m_settings.setValue("/Loadmode", iLoadMode); |
m_settings.setValue("/Loadmode", iLoadMode); |
241 |
m_settings.endGroup(); |
m_settings.endGroup(); |
242 |
|
|
243 |
|
// Save/commit to disk. |
244 |
|
m_settings.sync(); |
245 |
} |
} |
246 |
|
|
247 |
|
|
248 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
249 |
// Settings accessor. |
// Settings accessor. |
250 |
// |
// |
356 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
357 |
// Widget geometry persistence helper methods. |
// Widget geometry persistence helper methods. |
358 |
|
|
359 |
void Options::loadWidgetGeometry ( QWidget *pWidget ) |
void Options::loadWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
360 |
{ |
{ |
361 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
362 |
if (pWidget) { |
if (pWidget) { |
363 |
QPoint fpos; |
QPoint wpos; |
364 |
QSize fsize; |
QSize wsize; |
|
bool bVisible; |
|
365 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
366 |
fpos.setX(m_settings.value("/x", -1).toInt()); |
wpos.setX(m_settings.value("/x", -1).toInt()); |
367 |
fpos.setY(m_settings.value("/y", -1).toInt()); |
wpos.setY(m_settings.value("/y", -1).toInt()); |
368 |
fsize.setWidth(m_settings.value("/width", -1).toInt()); |
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
369 |
fsize.setHeight(m_settings.value("/height", -1).toInt()); |
wsize.setHeight(m_settings.value("/height", -1).toInt()); |
370 |
bVisible = m_settings.value("/visible", false).toBool(); |
if (!bVisible) bVisible = m_settings.value("/visible", false).toBool(); |
371 |
m_settings.endGroup(); |
m_settings.endGroup(); |
372 |
if (fpos.x() > 0 && fpos.y() > 0) |
if (wpos.x() > 0 && wpos.y() > 0) |
373 |
pWidget->move(fpos); |
pWidget->move(wpos); |
374 |
if (fsize.width() > 0 && fsize.height() > 0) |
if (wsize.width() > 0 && wsize.height() > 0) |
375 |
pWidget->resize(fsize); |
pWidget->resize(wsize); |
376 |
else |
// else |
377 |
pWidget->adjustSize(); |
// pWidget->adjustSize(); |
378 |
if (bVisible) |
if (bVisible) |
379 |
pWidget->show(); |
pWidget->show(); |
380 |
else |
// else |
381 |
pWidget->hide(); |
// pWidget->hide(); |
382 |
} |
} |
383 |
} |
} |
384 |
|
|
385 |
|
|
386 |
void Options::saveWidgetGeometry ( QWidget *pWidget ) |
void Options::saveWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
387 |
{ |
{ |
388 |
// Try to save form window position... |
// Try to save form window position... |
389 |
// (due to X11 window managers ideossincrasies, we better |
// (due to X11 window managers ideossincrasies, we better |
390 |
// only save the form geometry while its up and visible) |
// only save the form geometry while its up and visible) |
391 |
if (pWidget) { |
if (pWidget) { |
392 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
393 |
bool bVisible = pWidget->isVisible(); |
const QPoint& wpos = pWidget->pos(); |
394 |
const QPoint& fpos = pWidget->pos(); |
const QSize& wsize = pWidget->size(); |
395 |
const QSize& fsize = pWidget->size(); |
if (!bVisible) bVisible = pWidget->isVisible(); |
396 |
m_settings.setValue("/x", fpos.x()); |
m_settings.setValue("/x", wpos.x()); |
397 |
m_settings.setValue("/y", fpos.y()); |
m_settings.setValue("/y", wpos.y()); |
398 |
m_settings.setValue("/width", fsize.width()); |
m_settings.setValue("/width", wsize.width()); |
399 |
m_settings.setValue("/height", fsize.height()); |
m_settings.setValue("/height", wsize.height()); |
400 |
m_settings.setValue("/visible", bVisible); |
m_settings.setValue("/visible", bVisible); |
401 |
m_settings.endGroup(); |
m_settings.endGroup(); |
402 |
} |
} |