33 |
#endif |
#endif |
34 |
|
|
35 |
|
|
36 |
|
namespace QSampler { |
37 |
|
|
38 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
39 |
// qsamplerOptions - Prototype settings structure. |
// QSampler::Options - Prototype settings structure. |
40 |
// |
// |
41 |
|
|
42 |
// Constructor. |
// Constructor. |
43 |
qsamplerOptions::qsamplerOptions (void) |
Options::Options (void) |
44 |
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
45 |
{ |
{ |
46 |
// Begin into general options group. |
// Begin into general options group. |
47 |
m_settings.beginGroup("/Options"); |
m_settings.beginGroup("/Options"); |
48 |
|
|
49 |
|
// Load server options... |
50 |
|
m_settings.beginGroup("/Server"); |
51 |
|
sServerHost = m_settings.value("/ServerHost", "localhost").toString(); |
52 |
|
iServerPort = m_settings.value("/ServerPort", 8888).toInt(); |
53 |
|
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
54 |
|
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
55 |
|
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
56 |
|
iStartDelay = m_settings.value("/StartDelay", 3).toInt(); |
57 |
|
m_settings.endGroup(); |
58 |
|
|
59 |
|
// Load display options... |
60 |
|
m_settings.beginGroup("/Display"); |
61 |
|
sDisplayFont = m_settings.value("/DisplayFont").toString(); |
62 |
|
bDisplayEffect = m_settings.value("/DisplayEffect", true).toBool(); |
63 |
|
bAutoRefresh = m_settings.value("/AutoRefresh", true).toBool(); |
64 |
|
iAutoRefreshTime = m_settings.value("/AutoRefreshTime", 1000).toInt(); |
65 |
|
iMaxVolume = m_settings.value("/MaxVolume", 100).toInt(); |
66 |
|
sMessagesFont = m_settings.value("/MessagesFont").toString(); |
67 |
|
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
68 |
|
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
69 |
|
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
70 |
|
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
71 |
|
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
72 |
|
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
73 |
|
iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt(); |
74 |
|
// if libgig provides a fast way to retrieve instrument names even for large |
75 |
|
// .gig files, then we enable this feature by default |
76 |
|
#if HAVE_LIBGIG_SETAUTOLOAD |
77 |
|
bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); |
78 |
|
#else |
79 |
|
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
80 |
|
#endif |
81 |
|
m_settings.endGroup(); |
82 |
|
|
83 |
// Load server options... |
// And go into view options group. |
84 |
m_settings.beginGroup("/Server"); |
m_settings.beginGroup("/View"); |
85 |
sServerHost = m_settings.value("/ServerHost", "localhost").toString(); |
bMenubar = m_settings.value("/Menubar", true).toBool(); |
86 |
iServerPort = m_settings.value("/ServerPort", 8888).toInt(); |
bToolbar = m_settings.value("/Toolbar", true).toBool(); |
87 |
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
bStatusbar = m_settings.value("/Statusbar", true).toBool(); |
88 |
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
bAutoArrange = m_settings.value("/AutoArrange", true).toBool(); |
89 |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
m_settings.endGroup(); |
|
iStartDelay = m_settings.value("/StartDelay", 3).toInt(); |
|
|
m_settings.endGroup(); |
|
|
|
|
|
// Load display options... |
|
|
m_settings.beginGroup("/Display"); |
|
|
sDisplayFont = m_settings.value("/DisplayFont").toString(); |
|
|
bDisplayEffect = m_settings.value("/DisplayEffect", true).toBool(); |
|
|
bAutoRefresh = m_settings.value("/AutoRefresh", true).toBool(); |
|
|
iAutoRefreshTime = m_settings.value("/AutoRefreshTime", 1000).toInt(); |
|
|
iMaxVolume = m_settings.value("/MaxVolume", 100).toInt(); |
|
|
sMessagesFont = m_settings.value("/MessagesFont").toString(); |
|
|
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
|
|
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
|
|
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
|
|
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
|
|
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
|
|
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
|
|
iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt(); |
|
|
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
|
|
m_settings.endGroup(); |
|
|
|
|
|
// And go into view options group. |
|
|
m_settings.beginGroup("/View"); |
|
|
bMenubar = m_settings.value("/Menubar", true).toBool(); |
|
|
bToolbar = m_settings.value("/Toolbar", true).toBool(); |
|
|
bStatusbar = m_settings.value("/Statusbar", true).toBool(); |
|
|
bAutoArrange = m_settings.value("/AutoArrange", true).toBool(); |
|
|
m_settings.endGroup(); |
|
90 |
|
|
91 |
m_settings.endGroup(); // Options group. |
m_settings.endGroup(); // Options group. |
92 |
|
|
93 |
// Recent file list. |
// Recent file list. |
94 |
recentFiles.clear(); |
recentFiles.clear(); |
101 |
} |
} |
102 |
m_settings.endGroup(); |
m_settings.endGroup(); |
103 |
|
|
104 |
// Last but not least, get the default directories. |
// Last but not least, get the default directories. |
105 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Default"); |
106 |
sSessionDir = m_settings.value("/SessionDir").toString(); |
sSessionDir = m_settings.value("/SessionDir").toString(); |
107 |
sInstrumentDir = m_settings.value("/InstrumentDir").toString(); |
sInstrumentDir = m_settings.value("/InstrumentDir").toString(); |
108 |
sEngineName = m_settings.value("/EngineName").toString(); |
sEngineName = m_settings.value("/EngineName").toString(); |
109 |
sAudioDriver = m_settings.value("/AudioDriver").toString(); |
sAudioDriver = m_settings.value("/AudioDriver").toString(); |
110 |
sMidiDriver = m_settings.value("/MidiDriver").toString(); |
sMidiDriver = m_settings.value("/MidiDriver").toString(); |
111 |
iMidiMap = m_settings.value("/MidiMap", 0).toInt(); |
iMidiMap = m_settings.value("/MidiMap", 0).toInt(); |
112 |
iMidiBank = m_settings.value("/MidiBank", 0).toInt(); |
iMidiBank = m_settings.value("/MidiBank", 0).toInt(); |
113 |
iMidiProg = m_settings.value("/MidiProg", 0).toInt(); |
iMidiProg = m_settings.value("/MidiProg", 0).toInt(); |
114 |
iVolume = m_settings.value("/Volume", 100).toInt(); |
iVolume = m_settings.value("/Volume", 100).toInt(); |
115 |
iLoadMode = m_settings.value("/Loadmode", 0).toInt(); |
iLoadMode = m_settings.value("/Loadmode", 0).toInt(); |
116 |
m_settings.endGroup(); |
m_settings.endGroup(); |
117 |
} |
} |
118 |
|
|
119 |
|
|
120 |
// Default Destructor. |
// Default Destructor. |
121 |
qsamplerOptions::~qsamplerOptions (void) |
Options::~Options (void) |
122 |
{ |
{ |
123 |
// Make program version available in the future. |
// Make program version available in the future. |
124 |
m_settings.beginGroup("/Program"); |
m_settings.beginGroup("/Program"); |
125 |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
126 |
m_settings.endGroup(); |
m_settings.endGroup(); |
127 |
|
|
128 |
// And go into general options group. |
// And go into general options group. |
129 |
m_settings.beginGroup("/Options"); |
m_settings.beginGroup("/Options"); |
130 |
|
|
131 |
// Save server options. |
// Save server options. |
132 |
m_settings.beginGroup("/Server"); |
m_settings.beginGroup("/Server"); |
133 |
m_settings.setValue("/ServerHost", sServerHost); |
m_settings.setValue("/ServerHost", sServerHost); |
134 |
m_settings.setValue("/ServerPort", iServerPort); |
m_settings.setValue("/ServerPort", iServerPort); |
135 |
m_settings.setValue("/ServerTimeout", iServerTimeout); |
m_settings.setValue("/ServerTimeout", iServerTimeout); |
136 |
m_settings.setValue("/ServerStart", bServerStart); |
m_settings.setValue("/ServerStart", bServerStart); |
137 |
m_settings.setValue("/ServerCmdLine", sServerCmdLine); |
m_settings.setValue("/ServerCmdLine", sServerCmdLine); |
138 |
m_settings.setValue("/StartDelay", iStartDelay); |
m_settings.setValue("/StartDelay", iStartDelay); |
139 |
m_settings.endGroup(); |
m_settings.endGroup(); |
140 |
|
|
141 |
// Save display options. |
// Save display options. |
142 |
m_settings.beginGroup("/Display"); |
m_settings.beginGroup("/Display"); |
143 |
m_settings.setValue("/DisplayFont", sDisplayFont); |
m_settings.setValue("/DisplayFont", sDisplayFont); |
144 |
m_settings.setValue("/DisplayEffect", bDisplayEffect); |
m_settings.setValue("/DisplayEffect", bDisplayEffect); |
145 |
m_settings.setValue("/AutoRefresh", bAutoRefresh); |
m_settings.setValue("/AutoRefresh", bAutoRefresh); |
146 |
m_settings.setValue("/AutoRefreshTime", iAutoRefreshTime); |
m_settings.setValue("/AutoRefreshTime", iAutoRefreshTime); |
147 |
m_settings.setValue("/MaxVolume", iMaxVolume); |
m_settings.setValue("/MaxVolume", iMaxVolume); |
148 |
m_settings.setValue("/MessagesFont", sMessagesFont); |
m_settings.setValue("/MessagesFont", sMessagesFont); |
149 |
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
150 |
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
151 |
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
152 |
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
153 |
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
154 |
m_settings.setValue("/CompletePath", bCompletePath); |
m_settings.setValue("/CompletePath", bCompletePath); |
155 |
m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles); |
m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles); |
156 |
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
157 |
m_settings.endGroup(); |
m_settings.endGroup(); |
158 |
|
|
159 |
// View options group. |
// View options group. |
160 |
m_settings.beginGroup("/View"); |
m_settings.beginGroup("/View"); |
161 |
m_settings.setValue("/Menubar", bMenubar); |
m_settings.setValue("/Menubar", bMenubar); |
162 |
m_settings.setValue("/Toolbar", bToolbar); |
m_settings.setValue("/Toolbar", bToolbar); |
163 |
m_settings.setValue("/Statusbar", bStatusbar); |
m_settings.setValue("/Statusbar", bStatusbar); |
164 |
m_settings.setValue("/AutoArrange", bAutoArrange); |
m_settings.setValue("/AutoArrange", bAutoArrange); |
165 |
m_settings.endGroup(); |
m_settings.endGroup(); |
166 |
|
|
167 |
m_settings.endGroup(); // Options group. |
m_settings.endGroup(); // Options group. |
168 |
|
|
169 |
// Recent file list. |
// Recent file list. |
170 |
int iFile = 0; |
int iFile = 0; |
171 |
m_settings.beginGroup("/RecentFiles"); |
m_settings.beginGroup("/RecentFiles"); |
172 |
QStringListIterator iter(recentFiles); |
QStringListIterator iter(recentFiles); |
174 |
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
175 |
m_settings.endGroup(); |
m_settings.endGroup(); |
176 |
|
|
177 |
// Default directories. |
// Default directories. |
178 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Default"); |
179 |
m_settings.setValue("/SessionDir", sSessionDir); |
m_settings.setValue("/SessionDir", sSessionDir); |
180 |
m_settings.setValue("/InstrumentDir", sInstrumentDir); |
m_settings.setValue("/InstrumentDir", sInstrumentDir); |
181 |
m_settings.setValue("/EngineName", sEngineName); |
m_settings.setValue("/EngineName", sEngineName); |
182 |
m_settings.setValue("/AudioDriver", sAudioDriver); |
m_settings.setValue("/AudioDriver", sAudioDriver); |
183 |
m_settings.setValue("/MidiDriver", sMidiDriver); |
m_settings.setValue("/MidiDriver", sMidiDriver); |
184 |
m_settings.setValue("/MidiMap", iMidiMap); |
m_settings.setValue("/MidiMap", iMidiMap); |
185 |
m_settings.setValue("/MidiBank", iMidiBank); |
m_settings.setValue("/MidiBank", iMidiBank); |
186 |
m_settings.setValue("/MidiProg", iMidiProg); |
m_settings.setValue("/MidiProg", iMidiProg); |
187 |
m_settings.setValue("/Volume", iVolume); |
m_settings.setValue("/Volume", iVolume); |
188 |
m_settings.setValue("/Loadmode", iLoadMode); |
m_settings.setValue("/Loadmode", iLoadMode); |
189 |
m_settings.endGroup(); |
m_settings.endGroup(); |
190 |
} |
} |
191 |
|
|
192 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
193 |
// Settings accessor. |
// Settings accessor. |
194 |
// |
// |
195 |
|
|
196 |
QSettings& qsamplerOptions::settings (void) |
QSettings& Options::settings (void) |
197 |
{ |
{ |
198 |
return m_settings; |
return m_settings; |
199 |
} |
} |
200 |
|
|
201 |
|
|
204 |
// |
// |
205 |
|
|
206 |
// Help about command line options. |
// Help about command line options. |
207 |
void qsamplerOptions::print_usage ( const char *arg0 ) |
void Options::print_usage ( const char *arg0 ) |
208 |
{ |
{ |
209 |
QTextStream out(stderr); |
QTextStream out(stderr); |
210 |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
220 |
|
|
221 |
|
|
222 |
// Parse command line arguments into m_settings. |
// Parse command line arguments into m_settings. |
223 |
bool qsamplerOptions::parse_args ( int argc, char **argv ) |
bool Options::parse_args ( int argc, char **argv ) |
224 |
{ |
{ |
225 |
QTextStream out(stderr); |
QTextStream out(stderr); |
226 |
const QString sEol = "\n\n"; |
const QString sEol = "\n\n"; |
227 |
int iCmdArgs = 0; |
int iCmdArgs = 0; |
228 |
|
|
229 |
|
for (int i = 1; i < argc; i++) { |
230 |
|
|
231 |
for (int i = 1; i < argc; i++) { |
if (iCmdArgs > 0) { |
232 |
|
sSessionFile += " "; |
233 |
|
sSessionFile += argv[i]; |
234 |
|
iCmdArgs++; |
235 |
|
continue; |
236 |
|
} |
237 |
|
|
238 |
|
QString sArg = argv[i]; |
239 |
|
QString sVal = QString::null; |
240 |
|
int iEqual = sArg.indexOf("="); |
241 |
|
if (iEqual >= 0) { |
242 |
|
sVal = sArg.right(sArg.length() - iEqual - 1); |
243 |
|
sArg = sArg.left(iEqual); |
244 |
|
} |
245 |
|
else if (i < argc) |
246 |
|
sVal = argv[i + 1]; |
247 |
|
|
248 |
if (iCmdArgs > 0) { |
if (sArg == "-s" || sArg == "--start") { |
249 |
sSessionFile += " "; |
bServerStart = true; |
250 |
sSessionFile += argv[i]; |
} |
251 |
iCmdArgs++; |
else if (sArg == "-h" || sArg == "--hostname") { |
252 |
continue; |
if (sVal.isNull()) { |
253 |
} |
out << QObject::tr("Option -h requires an argument (hostname).") + sEol; |
254 |
|
return false; |
255 |
QString sArg = argv[i]; |
} |
256 |
QString sVal = QString::null; |
sServerHost = sVal; |
257 |
int iEqual = sArg.indexOf("="); |
if (iEqual < 0) |
258 |
if (iEqual >= 0) { |
i++; |
259 |
sVal = sArg.right(sArg.length() - iEqual - 1); |
} |
260 |
sArg = sArg.left(iEqual); |
else if (sArg == "-p" || sArg == "--port") { |
261 |
} |
if (sVal.isNull()) { |
262 |
else if (i < argc) |
out << QObject::tr("Option -p requires an argument (port).") + sEol; |
263 |
sVal = argv[i + 1]; |
return false; |
264 |
|
} |
265 |
if (sArg == "-s" || sArg == "--start") { |
iServerPort = sVal.toInt(); |
266 |
bServerStart = true; |
if (iEqual < 0) |
267 |
} |
i++; |
268 |
else if (sArg == "-h" || sArg == "--hostname") { |
} |
269 |
if (sVal.isNull()) { |
else if (sArg == "-?" || sArg == "--help") { |
270 |
out << QObject::tr("Option -h requires an argument (hostname).") + sEol; |
print_usage(argv[0]); |
271 |
return false; |
return false; |
272 |
} |
} |
273 |
sServerHost = sVal; |
else if (sArg == "-v" || sArg == "--version") { |
|
if (iEqual < 0) |
|
|
i++; |
|
|
} |
|
|
else if (sArg == "-p" || sArg == "--port") { |
|
|
if (sVal.isNull()) { |
|
|
out << QObject::tr("Option -p requires an argument (port).") + sEol; |
|
|
return false; |
|
|
} |
|
|
iServerPort = sVal.toInt(); |
|
|
if (iEqual < 0) |
|
|
i++; |
|
|
} |
|
|
else if (sArg == "-?" || sArg == "--help") { |
|
|
print_usage(argv[0]); |
|
|
return false; |
|
|
} |
|
|
else if (sArg == "-v" || sArg == "--version") { |
|
274 |
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
275 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
276 |
out << QString("%1: %2\n") |
out << QString("%1: %2\n") |
281 |
.arg(::lscp_client_package()) |
.arg(::lscp_client_package()) |
282 |
.arg(::lscp_client_version()); |
.arg(::lscp_client_version()); |
283 |
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
284 |
return false; |
return false; |
285 |
} |
} |
286 |
else { |
else { |
287 |
// If we don't have one by now, |
// If we don't have one by now, |
288 |
// this will be the startup sesion file... |
// this will be the startup sesion file... |
289 |
sSessionFile += sArg; |
sSessionFile += sArg; |
290 |
iCmdArgs++; |
iCmdArgs++; |
291 |
} |
} |
292 |
} |
} |
293 |
|
|
294 |
// Alright with argument parsing. |
// Alright with argument parsing. |
295 |
return true; |
return true; |
296 |
} |
} |
297 |
|
|
298 |
|
|
299 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
300 |
// Widget geometry persistence helper methods. |
// Widget geometry persistence helper methods. |
301 |
|
|
302 |
void qsamplerOptions::loadWidgetGeometry ( QWidget *pWidget ) |
void Options::loadWidgetGeometry ( QWidget *pWidget ) |
303 |
{ |
{ |
304 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
305 |
if (pWidget) { |
if (pWidget) { |
327 |
} |
} |
328 |
|
|
329 |
|
|
330 |
void qsamplerOptions::saveWidgetGeometry ( QWidget *pWidget ) |
void Options::saveWidgetGeometry ( QWidget *pWidget ) |
331 |
{ |
{ |
332 |
// Try to save form window position... |
// Try to save form window position... |
333 |
// (due to X11 window managers ideossincrasies, we better |
// (due to X11 window managers ideossincrasies, we better |
350 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
351 |
// Combo box history persistence helper implementation. |
// Combo box history persistence helper implementation. |
352 |
|
|
353 |
void qsamplerOptions::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
354 |
{ |
{ |
355 |
// Load combobox list from configuration settings file... |
// Load combobox list from configuration settings file... |
356 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
373 |
} |
} |
374 |
|
|
375 |
|
|
376 |
void qsamplerOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
377 |
{ |
{ |
378 |
// Add current text as latest item... |
// Add current text as latest item... |
379 |
const QString& sCurrentText = pComboBox->currentText(); |
const QString& sCurrentText = pComboBox->currentText(); |
402 |
m_settings.endGroup(); |
m_settings.endGroup(); |
403 |
} |
} |
404 |
|
|
405 |
|
} // namespace QSampler |
406 |
|
|
407 |
|
|
408 |
// end of qsamplerOptions.cpp |
// end of qsamplerOptions.cpp |