1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
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 |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
GNU General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
18 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
|
#include "qsamplerOptions.h" |
|
23 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
24 |
|
#include "qsamplerOptions.h" |
25 |
|
|
26 |
#include <qcombobox.h> |
#include <QTextStream> |
27 |
|
#include <QComboBox> |
28 |
|
|
29 |
#include <lscp/client.h> |
#include <lscp/client.h> |
30 |
|
|
31 |
#include "config.h" |
#ifdef CONFIG_LIBGIG |
32 |
|
#include <gig.h> |
33 |
|
#endif |
34 |
|
|
35 |
|
|
36 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
48 |
|
|
49 |
// Load server options... |
// Load server options... |
50 |
m_settings.beginGroup("/Server"); |
m_settings.beginGroup("/Server"); |
51 |
sServerHost = m_settings.readEntry("/ServerHost", "localhost"); |
sServerHost = m_settings.value("/ServerHost", "localhost").toString(); |
52 |
iServerPort = m_settings.readNumEntry("/ServerPort", 8888); |
iServerPort = m_settings.value("/ServerPort", 8888).toInt(); |
53 |
iServerTimeout = m_settings.readNumEntry("/ServerTimeout", 500); |
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
54 |
bServerStart = m_settings.readBoolEntry("/ServerStart", true); |
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
55 |
sServerCmdLine = m_settings.readEntry("/ServerCmdLine", "linuxsampler"); |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
56 |
iStartDelay = m_settings.readNumEntry("/StartDelay", 2); |
iStartDelay = m_settings.value("/StartDelay", 3).toInt(); |
57 |
m_settings.endGroup(); |
m_settings.endGroup(); |
58 |
|
|
59 |
// Load display options... |
// Load display options... |
60 |
m_settings.beginGroup("/Display"); |
m_settings.beginGroup("/Display"); |
61 |
sDisplayFont = m_settings.readEntry("/DisplayFont", QString::null); |
sDisplayFont = m_settings.value("/DisplayFont").toString(); |
62 |
bDisplayEffect = m_settings.readBoolEntry("/DisplayEffect", true); |
bDisplayEffect = m_settings.value("/DisplayEffect", true).toBool(); |
63 |
bAutoRefresh = m_settings.readBoolEntry("/AutoRefresh", true); |
bAutoRefresh = m_settings.value("/AutoRefresh", true).toBool(); |
64 |
iAutoRefreshTime = m_settings.readNumEntry("/AutoRefreshTime", 1000); |
iAutoRefreshTime = m_settings.value("/AutoRefreshTime", 1000).toInt(); |
65 |
iMaxVolume = m_settings.readNumEntry("/MaxVolume", 100); |
iMaxVolume = m_settings.value("/MaxVolume", 100).toInt(); |
66 |
sMessagesFont = m_settings.readEntry("/MessagesFont", QString::null); |
sMessagesFont = m_settings.value("/MessagesFont").toString(); |
67 |
bMessagesLimit = m_settings.readBoolEntry("/MessagesLimit", true); |
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
68 |
iMessagesLimitLines = m_settings.readNumEntry("/MessagesLimitLines", 1000); |
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
69 |
bConfirmRemove = m_settings.readBoolEntry("/ConfirmRemove", true); |
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
70 |
bStdoutCapture = m_settings.readBoolEntry("/StdoutCapture", true); |
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
71 |
bCompletePath = m_settings.readBoolEntry("/CompletePath", true); |
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
72 |
iMaxRecentFiles = m_settings.readNumEntry("/MaxRecentFiles", 5); |
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
73 |
|
iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt(); |
74 |
|
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
75 |
m_settings.endGroup(); |
m_settings.endGroup(); |
76 |
|
|
77 |
// And go into view options group. |
// And go into view options group. |
78 |
m_settings.beginGroup("/View"); |
m_settings.beginGroup("/View"); |
79 |
bMenubar = m_settings.readBoolEntry("/Menubar", true); |
bMenubar = m_settings.value("/Menubar", true).toBool(); |
80 |
bToolbar = m_settings.readBoolEntry("/Toolbar", true); |
bToolbar = m_settings.value("/Toolbar", true).toBool(); |
81 |
bStatusbar = m_settings.readBoolEntry("/Statusbar", true); |
bStatusbar = m_settings.value("/Statusbar", true).toBool(); |
82 |
bAutoArrange = m_settings.readBoolEntry("/AutoArrange", true); |
bAutoArrange = m_settings.value("/AutoArrange", true).toBool(); |
83 |
m_settings.endGroup(); |
m_settings.endGroup(); |
84 |
|
|
85 |
m_settings.endGroup(); // Options group. |
m_settings.endGroup(); // Options group. |
86 |
|
|
87 |
// Recent file list. |
// Recent file list. |
88 |
m_settings.beginGroup("/RecentFiles"); |
recentFiles.clear(); |
89 |
recentFiles.clear(); |
m_settings.beginGroup("/RecentFiles"); |
90 |
for (int i = 0; i < iMaxRecentFiles; i++) { |
for (int iFile = 0; iFile < iMaxRecentFiles; iFile++) { |
91 |
QString sFilename = m_settings.readEntry("/File" + QString::number(i + 1), QString::null); |
QString sFilename = m_settings.value( |
92 |
if (!sFilename.isEmpty()) |
"/File" + QString::number(iFile + 1)).toString(); |
93 |
recentFiles.append(sFilename); |
if (!sFilename.isEmpty()) |
94 |
} |
recentFiles.append(sFilename); |
95 |
m_settings.endGroup(); |
} |
96 |
|
m_settings.endGroup(); |
97 |
|
|
98 |
// Last but not least, get the default directories. |
// Last but not least, get the default directories. |
99 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Default"); |
100 |
sSessionDir = m_settings.readEntry("/SessionDir", QString::null); |
sSessionDir = m_settings.value("/SessionDir").toString(); |
101 |
sInstrumentDir = m_settings.readEntry("/InstrumentDir", QString::null); |
sInstrumentDir = m_settings.value("/InstrumentDir").toString(); |
102 |
sEngineName = m_settings.readEntry("/EngineName", QString::null); |
sEngineName = m_settings.value("/EngineName").toString(); |
103 |
sAudioDriver = m_settings.readEntry("/AudioDriver", QString::null); |
sAudioDriver = m_settings.value("/AudioDriver").toString(); |
104 |
sMidiDriver = m_settings.readEntry("/MidiDriver", QString::null); |
sMidiDriver = m_settings.value("/MidiDriver").toString(); |
105 |
|
iMidiMap = m_settings.value("/MidiMap", 0).toInt(); |
106 |
|
iMidiBank = m_settings.value("/MidiBank", 0).toInt(); |
107 |
|
iMidiProg = m_settings.value("/MidiProg", 0).toInt(); |
108 |
|
iVolume = m_settings.value("/Volume", 100).toInt(); |
109 |
|
iLoadMode = m_settings.value("/Loadmode", 0).toInt(); |
110 |
m_settings.endGroup(); |
m_settings.endGroup(); |
111 |
} |
} |
112 |
|
|
116 |
{ |
{ |
117 |
// Make program version available in the future. |
// Make program version available in the future. |
118 |
m_settings.beginGroup("/Program"); |
m_settings.beginGroup("/Program"); |
119 |
m_settings.writeEntry("/Version", QSAMPLER_VERSION); |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
120 |
m_settings.endGroup(); |
m_settings.endGroup(); |
121 |
|
|
122 |
// And go into general options group. |
// And go into general options group. |
124 |
|
|
125 |
// Save server options. |
// Save server options. |
126 |
m_settings.beginGroup("/Server"); |
m_settings.beginGroup("/Server"); |
127 |
m_settings.writeEntry("/ServerHost", sServerHost); |
m_settings.setValue("/ServerHost", sServerHost); |
128 |
m_settings.writeEntry("/ServerPort", iServerPort); |
m_settings.setValue("/ServerPort", iServerPort); |
129 |
m_settings.writeEntry("/ServerTimeout", iServerTimeout); |
m_settings.setValue("/ServerTimeout", iServerTimeout); |
130 |
m_settings.writeEntry("/ServerStart", bServerStart); |
m_settings.setValue("/ServerStart", bServerStart); |
131 |
m_settings.writeEntry("/ServerCmdLine", sServerCmdLine); |
m_settings.setValue("/ServerCmdLine", sServerCmdLine); |
132 |
m_settings.writeEntry("/StartDelay", iStartDelay); |
m_settings.setValue("/StartDelay", iStartDelay); |
133 |
m_settings.endGroup(); |
m_settings.endGroup(); |
134 |
|
|
135 |
// Save display options. |
// Save display options. |
136 |
m_settings.beginGroup("/Display"); |
m_settings.beginGroup("/Display"); |
137 |
m_settings.writeEntry("/DisplayFont", sDisplayFont); |
m_settings.setValue("/DisplayFont", sDisplayFont); |
138 |
m_settings.writeEntry("/DisplayEffect", bDisplayEffect); |
m_settings.setValue("/DisplayEffect", bDisplayEffect); |
139 |
m_settings.writeEntry("/AutoRefresh", bAutoRefresh); |
m_settings.setValue("/AutoRefresh", bAutoRefresh); |
140 |
m_settings.writeEntry("/AutoRefreshTime", iAutoRefreshTime); |
m_settings.setValue("/AutoRefreshTime", iAutoRefreshTime); |
141 |
m_settings.writeEntry("/MaxVolume", iMaxVolume); |
m_settings.setValue("/MaxVolume", iMaxVolume); |
142 |
m_settings.writeEntry("/MessagesFont", sMessagesFont); |
m_settings.setValue("/MessagesFont", sMessagesFont); |
143 |
m_settings.writeEntry("/MessagesLimit", bMessagesLimit); |
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
144 |
m_settings.writeEntry("/MessagesLimitLines", iMessagesLimitLines); |
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
145 |
m_settings.writeEntry("/ConfirmRemove", bConfirmRemove); |
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
146 |
m_settings.writeEntry("/StdoutCapture", bStdoutCapture); |
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
147 |
m_settings.writeEntry("/CompletePath", bCompletePath); |
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
148 |
m_settings.writeEntry("/MaxRecentFiles", iMaxRecentFiles); |
m_settings.setValue("/CompletePath", bCompletePath); |
149 |
|
m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles); |
150 |
|
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
151 |
m_settings.endGroup(); |
m_settings.endGroup(); |
152 |
|
|
153 |
// View options group. |
// View options group. |
154 |
m_settings.beginGroup("/View"); |
m_settings.beginGroup("/View"); |
155 |
m_settings.writeEntry("/Menubar", bMenubar); |
m_settings.setValue("/Menubar", bMenubar); |
156 |
m_settings.writeEntry("/Toolbar", bToolbar); |
m_settings.setValue("/Toolbar", bToolbar); |
157 |
m_settings.writeEntry("/Statusbar", bStatusbar); |
m_settings.setValue("/Statusbar", bStatusbar); |
158 |
m_settings.writeEntry("/AutoArrange", bAutoArrange); |
m_settings.setValue("/AutoArrange", bAutoArrange); |
159 |
m_settings.endGroup(); |
m_settings.endGroup(); |
160 |
|
|
161 |
m_settings.endGroup(); // Options group. |
m_settings.endGroup(); // Options group. |
162 |
|
|
163 |
// Recent file list. |
// Recent file list. |
164 |
m_settings.beginGroup("/RecentFiles"); |
int iFile = 0; |
165 |
for (int i = 0; i < (int) recentFiles.count(); i++) |
m_settings.beginGroup("/RecentFiles"); |
166 |
m_settings.writeEntry("/File" + QString::number(i + 1), recentFiles[i]); |
QStringListIterator iter(recentFiles); |
167 |
m_settings.endGroup(); |
while (iter.hasNext()) |
168 |
|
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
169 |
|
m_settings.endGroup(); |
170 |
|
|
171 |
// Default directories. |
// Default directories. |
172 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Default"); |
173 |
m_settings.writeEntry("/SessionDir", sSessionDir); |
m_settings.setValue("/SessionDir", sSessionDir); |
174 |
m_settings.writeEntry("/InstrumentDir", sInstrumentDir); |
m_settings.setValue("/InstrumentDir", sInstrumentDir); |
175 |
m_settings.writeEntry("/EngineName", sEngineName); |
m_settings.setValue("/EngineName", sEngineName); |
176 |
m_settings.writeEntry("/AudioDriver", sAudioDriver); |
m_settings.setValue("/AudioDriver", sAudioDriver); |
177 |
m_settings.writeEntry("/MidiDriver", sMidiDriver); |
m_settings.setValue("/MidiDriver", sMidiDriver); |
178 |
|
m_settings.setValue("/MidiMap", iMidiMap); |
179 |
|
m_settings.setValue("/MidiBank", iMidiBank); |
180 |
|
m_settings.setValue("/MidiProg", iMidiProg); |
181 |
|
m_settings.setValue("/Volume", iVolume); |
182 |
|
m_settings.setValue("/Loadmode", iLoadMode); |
183 |
m_settings.endGroup(); |
m_settings.endGroup(); |
184 |
|
|
185 |
m_settings.endGroup(); |
m_settings.endGroup(); |
202 |
// Help about command line options. |
// Help about command line options. |
203 |
void qsamplerOptions::print_usage ( const char *arg0 ) |
void qsamplerOptions::print_usage ( const char *arg0 ) |
204 |
{ |
{ |
205 |
const QString sEot = "\n\t"; |
QTextStream out(stderr); |
206 |
const QString sEol = "\n\n"; |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
207 |
|
QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n" |
208 |
fprintf(stderr, QObject::tr("Usage") + ": %s [" + QObject::tr("options") + "] [" + |
"Options:\n\n" |
209 |
QObject::tr("session-file") + "]" + sEol, arg0); |
" -s, --start\n\tStart linuxsampler server locally\n\n" |
210 |
fprintf(stderr, QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE) + sEol); |
" -h, --hostname\n\tSpecify linuxsampler server hostname\n\n" |
211 |
fprintf(stderr, QObject::tr("Options") + ":" + sEol); |
" -p, --port\n\tSpecify linuxsampler server port number\n\n" |
212 |
fprintf(stderr, " -s, --start" + sEot + |
" -?, --help\n\tShow help about command line options\n\n" |
213 |
QObject::tr("Start linuxsampler server locally") + sEol); |
" -v, --version\n\tShow version information\n\n") |
214 |
fprintf(stderr, " -h, --hostname" + sEot + |
.arg(arg0); |
|
QObject::tr("Specify linuxsampler server hostname") + sEol); |
|
|
fprintf(stderr, " -p, --port" + sEot + |
|
|
QObject::tr("Specify linuxsampler server port number") + sEol); |
|
|
fprintf(stderr, " -?, --help" + sEot + |
|
|
QObject::tr("Show help about command line options") + sEol); |
|
|
fprintf(stderr, " -v, --version" + sEot + |
|
|
QObject::tr("Show version information") + sEol); |
|
215 |
} |
} |
216 |
|
|
217 |
|
|
218 |
// Parse command line arguments into m_settings. |
// Parse command line arguments into m_settings. |
219 |
bool qsamplerOptions::parse_args ( int argc, char **argv ) |
bool qsamplerOptions::parse_args ( int argc, char **argv ) |
220 |
{ |
{ |
221 |
|
QTextStream out(stderr); |
222 |
const QString sEol = "\n\n"; |
const QString sEol = "\n\n"; |
223 |
int iCmdArgs = 0; |
int iCmdArgs = 0; |
224 |
|
|
233 |
|
|
234 |
QString sArg = argv[i]; |
QString sArg = argv[i]; |
235 |
QString sVal = QString::null; |
QString sVal = QString::null; |
236 |
int iEqual = sArg.find("="); |
int iEqual = sArg.indexOf("="); |
237 |
if (iEqual >= 0) { |
if (iEqual >= 0) { |
238 |
sVal = sArg.right(sArg.length() - iEqual - 1); |
sVal = sArg.right(sArg.length() - iEqual - 1); |
239 |
sArg = sArg.left(iEqual); |
sArg = sArg.left(iEqual); |
246 |
} |
} |
247 |
else if (sArg == "-h" || sArg == "--hostname") { |
else if (sArg == "-h" || sArg == "--hostname") { |
248 |
if (sVal.isNull()) { |
if (sVal.isNull()) { |
249 |
fprintf(stderr, QObject::tr("Option -h requires an argument (hostname).") + sEol); |
out << QObject::tr("Option -h requires an argument (hostname).") + sEol; |
250 |
return false; |
return false; |
251 |
} |
} |
252 |
sServerHost = sVal; |
sServerHost = sVal; |
255 |
} |
} |
256 |
else if (sArg == "-p" || sArg == "--port") { |
else if (sArg == "-p" || sArg == "--port") { |
257 |
if (sVal.isNull()) { |
if (sVal.isNull()) { |
258 |
fprintf(stderr, QObject::tr("Option -p requires an argument (port).") + sEol); |
out << QObject::tr("Option -p requires an argument (port).") + sEol; |
259 |
return false; |
return false; |
260 |
} |
} |
261 |
iServerPort = sVal.toInt(); |
iServerPort = sVal.toInt(); |
267 |
return false; |
return false; |
268 |
} |
} |
269 |
else if (sArg == "-v" || sArg == "--version") { |
else if (sArg == "-v" || sArg == "--version") { |
270 |
fprintf(stderr, "Qt: %s\n", qVersion()); |
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
271 |
fprintf(stderr, "liblscp: %s\n", ::lscp_client_version()); |
#ifdef CONFIG_LIBGIG |
272 |
fprintf(stderr, "qsampler: %s\n", QSAMPLER_VERSION); |
out << QString("%1: %2\n") |
273 |
|
.arg(gig::libraryName().c_str()) |
274 |
|
.arg(gig::libraryVersion().c_str()); |
275 |
|
#endif |
276 |
|
out << QString("%1: %2\n") |
277 |
|
.arg(::lscp_client_package()) |
278 |
|
.arg(::lscp_client_version()); |
279 |
|
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
280 |
return false; |
return false; |
281 |
} |
} |
282 |
else { |
else { |
297 |
|
|
298 |
void qsamplerOptions::loadWidgetGeometry ( QWidget *pWidget ) |
void qsamplerOptions::loadWidgetGeometry ( QWidget *pWidget ) |
299 |
{ |
{ |
300 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
301 |
if (pWidget) { |
if (pWidget) { |
302 |
QPoint fpos; |
QPoint fpos; |
303 |
QSize fsize; |
QSize fsize; |
304 |
bool bVisible; |
bool bVisible; |
305 |
m_settings.beginGroup("/Geometry/" + QString(pWidget->name())); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
306 |
fpos.setX(m_settings.readNumEntry("/x", -1)); |
fpos.setX(m_settings.value("/x", -1).toInt()); |
307 |
fpos.setY(m_settings.readNumEntry("/y", -1)); |
fpos.setY(m_settings.value("/y", -1).toInt()); |
308 |
fsize.setWidth(m_settings.readNumEntry("/width", -1)); |
fsize.setWidth(m_settings.value("/width", -1).toInt()); |
309 |
fsize.setHeight(m_settings.readNumEntry("/height", -1)); |
fsize.setHeight(m_settings.value("/height", -1).toInt()); |
310 |
bVisible = m_settings.readBoolEntry("/visible", false); |
bVisible = m_settings.value("/visible", false).toBool(); |
311 |
m_settings.endGroup(); |
m_settings.endGroup(); |
312 |
if (fpos.x() > 0 && fpos.y() > 0) |
if (fpos.x() > 0 && fpos.y() > 0) |
313 |
pWidget->move(fpos); |
pWidget->move(fpos); |
314 |
if (fsize.width() > 0 && fsize.height() > 0) |
if (fsize.width() > 0 && fsize.height() > 0) |
315 |
pWidget->resize(fsize); |
pWidget->resize(fsize); |
316 |
else |
else |
317 |
pWidget->adjustSize(); |
pWidget->adjustSize(); |
318 |
if (bVisible) |
if (bVisible) |
319 |
pWidget->show(); |
pWidget->show(); |
320 |
else |
else |
321 |
pWidget->hide(); |
pWidget->hide(); |
322 |
} |
} |
323 |
} |
} |
324 |
|
|
325 |
|
|
326 |
void qsamplerOptions::saveWidgetGeometry ( QWidget *pWidget ) |
void qsamplerOptions::saveWidgetGeometry ( QWidget *pWidget ) |
327 |
{ |
{ |
328 |
// Try to save form window position... |
// Try to save form window position... |
329 |
// (due to X11 window managers ideossincrasies, we better |
// (due to X11 window managers ideossincrasies, we better |
330 |
// only save the form geometry while its up and visible) |
// only save the form geometry while its up and visible) |
331 |
if (pWidget) { |
if (pWidget) { |
332 |
m_settings.beginGroup("/Geometry/" + QString(pWidget->name())); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
333 |
bool bVisible = pWidget->isVisible(); |
bool bVisible = pWidget->isVisible(); |
334 |
if (bVisible) { |
const QPoint& fpos = pWidget->pos(); |
335 |
QPoint fpos = pWidget->pos(); |
const QSize& fsize = pWidget->size(); |
336 |
QSize fsize = pWidget->size(); |
m_settings.setValue("/x", fpos.x()); |
337 |
m_settings.writeEntry("/x", fpos.x()); |
m_settings.setValue("/y", fpos.y()); |
338 |
m_settings.writeEntry("/y", fpos.y()); |
m_settings.setValue("/width", fsize.width()); |
339 |
m_settings.writeEntry("/width", fsize.width()); |
m_settings.setValue("/height", fsize.height()); |
340 |
m_settings.writeEntry("/height", fsize.height()); |
m_settings.setValue("/visible", bVisible); |
341 |
} |
m_settings.endGroup(); |
342 |
m_settings.writeEntry("/visible", bVisible); |
} |
|
m_settings.endGroup(); |
|
|
} |
|
343 |
} |
} |
344 |
|
|
345 |
|
|
346 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
347 |
// Combo box history persistence helper implementation. |
// Combo box history persistence helper implementation. |
348 |
|
|
|
void qsamplerOptions::add2ComboBoxHistory ( QComboBox *pComboBox, const QString& sNewText, int iLimit, int iIndex ) |
|
|
{ |
|
|
int iCount = pComboBox->count(); |
|
|
for (int i = 0; i < iCount; i++) { |
|
|
QString sText = pComboBox->text(i); |
|
|
if (sText == sNewText) { |
|
|
pComboBox->removeItem(i); |
|
|
iCount--; |
|
|
break; |
|
|
} |
|
|
} |
|
|
while (iCount >= iLimit) |
|
|
pComboBox->removeItem(--iCount); |
|
|
pComboBox->insertItem(sNewText, iIndex); |
|
|
} |
|
|
|
|
|
|
|
349 |
void qsamplerOptions::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void qsamplerOptions::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
350 |
{ |
{ |
351 |
pComboBox->setUpdatesEnabled(false); |
// Load combobox list from configuration settings file... |
352 |
pComboBox->setDuplicatesEnabled(false); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
353 |
|
|
354 |
m_settings.beginGroup("/History/" + QString(pComboBox->name())); |
if (m_settings.childKeys().count() > 0) { |
355 |
for (int i = 0; i < iLimit; i++) { |
pComboBox->setUpdatesEnabled(false); |
356 |
QString sText = m_settings.readEntry("/Item" + QString::number(i + 1), QString::null); |
pComboBox->setDuplicatesEnabled(false); |
357 |
if (sText.isEmpty()) |
pComboBox->clear(); |
358 |
break; |
for (int i = 0; i < iLimit; i++) { |
359 |
add2ComboBoxHistory(pComboBox, sText, iLimit); |
const QString& sText = m_settings.value( |
360 |
} |
"/Item" + QString::number(i + 1)).toString(); |
361 |
m_settings.endGroup(); |
if (sText.isEmpty()) |
362 |
|
break; |
363 |
|
pComboBox->addItem(sText); |
364 |
|
} |
365 |
|
pComboBox->setUpdatesEnabled(true); |
366 |
|
} |
367 |
|
|
368 |
pComboBox->setUpdatesEnabled(true); |
m_settings.endGroup(); |
369 |
} |
} |
370 |
|
|
371 |
|
|
372 |
void qsamplerOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void qsamplerOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
373 |
{ |
{ |
374 |
add2ComboBoxHistory(pComboBox, pComboBox->currentText(), iLimit, 0); |
// Add current text as latest item... |
375 |
|
const QString& sCurrentText = pComboBox->currentText(); |
376 |
m_settings.beginGroup("/History/" + QString(pComboBox->name())); |
int iCount = pComboBox->count(); |
377 |
for (int i = 0; i < iLimit && i < pComboBox->count(); i++) { |
for (int i = 0; i < iCount; i++) { |
378 |
QString sText = pComboBox->text(i); |
const QString& sText = pComboBox->itemText(i); |
379 |
if (sText.isEmpty()) |
if (sText == sCurrentText) { |
380 |
break; |
pComboBox->removeItem(i); |
381 |
m_settings.writeEntry("/Item" + QString::number(i + 1), sText); |
iCount--; |
382 |
} |
break; |
383 |
m_settings.endGroup(); |
} |
384 |
|
} |
385 |
|
while (iCount >= iLimit) |
386 |
|
pComboBox->removeItem(--iCount); |
387 |
|
pComboBox->insertItem(0, sCurrentText); |
388 |
|
iCount++; |
389 |
|
|
390 |
|
// Save combobox list to configuration settings file... |
391 |
|
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
392 |
|
for (int i = 0; i < iCount; i++) { |
393 |
|
const QString& sText = pComboBox->itemText(i); |
394 |
|
if (sText.isEmpty()) |
395 |
|
break; |
396 |
|
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
397 |
|
} |
398 |
|
m_settings.endGroup(); |
399 |
} |
} |
400 |
|
|
401 |
|
|